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

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/jnpiyush/agentx/context-management
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.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.svg" alt="Measured on agentmods" 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. 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.00038 $0.02467
Opus 5 $0.00019 $0.01234
Sonnet 5 $0.00008 $0.00493
Haiku 4.5 $0.00004 $0.00247

Measured today against content hash a987de479e39, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 today.

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. today Changed · +7 lines a987de479e39
  2. 4d 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 (15 stars, last pushed today), licensed Apache-2.0. It adds 38 tokens to every session and 2,467 once invoked, about $0.0002 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-30.

Related

Other skills, from other repositories

pick-a-pii-model

Select an on-device OpenMed PII model from the committed registry by language, runtime format, and size budget, then require recall validation before deployment. Use when an agent must choose a local PII detector for CPU, Apple Silicon, or a mobile export without relying on live model discovery.

maziyarpanahi/openmed · 64 tokens

context-fundamentals

This skill should be used when the user asks to "understand context", "explain context windows", "design agent architecture", "debug context issues", "optimize context usage", or discusses context components, attention mechanics, progressive disclosure, or context budgeting. Provides foundational understanding of…

foryourhealth111-pixel/Vibe-Skills · 69 tokens

letta-guide

Read the official Letta documentation (docs.letta.com) through its cached, ETag-checked fetch route. Load before ANY docs.letta.com retrieval — answering how Letta works, what Letta (or you) can do, setting up providers, models, channels, skills, memory, schedules, permissions, self-hosting, pricing, or billing, AND…

letta-ai/letta-code · 130 tokens

agents-build

Use to extend an existing agent project with memory, app integration, VPC, multi-agent, migration, model, browser, code interpreter, payments, or resource removal. Triggers: "add memory", "remember across sessions", "call agent from app", "invoke agent from code", "agent auth", "streaming", "VPC", "VPC connectivity"…

aws/agent-toolkit-for-aws · 239 tokens

moai-foundation-core

Provides MoAI-ADK foundational principles including TRUST 5 quality framework, SPEC-First DDD methodology, delegation patterns, progressive disclosure, agent catalog reference, and token budget management (absorbed from moai-foundation-context). Use when referencing TRUST 5 gates, SPEC workflow, or context window…

modu-ai/moai-adk · 68 tokens

tradememory

AI trading memory with outcome-weighted recall and autonomous strategy evolution. 17 MCP tools, 1,233 tests, works with any trading platform.

mnemox-ai/tradememory-protocol · 34 tokens