Skip to Sidebar Skip to Content
Workflow · Software and IT

Plan, write and test a code change with AI

Move through well-defined changes while keeping the understanding and the tests in your hands.
Try with checksIt is worth trying only with the checks on this page.
For: Working developers. If you can't read the code, get someone who can before it runs anywhere that matters.

What the evidence says

Studied directly. Studies look at this task or something very close to it.
Results differ a lot by task and experience. In one trial, experienced developers on their own projects were slower with AI while believing it sped them up. METR thinks newer tools help more, but calls its follow-up data very weak evidence.
This workflow itself is our recommended way of working, not a tested method. Studies searched to 2 November 2026.

Before you start

  • Pick a change you could explain to a colleague. Unclear jobs give unclear code.
  • Work on a branch, never directly on the live system.
  • Know your organisation's rules on which code may go into which tool. Never give an agent production keys.

The steps

Replace the words in square brackets with your own. Stay in the same chat for the next prompt, unless a step says otherwise.

  1. You
    Write what should change, how you'll know it works, and what must not change.
  2. AI
    Ask for a plan before any code, and correct it.
    Prompt
    Before writing any code, read the relevant files and give me a plan for this change: [change].
    
    It is done when: [acceptance test]. It must not change: [constraints].
    
    List the files you would touch and why, the risks, and anything you are unsure of. Ask me up to three questions if the job is unclear. Do not start until I agree.
  3. You
    Fix the plan. If you can't judge it, the change is too big or too unfamiliar: split it.
  4. AI
    Write a failing test first, then the smallest change that passes it.
    Prompt
    Write a test that fails now and will pass when the change is done. Run it, or give me the command if you can't. Show me the failure, and confirm it fails for the reason we expect. Then make the smallest change that passes it. Do not touch unrelated code, do not add libraries without asking, and do not change or delete existing tests to make them pass. If an existing test conflicts with this change, stop, show me the test and why, and wait. Do not skip it.
  5. You
    Read the whole diff line by line, and run the full test suite yourself.
  6. You
    Get a person to review it as usual, and tell them what the AI wrote.

How to catch its mistakes

  • You can explain every line. If you can't, it doesn't merge.
  • Tests weren't weakened, skipped or deleted to get a pass.
  • Any new library really exists and is the one you meant. Made-up package names can be taken over by attackers.
  • Look at input handling, permissions and secrets: an AI's code can run correctly and still be unsafe.

When not to use this

  • Payment, safety-critical or security code, unless your normal extra review applies in full.
  • A large change to a system you don't know. Use AI to explain the code first instead.
  • You are timing yourself against a deadline and the review would be skipped.

Tools

A coding agent, or an assistant in your code editor. Examples: Cursor, GitHub Copilot, OpenAI Codex. We chose these because they are common in workplace software, not because they are the best. We leave out Claude products as examples, because we draft this site with Claude. AI coding agents compared has them all, with dated facts. Use whichever your employer has approved. The steps work with any tool of this type. We take no money from AI companies.

Find out if it works for you

People often misjudge how much AI helps them. Try this on your next 10 similar tasks, letting a coin flip decide which ones use AI. What to measure: Hours from start to merged, including review, and bugs found in the following month. Your results stay in your browser. Start the self-test →

If you manage people

Measure time to merged and defects, not lines written or how fast people feel. Keep review standards the same for AI-written code.
Written by AI Adoption's editors as our own recommendation, last checked 5 November 2026. It has not been reviewed by an outside practitioner. Before publishing, we ran its prompts once on made-up samples with a second AI model, also from Anthropic. That is a check on the wording, not a test of whether the workflow works for you. Disclosure: AI Adoption uses AI tools in its research and editorial work, including Claude from Anthropic. No company has any say in this page. Reuse under CC BY 4.0. Spotted an error? Tell us.
Copied with its source. Want the next number like this in your inbox?Get the evidence