# Skill Compact

> Shrink the token footprint of Claude Code SKILL.md files without breaking the skill. Reports always-on description cost vs on-invoke body cost, losslessly minifies bodies, and validates a proposed shorter description keeps every trigger keyword before applying it. Use to trim a bloated skill library, reduce per-session context, or compact one skill's SKILL.md.

- Skill: `momenbasel/skill-compact` (Agent Skill, multi-file: 4 files)
- Install (CLI): `npx skillmds@latest add momenbasel/skill-compact`
- Raw SKILL.md: https://api.skillmd.com/api/skills/momenbasel/skill-compact/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: momenbasel (https://skillmd.com/u/momenbasel)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/momenbasel/skill-compact

---


# skill-compact

A skill's frontmatter description loads into every session. Its body loads only
when invoked. skill-compact attacks the always-on cost first, then the body,
and refuses any change that drops an activation trigger.

## Commands
- `analyze` - token report: always-on description cost, over-budget skills, reclaimable tokens
- `body <skill> [--apply]` - lossless body minify (strip HTML comments, collapse blank lines, trailing whitespace)
- `check <skill> --desc "..."` - dry-run: does a proposed description keep every trigger keyword and fit the budget
- `set-desc <skill> --desc "..." [--force]` - validate then apply a new description (backup written)

## Fidelity guarantee
`check`/`set-desc` extract trigger tokens from the original description (quoted
phrases, slash-commands, kebab and CamelCase identifiers, acronyms) and reject a
rewrite that drops any of them. The model proposes shorter prose; the tool
guarantees no trigger is lost. Every apply writes a timestamped `.orig` backup.

## Workflow
```bash
python3 scripts/analyze.py --top 20            # find the worst offenders
python3 scripts/compact.py check <skill> --desc "<shorter>"   # prove it is safe
python3 scripts/compact.py set-desc <skill> --desc "<shorter>"  # apply
python3 scripts/compact.py body <skill> --apply               # minify body
```

