RGR (Red-Green-Refactor) is a discipline tool for AI coding assistants that enforces strict test-driven development. It captures and locks failing tests with special codes, then verifies that code was only written after the test existed and that the original test was never modified. The tool works as a plugin for Claude Code and Codex, helping AI agents write meaningful tests instead of shallow ones. It creates a verifiable record showing the test failed first, the code was added, and then the test passed.
How It Works
You begin by telling RGR what you want to build, like 'billing-scope' or 'user-auth'. RGR creates a record to track your progress.
Before writing any code, you write a test that describes exactly what the feature should do. The test fails because the feature doesn't exist yet.
You run the 'red' command to capture a snapshot of your failing test. RGR remembers exactly what the test looked like, so nobody can change it later.
Now you write the actual code to make the feature work. RGR won't let you skip this step or modify the locked test.
You run the 'green' command to verify your code makes the test pass. RGR runs the exact same test command from before.
Clean up your code while RGR keeps the test locked. If the test still passes, your refactor worked.
If the test was wrong, explain why and start fresh with a new failing test.
You run the final check to prove everything works. RGR confirms the test failed first, then passed, and nothing was changed unfairly.
Star Growth
Repurpose is a Pro feature
Generate ready-to-use prompts for X threads, LinkedIn posts, blog posts, YouTube scripts, and more -- with full repo context baked in.
Unlock RepurposeSimilar repos coming soon.