Example 1: API Endpoint
Before
“Add a notifications endpoint.”
After
“Create GET /api/notifications for authenticated users. Return { id, type, message, read, createdAt } with cursor-based pagination (limit, cursor params). Return 401 if unauthenticated. Add unit tests covering pagination and auth.”
Example 2: Bug Fix
Before
“The form is broken, fix it.”
After
“The registration form in @src/components/RegisterForm.tsx submits successfully but doesn’t redirect. Expected: redirect to /dashboard after 201 response. Actual: stays on /register. The API call succeeds (confirmed in Network tab).”
Example 3: Refactoring
Before
“Refactor this code.”
After
“Extract the validation logic from @src/routes/orders.ts lines 45-89 into a separate validateOrder function in @src/validators/order.ts. Keep the same behavior. The function should accept an OrderInput and return { valid: boolean, errors: string[] }.”
The Pattern
Every good prompt rewrite adds the same things: specific files, expected behavior, data shapes, error cases, and verification criteria. The “after” prompts aren’t longer for the sake of length — every word narrows the solution space.
The 4 missing elements: When a prompt fails, it’s almost always missing one of: task scope, file locations, constraints, or verification steps. Add whichever is missing and retry.