context-mgmt

context-mgmt is a skill for Claude Code from ariaxhan/kernel-claude. It costs 37 tokens per session (1,590 once invoked), scanned A, original, MIT.

A guide to managing an AI agent's working context and token budget. It covers shortening context, keeping structured notes, sharing research through summaries, and restoring important state after a reset.

In plain words
What is it for?
Use it to monitor context usage, write handoff notes, store active task state, delegate research, limit unnecessary reads, and recover after compaction.
Why use it?
It helps preserve important decisions and reasoning when a task becomes large or the conversation needs to be compacted.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: mentions CLAUDE.md; mentions subagents.

Part of the kernel plugin — 27 skills, 10 agents, 4 hooks shipped together

Good fit Use it to monitor context usage, write handoff notes, store active task state, delegate research, limit unnecessary reads, and recover after compaction.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/ariaxhan/kernel-claude/context-mgmt
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.

Any agent
npx skills add ariaxhan/kernel-claude --skill context-mgmt
Clone the repo
git clone --depth 1 https://github.com/ariaxhan/kernel-claude

Made for: Claude Code.

Or install kernel, the plugin that ships this one along with the rest of its 27 skills, 10 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-mgmt

README.md
[![agentmods](https://agentmods.dev/badge/skills/ariaxhan/kernel-claude/context-mgmt/github.svg)](https://agentmods.dev/skills/ariaxhan/kernel-claude/context-mgmt)
Your own site
<a href="https://agentmods.dev/skills/ariaxhan/kernel-claude/context-mgmt"><img src="https://agentmods.dev/badge/skills/ariaxhan/kernel-claude/context-mgmt/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.

agentmods 80×15 button for context-mgmt

Your own site · 80×15
<a href="https://agentmods.dev/skills/ariaxhan/kernel-claude/context-mgmt"><img src="https://agentmods.dev/badge/skills/ariaxhan/kernel-claude/context-mgmt.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 37 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,590 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.00037 $0.01590
Opus 5.5 $0.00015 $0.00636
Sonnet 5.5 $0.00007 $0.00318
Haiku 4.5 $0.00004 $0.00159

Measured 13d ago against content hash ebacd10f4834, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

context-mgmt 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 13d 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.

skills/context-mgmt/SKILL.md · 100 lines

How it starts

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

Reasoning fidelity is the real metric, not token count. Quality degrades at ~60-70% fill, not at the limit.

<core_principles>

  1. COMPACTION: Summarize and reinitialize. Keep architecture decisions, discard noise.
  2. STRUCTURED NOTES: AgentDB + active.md persist across context resets.
  3. MULTI-AGENT: Delegate research to subagents. They explore, report summaries. Cap the return at ~1,000-2,000 tokens (conclusion + path:line evidence, no raw dumps); the exploration context stays in the subagent.
  4. MINIMAL READS: grep/glob to find, then read specific sections.
  5. TOOL RESULT CLEARING: Old tool output rarely needs to stay in context. When calling the Claude API directly (not via this harness), prefer the server-side context-management-2025-06-27 beta over hand-rolled truncation: clear_tool_uses_20250919 clears old tool results past a token trigger (client keeps full history, no sync needed), clear_thinking_20251015 clears old thinking blocks while preserving cache hits. Client-side SDK compaction (compaction_control, TypeScript/Ruby) is deprecated; use server-side compact_20260112 for summarization, which takes its own beta header compact-2026-01-12, not context-management-2025-06-27: trigger is input_tokens only (default 150000, minimum 50000), and custom instructions replace the default summarization prompt entirely, so restate the full framing (what to keep: goal, decisions, paths, errors) rather than appending. pause_after_compaction: true returns stop_reason: "compaction" with only the compaction block, so you can re-append recent messages or key instructions, then resend without the flag to continue. Ordering: clear_thinking_20251015 must precede clear_tool_uses_20250919 in edits. Set exclude_tools for results that must survive; clearing tool results invalidates the cached prefix, so set clear_at_least so each clear pays for itself. Pair with the memory_20250818 tool: Claude is warned as the threshold nears and saves state to memory files before results clear. clear_tool_inputs (default false) also drops call parameters. clear_thinking_20251015 with no keep defaults to thinking_turns: 1 on every model, even ones whose omitted-strategy default keeps all thinking (so including the edit silently drops older thinking and invalidates the cache there); set keep explicitly ({type:"thinking_turns",value:N} or "all"). clear_tool_uses_20250919 defaults: trigger 100,000 input_tokens, keep 3 tool uses; if clear_at_least cannot be met the edit is not applied. On Fable 5.1/Opus 5.5/Sonnet 5.5/Haiku 5.5, server-side edits never invalidate thinking blocks, but hand-editing earlier turns client-side can; for accounts created on/after 2026-08-31 a replayed invalidated block is rejected unless you opt into dropping it. Verify clearing fired from context_management.applied_edits in the response (cleared_tool_uses / cleared_thinking_turns and cleared_input_tokens; in streaming, the final message_delta). Preview savings by passing context_management to count_tokens: it returns original_input_tokens beside the post-clearing input_tokens. </core_principles>

<token_budget>

  • CLAUDE.md: <150 lines (always loaded)
  • rules/: <100 lines (always loaded)
  • Skills: metadata only at startup, full content on demand
  • Commands: only when invoked
  • Reference docs: only when skill explicitly reads them </token_budget>

Read the full file on GitHub · 100 lines

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. 13d ago Changed ebacd10f4834
  2. 28d ago Changed 5d3c3917a51f
  3. 1mo ago Changed e4fab492708a
  4. 1mo ago Changed 338afa770e39
  5. 1mo ago Changed 269c5e566cb4
  6. 1mo ago Changed 85b566ae71c6
  7. 1mo ago Changed b9977a8dbf63
  8. 2mo ago Changed 7c76f0ca9a6e
  9. 2mo ago Changed 18869b660400
  10. 2mo ago First seen · 100 lines · 37 tokens per session scan A 2c8504131c5d

Subscribe to this mod's changes

context-mgmt is a skill published in the GitHub repository ariaxhan/kernel-claude (16 stars, last pushed yesterday), licensed MIT. It adds 37 tokens to every session and 1,590 once invoked, about $0.0001 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-08-30.

Related

context-mgmt compared with skills from other repositories

context-mgmt next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
context-mgmtariaxhan/kernel-claudeSkill16yesterdayMITA37Claude Code
prolongalexisfox7/PRO-LONGSkill46428d agoMITA55Codex
setup-brainmycelium-hq/ai-brain-starterSkill61yesterdayMITA66Claude Code
cartographer-kb-createBeppeTemp/cartographerSkill692d agoApache-2.0A53Claude Code, Codex
second-brain-mappingmycelium-hq/ai-brain-starterSkill61yesterdayMITA116Claude Code
cartographer-kb-importBeppeTemp/cartographerSkill692d agoApache-2.0A51Claude Code, Codex
evolvemycelium-hq/ai-brain-starterSkill61yesterdayMITA100Claude Code