From omni-sw
Progressive Disclosure Optimizer — Analyze and restructure Claude Code configuration files (CLAUDE.md, skills, commands, agents) to minimize token consumption. Supports both project roots (CLAUDE.md) and skill directories (SKILL.md). Applies hierarchical fragmentation, content indexing, skill extraction, and script extraction to reduce startup/trigger context cost. Use when: (1) analyzing repository token budget (/apply-progressive-disclosure analyze), (2) optimizing CLAUDE.md or SKILL.md for token efficiency (/apply-progressive-disclosure optimize), (3) generating before/after token reports (/apply-progressive-disclosure report), (4) optimizing a skill directory (/apply-progressive-disclosure analyze <skill-path>), or (5) user says "optimize context", "reduce tokens", "progressive disclosure", "context bloat", "token budget", "fragment CLAUDE.md", "optimize skill".
How this skill is triggered — by the user, by Claude, or both
Slash command
/omni-sw:apply-progressive-disclosureThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Reduce tokens loaded at startup by fragmenting monolithic Claude Code configuration into hierarchical, lazy-loaded structures.
Reduce tokens loaded at startup by fragmenting monolithic Claude Code configuration into hierarchical, lazy-loaded structures.
Read the argument after /apply-progressive-disclosure. Route to the matching mode:
analyze — Scan repository or skill, calculate token metrics, produce diagnostic reportoptimize — Apply fragmentation and restructuring (add --dry-run to preview without changes)report — Generate before/after comparison of token usageIf no argument: run analyze by default.
This skill uses agency_cli.py for all deterministic token analysis operations:
Resolve CLI path: find this skill's own SKILL.md via Glob (**/apply-progressive-disclosure/SKILL.md), then the CLI is at ../shared/scripts/agency_cli.py relative to the skill directory. Store result as {CLI}.
Before executing any mode, determine the target type:
CLAUDE.md → analyze as project rootSKILL.md → analyze as skill directorySkill mode uses skill-specific thresholds and targets from references/fragmentation-rules.md (see "Skill Directory" section).
Scan the target and produce a token budget report.
Workflow (both modes):
Use the CLI for the entire analysis — it handles project vs skill mode automatically:
# Run full token analysis
python {CLI} tokens analyze --root <target-path>
# Returns JSON: files, total_tokens, startup_tokens, fragmentation_candidates, etc.
# Find duplicate content
python {CLI} tokens deduplicate --root <target-path>
# Returns: duplicates with locations and token counts
# Generate the analysis report
python {CLI} report context-analysis --input <analysis-json> --output <target-path>/docs/CONTEXT_ANALYSIS.md
Present a summary to the user with the top 3 recommendations from the analysis output.
Apply progressive disclosure transformations. Read references/fragmentation-rules.md for thresholds and rules.
Workflow (Project mode):
Use CLI for deterministic fragmentation:
# Fragment CLAUDE.md (Priority 1)
python {CLI} tokens fragment --file <root>/CLAUDE.md --threshold 300 --output-dir <root>/agent_docs/ [--dry-run]
# Fragment a SKILL.md (Priority 1, skill mode)
python {CLI} tokens fragment-skill --file <path>/SKILL.md --threshold 300 --output-dir <path>/references/ [--dry-run]
After CLI handles the mechanical extraction, apply these judgment-based steps manually:
scripts/.python {CLI} tokens deduplicate --root <path> to find duplicates, then resolve manually.After applying changes:
# Generate before/after comparison report
python {CLI} tokens report --before <before-analysis.json> --after <after-analysis.json> --output <root>/docs/CONTEXT_REPORT.md
Present token savings summary to the user.
Constraints (both modes):
Generate a comparison report of token usage.
Workflow (both modes):
Locate docs/CONTEXT_ANALYSIS.md and docs/CONTEXT_MIGRATION.md in the target directory (project root or skill directory). If either is missing, inform the user which step to run first.
Re-scan current state to get live token counts.
Produce a diff report:
Write to docs/CONTEXT_REPORT.md in the target directory and display summary.
Never fragment or move these out of CLAUDE.md root, regardless of size:
npx claudepluginhub vitorandtxr/omni-sw --plugin omni-swOptimizes .claude/ configurations to cut token usage: compresses CLAUDE.md under 150 lines, deduplicates content, prunes unused skills with confirmation, extracts verbose sections to on-demand skills. Requires prior /evaluate.
Optimizes Claude Code skills for token efficiency using progressive disclosure, 500-line rule, and three-level loading of metadata, instructions, and resources.
Audits and restructures CLAUDE.md files to reduce token bloat and improve Claude compliance. Targets 2,500–3,500 tokens with a hard 5,000 limit.