map-token-context

A context-management and decision-routing toolkit for AI agents. It helps choose specialist instructions and limit the files, history, tools, and other information sent to a model.

In plain words
What is it for?
Use it for token-heavy or reasoning-heavy tasks, specialist-skill routing, file and web context lookup, decision calculations, scheduling, reusable reasoning, and context-size measurement.
Why use it?
Large or unnecessary context can increase cost, slow reasoning, and make decisions harder to control. This toolkit provides structured ways to route work, search context, and verify results.

Skill for Claude CodeCodex

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/hakiyaka/capsule/map-token-context
Any agent
npx skills add hakiyaka/capsule --skill map-token-context
Clone the repo
git clone --depth 1 https://github.com/hakiyaka/capsule

Made for: Claude Code, Codex.

Per session 54 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 794 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 $0.00054 $0.00794
Opus 5 $0.00027 $0.00397
Sonnet 5 $0.00011 $0.00159
Haiku 4.5 $0.00005 $0.00079

Measured yesterday against content hash f72429f7325d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

map-token-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 yesterday.

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.

optional-skills/map-token-context/SKILL.md · 27 lines

What it actually says

Capsule

Use one capsule; put action fields in payload.

  • With a virtual router, call skills {operation:"route",query:"English intent"}; its default is one domain-anchored match. Read only that skill_file; request a larger limit only when the task truly needs another specialist.
  • Use cognition for exact cover, assignment, knapsack, shortest path, DAG scheduling, weighted decisions, information-gain checks, reasoning-governor status, or reusable decision kernels; trust its checksum certificate and reason only about unencoded judgment.
  • Use run|batch for commands, file for files, index|search|remember for context, fetch for web text, and execute for derivation.
  • Use progressive expand|diff for exact evidence and stats|gain|insight|doctor for measurement.
  • Treat [Capsule replay], [Capsule delta], [Capsule poll: exactly unchanged], and [Capsule session transcript projection] as complete control tags: reuse them directly and call expand only when exact bytes are required. The current exact= capsule always contains the complete latest result.
  • Treat [Capsule repeated failure] as proof that the same tool input produced the byte-identical error again. Use its short diagnostic, change input or external state, and call expand only if exact bytes are required.
  • Treat [Capsule round-trip tax] and the sequence fuse as measured prompts to batch independent work or execute the next concrete change. A costly uncached suffix also tightens output/history budgets mechanically. Successful exec control wrappers are removed automatically; oversized read-only output remains exact-capsule recoverable even at normal context pressure.
  • For automatic-context-compaction cost, call insight with compaction:true and the session id/path. It returns aggregates, the latest event, and context_pressure with occupancy, predicted runway, locally reported quota pressure, compaction churn, retained-image risk, reasons, and the active policy. Request bounded rows only with compaction_events:true. Treat pre/post input as observable exposure because hidden compactor generation is not exposed.
  • Treat gain as contract-valid local exposure telemetry, not billing. Legacy hook projections are excluded unless include_unverified:true is explicitly requested.
  • Start view_image at high; use original only for pixel-level evidence.
  • Give subagents self-contained messages. Automatic policy uses none for independent tasks, a small recent window for deictic continuations, and full history only for explicit whole-conversation dependencies.
  • Subagent work is task-bounded: keep the default total to 16 (never above 20), use one agent per UI/i18n/performance/release lane, pause after 10 independent agents for one compact {decisions,evidence,files,blockers} summary, and reuse that digest instead of opening another review wave. Return no raw screenshots, base64 media, full diffs, or transcripts; retain exact recovery in Capsule.
  • After each grouped mutation and decisive verification, call stats once and gain once. Treat both as local exposure evidence, not billing; do not rerun exploratory reads just to obtain a measurement.
  • Return the smallest complete answer; explicit detail requirements win.
  • Never sacrifice accuracy for compression.
  • Skill apply|restore requires an explicit request and confirm:true.
  • See capsule-contract.md for exact behavior and recovery.
Files

What ships with it

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

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. yesterday First seen · 27 lines · 54 tokens per session scan A f72429f7325d

Subscribe to this mod's changes

map-token-context is a skill published in the GitHub repository hakiyaka/capsule (1 stars, last pushed 22d ago), licensed MIT. It adds 54 tokens to every session and 794 once invoked, about $0.0003 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-08-31.