An agent skill that optimizes agent context files (AGENTS.md, CLAUDE.md, .cursorrules, .windsurfrules, etc.) using Addy Osmani's agents-md methodology.
Applies the discoverability filter to your agent context files:
- Baseline Analysis — Classifies every section as
discoverable,operational, orverbose - Gotcha Mining — Scans source code for non-obvious operational knowledge missing from your docs
- Optimization — Removes redundant content, compresses verbose sections, adds discovered gotchas
- Verification — Before/after statistics proving the optimization
Research shows redundant context degrades agent performance by 15-20%, while focused operational knowledge (gotchas, landmines) reduces runtime by ~28%.
npx skills add CaesiumY/agents-md-optimizerOr install from a local clone:
npx skills add ~/path/to/agents-md-optimizerAfter installation, trigger the skill in your AI coding agent with any of these phrases:
optimize CLAUDE.mdstreamline CLAUDE.mdagents-mddiscoverability filteradd gotchasoptimize AGENTS.mdoptimize context fileoptimize .cursorrules
| Flag | Effect |
|---|---|
--dry-run |
Analyze and show diff without modifying the file |
--report-only |
Output statistics and classification table only |
--path <path> |
Target file path (auto-detects if not specified) |
--help |
Display usage and exit |
When --path is not specified, the skill automatically searches for the first available file:
AGENTS.md → CLAUDE.md → .cursorrules → CURSOR.md → .github/copilot-instructions.md → .windsurfrules → codex.md
optimize CLAUDE.md
optimize CLAUDE.md --dry-run
optimize CLAUDE.md --report-only
optimize AGENTS.md --path ./AGENTS.md
Works with any AI coding agent that supports skills:
Claude Code · Cursor · GitHub Copilot · Windsurf · Cline · Gemini CLI · OpenAI Codex · and more
For each line in your context file, the skill asks:
"Can an agent discover this using Glob, Grep, or Read within 10 seconds?"
- Yes → Remove (directory trees, data flow diagrams, tech stack descriptions)
- No → Keep (timing constraints, implicit semantics, platform gotchas)
- Partially → Compress to the non-obvious implication
The skill systematically scans your codebase for 8 categories of hidden operational knowledge:
- Timing & Ordering — Hidden time budgets, sequencing requirements
- Implicit Semantics — Values that mean something unexpected
- Platform Detection — Non-obvious platform behavior
- Mandatory Contracts — Entry points that MUST produce specific output
- Error Exit Policies — Non-standard error handling
- Hidden Config Rules — Configuration behaviors not apparent from schema
- Cooldown & Dedup — Rate limiting with non-obvious scope
- Reserved Features — Defined interfaces with no implementation
A typical optimization on a real project:
| Metric | Before | After | Change |
|---|---|---|---|
| Total lines | 182 | 90 | -51% |
| Discoverable lines | 80 | 0 | Removed |
| Operational lines | 60 | 55 | Kept |
| Gotcha items | 0 | 25 | Added |
This skill is built on:
- Addy Osmani — agents-md: the developer's guide to AGENTS.md
- Lulla et al. (2026) — Human-authored AGENTS.md reduced runtime by 28.64%
- ETH Zurich — LLM-generated context files reduced success by 2-3%
MIT