A code-change prompt should identify the repository area, trigger, expected behavior, compatibility constraint, and tests that would prove the change. Ask the assistant to inspect relevant code before editing; do not paste secrets or an entire repository when a few files suffice. Separate the desired behavior from an implementation guess so the assistant can follow existing patterns. Review the diff, run meaningful tests, and inspect errors from the actual runtime. A successful generated patch is a candidate until those checks pass.
Coding prompts: name the files, behavior, and proof
Decision in practice
A dispatch service sometimes assigns the same shipment twice after a retry. The task is to make assignment idempotent for shipment SH-286 without changing the public response shape. The prompt points to the assignment handler and the persistence adapter, names the duplicate-retry trigger, and asks for a test that sends the same effect key twice. The reviewer checks that one database effect occurs and that the second request returns the stored result. If the assistant proposes a new queue library, the team requires evidence that the existing adapter cannot enforce the invariant.
Task: duplicate assignment retry for shipment SH-286.
Scope: assignment handler and persistence adapter.
Invariant: one effect per stable idempotency key.
Pass: repeated request returns one assignment; existing API shape unchanged.
Proof: focused test plus full relevant suite.Performance and operating cost
Repository inspection, edit generation, and tests cost more than a single chat response. Test runtime depends on the project, while diff review scales with changed lines and affected behavior. Keep the prompt narrow enough to avoid unrelated edits but include the interface contract and failure trigger. Track test failures separately from tool execution failures. A model can suggest a test that only mirrors its implementation; require a behavior-level case that would fail before the fix.
Common Mistakes
- Do not accept a patch because it compiles without testing the trigger.
- Do not include secrets in repository context.
- Do not broaden a small fix into an unrequested architecture rewrite.
Connected lessons
- Prompt engineering applications
- Prompt Engineering
- Prompt intent: turn an open request into an acceptance check
- Metamorphic tests: verify behavior when harmless details change
- SQL prompts: generate a query under database-enforced limits
- Project: produce a checked multimodal incident brief
- Applied prompt engineering decisions
Related implementation
Continue with: Diff-scoped code review: make every finding reproducible.
Continue with: UI prompts: turn a brief into components and states.
Continue with: API documentation prompts: bind prose to a versioned contract.
Continue with: Infrastructure prompts: bind scope, owner, and environment.
Continue with: Terminal agents: discover the workspace before changing it.
