### Setup TDD Guard Plugin
Source: https://github.com/nizos/tdd-guard/blob/main/plugin/README.md
Run this command after installing the plugin to configure a test reporter for your project. It detects your test framework and sets up the appropriate reporter.
```bash
/tdd-guard:setup
```
--------------------------------
### Install TDD Guard Go Reporter
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/go/README.md
Installs the TDD Guard Go reporter using the go install command. Ensure Go 1.24+ is installed.
```bash
go install github.com/nizos/tdd-guard/reporters/go/cmd/tdd-guard-go@latest
```
--------------------------------
### Setup Reporter Test Dependencies
Source: https://github.com/nizos/tdd-guard/blob/main/DEVELOPMENT.md
Installs language-specific dependencies required for running reporter tests. This includes Composer for PHP, pip for Python, Go build, and Bundler for Ruby.
```bash
# Install PHPUnit dependencies
composer install -d reporters/phpunit
# Set up Python virtual environment and install pytest
python3 -m venv reporters/pytest/.venv
reporters/pytest/.venv/bin/pip install -e reporters/pytest pytest
# Build Go reporter
go build -C reporters/go ./cmd/tdd-guard-go
# Install RSpec dependencies
bundle install --gemfile=reporters/rspec/Gemfile
# Build Rust reporter
cargo build --release --manifest-path reporters/rust/Cargo.toml
```
--------------------------------
### Install Reporter Directly
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/minitest/README.md
Install the tdd-guard-minitest gem directly using the gem command.
```bash
gem install tdd-guard-minitest
```
--------------------------------
### Install Rust Reporter
Source: https://github.com/nizos/tdd-guard/blob/main/docs/installation.md
Install the tdd-guard-rust reporter using cargo install.
```bash
cargo install tdd-guard-rust
```
--------------------------------
### Install Storybook Vitest Addon
Source: https://github.com/nizos/tdd-guard/blob/main/docs/storybook-vitest-addon.md
Install the @storybook/addon-vitest package as a development dependency.
```bash
npm install --save-dev @storybook/addon-vitest
```
--------------------------------
### Install PHPUnit Reporter
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/phpunit/README.md
Install the TDD Guard PHPUnit reporter using Composer.
```bash
composer require --dev tdd-guard/phpunit
```
--------------------------------
### Makefile Integration Example
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/go/README.md
Demonstrates how to integrate the TDD Guard Go reporter into a Makefile for automated testing. This example includes specifying the project root.
```makefile
test:
go test -json ./... 2>&1 | tdd-guard-go -project-root /absolute/path/to/project/root
```
--------------------------------
### Install Dependencies and Build Project
Source: https://github.com/nizos/tdd-guard/blob/main/DEVELOPMENT.md
Installs project dependencies and builds the TypeScript packages. Run this before testing or development.
```bash
# Install dependencies
npm install
# Build the main package and all workspaces
npm run build
```
--------------------------------
### Copy Example pytest.ini
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/pytest/README.md
When developing the pytest reporter, copy the example configuration file to pytest.ini.
```bash
cp pytest.ini.example pytest.ini
```
--------------------------------
### Install RuboCop
Source: https://github.com/nizos/tdd-guard/blob/main/docs/linting.md
Install RuboCop using the Ruby gem package manager.
```bash
gem install rubocop
```
--------------------------------
### Install ESLint
Source: https://github.com/nizos/tdd-guard/blob/main/docs/linting.md
Install the latest version of ESLint as a development dependency using npm.
```bash
npm install --save-dev eslint@latest
```
--------------------------------
### Install Vitest Reporter
Source: https://github.com/nizos/tdd-guard/blob/main/docs/storybook-vitest-addon.md
Install the tdd-guard-vitest package to capture Storybook test results through Vitest.
```bash
npm install --save-dev tdd-guard-vitest
```
--------------------------------
### Install Dependencies and Run RSpec for Development
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/rspec/README.md
Install project dependencies using Bundler and then run RSpec tests to verify development changes.
```bash
bundle install
bundle exec rspec
```
--------------------------------
### Install TDD Guard Pytest Reporter
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/pytest/README.md
Install the plugin using pip. The plugin activates automatically upon installation.
```bash
pip install tdd-guard-pytest
```
--------------------------------
### Install TDD Guard Storybook Reporter
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/storybook/README.md
Install the tdd-guard-storybook package as a development dependency using npm.
```bash
npm install --save-dev tdd-guard-storybook
```
--------------------------------
### Install TDD Guard Jest Reporter
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/jest/README.md
Install the reporter as a development dependency using npm.
```bash
npm install --save-dev tdd-guard-jest
```
--------------------------------
### Install TDD Guard with Homebrew
Source: https://github.com/nizos/tdd-guard/blob/main/docs/installation.md
Use this command to install TDD Guard using Homebrew package manager.
```bash
brew install tdd-guard
```
--------------------------------
### Install TDD Guard Globally with npm
Source: https://github.com/nizos/tdd-guard/blob/main/docs/installation.md
Use this command to install TDD Guard globally on your system using npm.
```bash
npm install -g tdd-guard
```
--------------------------------
### Install TDD Guard RSpec Reporter
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/rspec/README.md
Install the tdd-guard-rspec gem directly using the gem command.
```bash
gem install tdd-guard-rspec
```
--------------------------------
### Check Local Claude Installation
Source: https://github.com/nizos/tdd-guard/blob/main/docs/config-migration.md
Locate the Claude binary installed in the user's local directory.
```bash
# Check local installation
ls ~/.claude/local/claude
```
--------------------------------
### Migrate Claude Installation using Built-in Command
Source: https://github.com/nizos/tdd-guard/blob/main/docs/config-migration.md
Execute the `/migrate-installer` command to migrate your Claude installation, simplifying its configuration for TDD Guard.
```bash
/migrate-installer
```
--------------------------------
### Check System-Wide Claude Installation
Source: https://github.com/nizos/tdd-guard/blob/main/docs/config-migration.md
Verify if the Claude binary is installed system-wide by checking its location in the system's PATH.
```bash
# Check system-wide installation
which claude
```
--------------------------------
### Update Vitest to Latest Version
Source: https://github.com/nizos/tdd-guard/blob/main/docs/configuration.md
Install the latest Vitest version to ensure correct test output format for TDD Guard.
```bash
npm install --save-dev vitest@latest
```
--------------------------------
### Storybook Reporter Setup
Source: https://github.com/nizos/tdd-guard/blob/main/plugin/skills/setup/SKILL.md
Configure the StorybookReporter in .storybook/test-runner.ts for TDD Guard integration. The reporter instance needs the 'projectRoot' option.
```typescript
// .storybook/test-runner.ts
import { StorybookReporter } from 'tdd-guard-storybook'
const reporter = new StorybookReporter({
projectRoot: '/absolute/path/to/project',
})
module.exports = {
async postVisit(page, context) {
await reporter.onStoryResult(context)
},
}
process.on('exit', () => {
reporter.onComplete()
})
```
--------------------------------
### Check TDD Guard CLI Version
Source: https://github.com/nizos/tdd-guard/blob/main/docs/configuration.md
Verify the currently installed global version of the TDD Guard CLI tool.
```bash
npm list -g tdd-guard
```
--------------------------------
### Require Autorun in Test Files
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/minitest/README.md
Require the autorun entry point before your test files to register the reporter and install an at_exit hook for load errors.
```ruby
require "tdd_guard_minitest/autorun"
```
--------------------------------
### Check TDD Guard Pytest Reporter Version
Source: https://github.com/nizos/tdd-guard/blob/main/docs/configuration.md
Display information about the installed TDD Guard pytest reporter package, including its version.
```bash
pip show tdd-guard-pytest
```
--------------------------------
### Configure Project Root in setup.cfg
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/pytest/README.md
Set the TDD Guard project root using the setup.cfg file. The path must be absolute.
```ini
[tool:pytest]
tdd_guard_project_root = /absolute/path/to/project/root
```
--------------------------------
### Configure Storybook Main File
Source: https://github.com/nizos/tdd-guard/blob/main/docs/storybook-vitest-addon.md
Add the @storybook/addon-vitest to your Storybook configuration in `.storybook/main.ts`.
```typescript
import type { StorybookConfig } from '@storybook/react-vite'
const config: StorybookConfig = {
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-vitest'],
framework: '@storybook/react-vite',
}
export default config
```
--------------------------------
### Migrate from Claude CLI to SDK Configuration
Source: https://github.com/nizos/tdd-guard/blob/main/docs/config-migration.md
Use `VALIDATION_CLIENT=sdk` to switch from the legacy Claude CLI configuration to the new SDK client. The SDK client is the default and eliminates the need for binary configuration.
```bash
# Old configuration:
MODEL_TYPE=claude_cli
USE_SYSTEM_CLAUDE=true # or false
```
```bash
# New configuration:
VALIDATION_CLIENT=sdk # Or omit entirely, as SDK is the default
```
--------------------------------
### Run Reporter Tests
Source: https://github.com/nizos/tdd-guard/blob/main/DEVELOPMENT.md
Executes all reporter tests after their respective dependencies have been set up.
```bash
# Run all reporter tests
npm run test:reporters
```
--------------------------------
### Configure Claude Binary via Symlink
Source: https://github.com/nizos/tdd-guard/blob/main/docs/config-migration.md
Create a symbolic link to your Claude binary in `~/.claude/local/claude` to help TDD Guard find it. This is an alternative to having it in the system PATH.
```bash
# Create directory if needed
mkdir -p ~/.claude/local
# Create symlink to your Claude binary
ln -s /path/to/your/claude ~/.claude/local/claude
```
```bash
ln -s /opt/homebrew/bin/claude ~/.claude/local/claude
```
--------------------------------
### Go Test Reporter Integration
Source: https://github.com/nizos/tdd-guard/blob/main/plugin/skills/setup/SKILL.md
Pipe the output of 'go test -json' to the tdd-guard-go command. Use the '-project-root' flag to specify the absolute project path.
```bash
go test -json ./... 2>&1 | tdd-guard-go -project-root /absolute/path/to/project
```
--------------------------------
### Run Tests
Source: https://github.com/nizos/tdd-guard/blob/main/docs/storybook-vitest-addon.md
Execute your tests using the standard npm test command. Storybook interaction tests will run alongside other Vitest tests.
```bash
npm run test
```
--------------------------------
### Configure Legacy CLI Client (Deprecated)
Source: https://github.com/nizos/tdd-guard/blob/main/docs/config-migration.md
Use `VALIDATION_CLIENT=cli` to configure the deprecated CLI client. This option is not recommended and requires separate Claude binary configuration.
```bash
VALIDATION_CLIENT=cli # Deprecated - use sdk instead
```
--------------------------------
### Configure Claude Binary via Environment Variable
Source: https://github.com/nizos/tdd-guard/blob/main/docs/config-migration.md
Set `USE_SYSTEM_CLAUDE=true` to indicate that the Claude binary is available in the system's PATH.
```bash
USE_SYSTEM_CLAUDE=true
```
--------------------------------
### Monorepo Directory Structure
Source: https://github.com/nizos/tdd-guard/blob/main/docs/adr/004-monorepo-architecture.md
Illustrates the proposed monorepo structure with the main CLI package and separate reporter packages for Vitest and Pytest.
```tree
tdd-guard/ # Main CLI package (npm)
├── src/ # Core functionality and shared code
└── package.json
reporters/
├── vitest/ # tdd-guard-vitest package (npm)
│ └── package.json
└── pytest/ # tdd-guard-pytest package (PyPI)
└── pyproject.toml
```
--------------------------------
### Go Makefile Integration
Source: https://github.com/nizos/tdd-guard/blob/main/docs/installation.md
Integrate the tdd-guard-go reporter into a Makefile for running Go tests.
```makefile
test:
go test -json ./... 2>&1 | tdd-guard-go -project-root /Users/username/projects/my-app
```
--------------------------------
### Set Project Root via Environment Variable
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/phpunit/README.md
Configure the project root for TDD Guard by exporting the TDD_GUARD_PROJECT_ROOT environment variable.
```bash
export TDD_GUARD_PROJECT_ROOT=/absolute/path/to/project/root
```
--------------------------------
### Project Root Configuration
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/go/README.md
Configures the TDD Guard Go reporter with a specific project root when tests are run in subdirectories. The path provided must be absolute.
```bash
go test -json ./... 2>&1 | tdd-guard-go -project-root /absolute/path/to/project/root
```
--------------------------------
### Directory-based Argument Building for Golangci-lint
Source: https://github.com/nizos/tdd-guard/blob/main/docs/adr/007-golangci-lint-path-support.md
This snippet shows how to construct arguments for golangci-lint by extracting unique directories from a list of file paths. It uses the `dirname` function and the `--path-mode=abs` flag to enable directory-based linting.
```typescript
const directories = [...new Set(filePaths.map((file) => dirname(file)))]
const args = [
'run',
'--output.json.path=stdout',
'--path-mode=abs',
...directories,
]
```
--------------------------------
### TDD Guard Development Commands
Source: https://github.com/nizos/tdd-guard/blob/main/CLAUDE.md
Common npm commands for building, testing, linting, and formatting the TDD Guard project.
```bash
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
```
--------------------------------
### Configure Project Root in pyproject.toml
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/pytest/README.md
Set the TDD Guard project root using the pyproject.toml file. The path must be absolute.
```toml
[tool.pytest.ini_options]
tdd_guard_project_root = "/absolute/path/to/project/root"
```
--------------------------------
### Run Single Test File
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/minitest/README.md
Execute a single test file directly using Ruby with the autorun option.
```bash
ruby -rtdd_guard_minitest/autorun test/my_test.rb
```
--------------------------------
### Run Tests with Gradle
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/junit5/README.md
Execute tests using Gradle. The TDD Guard JUnit5 listener registers automatically if the dependency is present on the test classpath.
```bash
./gradlew test
```
--------------------------------
### Basic Usage: Pipe Go Test Output
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/go/README.md
Integrates the TDD Guard Go reporter by piping the JSON output of `go test -json` to the reporter. This is the standard way to use the reporter in a pipeline.
```bash
go test -json ./... 2>&1 | tdd-guard-go
```
--------------------------------
### Configure PHPUnit 10.x/11.x/12.x Extension
Source: https://github.com/nizos/tdd-guard/blob/main/docs/installation.md
Add the TddGuardExtension to your phpunit.xml for PHPUnit 10.x/11.x/12.x. Specify the project root path if your phpunit.xml is not at the project root.
```xml
```
--------------------------------
### Run Main Tests
Source: https://github.com/nizos/tdd-guard/blob/main/DEVELOPMENT.md
Executes the main test suite for TDD Guard's core functionality. Includes options for running all, unit, or integration tests.
```bash
# Run all tests
npm test
# Run unit tests only (faster)
npm run test:unit
# Run integration tests
npm run test:integration
```
--------------------------------
### Configure PHPUnit 9.x Listener
Source: https://github.com/nizos/tdd-guard/blob/main/docs/installation.md
Add the TddGuardListener to your phpunit.xml for PHPUnit 9.x. Specify the project root path if your phpunit.xml is not at the project root.
```xml
/Users/username/projects/my-app
```
--------------------------------
### PHPUnit Reporter Configuration (PHPUnit 9.x)
Source: https://github.com/nizos/tdd-guard/blob/main/plugin/skills/setup/SKILL.md
Use the TddGuardListener in your phpunit.xml for PHPUnit 9.x. Pass the absolute project root path as an argument to the listener.
```xml
/absolute/path/to/project
```
--------------------------------
### PHPUnit Reporter Configuration (PHPUnit 10+)
Source: https://github.com/nizos/tdd-guard/blob/main/plugin/skills/setup/SKILL.md
Add the TddGuardExtension to your phpunit.xml for PHPUnit 10 and later. The 'projectRoot' parameter must be set to the absolute project path.
```xml
```
--------------------------------
### Enable TDD Guard
Source: https://github.com/nizos/tdd-guard/blob/main/docs/quick-commands.md
Type this command in your Claude Code prompt to enable TDD Guard enforcement.
```shell
tdd-guard on
```
--------------------------------
### Configure Jest Reporter in Workspace/Monorepo (Root)
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/jest/README.md
For monorepos, configure the reporter in the root jest.config.js, providing the absolute path to the project root using path.resolve.
```javascript
const path = require('path')
module.exports = {
reporters: [
'default',
[
'tdd-guard-jest',
{
projectRoot: path.resolve(__dirname),
},
],
],
}
```
--------------------------------
### Configure Workspace/Monorepo Reporter
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/vitest/README.md
For workspaces or monorepos, specify the project root path in the reporter options to correctly locate test results. This is done by passing an object with the `projectRoot` property to the reporter.
```typescript
// vitest.config.ts in project root
import { defineConfig } from 'vitest/config'
import path from 'path'
export default defineConfig({
test: {
reporters: [
'default',
['tdd-guard-vitest', { projectRoot: path.resolve(__dirname) }],
],
},
})
```
--------------------------------
### Minitest Autorun Configuration
Source: https://github.com/nizos/tdd-guard/blob/main/plugin/skills/setup/SKILL.md
Require 'tdd_guard_minitest/autorun' in your test_helper.rb file for Minitest integration with TDD Guard.
```ruby
# test/test_helper.rb
require "tdd_guard_minitest/autorun"
```
--------------------------------
### Basic Storybook Test Runner Configuration
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/storybook/README.md
Configure the Storybook test-runner to use the StorybookReporter. The reporter captures story results during the postVisit phase and finalizes on process exit.
```typescript
import { StorybookReporter } from 'tdd-guard-storybook'
const reporter = new StorybookReporter()
module.exports = {
async postVisit(page, context) {
await reporter.onStoryResult(context)
},
}
process.on('exit', () => {
reporter.onComplete()
})
```
--------------------------------
### pytest Reporter Configuration
Source: https://github.com/nizos/tdd-guard/blob/main/plugin/skills/setup/SKILL.md
Configure the tdd_guard_project_root setting in your pytest configuration file (pyproject.toml, pytest.ini, or setup.cfg).
```toml
[tool.pytest.ini_options]
tdd_guard_project_root = "/absolute/path/to/project"
```
--------------------------------
### Configure PostToolUse Hook (Manual)
Source: https://github.com/nizos/tdd-guard/blob/main/docs/linting.md
Manually configure the PostToolUse hook in your settings file to enable TDD Guard after tool execution for write or edit operations.
```json
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit|MultiEdit",
"hooks": [
{
"type": "command",
"command": "tdd-guard"
}
]
}
]
}
}
```
--------------------------------
### Simplified Issue Parsing for Golangci-lint Results
Source: https://github.com/nizos/tdd-guard/blob/main/docs/adr/007-golangci-lint-path-support.md
This snippet demonstrates a simplified approach to parsing issues from golangci-lint results when directory-based linting is used. Path resolution is not needed as issues are reported at the package level.
```typescript
// Simplified issue parsing (no path resolution needed)
const issues = results.flatMap(toIssue)
```
--------------------------------
### Configure Vitest Reporter
Source: https://github.com/nizos/tdd-guard/blob/main/docs/storybook-vitest-addon.md
Add the 'tdd-guard-vitest' reporter to your `vitest.config.ts` and specify the project root.
```typescript
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
reporters: [
'default',
['tdd-guard-vitest', { projectRoot: '/Users/username/projects/my-app' }],
],
},
})
```
--------------------------------
### Add SessionStart Hook to Claude Code Configuration
Source: https://github.com/nizos/tdd-guard/blob/main/docs/session-management.md
This JSON snippet shows how to manually add the SessionStart hook to your Claude Code settings file to enable TDD Guard's session management.
```json
{
"hooks": {
"SessionStart": [
{
"matcher": "startup|resume|clear",
"hooks": [
{
"type": "command",
"command": "tdd-guard"
}
]
}
]
}
}
```
--------------------------------
### Run Tests with TDD Guard and cargo test
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/rust/README.md
Executes Rust tests using cargo test with JSON output format and pipes the output to the tdd-guard-rust reporter. Requires nightly Rust for --format json.
```bash
cargo test -- -Z unstable-options --format json 2>&1 | tdd-guard-rust --project-root /absolute/path/to/project
```
--------------------------------
### Rust Makefile Integration
Source: https://github.com/nizos/tdd-guard/blob/main/docs/installation.md
Integrate the tdd-guard-rust reporter into a Makefile for running Rust tests using nextest.
```makefile
test:
cargo nextest run 2>&1 | tdd-guard-rust --project-root $(PWD) --passthrough
```
--------------------------------
### Set Validation Client to SDK
Source: https://github.com/nizos/tdd-guard/blob/main/docs/validation-model.md
Configure TDD Guard to use the Claude Agent SDK for validation. This is the default setting and can be omitted.
```bash
VALIDATION_CLIENT=sdk # Default, can be omitted
```
--------------------------------
### Configure Jest Reporter in Workspace/Monorepo (Subdirectory)
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/jest/README.md
If the Jest configuration is in a subdirectory of a workspace, specify the absolute path to the main project root in the reporter options.
```javascript
module.exports = {
reporters: [
'default',
[
'tdd-guard-jest',
{
projectRoot: '/Users/username/projects/my-app',
},
],
],
}
```
--------------------------------
### Custom Ignore Patterns Configuration
Source: https://github.com/nizos/tdd-guard/blob/main/docs/ignore-patterns.md
Configure custom ignore patterns by creating a `config.json` file. This JSON object defines whether TDD Guard is enabled and lists the glob patterns for files to be ignored. Custom patterns replace defaults, so include any desired defaults in this list.
```json
{
"guardEnabled": true,
"ignorePatterns": [
"*.md",
"*.css",
"*.json",
"*.yml",
"**/*.generated.ts",
"**/public/**",
"*.config.*"
]
}
```
--------------------------------
### Rust Test Reporter Integration
Source: https://github.com/nizos/tdd-guard/blob/main/plugin/skills/setup/SKILL.md
Pipe the output of 'cargo nextest run' to the tdd-guard-rust command. Use '--project-root' for the absolute project path and '--passthrough' to forward output.
```bash
cargo nextest run 2>&1 | tdd-guard-rust --project-root /absolute/path/to/project --passthrough
```
--------------------------------
### Run Tests with TDD Guard and cargo-nextest
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/rust/README.md
Executes Rust tests using cargo-nextest and pipes the output to the tdd-guard-rust reporter. The --project-root flag specifies the absolute path to the project directory.
```bash
cargo nextest run 2>&1 | tdd-guard-rust --project-root /absolute/path/to/project
```
--------------------------------
### Configure pytest Project Root
Source: https://github.com/nizos/tdd-guard/blob/main/docs/installation.md
Add the tdd_guard_project_root setting to your pyproject.toml file to specify the project root for TDD Guard.
```toml
[tool.pytest.ini_options]
tdd_guard_project_root = "/Users/username/projects/my-app"
```
--------------------------------
### Set Validation Client to API
Source: https://github.com/nizos/tdd-guard/blob/main/docs/validation-model.md
Configure TDD Guard to use the Anthropic API for validation. This is suitable for CI/CD environments and requires a separate API key.
```bash
VALIDATION_CLIENT=api
TDD_GUARD_ANTHROPIC_API_KEY=your_api_key_here
```
--------------------------------
### Run Tests with Maven
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/junit5/README.md
Execute tests using Maven. The TDD Guard JUnit5 listener registers automatically if the dependency is present on the test classpath.
```bash
mvn test
```
--------------------------------
### Migrate from Anthropic API to API Client Configuration
Source: https://github.com/nizos/tdd-guard/blob/main/docs/config-migration.md
Update `MODEL_TYPE=anthropic_api` to `VALIDATION_CLIENT=api` for Anthropic API configurations. The API key variable remains the same.
```bash
# Old configuration:
MODEL_TYPE=anthropic_api
TDD_GUARD_ANTHROPIC_API_KEY=your-api-key-here
```
```bash
# New configuration:
VALIDATION_CLIENT=api
TDD_GUARD_ANTHROPIC_API_KEY=your-api-key-here # Same key variable
```
--------------------------------
### Direct Execution of TDD Guard Rust Reporter (Auto Runner)
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/rust/README.md
Executes tests directly using the tdd-guard-rust reporter, which auto-detects the test runner (prefers nextest). Requires the --project-root flag.
```bash
# Auto-detect runner (prefers nextest)
tdd-guard-rust --project-root /absolute/path/to/project
```
--------------------------------
### TDD Guard Project Structure
Source: https://github.com/nizos/tdd-guard/blob/main/CLAUDE.md
Illustrates the directory organization for the TDD Guard project, including core functionality and language-specific reporters.
```tree
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.)
```
--------------------------------
### Add Reporter to Gemfile
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/minitest/README.md
Add the tdd-guard-minitest gem to your project's Gemfile for integration.
```ruby
gem "tdd-guard-minitest"
```
--------------------------------
### Direct Execution of TDD Guard Rust Reporter (Force Runner)
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/rust/README.md
Executes tests directly using the tdd-guard-rust reporter, forcing a specific test runner (nextest or cargo). Requires the --project-root flag.
```bash
# Force specific runner
tdd-guard-rust --project-root /absolute/path/to/project --runner nextest
tdd-guard-rust --project-root /absolute/path/to/project --runner cargo
```
--------------------------------
### Configure TDD Guard Environment Variables
Source: https://github.com/nizos/tdd-guard/blob/main/docs/configuration.md
Set environment variables in a .env file to configure TDD Guard's behavior, such as the validation client, model version, API key, and linter type.
```bash
# Validation client for TDD enforcement (optional)
# Options: 'sdk' (default) or 'api'
VALIDATION_CLIENT=sdk
# Model version for validation (optional)
# Default: claude-sonnet-4-0
# See https://docs.anthropic.com/en/docs/about-claude/models/overview
TDD_GUARD_MODEL_VERSION=claude-sonnet-4-0
# Anthropic API Key
# Required when VALIDATION_CLIENT is set to 'api'
# Get your API key from https://console.anthropic.com/
TDD_GUARD_ANTHROPIC_API_KEY=your-api-key-here
# Linter type for refactoring phase support (optional)
# Options: 'eslint', 'golangci-lint' or unset (no linting)
# See docs/linting.md for detailed setup and configuration
LINTER_TYPE=eslint
```
--------------------------------
### PHPUnit 9.x Configuration
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/phpunit/README.md
Configure PHPUnit 9.x to use the TDD Guard listener by adding it to your phpunit.xml file.
```xml
tests
/absolute/path/to/project/root
```
--------------------------------
### View Current Ignore Patterns
Source: https://github.com/nizos/tdd-guard/blob/main/docs/ignore-patterns.md
Check the `config.json` file to view the currently active ignore patterns. If no custom configuration exists, TDD Guard uses its default patterns.
```bash
cat .claude/tdd-guard/data/config.json
```
--------------------------------
### Configure TDD Guard Code Hooks
Source: https://github.com/nizos/tdd-guard/blob/main/docs/installation.md
Add these JSON hooks to your TDD Guard settings file to define behavior for different code actions like PreToolUse, UserPromptSubmit, and SessionStart.
```json
{
"hooks": {
"PreToolUse": [
{
"matcher": "Write|Edit|MultiEdit|TodoWrite",
"hooks": [
{
"type": "command",
"command": "tdd-guard"
}
]
}
],
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "tdd-guard"
}
]
}
],
"SessionStart": [
{
"matcher": "startup|resume|clear",
"hooks": [
{
"type": "command",
"command": "tdd-guard"
}
]
}
]
}
}
```
--------------------------------
### Run Rust Tests with Cargo Test and Reporter
Source: https://github.com/nizos/tdd-guard/blob/main/docs/installation.md
Use cargo test with specific flags and the tdd-guard-rust reporter. The --passthrough flag ensures test output is passed through.
```bash
# With cargo test
cargo test -- -Z unstable-options --format json 2>&1 | tdd-guard-rust --project-root /Users/username/projects/my-app --passthrough
```
--------------------------------
### Run Code Quality Checks
Source: https://github.com/nizos/tdd-guard/blob/main/DEVELOPMENT.md
Performs comprehensive code quality checks including type checking, linting, and formatting. Individual commands are available for specific checks.
```bash
# Run all checks (typecheck, lint, format, test)
npm run checks
# Individual commands
npm run typecheck # Type checking
npm run lint # Lint and auto-fix
npm run format # Format code with Prettier
```
--------------------------------
### Configure Project Root in pytest.ini
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/pytest/README.md
Set the TDD Guard project root using the pytest.ini file. The path must be absolute.
```ini
[pytest]
tdd_guard_project_root = /absolute/path/to/project/root
```
--------------------------------
### Set Best Results Model Version
Source: https://github.com/nizos/tdd-guard/blob/main/docs/validation-model.md
Configure TDD Guard to use the Claude model version that provides the best results, though it will be the slowest. This is recommended for critical validation tasks.
```bash
TDD_GUARD_MODEL_VERSION=claude-opus-4-1
```
--------------------------------
### Run Rust Tests with Nextest and Reporter
Source: https://github.com/nizos/tdd-guard/blob/main/docs/installation.md
Use cargo nextest with the tdd-guard-rust reporter. The --passthrough flag ensures test output is passed through.
```bash
# With nextest (recommended)
cargo nextest run 2>&1 | tdd-guard-rust --project-root /Users/username/projects/my-app --passthrough
```
--------------------------------
### ESLint Configuration for Refactoring
Source: https://github.com/nizos/tdd-guard/blob/main/docs/linting.md
Configure ESLint rules in your .eslintrc.js file to encourage meaningful refactoring by setting complexity, depth, and line limits.
```javascript
module.exports = {
rules: {
complexity: ['warn', 10],
'max-depth': ['warn', 4],
'max-lines-per-function': ['warn', 50],
'max-nested-callbacks': ['warn', 3],
'max-params': ['warn', 4],
},
}
```
--------------------------------
### Configure Jest Reporter in jest.config.js
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/jest/README.md
Add the 'tdd-guard-jest' reporter to your Jest configuration file. Specify the project root for correct path resolution.
```javascript
module.exports = {
reporters: [
'default',
[
'tdd-guard-jest',
{
projectRoot: __dirname,
},
],
],
}
```
--------------------------------
### Configure Rake::TestTask
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/minitest/README.md
Pass the autorun option to Rake::TestTask so that every 'rake test' invocation loads the reporter first.
```ruby
Rake::TestTask.new do |t|
t.ruby_opts << "-rtdd_guard_minitest/autorun"
end
```
--------------------------------
### Run RSpec with TDD Guard Formatter
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/rspec/README.md
Execute RSpec tests using the TddGuardRspec::Formatter to capture results for TDD Guard.
```bash
rspec --format TddGuardRspec::Formatter
```
--------------------------------
### Storybook Test Artifacts Structure
Source: https://github.com/nizos/tdd-guard/blob/main/docs/adr/008-storybook-reporter-design.md
Illustrates the directory structure for Storybook test artifacts, including configuration, components, and different types of story files.
```tree
reporters/test/storybook/
├── .storybook/
│ └── main.js # Storybook configuration
├── Calculator.js # Simple component module
├── single-passing.stories.js # Story with passing assertions
├── single-failing.stories.js # Story with failing expect()
└── single-import-error.stories.js # Story importing non-existent module
```
--------------------------------
### Set TDD Guard Project Root Environment Variable
Source: https://github.com/nizos/tdd-guard/blob/main/reporters/junit5/README.md
Configure the TDD_GUARD_PROJECT_ROOT environment variable to specify your project's root directory. This can be an absolute or relative path.
```bash
export TDD_GUARD_PROJECT_ROOT="/absolute/path/to/project/root"
```