Skill Context Refactoring (skill-context-refactor)
Refactor existing Agent Skills to dramatically reduce context window overhead, eliminate restrictive micro-management instructions (unhobble), and establish typed semantic interfaces.
Refactoring Workflow
Follow this 4-stage pipeline when refactoring any skill:
[1. Audit & Benchmark] ──> [2. Unhobble] ──> [3. Design Interfaces] ──> [4. Progressive Disclosure]
Stage 1: Audit & Benchmark
- Measure initial metrics: line count, line count of
SKILL.md, estimated token size, and count of restrictive keywords (MUST,NEVER,ALWAYS,DO NOT). - Identify core capability vs. auxiliary details:
- Core Spine: Workflow steps, triggering logic, essential parameters.
- Auxiliary: Deep domain knowledge, edge-case handling rules, long output templates, verbose examples.
Stage 2: Unhobble (Strip Micro-Regulations)
- Eliminate micro-management rules that restrict reasoning without adding quality.
- Before: "NEVER write more than 3 bullet points. ALWAYS use present tense. DO NOT use adjectives."
- After: State the goal clearly and explain the rationale: "Keep summary bullet points concise and focused on actionable technical decisions so the reader can digest changes rapidly."
- Remove redundant, duplicate, or contradictory constraints across sections.
- Replace rigid MUST/NEVER directives with intent descriptions and boundary conditions.
Stage 3: Design Interfaces (Semantic Interface Refactoring)
- Replace free-text example blocks with typed JSON/YAML Schemas or TypeScript/Pydantic interface specs.
- Define explicit Enums for categorical fields (e.g. status, severity, category).
- Specify strict contract formats for inputs, outputs, and intermediate data structures.
- Read
references/context_engineering_principles.mdfor schema templates and design patterns.
Stage 4: Progressive Disclosure (Lean Spine Architecture)
- Restructure
SKILL.mdinto a Lean Spine (<200 lines target). - Move auxiliary content into dedicated reference files:
references/schema.mdorreferences/<topic>.mdfor schemas and templates.scripts/for deterministic tasks, scripts, or parsers.
- Add explicit triggers in
SKILL.mdspecifying when to load reference files on-demand. - Verify using
references/refactor_checklist.md.
Verification & Metrics
After refactoring, verify against target benchmarks:
- Token / Line Reduction: Target >= 40-50% reduction in
SKILL.mdline count. - Strict Interfaces: All structured outputs must have explicit schemas or Enums.
- Spine Budget:
SKILL.mdshould be under 200 lines (hard max 300 lines).