Skip to main content

TDDAI Quick Reference Guide

πŸš€ Quick Start​

Install TDDAI in Your Project​

# For TypeScript/JavaScript projects
npm install --save-dev @bluefly/tddai

# For Python projects
pip install tddai

# For PHP/Drupal projects
composer require bluefly/tddai

Initialize TDDAI​

# Interactive setup
npx tddai init

# Quick setup with defaults
npx tddai init --defaults

# Setup Claude integration
npx tddai setup claude

πŸ“‹ Essential Commands​

Testing Commands​

# Run tests
npx tddai test

# Run specific test file
npx tddai test src/utils/helpers.test.ts

# Run with coverage
npx tddai coverage

# Watch mode
npx tddai test --watch

Validation & Compliance​

# Check TDD compliance
npx tddai validate

# Strict validation (fails on warnings)
npx tddai validate --strict

# Check specific files
npx tddai validate src/

AI-Powered Features​

# Generate missing tests
npx tddai generate-tests

# Analyze project quality
npx tddai improve analyze --detailed

# Auto-fix common issues
npx tddai improve fix --all

# AI chat assistance
npx llmcli ai chat "How do I test this async function?"

πŸ”§ Configuration​

Basic tddai.config.yml​

project:
name: my-project
type: typescript

testing:
framework: jest
coverageThreshold: 95

ai:
enabled: true
provider: ollama

Claude Settings (.claude/settings.json)​

{
"hooks": {
"UserPromptSubmit": {
"command": "/path/to/.claude/hooks/tdd-context-injector.js"
},
"PreToolUse": {
"command": "/path/to/.claude/hooks/tdd-compliance-guardian.js"
}
}
}

🎯 TDD Workflow​

1️⃣ RED Phase​

# Create test file
touch src/calculator.test.ts

# Write failing test
echo "test('adds numbers', () => {
expect(add(2, 3)).toBe(5);
});" > src/calculator.test.ts

# Verify it fails
npx tddai test src/calculator.test.ts

2️⃣ GREEN Phase​

# Create implementation
touch src/calculator.ts

# Write minimal code
echo "export const add = (a, b) => a + b;" > src/calculator.ts

# Verify test passes
npx tddai test src/calculator.test.ts

3️⃣ REFACTOR Phase​

# Improve code (with types)
echo "export const add = (a: number, b: number): number => {
return a + b;
};" > src/calculator.ts

# Ensure tests still pass
npx tddai test

πŸ“Š Coverage Thresholds​

Project TypeMinimumRecommendedExcellent
TypeScript85%90%95%+
Python80%85%90%+
PHP/Drupal75%80%85%+
Docker70%75%80%+

πŸ› οΈ Common Tasks​

Generate Tests for Existing Code​

# Single file
npx llmcli test-gen src/utils/parser.ts

# Multiple files
npx llmcli test-gen batch "src/**/*.ts"

# Analyze coverage gaps
npx llmcli test-gen analyze ./

Fix Common Issues​

# Auto-fix linting issues
npx tddai fix lint

# Update dependencies
npx tddai fix deps

# Fix test imports
npx tddai fix imports

Project Analysis​

# Full analysis
npx tddai improve analyze --all --detailed

# Quick health check
npx tddai status

# Coverage report
npx tddai coverage --report

⚑ Keyboard Shortcuts (Claude Code)​

ActionShortcutDescription
Run TestsCmd+Shift+TRun all tests
CoverageCmd+Shift+CShow coverage
GenerateCmd+Shift+GGenerate tests
ValidateCmd+Shift+VCheck compliance

🚨 Troubleshooting​

Hook Not Working​

# Check installation
ls -la .claude/hooks/

# Test manually
node .claude/hooks/tdd-context-injector.js

# Fix permissions
chmod +x .claude/hooks/*.js

Coverage Too Low​

# Find uncovered code
npx tddai coverage --show-uncovered

# Generate tests for gaps
npx tddai generate-tests --uncovered-only

# Focus on critical paths
npx tddai coverage --critical

ES Module Issues​

# For "type": "module" projects
mv .claude/hooks/*.js .claude/hooks/*.cjs

# Update settings
sed -i '' 's/\.js/.cjs/g' .claude/settings.json

πŸ“š Resources​

Documentation​

Examples​

Support​

  • Issues: gitlab.com/bluefly/tddai/issues
  • Discussions: gitlab.com/bluefly/tddai/discussions
  • Chat: #tddai on Slack

πŸ’‘ Pro Tips​

  1. Start Small: Write one test at a time
  2. Test Behavior: Not implementation details
  3. Keep It Simple: Minimal code to pass tests
  4. Refactor Often: Clean code with green tests
  5. Use AI: Let TDDAI generate boilerplate

🎯 Quick Wins​

# Monday: Setup TDDAI
npx tddai init --defaults

# Tuesday: Generate missing tests
npx tddai generate-tests

# Wednesday: Fix issues
npx tddai improve fix --all

# Thursday: Increase coverage
npx tddai coverage --improve

# Friday: Celebrate 95%+ coverage! πŸŽ‰
npx tddai status --celebrate

Remember: Red β†’ Green β†’ Refactor β†’ Repeat! πŸ”„