Skip to content

Prompting for Code Work

Good prompting for code work is less about “magic wording” and more about reducing ambiguity.

The highest-leverage prompt upgrades are scope, constraints, and verification.

  • The exact outcome you want
  • Constraints the agent must respect
  • Whether to plan first or implement immediately
  • What tests or checks should be run
  • Whether docs or context files should be updated
  • What evidence you want back
  1. State the goal.
  2. Name the relevant constraints.
  3. Ask for tests if behavior changes.
  4. Ask for docs updates if the workflow or API changes.
  5. Ask the agent to say what it verified versus what it assumed.

Add a bulk archive action to the admin table. Keep the current route structure and table component. Add tests for the happy path and the permission error case. Update docs if the user-facing workflow changes. Run the relevant checks and tell me what you verified versus what you could not verify.

PatternWeak versionBetter version
Verification criteria”Implement a rate limiter""Implement a rate limiter. Test 100 req/min passes and the 101st returns 429. Run tests after.”
Root cause”The build is failing""The build fails with this error: [paste error]. Fix the root cause and verify the build succeeds.”
Visual verification”Make this page look better""Implement this design and compare the result with a screenshot before finishing.”
Scope control”Fix the TypeScript errors""Fix the TypeScript errors in src/auth/ only.”

Ask for a plan first when:

  • the change touches multiple systems
  • the behavior is not fully specified
  • the repo is unfamiliar
  • there is migration, data, or security risk

This usually leads to better changes than jumping straight into edits.

Before making any changes, tell me:
1. Which files you plan to modify
2. What changes you will make to each
3. What tests or checks you will run
Wait for approval before proceeding.
  • “Fix this” with no success criteria
  • asking for a rewrite when a small diff would do
  • forgetting to specify what must stay unchanged
  • not asking for tests or verification
  • assuming the agent knows which command is canonical in your repo

The best prompts sound like instructions to a teammate who is smart but new to the codebase.