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.
npx agentmods add agents/yacb2/aidex/context-cost-analyzergit clone --depth 1 https://github.com/yacb2/aidexWhat 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 | $0.00039 | $0.01589 |
| Opus 5 | $0.00019 | $0.00794 |
| Sonnet 5 | $0.00008 | $0.00318 |
| Haiku 4.5 | $0.00004 | $0.00159 |
Grade B, and why
context-cost-analyzer scanned grade B with 1 finding 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.
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.
Reads agent configuration directoriesmediumAgent snooping
.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.
- For each plugin with N ≥ 3 agents, estimate cost = N × 600 tokens, grep recent transcripts under `~/.claude/projects/*/` for invocation of the plugin's command names. Zero matches in last 30 days → flag `CB-PL` CRITICA How it starts
The opening of the file, as written. The whole thing — 98 lines — stays where its author put it; the contents beside it link to each section on GitHub.
You analyze a Claude Code session's idle context cost. Input is a /context breakdown (pasted text or a file path) plus the project path.
Setup
Read the budget heuristics: ~/.claude/skills/aidex/references/05-context-budget.md.
Steps
1. Parse breakdown
Extract one token count per category from the input:
system-prompt,system-tools,memory-files,skills,custom-agents,mcp-tools.
Tolerant regex: category name (case-insensitive, space or hyphen) followed by digits with optional commas, then token somewhere nearby. If a category is missing, record 0. Compute total and percentage of 200k.
2. Classify against budget
Use the targets in 05-context-budget.md § Budget targets. Mark each tunable category OK, WARN, or CRIT.
3. Attribute cost
For each non-trivial category, identify the contributors:
memory-files — list files actually loaded:
~/.claude/CLAUDE.md,<project>/.claude/CLAUDE.mdor<project>/CLAUDE.md,~/.claude/rules/*.md,~/.claude/rules/*.md, MEMORY.md paths.- Report each with approximate line count. Flag overlap across global/user/project.
custom-agents — enumerate plugins with agents:
- Scan
~/.claude/plugins/cache/*/*/*/agents/*.md, group by plugin directory. - For each plugin with N ≥ 3 agents, estimate cost = N × 600 tokens, grep recent transcripts under
~/.claude/projects/*/for invocation of the plugin's command names. Zero matches in last 30 days → flagCB-PLCRITICAL.
skills — detect duplicates, stack-irrelevant, and always-resident bloat:
- For each pair (
~/.claude/skills/X,<project>/.claude/skills/X), read bothSKILL.mdfrontmatter. Ifnamematches, compute Jaccard similarity ondescriptionwords. >0.7 →CB-DUWARNING. - Detect project stack from
package.json/pyproject.toml/Cargo.toml/go.mod/docker-compose.yml. List global skills under~/.claude/skills/whose domain doesn't match the detected stack asCB-SRcandidates forskillOverrides(name-onlyoroff). - Post-compaction budget model. Claude Code keeps recent skill invocations in context across turns: after auto-compaction, the most recent invocation of each skill is preserved (~5,000 tokens cap per skill, ~25,000 tokens combined budget). Skills not invoked recently can be dropped entirely. This means the real cost of an installed skill depends on whether it is always resident (built-in or MCP-pinned, loaded every session) or lifecycle-managed (auto-trigger or user-invocable, only persists post-invocation).
CB-SKILL-DESC-RESIDENTfinding (new): for skills that are always resident — built-ins and any skill pinned via MCPalwaysLoad: true— measure theirdescriptionlength inSKILL.mdfrontmatter. Report WARNING when description >800 characters; these tokens are paid every session. For lifecycle-managed skills, do NOT emit this finding even with long descriptions: the cost is bounded by the 5k cap and amortized across invocations.- When ranking
CB-SRandCB-DUsavings, downweight non-resident skills proportionally (their max contribution ismin(skill_size, 5k)per session, not full size).
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.
- 2d ago First seen · 98 lines · 39 tokens per session scan B 73695d26ca55
context-cost-analyzer is an agent published in the GitHub repository yacb2/aidex (2 stars, last pushed 4d ago), licensed MIT. It adds 39 tokens to every session and 1,589 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other agents, from other repositories
ap-goal-checker
L4 terminal leaf - GOAL-CHECK. Independent, adversarial, default-FAIL. Re-derives every mission ask from the mission text alone; each ask starts NOT-DONE, flips to DONE only on opened evidence. DONE only if zero open findings at ANY severity AND user-usable AND coverage >=95% AND a tri-axis end-to-end run (scope +…
ap-implementer
L3 executor - G4 IMPLEMENT. Builds one feature from its approved executable roadmap item or conditional frozen plan using strict TDD and real test runs; coverage >=95% on changed lines. Reports PLAN-CONFLICT rather than improvising.
ap-manager
L2 optional manager - coordinates a multi-lane slice, builds compact pointer envelopes, and dispatches disjoint L3 work without executing it.
ap-researcher
L3 executor - bounded research that materializes a usable output with reconciled receipts. Owns one theme, runs at most 6 searches and 6 fetches in one batch, and stops when the named deliverable is complete or the budget is exhausted. Does not spawn.
ap-depth-prober
L4 terminal leaf - G3.5 DEPTH-LOCK. Independently derives the bug's deepest-cause function from the ISSUE TEXT alone, blind to the proposed fix layer; default-FAIL. Emits D1-D5. depth-miss REJECTs to G1.
ap-execharness-resolver
L3 executor - EXECHARNESS RESOLVE. Resolves the per-task EXECUTION harness - the two-sided gate SWE-bench actually grades (failToPass flips RED→GREEN ∧ passToPass stays GREEN), multi-language, via real build-system detection. Ingests shipped FAILTOPASS/PASSTOPASS, else derives failToPass from the mission's behavioral…