Skill Chains
Orchestrate multiple skills for complex workflows.
Overview
Skill chains allow you to:
- Combine multiple skills sequentially
- Pass state between skills
- Handle errors gracefully
- Create reusable workflows
- Implement verification loops
When to Use Skill Chains
Use skill chains when:
- Tasks require multiple steps
- Different domains are involved
- Verification is needed after implementation
- Workflows are reusable
Examples:
- "Implement and test a feature"
- "Refactor and verify code"
- "Create documentation and examples"
Chain Structure
A skill chain is a sequence of skills with state passing:
yaml
skill-chain:
name: implement-verify
skills:
- name: dev
module: architecture.md
verify: false
continue_on_error: false
- name: verification
module: testing-standards.md
verify: true
continue_on_error: true
- name: formatter
module: coding-standards.md
verify: false
continue_on_error: trueState Passing
State flows between skills through:
1. Task List (todowrite)
First skill creates a task list:
python
todowrite({
"todos": [
{"content": "Implement API endpoint", "status": "pending"},
{"content": "Write tests", "status": "pending"},
{"content": "Run tests", "status": "pending"}
]
})Subsequent skills update task list:
python
todowrite({
"todos": [
{"content": "Implement API endpoint", "status": "completed"},
{"content": "Write tests", "status": "in_progress"},
{"content": "Run tests", "status": "pending"}
]
})2. File Persistence
Write intermediate results:
python
# Skill 1: Implement
file.write("implementation.json", results)
# Skill 2: Verify
results = file.read("implementation.json")
# Verify implementation3. Plan Files
Save and load plan state:
python
# Skill 1: Plan
plan.save_state("plan_state.json")
# Skill 2: Execute
plan = Plan.load_state("plan_state.json")
plan.execute()Error Handling
Skill chains handle errors based on configuration:
continue_on_error: false
Chain stops on first error:
yaml
skills:
- name: implement
continue_on_error: false # Stop here on error
- name: verify
continue_on_error: falseResult: If implement fails, verify never runs.
continue_on_error: true
Chain continues despite errors:
yaml
skills:
- name: implement
continue_on_error: true # Continue even if this fails
- name: verify
continue_on_error: true
- name: report
continue_on_error: trueResult: All skills run, errors are collected in final report.
Common Chain Patterns
1. Implement-Verify
yaml
implement-verify:
skills:
- dev # Generate
- dev # Verify (built-in)
- formatter # Clean upFlow:
- Implement feature
- Verify correctness
- Format code
2. Research-Implement
yaml
research-implement:
skills:
- context # Explore codebase
- plan # Create plan
- dev # Implement
- dev # Verify (built-in)Flow:
- Research existing patterns
- Create implementation plan
- Execute implementation
- Verify results
3. Refactor-Verify
yaml
refactor-verify:
skills:
- dev # Refactor (includes refactoring methods)
- dev # Verify (built-in)
- dev # Run tests (if available)Flow:
- Refactor code structure
- Verify behavior unchanged
- Run test suite
4. Full Pipeline
yaml
full-pipeline:
skills:
- context # Understand context
- plan # Create plan
- dev # Implement
- dev # Verify correctness
- dev # Run tests
- dev # Format codeFlow:
- Research existing code
- Create implementation plan
- Write code
- Verify correctness
- Run tests
- Format code
- Commit changes (via direct git commands)
Creating a Skill Chain
Step 1: Define Chain
Create config/skill-chains.yaml:
yaml
my-chain:
name: My Custom Chain
description: Description of what this chain does
skills:
- skill-one
- skill-two
- skill-threeStep 2: Configure Each Skill
yaml
my-chain:
skills:
- name: dev
module: architecture.md
context:
project: "my-project"
branch: "main"
- name: verification
module: testing-standards.md
criteria:
- "All tests pass"
- "Code follows standards"Step 3: Define State Passing
yaml
my-chain:
state:
- task-list # Track progress
- plan-file # Save/load plans
- results-file # Pass resultsStep 4: Configure Error Handling
yaml
my-chain:
error_handling:
continue_on_error: true
collect_errors: true
on_failure: report-errorExample: Complete Chain
yaml
feature-implementation:
name: Feature Implementation Chain
description: Implements, tests, and commits a new feature
skills:
# Step 1: Research existing patterns
- name: context
module: architecture.md
output: research-results.json
continue_on_error: false
# Step 2: Create implementation plan
- name: plan
module: coding-standards.md
input: research-results.json
output: plan.json
continue_on_error: false
# Step 3: Implement feature
- name: dev
module: architecture.md
input: plan.json
output: implementation.json
continue_on_error: false
# Step 4: Verify correctness
- name: dev
module: testing-standards.md
input: implementation.json
output: verification-report.json
verify: true
iterations: 3
continue_on_error: true
# Step 5: Run tests
- name: dev
module: testing-standards.md
command: npm test
output: test-results.json
continue_on_error: true
# Step 6: Format code
- name: dev
command: npm run format
continue_on_error: true
# Step 7: Commit changes
- name: dev
type: conventional
continue_on_error: true
state:
- task-list # Track progress
- plan-file # Save/load plans
- results-file # Pass results
error_handling:
continue_on_error: true
collect_errors: true
final_report: implementation-summary.jsonRunning a Skill Chain
Skill chains are invoked through intent routing:
yaml
routes:
implement:
patterns:
- "implement.*feature"
- "add.*functionality"
confidence_threshold: 0.7
skill_chain: feature-implementation
strategy: sequentialUser: "Implement user authentication"
Execution:
- Intent classified as
implement - Route to
feature-implementationchain - Execute skills sequentially
- Generate final report
Best Practices
For Chain Authors
- Break down logically — Each skill should have clear purpose
- Define state passing — Specify how data flows between skills
- Handle errors gracefully — Configure
continue_on_errorappropriately - Verify at end — Final skill should validate entire chain
- Document dependencies — State which skills require which inputs
For Users
- Understand the chain — Know what each step does
- Review intermediate results — Check outputs between skills
- Handle errors — Review error reports if chain fails
- Iterate if needed — Re-run chain or individual skills
Research
This feature is based on research from:
- Modularity — "Agentic Proposing" (arXiv:2602.03279)
- Finding: Modular components beat monolithic approaches
- Implication: Use focused skills, not all-in-one agents
See Also
- Skill Execution — Individual skill usage
- Intent Routing — How chains are selected
- PAUL Methodology — Structured planning
- Verification Loops — Quality verification