TDD Guard is an automated Test-Driven Development enforcement tool for Claude Code that ensures AI agents follow proper TDD discipline. It hooks into Claude Code's lifecycle events to block implementation attempts that lack corresponding failing tests, preventing over-implementation and test-skipping. The tool supports multiple languages and frameworks including TypeScript, JavaScript, Python, PHP, Go, Rust, and Storybook. It validates that code changes satisfy only current test requirements, enforces refactoring through lint integration, and provides session-level toggle controls. With customizable validation rules and flexible model selection for speed-versus-capability trade-offs, TDD Guard brings rigorous Red-Green-Refactor workflows to AI-assisted development, ensuring code quality without sacrificing developer velocity.
git clone https://github.com/nizos/tdd-guard.git
npm install -g tdd-guard
# In your vitest config:
import { defineConfig } from "vitest/config"
import { VitestReporter } from "tdd-guard-vitest"
export default defineConfig({
test: {
reporters: ["default", new VitestReporter("/path/to/project")],
},
})
# Then configure Claude Code hooks:
# PreToolUse, UserPromptSubmit, SessionStart
# pointing to the tdd-guard command