How nizos/tdd-guard works
TDD Guard is a Claude Code TDD-enforcement plugin, accompanied by test-framework reporters that supply test results. The principal flow is a tool action entering the hooks, being checked against test, lint and instruction context, and receiving validation that can block a TDD violation. Separate capabilities include session toggling, configurable model clients, lint integration, and reporters for supported test frameworks. The source index establishes several module references; where detailed runtime wiring was not shown, the graph omits the edge rather than inferring a call.
Main entry points: TestResultsProcessor.ts Test results processor · context.ts Validation context · userPromptHandler.ts Prompt handler · Storage.ts Storage interface
Components 24
Claude interaction
- Tool hooks
src/hooks - Session handler
src/hooks/sessionHandler.ts - Prompt handler
src/hooks/userPromptHandler.ts - Guard controls
src/guard/GuardManager.ts
Validation
- Validation context
src/validation/context/context.ts - Validator
src/validation/validator.ts - Model clients
src/validation/models - Model selection
src/providers/ModelClientProvider.ts - TDD rules and prompts
src/validation/prompts - Lint processing
src/processors/lintProcessor.ts - Linter integrations
src/linters
Configuration and state
- Configuration
src/config/Config.ts - Storage interface
src/storage/Storage.ts - File storage
src/storage/FileStorage.ts - Memory storage
src/storage/MemoryStorage.ts
Test reporters
- Go reporter
reporters/go/cmd/tdd-guard-go/main.go - Rust reporter
reporters/rust/src/main.rs - JUnit 5 reporter
reporters/junit5/src/main/java/io/github/nizos/tddguard/junit5/TestJsonWriter.java - Jest and Vitest
reporters/jest/src/JestReporter.ts - Other reporters
reporters
Reporter processing
- Test results processor
src/processors/testResults/TestResultsProcessor.ts - Lint result schemas
src/contracts/schemas/lintSchemas.ts - Reporter schemas
src/contracts/schemas/reporterSchemas.ts
Other components
- Claude Code
Connections 26
- Claude Code → Tool hooks: invokes
- Claude Code → Prompt handler: requests validation
- Tool hooks → Session handler: handles sessions
- Tool hooks → Prompt handler: handles prompts
- Prompt handler → Guard controls: checks guard state
src/hooks/userPromptHandler.ts - Prompt handler → Validator: requests validation
- Validation context → TDD rules and prompts: assembles prompts
src/validation/context/context.ts - Validation context → Test results processor: processes test output
src/validation/context/context.ts - Validation context → Lint processing: formats lint data
src/validation/context/context.ts - Validator → Validation context: builds context
- Validator → Model selection: selects client
- Model selection → Model clients: creates client
src/providers/ModelClientProvider.ts - Linter integrations → Lint processing: provides lint data
- Session handler → Storage interface: uses storage
src/hooks/sessionHandler.ts - Session handler → TDD rules and prompts: seeds instructions
src/hooks/sessionHandler.ts - Guard controls → Storage interface: uses storage
src/guard/GuardManager.ts - File storage → Configuration: gets paths
src/storage/FileStorage.ts - File storage → Storage interface: implements
src/storage/FileStorage.ts - Memory storage → Storage interface: implements
src/storage/MemoryStorage.ts - Go reporter → Test results processor: writes results
- Rust reporter → Test results processor: writes results
- JUnit 5 reporter → Test results processor: writes results
- Jest and Vitest → Test results processor: writes results
- Other reporters → Test results processor: writes results
- Test results processor → Reporter schemas: validates results
src/processors/testResults/TestResultsProcessor.ts - Lint processing → Lint result schemas: uses schemas
src/cli/buildContext.ts