Enforces Test-Driven Development principles in Claude Code through automated validation
Project description
TDD Guard
Automated TDD enforcement for Claude Code.
Overview
TDD Guard monitors file operations in real-time and blocks any changes that violate TDD principles. By analyzing test results, todos, and code changes, it ensures Claude Code follows the red-green-refactor cycle without manual reminders.
Click to watch TDD Guard in action
Why TDD Guard?
- Focus on solving problems - TDD Guard enforces the rules while you design solutions
- Save context for what matters - No more TDD instructions cluttering your CLAUDE.md
- Works with your stack - TypeScript, JavaScript, and Python today. More languages coming soon
- Control without context switches - Toggle with
tdd-guard on/offmid-session - Flexible validation - Use local Claude or configure Anthropic API
Requirements
- Node.js 18+
- Test Runner:
- JavaScript/TypeScript: Vitest
- Python: pytest
Installation
Install the TDD Guard CLI globally:
npm install -g tdd-guard
For Python projects, also install the pytest reporter:
pip install tdd-guard
Quick Start
Getting started is quick and simple:
1. Configure Claude Code Hook
Use the /hooks command in Claude Code:
- Type
/hooksin Claude Code - Select
PreToolUse - Before tool execution - Choose
+ Add new matcher... - Enter:
Write|Edit|MultiEdit|TodoWrite - Select
+ Add new hook... - Enter command:
tdd-guard - Choose where to save (Project settings recommended)
Tip: Also configure quick commands for tdd-guard on/off and ESLint integration for automated refactoring support.
2. Configure Test Reporter
TDD Guard captures test results from your test runner. Ensure your package.json or project scripts use the correct test command.
JavaScript/TypeScript (Vitest)
Add to vitest.config.ts:
import { VitestReporter } from 'tdd-guard'
export default defineConfig({
test: {
reporters: ['default', new VitestReporter()],
},
})
Python (pytest)
No configuration needed - the pytest plugin activates automatically when installed.
Security Notice
As stated in the Claude Code Hooks documentation:
Hooks execute shell commands with your full user permissions without confirmation. You are responsible for ensuring your hooks are safe and secure. Anthropic is not liable for any data loss or system damage resulting from hook usage.
We share this information for transparency. Please read the full security considerations before using hooks.
TDD Guard runs with your user permissions and has access to your file system. We follow security best practices including automated security scanning, dependency audits, and test-driven development. Review the source code if you have security concerns.
Known Limitations
- Not tested with multiple subagents in the same project
Roadmap
- Add support for more testing frameworks (Jest, Mocha, unittest, etc.)
- Add support for additional programming languages (Go, Rust, Java, etc.)
- Encourage meaningful refactoring opportunities when tests are green
- Add support for multiple concurrent subagents per project
Contributing
Contributions are welcome! Feel free to submit issues and pull requests.
Contributors:
- Python/pytest support: @Durafen
Learn More
- Configuration Guide - Environment variables, model options, and troubleshooting
- Architecture Decision Records - Technical design decisions and rationale
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tdd_guard-0.5.3.tar.gz.
File metadata
- Download URL: tdd_guard-0.5.3.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2da053e50dde5563fdda829a872557ea779f0d7379c3342a1bf4d2c334ad6a35
|
|
| MD5 |
62b53afb826ce30c92312ccfe116cbde
|
|
| BLAKE2b-256 |
495b43f484dab023bbf730c7798841202811f0f417b131704878be3aa5f225ba
|
File details
Details for the file tdd_guard-0.5.3-py3-none-any.whl.
File metadata
- Download URL: tdd_guard-0.5.3-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13b8acf665d32843534b4c1c8689d9d3984030ede8a2620cbf30c932b7514050
|
|
| MD5 |
979e7257df14b0f019a2bdb0f00ffc84
|
|
| BLAKE2b-256 |
57195cf4e5d908c5e7cf0536f11794e9bfa517e5903c78cdfbb00e98dd8ced1d
|