Implement a feature from a spec, with tests
Plans and writes production-quality code for a feature, including tests and edge cases.
The prompt
Role: Act as a senior software engineer working in an existing codebase.
Context: Feature spec / acceptance criteria: [SPEC]. Language, framework and versions: [STACK]. Relevant existing code / modules / patterns to match: [EXISTING_CODE]. Constraints (performance, compatibility, style guide): [CONSTRAINTS]. How tests are run here: [TEST_SETUP]. Non-goals: [NON_GOALS].
Task: Produce: (1) a short implementation plan - files to touch, the approach, and any interface changes; (2) the code, matching the surrounding style and patterns, with clear names and only the comments the codebase would use; (3) unit tests covering the acceptance criteria and the important edge cases; (4) a note on anything the spec leaves ambiguous.
Format: Sections: Plan | Code (by file) | Tests | Open questions. Code in fenced blocks with file paths.
Verification: State any assumption you made about the existing code you cannot see; do not invent APIs or config. Flag where the acceptance criteria are untestable as written.
Validation: Trace each acceptance criterion to a test; run the tests mentally against a tricky input and confirm the expected result. Note the riskiest part of the change.
Highlighted [brackets] are blanks to replace with your own details.
Fill in the blanks and use this promptMore Software Development prompts
What to fill in
- SPEC
- STACK
- EXISTING_CODE
- CONSTRAINTS
- TEST_SETUP
- NON_GOALS
How this prompt is built
This prompt follows the RCTFVV structure (Role, Context, Task, Format, Verification, Validation). RCTFVV extends RCTF with two checking steps. Verification asks the model to review its own draft against your requirements; Validation asks it to flag assumptions and gaps you should confirm.
Related prompts
- Set up CI/CD and infrastructure as codeCI/CD pipelines and IaC templates with environments, checks, and rollback.
- Plan a major framework or dependency upgradeBuilds an incremental upgrade path for a framework, language, or library version, with breaking changes mapped to your codebase.
- Respond to a secret leaked in a code repositoryWalks you through containing a leaked API key, password, or token: revoke, rotate, check for misuse, and clean up history.
- Debug an error and find the root causeReproduces, isolates, and fixes a bug — with a test to prevent it coming back.