Getting it into your agent
It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.
git clone --depth 1 https://github.com/richfrem/agent-plugins-skillsnpx agentmods add skills/richfrem/agent-plugins-skills/optimize-contextWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/richfrem/agent-plugins-skills/optimize-context)<a href="https://agentmods.dev/skills/richfrem/agent-plugins-skills/optimize-context"><img src="https://agentmods.dev/badge/skills/richfrem/agent-plugins-skills/optimize-context/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/richfrem/agent-plugins-skills/optimize-context"><img src="https://agentmods.dev/badge/skills/richfrem/agent-plugins-skills/optimize-context.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00050 | $0.00638 |
| Opus 5.5 | $0.00020 | $0.00255 |
| Sonnet 5.5 | $0.00010 | $0.00128 |
| Haiku 4.5 | $0.00005 | $0.00064 |
Grade A, and why
optimize-context scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 17d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 64 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Optimize Context (optimize-context)
Reduces AI agent context bloat through duplicate skill deduplication, canonical AGENTS.md optimization, and session token hygiene.
Contents
Critical Constraints
- Scope Boundary: USE ONLY for diagnosing token bloat, deduplicating installed skill mirrors, trimming instruction files, or auditing session efficiency.
- Destructive Action Gate: Never delete duplicate skills or platform instruction files autonomously; deletions require explicit user confirmation.
- Canonical Instruction Anchor: Treat
AGENTS.mdas the sole canonical instruction authority; avoid blind synchronizations to legacy mirrors. - Artifact Passing: Pass bounded structured artifacts rather than raw terminal traces between subagent boundaries.
Quick start
# Scan for duplicate skills and context bloat (dry-run)
python3 plugins/dev-utils/skills/optimize-context/scripts/optimize_context.py --dry-run
Workflow
- Phase 1: Skill Deduplication Scan: Run
optimize_context.py --dry-runto detect duplicate skill declarations across.claude/and workspace plugin roots. - Phase 2: Instruction File Audit: Review
AGENTS.mdagainst the target line budget and identify duplicate mirror surfaces. - Phase 3: Session Token Efficiency: Verify lean delegation patterns and enforce artifact passing over raw transcript dumps.
- Phase 4: Hygiene Verification: Re-run diagnostic checks to confirm duplicate elimination and verify zero broken references.
Verification
# Run context hygiene verification
python3 plugins/dev-utils/skills/optimize-context/scripts/optimize_context.py --dry-run
# Audit skill compliance
python3 plugins/agent-scaffolders/scripts/audit_skill.py plugins/dev-utils/skills/optimize-context --mode source
References
- deduplication-topology.md - Loading hierarchy and deduplication mechanics.
- instruction-optimization.md - Pruning guidelines and mirror sync rules.
- session-efficiency.md - Delegation rules and subagent context boundaries.
- acceptance-criteria.md - Verification contracts and test criteria.
- fallback-tree.md - Failure recovery and fallback procedures.
What ships with it
7 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 17d ago Changed · +8 lines d580db7390d4
- 1mo ago Changed · +3 lines · -12 tokens per session scan C → A 43554d12b300
- 1mo ago Changed · -231 lines · -102 tokens per session scan D → C 48187120b903
- 1mo ago First seen · 284 lines · 164 tokens per session scan D 07b5d73d5865
optimize-context is a skill published in the GitHub repository richfrem/agent-plugins-skills (7 stars, last pushed yesterday), licensed MIT. It adds 50 tokens to every session and 638 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.
Other skills, from other repositories
feishu
Work with Feishu or Lark bots, docs, sheets, bitables, approval flows, and OpenAPI/MCP setup without hardcoding credentials.
schedule
Manages recurring and one-off scheduled tasks. Session-scoped scheduling via CronCreate/CronDelete/CronList. Documents the cloud path for tasks that need to survive machine sleep or network drops.
cog-knowledge-consolidation
Build structured knowledge frameworks from scattered vault notes with source attribution.
release
Cut and publish a full stable NAC release after main, release-PR, and publication CI pass. Use when a maintainer asks for a stable version bump, tag, or GitHub Release. Never use for release candidates; NAC RC releases are automated.
ap-arbiter
Report the compatibility redirect to ap-independent-checker; this retired role cannot perform new work.
ap-sweeper
Report the compatibility redirect to ap-independent-checker; this retired role cannot perform new work.