Example result: Turn a user story into working code
AI-generated example · Build · Feature
Updated

Turn a user story into working code

This prompt works like a senior developer picking up a ticket. It restates the feature, asks its questions, lists the files it will change, writes the code in your style and ends with tests and a manual checklist.

text-code-feature-from-user-story — claude — 83 words

Act as a senior full-stack developer on my project.

User story: As a [WHO], I want to [WHAT], so that [WHY].
Acceptance criteria:
[LIST]
Stack: [e.g. Next.js, Postgres, Prisma]
Relevant existing code:
[PASTE OR DESCRIBE THE FILES]

First, restate the feature in two lines and list questions or assumptions. Then list every file you would add or change. Then write the code, following the patterns in the existing code. Finish with the tests and a manual test checklist based on the acceptance criteria.

Answer its questions before it writes code. Five minutes of clarifying saves an hour of rework.

Get a better result

What you will get

A restated feature, a list of questions and assumptions, the files to add or change, the code in your project’s style, and tests plus a manual checklist tied to your acceptance criteria.

Common mistake

It invents files that do not exist.

Fix: Paste the real folder tree and the files it will touch, and ask it to name only those.

Also watch for
  • It ignores your project’s patterns. Include one finished example of a similar feature and say “follow this style exactly”.
  • The acceptance criteria are too loose. Write each criterion so it can pass or fail, such as “returns 404 for an unknown id”, not “handles errors well”.
Try a variation: start with the tests

Ask for the failing tests first, then the smallest code that makes them pass, so the behaviour is fixed before the design.

Still not right? Reply with this

Here are my answers to your questions: [ANSWERS]. Build one file at a time, and tell me the test command to run after each step before moving on.

Guides on this topic

More chat & writing prompts

See all 465 →