refine-workflow
Use when analyzing workflow effectiveness or identifying skill extraction opportunities - systematically identifies patterns worthy of new skills and improvement areas
SKILL.md
| Name | refine-workflow |
| Description | Use when analyzing workflow effectiveness or identifying skill extraction opportunities - systematically identifies patterns worthy of new skills and improvement areas |
name: refine-workflow description: Use when analyzing workflow effectiveness or identifying skill extraction opportunities - systematically identifies patterns worthy of new skills and improvement areas
Refine Workflow
Purpose
Analyze existing workflows to:
- Identify repeating patterns that should become skills
- Find quality gates embedded in workflows that should be extracted
- Discover context assembly patterns used across multiple workflows
- Optimize workflow efficiency and maintainability
When to Use This Skill
Activate when:
- User asks "How can we improve this workflow?"
- You notice repeated logic across multiple workflows
- A workflow is becoming too long or complex
- Quality controls are duplicated in multiple places
- Context gathering patterns are reused frequently
- User requests workflow analysis or optimization
Analysis Framework
1. Pattern Recognition
Scan workflows for these patterns:
Validation Patterns (candidates for quality gates):
- Citation checking logic
- Schema validation
- Style enforcement
- Link verification
- Data integrity checks
Context Assembly Patterns (candidates for context skills):
- Meeting transcript synthesis
- Research gathering by topic
- Priority scoring algorithms
- Source normalization logic
Reusable Procedures (candidates for technique skills):
- File parsing routines
- YAML processing
- State management
- Checkpoint creation
2. Duplication Detection
Identify logic duplicated across workflows:
Method:
- List all workflow skills in
.claude/skills/workflows/ - Read each SKILL.md file
- Identify common phrases, procedures, or validation steps
- Group duplicates by similarity
- Prioritize by frequency and impact
Threshold:
- If logic appears in 3+ workflows → strong extraction candidate
- If logic appears in 2 workflows → potential extraction candidate
- If logic is complex and appears once → consider extraction for clarity
3. Complexity Analysis
Measure workflow complexity:
Token Count:
- Count total tokens in SKILL.md
- If >1000 tokens → candidate for decomposition
- If >2000 tokens → high priority for decomposition
Step Count:
- Count numbered procedure steps
- If >10 steps → consider breaking into phases
- If >20 steps → high priority for decomposition
Quality Gates:
- Count embedded validation steps
- If >3 validations → extract quality gates
- If validation logic >100 tokens → extract as separate skill
4. Dependency Mapping
Understand skill relationships:
Create a dependency graph:
- List all workflow skills
- For each skill, identify invoked sub-skills
- Identify quality gates applied
- Map context assembly patterns used
- Visualize relationships
Look for:
- Skills that never invoke sub-skills (atomic candidates)
- Skills with circular dependencies (refactoring needed)
- Quality gates not yet extracted
- Orphaned workflows (unused skills)
Extraction Process
When to Extract a Quality Gate
Criteria:
- Validation logic appears in 2+ workflows
- Validation has pass/fail criteria
- Validation is atomic (self-contained)
- Validation enforces a specific standard
Extraction Steps:
- Use
create-skillmeta-skill - Target category:
.claude/skills/quality-gates/ - Define iron law (non-negotiable requirement)
- Include anti-rationalization blocks
- Update workflows to invoke the quality gate
Example:
Before: Citation checking embedded in content-pipeline skill
After: `citation-compliance` quality gate skill invoked by content-pipeline
When to Extract Context Assembly
Criteria:
- Context gathering logic appears in 2+ workflows
- Logic synthesizes data from multiple sources
- Logic applies reusable filters or transformations
- Logic produces standardized output format
Extraction Steps:
- Use
create-skillmeta-skill - Target category:
.claude/skills/context-assembly/ - Define input sources and output schema
- Include filtering and normalization logic
- Update workflows to invoke the context assembly skill
Example:
Before: Meeting synthesis logic duplicated in product-planning and cs-prep
After: `meeting-synthesis` context skill invoked by both workflows
When to Extract a Sub-Workflow
Criteria:
- Workflow has >10 steps
- Steps can be grouped into logical phases
- Phases have clear checkpoints
- Phases may be useful independently
Extraction Steps:
- Identify phase boundaries
- Create sub-workflow skills for each phase
- Update parent workflow to invoke sub-workflows
- Maintain state between phases
Example:
Before: content-pipeline (20 steps in one skill)
After: content-pipeline invokes:
- content-intent-gathering
- content-brief-creation
- content-outlining
- content-drafting
- content-snippet-generation
Optimization Techniques
Token Efficiency
Reduce token usage:
- Replace verbose examples with concise ones
- Use tables for quick reference
- Inline simple code, link to external files for complex code
- Remove redundant explanations
Targets:
- Frequently-loaded skills: <200 words
- Other skills: <500 words
Description Optimization (CSO)
Improve auto-discovery:
- Front-load distinctive triggering conditions
- Include specific symptoms (not abstract categories)
- Use third-person perspective
- Start with "Use when..."
Test effectiveness:
- Create scenarios where skill should activate
- Verify Claude auto-discovers the skill
- Refine description if activation fails
Cross-Reference Clarity
Improve skill invocation:
- Mark required dependencies with asterisks
- Use explicit skill names (not @ syntax)
- Explain integration points
- Document expected inputs/outputs
Refining Workflow
1. Analyze Current State
Run pattern recognition, duplication detection, and complexity analysis.
2. Identify Improvements
Prioritize extraction candidates:
- High duplication + high impact = highest priority
- High complexity + low modularity = high priority
- Single-use but complex = medium priority
3. Create Extraction Plan
For each candidate:
- Define new skill name and category
- Specify extraction boundaries (what moves, what stays)
- Identify workflows that will invoke the new skill
- Estimate token savings
4. Execute Extractions
Use create-skill meta-skill for each new skill:
- Write failing test first
- Extract logic into new SKILL.md
- Update parent workflows to invoke new skill
- Validate integration
5. Validate Improvements
Metrics:
- Total token count before/after
- Duplication eliminated (lines of duplicated logic removed)
- Modularity score (number of reusable components)
- Maintainability (ease of updating)
Success Criteria
Workflow is refined when:
- No logic duplicated across 3+ workflows
- All workflows <1000 tokens
- Quality gates extracted and reusable
- Context assembly patterns standardized
- Skill dependencies clearly mapped
- Token efficiency maximized
Common Mistakes
| Mistake | Fix |
|---|---|
| Extracting too aggressively | Keep skills >100 words; don't over-modularize |
| Missing CSO opportunities | Optimize descriptions for auto-discovery |
| Breaking working workflows | Test before/after with real scenarios |
| Not updating invoking workflows | Ensure parent workflows reference new skills |
| Forgetting documentation | Use documentation-sync quality gate (all 6 files) |
Related Skills
- create-skill: Use after identifying extraction candidates
- skill-discovery: Find existing skills before creating duplicates
- using-skills: Ensure extracted skills are used mandatorily
- documentation-sync: Required for maintaining documentation consistency after extraction