TDDAI Claude Code Integration Guide
Overviewβ
This document details the comprehensive TDDAI (Test-Driven Development AI) integration with Claude Code hooks across the entire LLM Platform ecosystem. The integration provides intelligent TDD enforcement and contextual development assistance for all projects.
Implementation Summaryβ
Coverage Statisticsβ
- Total Projects Configured: 33 projects
- TypeScript Projects: 18
- PHP/Drupal Projects: 15
- Python Projects: 1
- Docker Services: 2
Project Categoriesβ
1. _CommonNPM TypeScript Projects (13 projects)β
- llmcli
- tddai
- llm-gateway
- llm-mcp
- llm-ui
- secure-project
- llm-gateway-sdk
- llm-docs
- llm-monitoring-stack
- bfapi
- bfapiclient
- bfllm
- unified-compliance
2. _DrupalSource Modules (12 modules)β
- llm
- mcp_registry
- gov_compliance
- api_normalizer
- alternative_services
- ai_agent_crewai
- ai_agent_huggingface
- ai_agent_orchestra
- ai_agentic_workflows
- ai_provider_langchain
- ai_provider_apple
- recipe_onboarding
3. _DrupalSource Recipes and Themes (3 projects)β
- Recipes/llm_platform
- Recipes/secure_drupal
- Themes/llm_platform_manager
4. Models and LLM-Tools Projects (5 projects)β
- Models/llm-platform-model
- Models/tddai-model
- LLM-Tools/tddai-cursor-agent
- LLM-Tools/docker-intelligence
- LLM-Tools/Qdrant
Directory Structureβ
Each configured project follows this structure:
project-root/
βββ .claude/
β βββ settings.json
β βββ hooks/
β βββ tdd-context-injector.[js|cjs]
β βββ tdd-compliance-guardian.[js|cjs]
βββ .tddai/
βββ config.yaml
Hook Implementationsβ
1. TDD Context Injector Hookβ
Purpose: Provides contextual TDD reminders and project-specific information when working in Claude Code.
Features:
- Automatic project type detection (TypeScript, Python, PHP, Docker)
- Dynamic coverage threshold display
- Project-specific command suggestions
- Framework detection (Jest, PHPUnit, pytest)
Example Output:
## TDD Context for TypeScript Project: llmcli
**Project Type**: typescript
**Framework**: jest
**Coverage Target**: 95%
### TDD Requirements:
- β
RED: Write failing test first
- β
GREEN: Make test pass (minimal code)
- β
REFACTOR: Improve code while keeping tests green
- β
Coverage: 95% minimum
- β
Follow typescript coding standards
2. TDD Compliance Guardian Hookβ
Purpose: Enforces TDD workflow by blocking production code changes without failing tests first.
Features:
- Monitors code-writing tools (Edit, MultiEdit, Write)
- Detects test vs production files
- Configurable enforcement via TDDAI config
- Project-specific reminders
Enforcement Message:
β οΈ TDD COMPLIANCE CHECK - TypeScript Project: llmcli
You're about to modify production code. Per TDD requirements:
1. β
Have you written a FAILING test first?
2. β
Is this the minimal code to make the test pass?
3. β
Are you in the GREEN or REFACTOR phase?
Configuration Filesβ
.claude/settings.jsonβ
{
"hooks": {
"UserPromptSubmit": {
"command": "/absolute/path/to/project/.claude/hooks/tdd-context-injector.js"
},
"PreToolUse": {
"command": "/absolute/path/to/project/.claude/hooks/tdd-compliance-guardian.js"
}
}
}
.tddai/config.yamlβ
project:
name: project-name
type: typescript|python|drupal-module|drupal-recipe|drupal-theme|docker-service
root: /absolute/path/to/project
testing:
framework: jest|phpunit|pytest|docker-test
coverageThreshold: 80-95
strictMode: false
testPatterns: [
"**/*.test.ts",
"**/*.spec.ts",
"__tests__/**/*.ts",
"tests/**/*.php",
"tests/**/*.py"
]
sourcePatterns: [
"src/**/*.ts",
"src/**/*.php",
"src/**/*.py",
"!src/**/*.test.ts",
"!src/**/*.spec.ts"
]
ai:
enabled: true
providers:
primary: ollama
fallbacks: [
anthropic,
openai
]
integrations:
claudeCode: true
gitHooks: true
ide: [
cursor,
vscode
]
quality:
enforcePhases: false
autoFix: true
generateMissingTests: true
Special Handlingβ
ES Module Projectsβ
Projects with "type": "module"
in package.json automatically have their hooks renamed to .cjs
files to ensure CommonJS compatibility.
Multi-Language Supportβ
The hooks automatically detect project type based on:
package.json
β TypeScript/JavaScriptrequirements.txt
or.py
files β Pythondocker-compose.yml
β Docker service.info.yml
β Drupal module/theme
Coverage Thresholds by Typeβ
- TypeScript projects: 95%
- Python projects: 90%
- PHP/Drupal projects: 80-95%
- Docker services: 80%
Setup Commandsβ
Batch Setup Scriptβ
# Setup for all TypeScript projects
for project in _CommonNPM/*; do
mkdir -p "$project/.claude/hooks"
# Create settings.json and hooks...
done
# Setup for all Drupal modules
for module in _DrupalSource/Modules/*; do
mkdir -p "$module/.claude/hooks"
# Create settings.json and hooks...
done
Testing the Integrationβ
Verify Hook Installationβ
# Test context injector
cd /path/to/project
node .claude/hooks/tdd-context-injector.js
# For ES modules
node .claude/hooks/tdd-context-injector.cjs
Expected Behaviorsβ
-
Opening a project in Claude Code:
- TDD context automatically appears
- Project-specific information displayed
-
Attempting to edit production code:
- Guardian hook triggers warning
- Must confirm TDD compliance
-
Editing test files:
- No blocking occurs
- Normal editing allowed
Troubleshootingβ
Common Issuesβ
-
"require is not defined" error
- Solution: Rename hooks to
.cjs
for ES module projects
- Solution: Rename hooks to
-
Hook not triggering
- Verify absolute paths in settings.json
- Check file permissions (hooks must be executable)
-
YAML parsing errors
- Ensure proper YAML syntax in config files
- No tabs, only spaces for indentation
Debug Commandsβ
# Check hook permissions
ls -la .claude/hooks/
# Test hook execution
node .claude/hooks/tdd-context-injector.js
# Verify Claude settings
cat .claude/settings.json | jq .
Benefitsβ
- Enforced TDD Workflow: Prevents code-first development patterns
- Contextual Assistance: Project-specific reminders and commands
- Quality Gates: Coverage thresholds visible at all times
- Multi-Language Support: Works across entire tech stack
- Seamless Integration: No manual activation required
Future Enhancementsβ
- Dynamic Coverage Analysis: Real-time coverage display in context
- Test Generation Suggestions: AI-powered test stubs
- Workflow Analytics: Track TDD compliance over time
- Team Synchronization: Shared TDD configurations
- IDE Integration: Beyond Claude Code to VS Code, Cursor
Maintenanceβ
Updating Hooksβ
# Update hook logic
vim .claude/hooks/tdd-context-injector.js
# Test changes
node .claude/hooks/tdd-context-injector.js
# Commit and propagate
git add .claude/
git commit -m "Update TDD hooks"
Adding New Projectsβ
- Create
.claude/
directory structure - Copy hook templates
- Update paths in settings.json
- Create
.tddai/config.yaml
- Test integration
Conclusionβ
The TDDAI Claude Code integration provides comprehensive TDD enforcement across the entire LLM Platform ecosystem. With 33 projects configured and intelligent multi-language support, developers receive consistent, contextual guidance to maintain high code quality standards through proper test-driven development practices.