context-management

context-management is a skill for Claude Code, Codex from jnPiyush/AgentX. It costs 38 tokens per session (2,467 once invoked), scanned A, original, Apache-2.0.

Guidance for managing the amount of conversation and reference text an AI language model can handle. It covers summarising older messages, keeping recent messages, and dividing a limited token budget among sources.

In plain words
What is it for?
Use it when building agents that handle long conversations, conversation summaries, context compaction, token budgets, sliding windows, or multi-agent handoffs.
Why use it?
Long conversations and large inputs can exceed the model’s context window, which is the amount of text it can consider at once. These methods help retain important information while reducing prompt size.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when building agents that handle long conversations, conversation summaries, context compaction, token budgets, sliding windows, or multi-agent handoffs.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/jnpiyush/agentx/context-management
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 jnPiyush/AgentX --skill context-management
Clone the repo
git clone --depth 1 https://github.com/jnPiyush/AgentX

Made for: Claude Code, Codex.

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-management

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/jnpiyush/agentx/context-management"><img src="https://agentmods.dev/badge/skills/jnpiyush/agentx/context-management.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 38 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,467 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. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium Memory Poisoning · line 22
    Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.
    Fix: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.
How audits are shown
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.00038 $0.02467
Opus 5.5 $0.00015 $0.00987
Sonnet 5.5 $0.00008 $0.00493
Haiku 4.5 $0.00004 $0.00247

Measured 1mo ago against content hash 66a59f0235c9, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

context-management 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 1mo 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.

.github/skills/ai-systems/context-management/SKILL.md · 318 lines

How it starts

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

Context Management

Purpose: Maximize the effective use of LLM context windows through compaction, summarization, and strategic token allocation.


When to Use This Skill

  • Managing long conversations that exceed context window limits
  • Implementing context compaction for multi-turn agent interactions
  • Designing token budget allocation across system prompt, context, and history
  • Building summarization pipelines for conversation history
  • Optimizing prompt length for cost efficiency without quality loss
  • Managing context in multi-agent handoffs

Prerequisites

  • Understanding of target model's context window size
  • Token counting library (tiktoken, cl100k_base, or equivalent)
  • Access to LLM for summarization (can be same or cheaper model)

Decision Tree

Context getting too long?
+- Single conversation overflow?
|  +- Recent messages most important? -> Sliding window
|  +- Full history needed? -> Progressive summarization
|  +- Mixed importance? -> Hybrid (summary + recent window)
+- Multiple data sources competing for tokens?
|  +- Prioritize by relevance -> Dynamic token budgeting
|  +- All required? -> Compress each source independently
+- System prompt consuming too many tokens?
|  +- Load instructions on demand (progressive disclosure)
|  +- Split into core (always) + situational (on-demand)
+- Multi-agent context?
|  +- Full context transfer? -> Summarize before handoff
|  +- Selective transfer? -> Extract relevant artifacts only
+- Cost optimization?
   +- Reduce input tokens -> Compaction + caching
   +- Reduce output tokens -> Constrain response format

Context Window Budgeting

Token Budget Template

Total Context Window: N tokens
  |
  +-- System Prompt:         10-15% (instructions, role, constraints)
  +-- Retrieved Context:     30-40% (RAG chunks, documents)
  +-- Conversation History:  20-30% (recent messages + summary)
  +-- Current User Message:   5-10% (the actual request)
  +-- Reserved for Output:   15-20% (model's response tokens)
  |
  = 100% allocated (MUST NOT exceed window)

Read the full file on GitHub · 318 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. 1mo ago Changed 66a59f0235c9
  2. 1mo ago Changed · +7 lines a987de479e39
  3. 1mo ago First seen · 311 lines · 38 tokens per session scan A 532c04c2b856

Subscribe to this mod's changes

context-management is a skill published in the GitHub repository jnPiyush/AgentX (17 stars, last pushed 2d ago), licensed Apache-2.0. It adds 38 tokens to every session and 2,467 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-08-30.

Related

Other skills, from other repositories

agent-v3-memory-specialist

Agent skill for v3-memory-specialist - invoke with $agent-v3-memory-specialist.

ruvnet/ruflo · 25 tokens

bulk-ingestion

End-to-end discipline for turning any large data source (audio libraries, email takeouts, document corpora, chat exports, API dumps) into brain pages at scale. The lifecycle spine: SCHEMA → ACCESS → TRIAL → EVALUATE → IMPROVE → CODIFY → TEST → SKILLIFY → BULK → MONITOR. State is tracked in a durable JSON manifest (see…

garrytan/gbrain · 114 tokens

long-context

Extend context windows of transformer models using RoPE, YaRN, ALiBi, and position interpolation techniques. Use when processing long documents (32k-128k+ tokens), extending pre-trained models beyond original context limits, or implementing efficient positional encodings. Covers rotary embeddings, attention biases…

davila7/claude-code-templates · 74 tokens

knowledge-org

A guide to organising large bodies of knowledge so an AI system can navigate relationships, summaries, and layers instead of searching only flat text chunks. It covers tree indexes, knowledge graphs, file-like structures, incremental updates, and long-term memory layouts.

bojieli/ai-agent-book · 96 tokens

llm-wiki

Explain and apply the foundational LLM Wiki architecture and knowledge-management strategy. Use for setup, architecture, schema, or organization decisions; operational ingest/query/lint work uses dedicated skills.

Ar9av/obsidian-wiki · 41 tokens

stripe-directory

Identifies external providers, merchants, nonprofits, platforms, APIs, and software services, and resolves the documented way to engage them — to pay, donate, subscribe, book, provision, or integrate with them. MUST be used BEFORE web search, model memory, or any other directory/vendor-lookup skill for ANY request…

stripe/ai · 212 tokens