Technical House
Prompt engineering

Write prompts that get usable answers

Strong prompts have a role, a clear task, real context, constraints, and an output format. Practice below — scoring runs in your browser.

Part of the Learn hub. No account. No API key. Copy into ChatGPT, Claude, Gemini, or Cursor.

Interactive Prompt Lab

Use Builder mode to assemble a prompt piece by piece, or Freeform to paste one you already wrote. Load a template chip to see a production-ready example.

Examples

Weak vs strong prompts

Same goal — wildly different results. Study the strong versions, then adapt them in the lab.

Debugging

Debug a React bug

Get a structured diagnosis instead of vague “try rewriting it” advice.

Weak

My React app is broken fix it

Strong

You are a senior React engineer.

Task: Diagnose why this component re-renders infinitely and propose a minimal fix.

Context:
- Next.js App Router, React 19
- The bug appears only when the parent passes a new object prop each render
- Code:
```tsx
useEffect(() => { fetchData(filters); }, [filters]);
```

Constraints:
- Do not rewrite the whole file
- Prefer useMemo / stable callbacks over removing the effect
- Call out if the root cause is in the parent

Output format:
1. Root cause (2–4 sentences)
2. Minimal code fix
3. How to verify

Backend

Write an API route

Scaffold a safe Express/Next API handler with validation and errors.

Weak

Write an API for blogs

Strong

You are a Node.js API designer.

Task: Design a GET /api/blogs list endpoint with pagination and category filter.

Context:
- Stack: Next.js Route Handler + Supabase
- Posts have status published|draft; only published should be public
- Need page, limit, category query params

Constraints:
- Validate query params
- Return { items, total, page, limit }
- Never leak draft posts
- Include TypeScript types

Output format:
- Handler code
- Example request/response
- Edge cases checklist

Content

SEO meta & outline

Turn a vague topic into title, description, and article outline.

Weak

Write SEO for my AI blog

Strong

You are an SEO editor for developer blogs.

Task: Create title, meta description, slug, and H2 outline for an article.

Topic: Prompt engineering for web developers using Cursor AI
Audience: junior–mid developers in India
Goal: educational, original, AdSense-safe (no thin fluff)

Constraints:
- Title under 60 characters
- Meta description 140–160 characters
- 6–8 H2s with practical takeaways
- No keyword stuffing

Output format: JSON with title, description, slug, outline[]

Quality

Code review checklist

Ask for severity-ranked review notes, not a full rewrite.

Weak

Review my code

Strong

You are a staff frontend engineer doing a PR review.

Task: Review the following TypeScript React code for bugs, a11y, and maintainability.

Constraints:
- Rank findings: blocker / major / nit
- Suggest patches, do not rewrite everything
- Flag missing error/empty states
- Call out any security issues (XSS, unsafe HTML)

Output format:
- Summary (3 bullets)
- Findings table: severity | issue | fix
- What looks good

Refactor

Safe refactor plan

Get a step-by-step plan before changing a messy module.

Weak

Refactor this file

Strong

You are a careful refactoring coach.

Task: Propose a safe, incremental refactor plan for a bloated React page component.

Context:
- ~600 lines mixing data fetching, UI, and form logic
- Must keep behavior identical
- Team uses Next.js + TypeScript

Constraints:
- No big-bang rewrite
- Each step must be shippable alone
- Name extraction targets (hooks, subcomponents)

Output format:
1. Risks
2. Step-by-step plan
3. Definition of done / tests

Debugging

Explain a build error

Turn a scary stack trace into plain-language cause + fix.

Weak

What does this error mean

Strong

You are a patient TypeScript mentor.

Task: Explain this error in plain language and give the most likely fix.

Constraints:
- First: what the error means (no jargon pile-up)
- Then: likely causes ranked
- Then: exact fix steps
- If you need more info, ask up to 3 clarifying questions

Output format: Meaning → Causes → Fix → Questions (if needed)

How to learn prompt engineering

  1. 1. Always set a role. “You are a senior React engineer” beats “help me with code.”
  2. 2. One primary task. Debug, write, review, or explain — pick one per prompt.
  3. 3. Give context. Stack, error text, and a short snippet beat vague descriptions.
  4. 4. Add constraints. “Do not rewrite the whole file” keeps answers usable.
  5. 5. Demand a format. Steps, JSON, or a checklist make outputs easy to apply.
  6. 6. Iterate. If the answer is wrong, reply with what failed — do not start from zero every time.

Never miss a drop

Get new guides on web development and AI, Prompt Lab tips, videos, downloads and exclusive deals — straight to your inbox. No spam, unsubscribe anytime.