# Implement a feature from a spec, with tests

Plans and writes production-quality code for a feature, including tests and edge cases.

- Topic: Software Development
- Framework: RCTFVV
- Level: Advanced
- Tags: Coding, Plan, Code, Fill-in Template
- Source: https://www.thinkwithprompt.com/prompts/implement-a-feature-from-a-spec-with-tests

## Prompt

```text
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.
```

## What to fill in

- SPEC
- STACK
- EXISTING_CODE
- CONSTRAINTS
- TEST_SETUP
- NON_GOALS

Free to copy and use. From ThinkWithPrompt (https://www.thinkwithprompt.com/), a library of 2,663 curated AI prompts.
