context-optimizer

context-optimizer is a skill for Claude Code from rjmurillo/ai-agents. It costs 103 tokens per session (4,353 once invoked), scanned A, original, MIT.

A tool for deciding whether guidance belongs in an on-demand skill, always-loaded project context, or both. It can also shorten Markdown instructions and check whether context rules follow its placement criteria.

In plain words
What is it for?
Use it to review skill placement, compress context files, split large guidance into indexed details, and audit always-on rules.
Why use it?
It helps keep agent instructions focused, reducing unnecessary context and repeated decision-making.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: reads .claude/ paths; mentions CLAUDE.md; mentions Claude Code.

Part of the project-toolkit plugin — 95 skills, 26 commands, 33 agents, 4 hooks shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/rjmurillo/ai-agents/context-optimizer
Any agent
npx skills add rjmurillo/ai-agents --skill context-optimizer
Clone the repo
git clone --depth 1 https://github.com/rjmurillo/ai-agents

Made for: Claude Code.

Or install project-toolkit, the plugin that ships this one along with the rest of its 95 skills, 26 commands, 33 agents, 4 hooks.

Wrote 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.

agentmods badge for context-optimizer

README.md
[![agentmods](https://agentmods.dev/badge/skills/rjmurillo/ai-agents/context-optimizer.svg)](https://agentmods.dev/skills/rjmurillo/ai-agents/context-optimizer)
Your own site
<a href="https://agentmods.dev/skills/rjmurillo/ai-agents/context-optimizer"><img src="https://agentmods.dev/badge/skills/rjmurillo/ai-agents/context-optimizer.svg" alt="Measured on agentmods" height="20"></a>
Per session 103 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,353 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00103 $0.04353
Opus 5 $0.00051 $0.02176
Sonnet 5 $0.00021 $0.00871
Haiku 4.5 $0.00010 $0.00435

Measured 2d ago against content hash eb0f4a89d3af, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

context-optimizer 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 2d ago.

The scan reads SKILL.md. This mod also ships 5 executable files (scripts/analyze_skill_placement.py, scripts/compress_markdown_content.py, scripts/extract_and_index.py, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

.claude/skills/context-optimizer/SKILL.md · 426 lines

How it starts

The opening of the file, as written. The whole thing — 426 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Context Optimizer

Tooling suite for optimizing Claude Code context placement. Passive context (AGENTS.md, @imports) achieves 100% pass rates versus 53-79% for skills by eliminating decision points.

Triggers

  • analyze skill placement - classify and validate content as Skill vs Passive Context
  • compress markdown - reduce token count for context files
  • optimize context - lower API costs and improve agent performance
  • extract and index - split markdown into detail files with compact index
  • audit always-on rules - eval-gated procedure for whether a rule earns its slot, and the doctrine behind it, in rule-audit-procedure.md and model-context-doctrine.md. Also the entry point when a new model ships. Requires a full rjmurillo/ai-agents checkout: the procedure runs this repo's eval harness and rule generator, neither of which ships in a plugin install. The doctrine and the instrument write-ups are readable anywhere; only the commands need the checkout

Process

  1. Analyze: Run analyze_skill_placement.py to classify content
  2. Compress: Run compress_markdown_content.py to reduce token counts
  3. Validate: Run test_skill_passive_compliance.py to check compliance
  4. Verify: Confirm output JSON contains expected classification and metrics

Verification

  • Classification matches expected type (Skill/PassiveContext/Hybrid)
  • Compression achieves target reduction (40-80% depending on level)
  • Compliance validator returns exit code 0
  • Output JSON is valid and contains all required fields

Scripts

Script Purpose Exit Codes
analyze_skill_placement.py Classify content as Skill/PassiveContext/Hybrid 0=success, 1=error
compress_markdown_content.py Compress markdown with token reduction metrics 0=success, 1=error, 2=config, 3=external
test_skill_passive_compliance.py Validate compliance with decision framework 0=pass, 1=violations
extract_and_index.py Extract sections into detail files with pipe-delimited index 0=success, 1=error, 2=config, 3=external
path_validation.py Shared CWE-22 repo-root-anchored path validation N/A (library module)

Read the full file on GitHub · 426 lines

Changes

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.

  1. 2d ago First seen · 426 lines · 103 tokens per session scan A eb0f4a89d3af

Subscribe to this mod's changes

context-optimizer is a skill published in the GitHub repository rjmurillo/ai-agents (45 stars, last pushed today), licensed MIT. It adds 103 tokens to every session and 4,353 once invoked, about $0.0005 per session on Opus 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.