Prompting for Code Work
Good prompting for code work is less about “magic wording” and more about reducing ambiguity.
Quick Take
Section titled “Quick Take”The highest-leverage prompt upgrades are scope, constraints, and verification.
What To Include
Section titled “What To Include”- 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
A Strong Default Prompt Shape
Section titled “A Strong Default Prompt Shape”- State the goal.
- Name the relevant constraints.
- Ask for tests if behavior changes.
- Ask for docs updates if the workflow or API changes.
- Ask the agent to say what it verified versus what it assumed.
Example
Section titled “Example”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.
Prompt Patterns That Work
Section titled “Prompt Patterns That Work”| Pattern | Weak version | Better 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.” |
When To Ask For A Plan First
Section titled “When To Ask For A Plan First”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.
Plan-First Template
Section titled “Plan-First Template”Before making any changes, tell me:1. Which files you plan to modify2. What changes you will make to each3. What tests or checks you will run
Wait for approval before proceeding.Common Prompting Mistakes
Section titled “Common Prompting Mistakes”- “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.