Implement [FEATURE OR CHANGE] in [LANGUAGE AND FRAMEWORK]. The relevant existing code, APIs, schemas, and conventions are [PROJECT CONTEXT]. The required behavior is [REQUIREMENTS]. Inputs, outputs, and important edge cases are [INTERFACE AND EDGE CASES]. The constraints are [CONSTRAINTS]. The test environment and command are [TEST SETUP]. First, summarize the proposed approach in 5 bullets or fewer. Identify files you expect to change, public interfaces affected, and assumptions that could change the implementation. Do not redesign unrelated code. Then provide: 1. A complete implementation organized by file path, with only the additions or replacements needed. Preserve the project’s naming, error-handling, dependency, and formatting conventions where supplied. 2. Types, validation, and error behavior at each external boundary. For user-controlled input, distinguish malformed input, missing input, unauthorized access, not-found data, and internal failures where relevant. 3. Tests that cover the happy path, the most likely failure path, boundary values, and one regression case tied to the feature. Use the stated test framework; if it is absent, show framework-neutral test cases rather than inventing a setup. 4. Exact commands to run locally and a short explanation of expected results. 5. A brief risk note for migration, backward compatibility, performance, concurrency, security, or observability when applicable. Ask up to 3 clarifying questions only if a required input is missing. Before answering, self-check that every required behavior has a corresponding implementation path and test, and flag any code that depends on an API, package, environment variable, or behavior not established in my context. Do not invent project files, secrets, endpoints, library APIs, benchmark results, or passing test output.
Fill in
| Placeholder | What to enter | Example |
|---|---|---|
| [FEATURE OR CHANGE] | Describe the exact feature, bug fix, or code change you need. | Add a CSV export endpoint for filtered invoice records |
| [LANGUAGE AND FRAMEWORK] | State the programming language, runtime, framework, and versions when relevant. | TypeScript, Node 20, Express 4, PostgreSQL, Jest |
| [PROJECT CONTEXT] | Paste relevant files, interfaces, schemas, API contracts, and coding conventions. | Invoice routes use requireUser middleware; invoices table has id, client_name, status, issued_at, total_cents; repository functions use parameterized pg queries |
| [REQUIREMENTS] | List observable behavior, acceptance criteria, and non-goals. | GET /api/invoices/export accepts optional status and issued_after filters and returns UTF-8 CSV with a header row; users may export only their own invoices |
| [INTERFACE AND EDGE CASES] | Describe inputs, outputs, error cases, limits, and example requests or calls. | Reject an invalid ISO date with 400; escape commas and quotes in client names; return header-only CSV when no rows match |
| [CONSTRAINTS] | List allowed dependencies, performance limits, security requirements, and compatibility needs. | No new CSV package; avoid loading more than 10,000 rows into memory; preserve current authorization model |
| [TEST SETUP] | State the test framework, existing test patterns, and command used to run tests. | Jest with supertest; run npm test; existing route tests mock the invoice repository |
How to use
- Paste the smallest set of real files that defines the boundary being changed, along with the test pattern used in the repository.
- Check the proposed file list before applying code so the change stays within the intended scope.
- Run the generated tests and inspect failures rather than treating the model’s code as verified.
- Follow up with: “Review this implementation as a maintainer and list only concrete correctness, security, and compatibility issues.”
Variations
Bug fix
Use this when you can reproduce a defect and need a narrow repair.
Diagnose and fix this bug in [LANGUAGE AND FRAMEWORK]: [BUG DESCRIPTION]. Reproduction steps are [STEPS], expected behavior is [EXPECTED], actual behavior is [ACTUAL], and relevant code or logs are [CODE AND LOGS]. Find the smallest root-cause fix, explain why it causes the symptom, and provide a patch organized by file. Add a regression test that fails before the fix and passes after it. Check nulls, async errors, state reuse, and boundary conditions relevant to the code. Do not guess missing runtime facts; ask up to 3 questions when necessary.
Code review
Use this when implementation exists and needs a careful pre-merge review.
Review this change for [LANGUAGE AND FRAMEWORK]: [DIFF OR CODE]. Its intended behavior is [INTENT], and the relevant contract is [API OR DATA CONTRACT]. Return findings ordered by severity. For each finding, cite the specific code behavior, the realistic trigger, impact, and a concrete correction. Focus on correctness, security, data loss, concurrency, performance regressions, error handling, backward compatibility, and missing tests. Do not praise style or invent repository conventions. Ask up to 3 questions only when needed to evaluate a material risk.
Refactor plan
Use this when code works but is difficult to change safely.
Plan a low-risk refactor of [CODE AREA] in [LANGUAGE AND FRAMEWORK]. Current code is [CODE OR DESCRIPTION], the pain point is [PAIN POINT], and behavior that must remain unchanged is [INVARIANTS]. Propose incremental commits with a characterization test before each behavior-changing step. Identify dependencies, public interfaces, data migration risks, rollback points, and tests for preserving behavior. Include a before-and-after module boundary sketch in plain text. Do not change product behavior or add dependencies unless I authorize it. Ask up to 3 clarifying questions only if needed.
Tips
- Give the model the existing interface and test style; guessing those contracts is a frequent source of code that looks plausible but does not integrate.
- Define error semantics at the boundary, including status codes or exception types, before asking for implementation.
- A regression test should reproduce the original failure, not merely call the new function.
- For changes touching money, permissions, deletion, or migrations, ask for a failure and rollback path in addition to the happy path.
FAQ
Can I paste proprietary code into an AI prompt?
Follow your organization’s data and tool policies first. Remove secrets, tokens, customer data, and production credentials.
Should I ask for the whole application?
Usually no. Provide the relevant boundary, contracts, and tests; smaller context makes it easier to verify assumptions.
Does generated code count as tested?
No. Run the project’s real test suite, exercise the changed path, and review the diff in the repository.