agentleFS
nizosnizos/tdd-guard/CLAUDE.md

tdd-guard

CLAUDE.md2.4k starsChanged 5 months agoMITView on GitHub

TDD Guard is a Claude Code hook that enforces Test-Driven Development by intercepting file operations. When Claude Code attempts to edit or write files, TDD Guard: This automated enforcement maintains code quality without cluttering prompts with TDD reminders. Example: feat: add network request filtering to reduce noise in captured data (explains why, not just what) The codebase is organized with core functionality in src/ and language-specific reporters: TDD Guard is organized as a TypeScript project with integrated language-specific reporters:

Trending

Quiet since September.about the whole repository

Dec 2025: 2 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 1 mentionApr 2026: 2 mentionsMay 2026: 4 mentionsJun 2026: 1 mentionJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 1 mentionOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the nizos/tdd-guard repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about nizos/tdd-guard

The biggest 5 of 31 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 31

Talked about on GitHub, Bluesky and Hacker News (31 times).

On GitHub · 23

18 more on GitHub

On Bluesky · 5

The file

We split this CLAUDE.md into the rules it gives an agent

7 rules. About 0 are common, 5 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When Claude Code attempts to edit or write files, TDD Guard:

    line 6
  2. Distinctive:

    Test and implementation together: Never separate tests from the code they test

    line 21
  3. Distinctive:

    Explain why, not what: Commit messages should explain the reason for the change

    line 22
  4. Distinctive:

    Conventional format: Use prefixes to categorize changes: feat, fix, refactor, test, chore, docs

    line 23
  5. Very specific:

    Use test factories: Always use factories from test/utils/ instead of creating data inline

    line 78
  6. Very specific:

    Group tests effectively: Use describe blocks and beforeEach for common setup

    line 79
  7. Distinctive:

    Keep tests concise: Keep as little logic in the tests themselves as possible

    line 80

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

TDD Guard

Project Goal

TDD Guard is a Claude Code hook that enforces Test-Driven Development by intercepting file operations. When Claude Code attempts to edit or write files, TDD Guard:

  1. Captures: Intercepts Edit, MultiEdit, and Write operations
  2. Analyzes: Examines test results, file paths, and code changes
  3. Validates: Checks TDD compliance using an AI model
  4. Blocks: Prevents operations that skip tests or over-implement
  5. Guides: Explains violations and suggests corrections

This automated enforcement maintains code quality without cluttering prompts with TDD reminders.

Development Workflow

Commit Guidelines

  • Atomic commits: Each commit represents one logical change with its tests
  • Test and implementation together: Never separate tests from the code they test
  • Explain why, not what: Commit messages should explain the reason for the change
  • Conventional format: Use prefixes to categorize changes: feat, fix, refactor, test, chore, docs

Example: feat: add network request filtering to reduce noise in captured data (explains why, not just what)

Project Structure

The codebase is organized with core functionality in src/ and language-specific reporters:

reporters/                        # Language-specific test reporters
├── go/                           # tdd-guard-go - Go test reporter
├── jest/                         # tdd-guard-jest - Jest reporter (npm)
├── minitest/                     # tdd-guard-minitest - Minitest reporter (gem)
├── phpunit/                      # tdd-guard/phpunit - PHPUnit reporter (composer)
├── pytest/                       # tdd-guard-pytest - Pytest reporter (pip)
├── rspec/                        # tdd-guard-rspec - RSpec reporter (gem)
├── rust/                         # tdd-guard-rust - Rust test reporter (crates.io)
├── storybook/                    # tdd-guard-storybook - Storybook test-runner reporter (npm)
├── test/                         # Shared test artifacts and integration tests
└── vitest/                       # tdd-guard-vitest - Vitest reporter (npm)

src/                              # Main CLI application
├── cli/                          # Hook entry point and context builder
├── config/                       # Configuration management
├── contracts/                    # Types and Zod schemas
├── guard/                        # Guard enable/disable management
├── hooks/                        # Claude Code hook parsing and processing
├── linters/                      # ESLint integration for code quality
├── processors/                   # Test result and lint processing
├── providers/                    # Model and linter client factories
├── storage/                      # Storage abstractions
├── validation/                   # TDD principle validation
│   ├── validator.ts              # Sends context to AI model and parses response
│   ├── context/                  # Formats operations for AI validation
│   ├── prompts/                  # TDD validation rules and AI instructions
│   └── models/                   # Claude SDK and Anthropic API clients
└── index.ts                      # Package entry point

test/                             # Main test suite (hooks, integration, utils)
docs/                             # Documentation (ADRs, configuration, etc.)

Architecture

TDD Guard is organized as a TypeScript project with integrated language-specific reporters:

  • src/: Core functionality including contracts, config, storage, and validation
  • reporters/: Language-specific test reporters (go, jest, minitest, phpunit, pytest, rspec, rust, storybook, vitest)
  • test/: Comprehensive test suite with integration tests and utilities

Testing

Guidelines

  • Use test helpers: Extract setup logic into helper functions placed at the bottom of test files
  • Use test factories: Always use factories from test/utils/ instead of creating data inline
  • Group tests effectively: Use describe blocks and beforeEach for common setup
  • Keep tests concise: Keep as little logic in the tests themselves as possible

Commands

npm run build             # Build main package and workspace reporters (jest, storybook, vitest)
npm run test              # All unit tests and base integration tests
npm run test:unit         # Fast unit tests only
npm run test:reporters    # Test all reporter implementations
npm run lint              # Check code style and quality
npm run format            # Auto-format code with Prettier
npm run checks            # Run all checks: typecheck, lint, format, and test

Key Design Principles

  • Interface-driven: Core functionality defined by interfaces (Storage, ModelClient)
  • Dependency injection: Components receive dependencies as parameters
  • Single responsibility: Each module has one clear purpose
  • Type safety: Comprehensive TypeScript types with runtime validation

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.