Skill站外收录 @skilllib/skill-2014279394095738882
optimizing-large-skills
通过分离关注点和结构化组织,将大型技能文件拆分为核心文档与外部工具,实现代码精简与可维护性提升,适用于处理超长文件或重复逻辑的重构场景。
测试与安全 AI 技能
Skills.MD
# 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:**
```bash
# Analyze any skill file for optimization opportunities
python skills/optimizing-large-skills/tools/optimization-patterns.py \
skills/path/SKILL.md --verbose --generate-plan
```
## 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
1. **Run automated analysis**: Use `optimization-patterns.py` to generate optimization plan
2. **Review modules**: Check `modules/patterns.md` for detailed implementation patterns
3. **Learn from examples**: Review `modules/examples.md` for anti-patterns to avoid
4. **Apply systematically**: Follow the 4-phase workflow above
5. **Validate results**: Run skills-eval to confirm optimization success
## Modules
- **[Detailed Patterns](modules/patterns.md)** - Externalization, consolidation, and progressive loading implementation details
- **[Examples & Anti-Patterns](modules/examples.md)** - 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
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「optimizing-large-skills」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次