Claude Code Integration
Integrate fspec with Claude Code for AI-driven ACDD workflows using slash commands.
What is Claude Code?
Claude Code is Anthropic's official CLI tool for Claude AI that helps with software engineering tasks. It provides a conversational interface where you can use slash commands to trigger specialized workflows.
Why Integrate fspec with Claude Code?
fspec provides a powerful slash command for Claude Code:
/fspec
- ACDD workflow (both forward and reverse)
This command enables Claude to:
- ✅ Manage work through Kanban states
- ✅ Conduct Example Mapping discovery
- ✅ Generate validated Gherkin specifications
- ✅ Follow ACDD methodology rigorously
- ✅ Track progress with persistent state
Installation
Prerequisites
- Install fspec globally (see Local Installation)
- Install Claude Code from Anthropic
Initialize fspec in Your Project
cd /path/to/your/project
fspec init
This creates:
.claude/commands/fspec.md
- ACDD slash command for Claude Codespec/CLAUDE.md
- Specification guidelines for AI
Verify Installation
In Claude Code, type /
to see available commands. You should see:
/fspec
- Manage specifications and work units using ACDD (forward and reverse)
Using /fspec (Forward ACDD)
The /fspec
command helps Claude manage specifications and work units following ACDD workflow.
When to Use
Use /fspec
when:
- Starting a new feature from scratch
- You want Claude to follow ACDD methodology
- Managing work units and specifications together
- Need collaborative discovery (Example Mapping)
Example Workflow
User: /fspec Create a user authentication feature
Claude:
I'll help you create a user authentication feature using ACDD workflow.
Creating work unit...
$ fspec create-work-unit AUTH "User authentication"
✓ Work unit AUTH-001 created
Moving to specifying phase...
$ fspec update-work-unit-status AUTH-001 specifying
Let's start with Example Mapping. What are the key rules for authentication?
User: Email and password required, must validate format
Claude:
Adding rules...
$ fspec add-rule AUTH-001 "Email and password required for authentication"
$ fspec add-rule AUTH-001 "Email must be valid format"
Let me add some concrete examples...
$ fspec add-example AUTH-001 "user@example.com with password 'secret123' succeeds"
I have a question: Should we support OAuth providers like Google?
$ fspec add-question AUTH-001 "Should we support OAuth providers like Google/GitHub?"
[... workflow continues ...]
What /fspec Does
The command guides Claude to:
- Create work units with proper prefixes and epics
- Conduct Example Mapping by asking questions, capturing rules and examples
- Generate Gherkin scenarios from discovery artifacts
- Manage Kanban workflow through all states
- Link coverage between specs, tests, and implementation
- Follow ACDD phases strictly (no skipping)
Using Reverse ACDD with /fspec
Reverse ACDD mode helps Claude reverse engineer existing codebases to create specifications using the fspec reverse
command.
When to Use
Use Reverse ACDD when:
- You have existing code without specifications
- Want to document what the system currently does
- Transitioning a legacy project to ACDD
- Need to understand inherited code
Example Workflow
User: Analyze the authentication system in src/auth/ using fspec reverse
Claude:
I'll reverse engineer the authentication system using fspec reverse.
Analyzing codebase...
[Reads src/auth/login.ts, src/auth/register.ts, etc.]
Found 3 user-facing features:
1. User Login (POST /api/login)
2. User Registration (POST /api/register)
3. Password Reset (POST /api/reset-password)
Creating epic...
$ fspec create-epic user-management AUTH "User authentication and management"
Creating work unit for User Login...
$ fspec create-work-unit AUTH "User login feature" --epic=user-management
$ fspec update-work-unit-status AUTH-001 specifying
Inferring scenarios from code...
$ fspec create-feature "User Login"
$ fspec add-scenario user-login "Login with valid credentials"
$ fspec add-scenario user-login "Login with invalid password"
Creating skeleton test file...
[Creates src/__tests__/auth-login.test.ts]
Linking existing implementation...
$ fspec link-coverage user-login --scenario "Login with valid credentials" \
--test-file src/__tests__/auth-login.test.ts --test-lines 13-27 \
--impl-file src/auth/login.ts --impl-lines 45-67 \
--skip-validation
[... continues for all features ...]
What fspec reverse Does
The fspec reverse command guides Claude to:
- Analyze existing code to identify user-facing features
- Create work units for each discovered feature
- Infer scenarios from code behavior
- Generate feature files with best-guess acceptance criteria
- Create test skeletons (structure only, not implemented)
- Link coverage to existing implementation
- Document ambiguities for human clarification
Command Prompts
The slash commands load comprehensive prompts that guide Claude through ACDD workflows. These prompts include:
/fspec Prompt Includes
- Complete ACDD workflow steps
- fspec command reference
- Example Mapping guidance
- Gherkin best practices
- Coverage tracking instructions
- Error handling patterns
Reverse ACDD Mode Includes
- Code analysis strategies
- Scenario inference patterns
- Test skeleton generation
- Coverage linking for existing code
- Ambiguity documentation
- Transition to forward ACDD
Customizing Commands
You can customize the slash command by editing:
.claude/commands/fspec.md
- Modify ACDD workflowspec/CLAUDE.md
- Update specification guidelines
Best Practices
For Forward ACDD (/fspec)
- Start with discovery - Don't skip Example Mapping
- Answer questions - Red cards must be answered before proceeding
- Trust the workflow - Let Claude follow ACDD phases
- Review generated specs - Always validate Claude's Gherkin
For Reverse ACDD (fspec reverse)
- Provide context - Tell Claude which directories to analyze
- Clarify ambiguities - Review and answer ambiguous scenarios
- Implement skeletons - Use generated test skeletons as templates
- Validate coverage - Check that all code is mapped
General Tips
- Use explicit prefixes - AUTH, API, UI, etc. for clear organization
- Create epics first - Group related work for better tracking
- Check the board - Run
fspec board
to visualize progress - Trust coverage tracking - Keep specs, tests, and code linked
Troubleshooting
Commands not appearing
If /fspec
doesn't appear in Claude Code:
-
Verify file exists:
ls -la .claude/commands/ # Should show fspec.md
-
Restart Claude Code
-
Re-run
fspec init
if files are missing
Claude not following workflow
If Claude skips phases or doesn't use fspec commands:
-
Remind Claude about the workflow:
Please follow the ACDD workflow and use fspec commands
-
Reference the documentation:
Check spec/CLAUDE.md for the correct process
-
Use explicit commands:
Run: fspec update-work-unit-status AUTH-001 testing
Next Steps
- Quick Start - Try your first work unit
- ACDD Methodology - Understand the workflow
- Commands Reference - Learn all fspec commands
- Reverse ACDD Guide - Master reverse engineering