context-optimization

context-optimization is a skill for Claude Code, Codex from seb1n/awesome-ai-agent-skills. It costs 55 tokens per session (2,524 once invoked), scanned A, original, MIT.

A method for cleaning and arranging the information given to an AI model. It removes repeated or low-value material, orders the remaining material, and fits it within the available token limit, where tokens are the small pieces of text models process.

In plain words
What is it for?
Use it to review a complete context package, find duplicate passages, filter out marginally relevant content, measure its size, and allocate the context budget.
Why use it?
It helps when retrieved documents, chat history, or tool results are too long, repetitive, or poorly organized for the model to use well.

Skill for Claude CodeCodex

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

Good fit Use it to review a complete context package, find duplicate passages, filter out marginally relevant content, measure its size, and allocate the context budget.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/seb1n/awesome-ai-agent-skills/context-optimization
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 seb1n/awesome-ai-agent-skills --skill context-optimization
Clone the repo
git clone --depth 1 https://github.com/seb1n/awesome-ai-agent-skills

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

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/seb1n/awesome-ai-agent-skills/context-optimization"><img src="https://agentmods.dev/badge/skills/seb1n/awesome-ai-agent-skills/context-optimization.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 55 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,524 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.00055 $0.02524
Opus 5 $0.00028 $0.01262
Sonnet 5 $0.00011 $0.00505
Haiku 4.5 $0.00006 $0.00252

Measured 9d ago against content hash 5c9eee4b5d58, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

context-optimization 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 9d 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.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

context-engineering/context-optimization/SKILL.md · 107 lines

How it starts

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

Context Optimization

Context optimization is the process of refining the raw context assembled for an AI model so that every token contributes meaningfully to the task. In a typical RAG or agent pipeline, the retrieved context often contains redundant passages, marginally relevant chunks, and poorly ordered information. Optimization transforms this raw material into a lean, high-signal context block that improves answer quality, reduces inference cost, and makes the most of the model's attention budget.

Workflow

  1. Audit the Raw Context: Inventory every piece of context that has been gathered -- retrieved documents, conversation history, tool outputs, and metadata. Measure the total token count and compare it against the available context budget. Identify the compression ratio needed if the raw context exceeds the budget.

  2. Deduplicate Overlapping Content: Scan the context for near-duplicate passages that convey the same information. This is common in RAG pipelines where chunking with overlap produces multiple chunks covering the same paragraph, or when multiple source documents repeat the same facts. Use semantic similarity (cosine distance > 0.92) or exact n-gram overlap detection to identify duplicates, then keep only the most complete version of each piece of information.

  3. Score Relevance and Information Density: Assign each context chunk two scores: a relevance score (how closely it relates to the current query) and an information density score (how many useful facts it conveys per token). Relevance can be measured via the retrieval score or a lightweight cross-encoder pass. Density can be estimated by counting named entities, code identifiers, numerical data, and key terms relative to chunk length. Multiply the two scores to produce a composite utility score.

  4. Filter Low-Value Content: Remove chunks whose composite utility score falls below a threshold. A good starting point is to keep the top 60-70% of chunks by utility score. Also remove boilerplate text (copyright notices, navigation menus, repeated headers) that contributes zero information. Be conservative -- it is better to include a marginally relevant chunk than to lose a critical fact.

Read the full file on GitHub · 107 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. 9d ago First seen · 107 lines · 55 tokens per session scan A 5c9eee4b5d58

Subscribe to this mod's changes

context-optimization is a skill published in the GitHub repository seb1n/awesome-ai-agent-skills (176 stars, last pushed 1mo ago), licensed MIT. It adds 55 tokens to every session and 2,524 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-30.

Related

Other skills, from other repositories

promote-memory

Review candidate learnings in Claude Code's native auto memory (/.claude/projects/ /memory/, machine-local) and run them through a five-critic council in parallel: generality, staleness, redundancy, evidence, format. Majority vote (3+ of 5) promotes the entry to MEMORY.md. Use when user says "promote memory", "review…

pedrohcgs/claude-code-my-workflow · 0 tokens

context-engineering

A project documentation framework that records a project's goals, requirements, roadmap, and current state in separate files. It also keeps those documents within set size limits for an AI coding agent.

hashgraph-online/awesome-codex-plugins · 73 tokens

compress-session

Distill the current conversation into a structured note (decisions made, open questions, file pointers with line numbers, next 1–3 actions) and save to qualityreports/sessionlogs/ before auto-compression. Differs from /checkpoint (explicit stop-point snapshot) and from auto-compaction (which truncates rather than…

pedrohcgs/claude-code-my-workflow · 123 tokens

cross-border-ecommerce

Cross-border e-commerce expansion advisor. Scores target markets on 8 weighted dimensions (market size, ecommerce penetration, competition, regulatory complexity, logistics infrastructure, payment ecosystem, cultural distance, IP protection), compares 5 fulfillment models with cost and transit data, provides…

nexscope-ai/eCommerce-Skills · 106 tokens

ecommerce-email-marketing-builder

E-commerce email marketing system builder. Creates complete email automation flows with full copywriting, subject lines, ESP setup instructions, segmentation rules, and annual campaign calendars. Generates copy-paste-ready email sequences for Klaviyo, Omnisend, Mailchimp, or any ESP. Covers welcome series, cart…

nexscope-ai/eCommerce-Skills · 159 tokens

ecommerce-content-marketing

E-commerce content marketing strategy planner. Generates content calendars, topic ideas, and platform-specific strategies by analyzing customer reviews, trends, competitor content, and SEO opportunities. Two modes: (A) Build — create a full content strategy from scratch, (B) Audit — analyze existing content and find…

nexscope-ai/eCommerce-Skills · 139 tokens