TDD Guard is an npm package providing automated Test-Driven Development enforcement for AI agents, specifically within the Claude Code environment. It is currently at version 1.6.3 and exhibits a rapid release cadence, with frequent updates addressing bugs, introducing new features, and enhancing refactoring capabilities. Its primary function is to ensure AI agents adhere strictly to TDD principles by proactively blocking actions that violate test-first or minimal implementation rules, such as adding code without accompanying failing tests or implementing beyond the scope of current test requirements. Key differentiators include its broad multi-language support (e.g., JavaScript, TypeScript, Ruby, Python, Go, Rust, PHP) and integration with numerous test frameworks (including Vitest, Jest, RSpec, and PHPUnit). The package also offers customizable validation rules, lint integration for automated refactoring support, and granular control over validation models and session management.
npm install tdd-guardVerified import paths — ran on the pinned version, not inferred.
Demonstrates the initial setup commands within Claude Code to install and configure TDD Guard.
Update `VitestReporter` instantiation from `new VitestReporter('/path/to/project')` to `new VitestReporter({ projectRoot: '/path/to/project' })` in your `vitest.config.ts` or similar.Back up your custom `instructions.md`, delete the old file, and start a new Claude Code session to regenerate the default, updated instructions. Then, manually reapply your customizations.
Upgrade to TDD Guard v1.6.3 or newer to benefit from improved refactor recognition during green-state operations. If on an older version, be mindful of these blocks and adjust your workflow or update the plugin.
Ensure your development environment is running Node.js 22.0.0 or a newer compatible version. Use a version manager like `nvm` to easily switch Node.js versions.
Upgrade to TDD Guard v1.5.1 or newer to mitigate this security vulnerability related to file system operations.
Ensure a failing test is present that requires the new code. If refactoring, ensure you are on TDD Guard v1.6.3+ which has improved refactor recognition. Consider the 'adjusting an implementation's signature' or 'tidying existing tests' patterns now allowed.
Update your Node.js installation to version 22.0.0 or later. Use a Node.js version manager like `nvm` (`nvm install 22 && nvm use 22`) for easier management.
Backup your custom `instructions.md` file. Delete the original `.claude/tdd-guard/data/instructions.md`. Start a new Claude Code session to let TDD Guard regenerate the latest default instructions. Then, manually re-apply your specific customizations to the new file.