Install
openclaw skills install skill-rules-designerAnalyzes an existing Claude Code skill and designs an optimal rules/ file structure. Covers three operations: (1) compressing SKILL.md by moving verbose cont...
openclaw skills install skill-rules-designerYou help users restructure existing Claude Code skills. The guiding principle is lossless restructuring: every operation either moves content to a new location, or adds new content. Nothing is ever deleted without being placed somewhere else first.
There are four things you can do to a skill, and you should analyze which apply:
Compress — move verbose content from SKILL.md into a rules file. SKILL.md gets shorter, total content is unchanged, per-invocation token cost is unchanged (rules files in a skill's directory are still loaded). Worth doing for readability and maintainability.
Encapsulate — move content that is only needed in some invocations into a rules file that is loaded conditionally. SKILL.md shrinks AND per-invocation token cost drops. This is the highest-value operation.
Enrich — create a new rules file containing templates, checklists, or scripts for something the skill currently handles by ad-hoc reasoning each time. Doesn't shorten SKILL.md but makes the skill faster, more consistent, and more capable.
Harden — rewrite vague instructions in any file to make them precise and unambiguous. No structural change; improves reliability.
Always show a plan first. Wait for user confirmation before writing anything.
Ask for the skill directory path (or accept it if already provided).
Read:
SKILL.md (required — stop if missing)rules/*.md filesscripts/ or assets/ directories (note what exists)Build a mental model: what does this skill do, what are its phases, what files exist?
Print a one-line inventory:
skill-track — SKILL.md (59 lines) + 6 rules files (640 lines total)
Work through each of the four operations. For each one, identify specific candidates.
Look for content in SKILL.md that is:
For each candidate: name it, estimate line count, state what file it would move to.
Look for content in SKILL.md (or existing rules files) that is only needed sometimes:
For each candidate: name it, estimate token savings per typical invocation, state the condition that gates it.
Look for steps where the skill currently says something like:
For each candidate: describe what the new file would contain, why it saves the model from reasoning from scratch, and what the skill currently does instead.
Look for instructions that use vague verbs or implicit branching:
For each candidate: quote the original, explain the ambiguity, propose a precise rewrite.
Use this format:
## Restructuring Plan — [skill name]
Current: SKILL.md ([N] lines) + [N] rules files
After: SKILL.md (~[N] lines) + [N] rules files
### Compress
→ Move [section name] (~[N] lines) → rules/[filename].md
[One sentence on why this is worth doing]
→ (or: Nothing to compress — SKILL.md is already lean)
### Encapsulate
→ Move [section name] (~[N] lines) → rules/[filename].md
Condition: only loaded when [specific trigger]
Token savings: ~[N] lines on typical invocations that skip this path
→ (or: No clear encapsulation opportunities)
### Enrich
→ New file: rules/[filename].md
Contains: [what it holds — template, checklist, script]
Replaces: [what the skill currently does ad-hoc]
→ (or: No enrichment needed)
### Harden
1. [file:line] "[original quote]"
Problem: [why it's ambiguous]
Proposed: "[precise rewrite]"
→ (or: No vague instructions found)
---
Lossless check: all content currently in SKILL.md will exist in the new file set.
No original content is removed without a destination.
After the plan, ask:
Does this look right? Tell me:
- Any changes to the plan
- Which operations to skip
- Whether to write all files at once or one at a time
Say "go" to proceed.
Once confirmed, write in this order to preserve losslessness:
rules/*.md files with the content they'll receiveNever remove content from SKILL.md until it has been written to its destination file.
Each new rules file structure:
# [filename] — [one-line purpose]
[Content]
References in updated SKILL.md:
## Modules
- `rules/[name].md` — [when to read it]
Print a summary when done:
Done.
✓ Created rules/[name].md ([N] lines) [compress/encapsulate/enrich]
✓ Updated SKILL.md: [before] → [after] lines
Token impact: [N] lines removed from always-loaded context.
[Module] only loads when [condition] — saves ~[N] tokens on [typical scenario].
The restructuring is lossless when:
If the user asks you to delete a section with no destination, propose a destination first. If no destination makes sense, suggest keeping it in SKILL.md even if it's long.
Use this when the user wants to compare two versions of a skill (e.g., before and after a restructuring) to check whether quality degraded and quantify the token/time tradeoff.
This section follows the same pattern as skill-creator's eval workflow. Read the agent files
in agents/ and the schemas in references/schemas.md when running evals.
<skill-name>-workspace/
ab-comparison/
eval-1/
version_a/outputs/
version_b/outputs/
eval-2/
version_a/outputs/
version_b/outputs/
eval-3/
version_a/outputs/
version_b/outputs/
Create an eval_metadata.json in each eval directory:
{
"eval_id": 1,
"eval_name": "descriptive-name-here",
"prompt": "The eval prompt",
"assertions": []
}
For each of the 3 test cases (see evals/evals.json), spawn two subagents simultaneously:
Prompt template for each executor subagent:
Execute this task using the skill at <skill-path>:
Task: <eval prompt>
Save all output files to: <workspace>/ab-comparison/eval-<ID>/<version>/outputs/
Also save a transcript.md summarizing your steps to that same outputs/ directory.
While runs execute, draft assertions for each eval and add them to eval_metadata.json.
Good assertions for skill-rules-designer check:
When each subagent completes, save the total_tokens and duration_ms from the task
notification immediately to timing.json in the run directory. This data is not persisted
elsewhere.
Spawn a grader subagent per run using agents/grader.md. Save results to grading.json
in each run directory (sibling to outputs/).
Create benchmark.json at the workspace root using the schema in references/schemas.md.
Use "version_a" and "version_b" as the configuration values. Include:
run_summary with mean ± stddev for both versions and the deltanotes from an analyst pass (read agents/analyzer.md — "Analyzing Benchmark Results" section)Print a formatted summary directly in the terminal. No viewer needed.
## A/B Comparison — skill-rules-designer
─────────────────────────────────────────────────
Quality (Pass Rate) Version A: 86% Version B: 71% Δ +15% ✓ A wins
Token Usage Version A: 42,500 Version B: 31,000 Δ +37% ✗ A costs more
Duration Version A: 95s Version B: 78s Δ +22% ✗ A is slower
─────────────────────────────────────────────────
Per-eval breakdown:
Eval 1 — compress-and-encapsulate
Version A: 6/7 passed (86%) │ 95s │ 42,500 tok
Version B: 5/7 passed (71%) │ 80s │ 32,000 tok
✗ Version B missed: "SKILL.md updated with module references"
Eval 2 — harden-vague-instructions
Version A: 7/7 passed (100%) │ 88s │ 39,000 tok
Version B: 4/7 passed (57%) │ 72s │ 28,000 tok
✗ Version B missed: "Quotes the original instruction verbatim"
"Explains the ambiguity precisely"
"Presents change as plan before applying"
Eval 3 — enrich-with-template
Version A: 6/7 passed (86%) │ 102s │ 46,500 tok
Version B: 6/7 passed (86%) │ 82s │ 33,000 tok
✗ Both missed: "Template contains actual section headers"
─────────────────────────────────────────────────
Analysis notes:
• Version A consistently enforces plan-before-write; Version B skips it under time pressure
• Token cost of Version A is higher due to additional losslessness verification steps
• Eval 2 shows the largest quality gap — harden workflow needs clearer trigger in Version B
Adapt the actual numbers and missed assertions from the real grading results.
For deeper analysis, run the blind comparator on each eval's outputs:
agents/comparator.md without revealing which is A/Bcomparison-<eval_id>.jsonagents/analyzer.md to understand why the winner wonSee references/schemas.md for the comparison.json and analysis.json schemas.
agents/grader.md — How to evaluate assertions against outputsagents/comparator.md — How to do blind A/B comparison between two outputsagents/analyzer.md — How to analyze why one version beat anotherreferences/schemas.md — JSON schemas for evals.json, grading.json, benchmark.json, etc.evals/evals.json — The 3 test cases for this skill