npx skills add https://github.com/eddiebe147/claude-settings --skill chain-builderSKILL.md
Chain Builder
The Chain Builder skill helps you design and execute multi-step prompt chains where the output of one prompt becomes the input to the next. This enables complex, multi-stage processing that would be difficult to accomplish in a single prompt, while maintaining clarity, modularity, and debuggability.
This skill guides you through chain design, identifying optimal breakpoints, managing data flow between steps, handling errors, and validating outputs at each stage. It's particularly valuable for tasks that involve multiple distinct phases like research → analysis → synthesis → formatting, or ideation → planning → implementation → review.
Use this skill when you have complex tasks that benefit from sequential processing, when you need intermediate validation between steps, or when different parts of a task require different specialized prompts or tools.
Core Workflows
Workflow 1: Design Prompt Chain from Goal
- Clarify the end goal:
- What's the final output?
- What quality standards apply?
- What constraints exist?
- Decompose into logical stages:
- Identify distinct phases
- Determine stage boundaries
- Order by dependencies
- Design individual prompts:
- Purpose of each stage
- Input requirements
- Output specifications
- Success criteria
- Define data flow:
- What passes between stages?
- What format for intermediate outputs?
- What state is maintained?
- Add validation:
- Checkpoints after each stage
- Quality gates
- Error handling
- Document the chain:
- Chain purpose
- Stage descriptions
- Data flow diagram
- Usage examples
- Test end-to-end
Workflow 2: Execute Existing Chain
- Load chain definition:
- Read chain specification
- Understand stages
- Prepare inputs
- Initialize chain state:
- Set initial inputs
- Prepare storage for outputs
- Initialize tracking
- Execute each stage sequentially:
- Run stage prompt
- Validate output
- If validation fails: Handle error
- If validation passes: Continue
- Store intermediate result
- Pass output to next stage
- Monitor progress:
- Track current stage
- Log outputs
- Report status
- Validate final output
- Report results and any issues
Workflow 3: Debug Chain Failure
- Identify failure point:
- Which stage failed?
- What was the input to that stage?
- What error occurred?
- Analyze root cause:
- Was input malformed?
- Was prompt unclear?
- Was validation too strict?
- Was context insufficient?
- Test stage in isolation:
- Run stage with known good input
- Verify prompt works correctly
- Check output format
- Fix the issue:
- Update prompt if unclear
- Adjust validation if too strict
- Add error handling if needed
- Improve data passing if malformed
- Retest from failure point
- Document the fix
Workflow 4: Optimize Chain Performance
- Analyze current chain:
- Execution time per stage
- Token usage per stage
- Success rate per stage
- Bottlenecks
- Identify optimization opportunities:
- Stages that could be parallelized
- Redundant processing
- Overly complex prompts
- Unnecessary validation
- Refactor for efficiency:
- Combine related stages
- Parallelize independent stages
- Simplify prompts
- Optimize data passing
- Maintain quality:
- Don't sacrifice accuracy for speed
- Keep validation comprehensive
- Preserve error handling
- Test optimized chain
- Measure improvements
Quick Reference
| Action | Command/Trigger |
|---|---|
| Design new chain | "Design a prompt chain for [goal]" |
| Execute chain | "Run this chain: [chain spec]" |
| Debug chain failure | "Debug this chain: [error details]" |
| Optimize chain | "Optimize this chain: [chain spec]" |
| Validate chain design | "Review this chain design: [spec]" |
| Add stage to chain | "Add stage for [purpose] to this chain" |
| Parallelize stages | "Which stages can run in parallel?" |
Best Practices
-
Keep Stages Focused: Each stage should have one clear purpose
- Don't mix research and analysis in one prompt
- Don't combine formatting with content generation
- Each stage = one transformation
-
Make Outputs Explicit: Define exactly what each stage produces
- Specify format (JSON, markdown, etc.)
- Define required fields
- Set quality criteria
- Provide examples
-
Validate Between Stages: Catch errors early
- Check output format
- Verify required fields exist
- Validate against criteria
- Fail fast if something's wrong
-
Handle Errors Gracefully: Plan for failures
- Define retry logic
- Provide fallback options
- Log failures for debugging
- Don't cascade bad data
-
Maintain State Carefully: Track what you need, discard what you don't
- Pass only necessary data for
...