optimizing-large-skills
19
总安装量
13
周安装量
#18614
全站排名
安装命令
npx skills add https://github.com/athola/claude-night-market --skill optimizing-large-skills
Agent 安装分布
claude-code
12
opencode
8
codex
7
antigravity
6
gemini-cli
6
Skill 文档
Table of Contents
- When to Use
- Core Pattern: Externalize-Consolidate-Progress
- Quick Reference
- Optimization Workflow
- Key Success Factors
- Modules
Optimizing Large Skills
Systematic methodology for reducing skill file size while preserving functionality through separation of concerns and strategic code organization.
When To Use
Symptoms that trigger this skill:
- Skills-eval validation shows “[WARN] Large skill file” warnings
- SKILL.md files exceed 300 lines
- Multiple code blocks (10+) with similar functionality
- Heavy Python implementations inline with markdown
- Functions >20 lines embedded in documentation
Quick Analysis:
# Analyze any skill file for optimization opportunities
python skills/optimizing-large-skills/tools/optimization-patterns.py \
skills/path/SKILL.md --verbose --generate-plan
When NOT To Use
- Skill is under 300 lines and well-organized
Core Pattern: Externalize-Consolidate-Progress
Transformation Pattern
Before: 654-line skill with heavy inline Python implementations After: ~150-line skill with external tools and references
Key Changes:
- Externalize heavy implementations (>20 lines) to dedicated tools
- Consolidate similar functions with parameterization
- Replace code blocks with structured data and tool references
- Implement progressive loading for non-essential content
Quick Reference
Size Reduction Strategies
| Strategy | Impact | When to Use |
|---|---|---|
| Externalize Python modules | 60-70% reduction | Heavy implementations (>20 lines) |
| Consolidate similar functions | 15-20% reduction | Repeated patterns with minor variations |
| Replace code with structured data | 10-15% reduction | Configuration-driven logic |
| Progressive loading patterns | 5-10% reduction | Multi-stage workflows |
File Organization
skill-name/
SKILL.md # Core documentation (~150-200 lines)
modules/
examples.md # Usage examples and anti-patterns
patterns.md # Detailed implementation patterns
tools/
analyzer.py # Heavy implementations with CLI
config.yaml # Structured data
examples/
basic-usage.py # Minimal working example
Optimization Workflow
Phase 1: Analysis
- Identify files >300 lines
- Count code blocks and functions
- Measure inline code vs documentation ratio
- Find repeated patterns and similar functions
Phase 2: Externalization
- Move heavy implementations (>20 lines) to separate files
- Add CLI interfaces to externalized tools
- Create tool directory structure
- Add usage examples for each tool
Phase 3: Consolidation
- Merge similar functions with parameterization
- Replace code blocks with structured data where appropriate
- Implement progressive loading for non-essential content
- Update skill documentation to reference external tools
Phase 4: Validation
- Verify line count <300 (target: 150-200)
- Test all externalized tools work correctly
- Confirm progressive loading functions
- Run skills-eval validation to verify size reduction
Quick Decision Tree
Is skill >300 lines?
ââ No â Continue as-is (well-organized skills don't need optimization)
ââ Yes â Analyze composition
ââ Has heavy code blocks (>20 lines)?
â ââ Yes â Externalize to tools/ with CLI (60-70% reduction)
ââ Has repeated patterns?
â ââ Yes â Consolidate with parameterization (15-20% reduction)
ââ Has structured config data embedded?
â ââ Yes â Extract to config.yaml (10-15% reduction)
ââ Has non-essential details?
ââ Yes â Use progressive loading (5-10% reduction)
Key Success Factors
DO:
- â Always add CLI interfaces to external tools
- â Keep core concepts inline in SKILL.md
- â Consolidate related functionality
- â Include working examples
- â Test all tools have correct references
DON’T:
- â Externalize without CLI (hard to use/test)
- â Create too many small files (increases complexity)
- â Remove essential documentation (reduces discoverability)
- â Add complex dependencies (hard to maintain)
- â Skip usage examples (unclear tool usage)
Next Steps
- Run automated analysis: Use
optimization-patterns.pyto generate optimization plan - Review modules: Check
modules/patterns.mdfor detailed implementation patterns - Learn from examples: Review
modules/examples.mdfor anti-patterns to avoid - Apply systematically: Follow the 4-phase workflow above
- Validate results: Run skills-eval to confirm optimization success
Modules
- Detailed Patterns – Externalization, consolidation, and progressive loading implementation details
- Examples & Anti-Patterns – Real-world impact, common mistakes, and rationalization prevention
Result
Expected Outcome:
- 50-70% line count reduction
- 40-60% token usage reduction
- No skills-eval warnings
- Clear separation of concerns
- Maintainable external tools with CLI interfaces