context-manager

context-manager is a skill for Claude Code, Codex from khalilbenaz/claude-skills-collection. It costs 84 tokens per session (2,408 once invoked), scanned A, original, MIT.

A guide for managing the information an AI agent can use in one interaction. It covers limits on conversation and document size, trimming or compressing context, retrieving relevant information, and remembering information between sessions.

In plain words
What is it for?
Designing agents with long conversations, large documents, persistent memory, retrieved information, or strict limits on input size and cost.
Why use it?
It helps prevent errors caused by sending too much information and helps control usage costs. It also provides ways to keep long conversations and large documents useful.

Skill for Claude CodeCodex

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

Good fit Designing agents with long conversations, large documents, persistent memory, retrieved information, or strict limits on input size and cost.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/khalilbenaz/claude-skills-collection/context-manager
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 khalilbenaz/claude-skills-collection --skill context-manager
Clone the repo
git clone --depth 1 https://github.com/khalilbenaz/claude-skills-collection

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

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/khalilbenaz/claude-skills-collection/context-manager"><img src="https://agentmods.dev/badge/skills/khalilbenaz/claude-skills-collection/context-manager.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 84 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,408 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 pass 7 Sept 2026
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.00084 $0.02408
Opus 5 $0.00042 $0.01204
Sonnet 5 $0.00017 $0.00482
Haiku 4.5 $0.00008 $0.00241

Measured 11d ago against content hash 0909f37d48e7, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

context-manager 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 11d 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.

agent-skills/context-manager/SKILL.md · 271 lines

How it starts

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

Agent Context Manager

Quand utiliser ce skill

  • L'agent retourne context_length_exceeded ou une erreur 413/400 équivalente
  • Les coûts de tokens dépassent le budget prévu
  • Tu conçois un agent avec sessions multi-tours longues ou documents volumineux
  • Tu dois implémenter une mémoire persistante entre sessions

Fenêtres de contexte de référence (2026)

Modèle Fenêtre Prompt cache natif
Claude 3.7 Sonnet 200 k tokens Oui (Anthropic API)
GPT-4o 128 k tokens Oui (OpenAI API)
Gemini 2.0 Flash 1 M tokens Oui (Google AI)
Llama 3.3 70B 128 k tokens Non (self-hosted)

Workflow en 10 étapes

1. Cartographier le budget par couche

Avant tout code, décompose la fenêtre en couches fixes et dynamiques :

Fenêtre totale = 200 000 tokens
├── System prompt (fixe)          ~  2 000  (1 %)
├── Descriptions d'outils (fixe)  ~  3 000  (1.5 %)
├── Mémoire long terme            ~  5 000  (2.5 %)
├── Contexte RAG injecté          ~ 20 000  (10 %)
├── Historique conversation       ~ 40 000  (20 %)
├── Réponse réservée              ~ 10 000  (5 %)
└── Marge sécurité (10 %)        ~ 20 000

Définis deux seuils : alerte 80 % (log warning), action 90 % (compression obligatoire).

2. Compter les tokens précisément

# OpenAI / tiktoken
import tiktoken
enc = tiktoken.encoding_for_model("gpt-4o")
n_tokens = len(enc.encode(text))

# Anthropic SDK
import anthropic
client = anthropic.Anthropic()
response = client.messages.count_tokens(
    model="claude-sonnet-4-5",
    system=system_prompt,
    messages=messages,
)
print(response.input_tokens)  # total exact avant envoi

Appelle le comptage avant chaque appel API, pas après. C'est le seul moyen de gérer proactivement.

3. Choisir la stratégie de contexte

Situation Stratégie recommandée
Conversation courte, budget abondant Verbatim — rien à faire
Historique long mais requêtes récentes dominantes Sliding window
Documents volumineux, requête ponctuelle RAG dynamique
Sessions très longues (agent autonome multi-jours) Résumé progressif + LTM externe
Coût critique (prod haute volumétrie) Prompt caching + compression agressive

Read the full file on GitHub · 271 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. 11d ago First seen · 271 lines · 84 tokens per session scan A 0909f37d48e7

Subscribe to this mod's changes

context-manager is a skill published in the GitHub repository khalilbenaz/claude-skills-collection (22 stars, last pushed 17d ago), licensed MIT. It adds 84 tokens to every session and 2,408 once invoked, about $0.0004 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

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

edgartools

Python library for accessing, analyzing, and extracting data from SEC EDGAR filings. Use when working with SEC filings, financial statements (income statement, balance sheet, cash flow), XBRL financial data, insider trading (Form 4), institutional holdings (13F), company financials, annual/quarterly reports (10-K…

foryourhealth111-pixel/Vibe-Skills · 110 tokens

Vizra ADK Memory System

Implement persistent memory, session context, and vector memory (RAG) for AI agents.

vizra-ai/vizra-adk · 24 tokens

rag-patterns

RAG: embeddings, chunking, hybrid search (BM25+vector), reranking, CRAG, multi-hop. Triggers: RAG, embedding, pgvector, Qdrant, Pinecone, Weaviate, reranker, semantic search.

softspark/ai-toolkit · 57 tokens

evaluate

Evaluates RAG retrieval and LLM-as-judge metrics (faithfulness, relevancy, context precision). Triggers: measure RAG quality, knowledge gap, RAG eval, golden dataset.

softspark/ai-toolkit · 42 tokens

explain

Explains code/architecture with Mermaid diagrams and sequence flows. Triggers: what does X do, how does Y work, explain code, sequence diagram.

softspark/ai-toolkit · 34 tokens