# TDD: red → green → refactor Source: https://refyneit.com/prompts/tdd-red-green-refactor Deliver one behavior at a time with visible failing and passing test evidence. ## When to use it Each requested behavior gets an observable red and green signal, while the refactor boundary prevents speculative cleanup from hiding inside the feature diff. ## Prompt Implement [BEHAVIOR OR ISSUE] using strict red → green → refactor cycles. First, read the issue/specification, repository guidance, existing implementation, and nearby tests. Convert the requested behavior into a short checklist of externally observable outcomes. For each outcome, one at a time: 1. RED — write the smallest meaningful test for that behavior. Run it and confirm it fails for the expected behavioral reason, not because of setup, import, or syntax errors. Show the test name and concise failure. 2. GREEN — make the minimum production change needed to pass that test. Run the targeted test and show the passing result. 3. REFACTOR — improve names or structure only while the tests remain green. Do not add unrelated abstractions or features. After all cycles: - Run the relevant full suite and project checks. - Cross-check every acceptance criterion against a test or an explicit verification step. - Report cycles completed, behaviors covered, commands/results, and anything intentionally left untested with the reason. Never modify a test merely to make an incorrect implementation pass. If the specification conflicts with existing behavior, stop and describe the conflict before choosing a side. ## Adaptation and provenance Combined and condensed from the red, green, and refactor agents in GitHub Awesome Copilot. Contributor: [@aaronpowell](https://github.com/aaronpowell) Repository: https://github.com/github/awesome-copilot Pinned commit: b95e24caae4f25c5985f8527fd092ccfed039c36 License: [MIT](https://github.com/github/awesome-copilot/blob/b95e24caae4f25c5985f8527fd092ccfed039c36/LICENSE) - [tdd-red](https://github.com/github/awesome-copilot/blob/b95e24caae4f25c5985f8527fd092ccfed039c36/agents/tdd-red.agent.md) - [tdd-green](https://github.com/github/awesome-copilot/blob/b95e24caae4f25c5985f8527fd092ccfed039c36/agents/tdd-green.agent.md) - [tdd-refactor](https://github.com/github/awesome-copilot/blob/b95e24caae4f25c5985f8527fd092ccfed039c36/agents/tdd-refactor.agent.md) Review: source-reviewed, 2026-08-23. Compared with the commit-pinned source and adapted into a tool-neutral, copy/paste request. This is a non-visual task, so no output artifact is required.