Context Doctor
jzOcb/context-doctor
Visualize and diagnose OpenClaw context window usage. An agent skill from jzOcb/context-doctor.
Optimize a complete candidate context package by deduplicating, filtering, ordering, and allocating its token budget.
$ npx skills add seb1n/awesome-ai-agent-skills --skill context-optimization -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install seb1n/awesome-ai-agent-skills context-optimization --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/seb1n/awesome-ai-agent-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/context-engineering/context-optimization .claude/skills/context-optimization && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "context-optimization" agent skill from https://github.com/seb1n/awesome-ai-agent-skills/tree/main/context-engineering/context-optimization into .claude/skills/context-optimization/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "context-optimization", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/seb1n/awesome-ai-agent-skills/tree/main/context-engineering/context-optimizationType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add seb1n/awesome-ai-agent-skills --skill context-optimization -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install seb1n/awesome-ai-agent-skills context-optimization --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/seb1n/awesome-ai-agent-skills.git skills-src && mkdir -p .agents/skills && cp -r skills-src/context-engineering/context-optimization .agents/skills/context-optimization && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "context-optimization" agent skill from https://github.com/seb1n/awesome-ai-agent-skills/tree/main/context-engineering/context-optimization into .agents/skills/context-optimization/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "context-optimization", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add seb1n/awesome-ai-agent-skills --skill context-optimization -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install seb1n/awesome-ai-agent-skills context-optimization --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/seb1n/awesome-ai-agent-skills.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/context-engineering/context-optimization .cursor/skills/context-optimization && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "context-optimization" agent skill from https://github.com/seb1n/awesome-ai-agent-skills/tree/main/context-engineering/context-optimization into .cursor/skills/context-optimization/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "context-optimization", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/seb1n/awesome-ai-agent-skills.git --path context-engineering/context-optimization--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add seb1n/awesome-ai-agent-skills --skill context-optimization -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install seb1n/awesome-ai-agent-skills context-optimization --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/seb1n/awesome-ai-agent-skills.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/context-engineering/context-optimization .gemini/skills/context-optimization && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "context-optimization" agent skill from https://github.com/seb1n/awesome-ai-agent-skills/tree/main/context-engineering/context-optimization into .gemini/skills/context-optimization/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "context-optimization", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install seb1n/awesome-ai-agent-skills context-optimizationInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add seb1n/awesome-ai-agent-skills --skill context-optimization -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/seb1n/awesome-ai-agent-skills.git skills-src && mkdir -p .github/skills && cp -r skills-src/context-engineering/context-optimization .github/skills/context-optimization && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "context-optimization" agent skill from https://github.com/seb1n/awesome-ai-agent-skills/tree/main/context-engineering/context-optimization into .github/skills/context-optimization/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "context-optimization", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add seb1n/awesome-ai-agent-skills --skill context-optimization -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install seb1n/awesome-ai-agent-skills context-optimization --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/seb1n/awesome-ai-agent-skills.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/context-engineering/context-optimization .opencode/skills/context-optimization && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "context-optimization" agent skill from https://github.com/seb1n/awesome-ai-agent-skills/tree/main/context-engineering/context-optimization into .opencode/skills/context-optimization/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "context-optimization", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
context-optimizationOptimize a complete candidate context package by deduplicating, filtering, ordering, and allocating its token budget.
Context Optimization is an agent skill from seb1n/awesome-ai-agent-skills. Optimize a complete candidate context package by deduplicating, filtering, ordering, and allocating its token budget. Use when retrieved or assembled material is noisy or exceeds the useful context budget; use context-ranking for scoring chunks and context-compression for shrinking selected content.
Its SKILL.md is about 2.9k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.
It sits in Agent Workflows, covering Context engineering and LLM cost and token optimization. The repository describes itself as: 103 ready-to-use AI agent skills for Claude Code, OpenAI Codex, Gemini CLI, Cursor, GitHub Copilot, Windsurf, and other Agent Skills-compatible tools. Complete SKILL.md… The licence is MIT.
6 steps, taken from the first numbered list in SKILL.md.
Read from SKILL.md and the folder at commit 75865a5. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
No scripts in the folder and no shell commands in SKILL.md.
From the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Context Optimization loads about 2.9k tokens when it runs. Until then it costs about 80 tokens; SKILL.md has 1,549 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from seb1n/awesome-ai-agent-skills at commit 75865a5, republished under its MIT licence (© seb1n). 1,549 words, ~2,891 tokens.
.claude/skills/context-optimization/SKILL.md (or your agent's skills folder).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.
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.
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.
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.
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.
Reorder by Priority: Arrange the remaining chunks to maximize the model's attention. Place the highest-utility chunks first (models attend most to the beginning of the context) and the second-highest near the end (models also attend to recency). Avoid burying critical information in the middle of a long context block -- this is the "lost in the middle" zone where model attention is weakest.
Validate Coverage: After filtering and reordering, verify that the optimized context still covers all aspects of the query. If the query has multiple sub-questions, ensure at least one chunk addresses each. If coverage gaps appear, selectively re-add previously filtered chunks that fill the gap, even if their utility score was below the threshold.
Provide the raw context (a list of text chunks with optional metadata and scores), the user query, and the target token budget. The skill returns an optimized context block -- deduplicated, filtered, scored, and reordered -- ready for prompt assembly. Optionally provide a coverage checklist (key topics the context must address) to prevent important information from being filtered out.
Task: "Refactor the authentication module to use async/await instead of callbacks."
Raw Context (7 chunks, ~4,200 tokens):
| # | Source | Relevance | Density | Content Summary |
|---|---|---|---|---|
| 1 | src/auth/login.js:1-45 | 0.93 | High | Login function using callback-based db.findUser() |
| 2 | src/auth/login.js:20-55 | 0.90 | High | Overlapping chunk -- duplicates lines 20-45 of chunk 1, adds token refresh logic |
| 3 | src/auth/middleware.js:1-30 | 0.88 | High | Auth middleware with callback-based token verification |
| 4 | README.md:100-130 | 0.45 | Low | Project setup instructions -- no code, no auth details |
| 5 | src/auth/register.js:1-40 | 0.82 | High | Registration function using callbacks |
| 6 | package.json:1-25 | 0.35 | Low | Dependency list -- no auth-related logic |
| 7 | src/auth/login.js:40-70 | 0.91 | High | Token generation and session creation with callbacks |
Optimization Steps:
login.js.package.json, relevance 0.35) -- below the 0.50 threshold.Optimized Context (~2,800 tokens, 33% reduction):
src/auth/login.js:1-55 (merged) -- Login function with callback-based DB lookup and token refreshsrc/auth/login.js:40-70 -- Token generation and session creationsrc/auth/middleware.js:1-30 -- Auth middleware with callback token verificationsrc/auth/register.js:1-40 -- Registration function using callbacksQuery: "What is the company's return policy for electronics?"
Raw Retrieved Chunks (6 chunks, ~3,000 tokens):
returns-policy.md (score 0.95) -- "Electronics purchased from our store may be returned within 30 days of purchase. Items must be in original packaging with all accessories. A 15% restocking fee applies to opened items."faq.md (score 0.88) -- "Q: Can I return electronics? A: Yes, within 30 days. Items must be in original packaging. A 15% restocking fee applies to opened items. See our returns policy for full details."holiday-policy.md (score 0.72) -- "During the holiday season (Nov 15 - Jan 15), the return window for all products, including electronics, is extended to 60 days. All other conditions apply."shipping-info.md (score 0.40) -- "We ship electronics via insured ground shipping. Delivery takes 3-7 business days."returns-policy.md (score 0.85) -- "Refunds are processed to the original payment method within 5-10 business days. Defective items are exempt from the restocking fee and may be returned within 90 days."store-locator.md (score 0.30) -- "Visit any of our 200 retail locations nationwide."Optimization Steps:
Optimized Context (~900 tokens, 70% reduction):
© seb1n, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in context-engineering/context-optimization of seb1n/awesome-ai-agent-skills.
Open the folder on GitHubat commit 75865a5
Context Optimization next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Context Optimization this skillseb1n/awesome-ai-agent-skills | 206 | — | ~2.9k | Automated safety check: Pass | MIT | |
| Context DoctorjzOcb/context-doctor | 119 | — | ~642 | Automated safety check: Pass | MIT | |
| Caveman Learn Token FixesJuliusBrussee/caveman | 110k | — | ~2.8k | Automated safety check: Pass | Apache-2.0 | |
| OmniRoute Context CLIdiegosouzapw/OmniRoute | 74k | — | ~1.2k | Automated safety check: Pass | MIT | |
| Subagent Brief DisciplineLichAmnesia/lich-skills | 234 | — | ~1.6k | Automated safety check: Pass | MIT | |
| Compact Guidejh941213/my-cc-harness | 126 | — | ~621 | Automated safety check: Pass | None |
jzOcb/context-doctor
Visualize and diagnose OpenClaw context window usage. An agent skill from jzOcb/context-doctor.
JuliusBrussee/caveman
Acts on a Caveman learn report: reviews ranked token sinks, applies cost-lowering edits one at a time with your consent, and reports what each fix returned.
diegosouzapw/OmniRoute
Manage context engineering configurations, RTK filter sets, and conversation sessions from the CLI. Apply context-relay settings and inspect active context…
LichAmnesia/lich-skills
Checks every subagent prompt before spawning, swapping pasted files and context for paths and short summaries and trimming the brief, to avoid multiplied token cost.
jh941213/my-cc-harness
Context window management and token optimization guide. An agent skill from jh941213/my-cc-harness.
rlaope/oh-my-hermes
[omh] Context window or token budget at risk: plan compact context, token/cost budgets, summarization checkpoints, and overflow recovery before long agent work.
seb1n/awesome-ai-agent-skills
Plan, execute, document, and retest authorized security assessments of AI agents and multi-agent workflows using safe adversarial cases, synthetic identities, canaries, and evidence-based findings.
seb1n/awesome-ai-agent-skills
Build a preliminary, evidence-based EU AI Act readiness assessment across AI-system inventory, territorial scope, operator roles, prohibited-practice screening, risk classification, transparency…
seb1n/awesome-ai-agent-skills
Design and verify auditable human oversight, approval gates, escalation paths, and safe state transitions for AI agent workflows.
seb1n/awesome-ai-agent-skills
Design, implement, harden, and verify Model Context Protocol (MCP) servers with precise tool contracts, least-privilege authorization, safe transports, structured errors, and interoperability tests.
seb1n/awesome-ai-agent-skills
Audit agent skills, plugins, prompts, manifests, scripts, dependencies, and bundled assets for provenance, prompt-injection, permission, execution, exfiltration, persistence, and update risk.
seb1n/awesome-ai-agent-skills
Inspect, profile, clean, reconcile, analyze, visualize, and verify spreadsheet data while preserving formulas, formatting, types, and source files.
Categories
Optimize a complete candidate context package by deduplicating, filtering, ordering, and allocating its token budget. Context Optimization is an agent skill from seb1n/awesome-ai-agent-skills. Optimize a complete candidate context package by deduplicating, filtering, ordering, and allocating its token budget.
Context Optimization fits situations like: assembled material is noisy; exceeds the useful context budget; use context-ranking for scoring chunks and context-compression for shrinking selected content.
Run `npx skills add seb1n/awesome-ai-agent-skills --skill context-optimization -a claude-code`. Or copy the skill folder (context-engineering/context-optimization in seb1n/awesome-ai-agent-skills) into .claude/skills/context-optimization in your project. Claude Code loads it when a task matches its description.
Run `npx skills add seb1n/awesome-ai-agent-skills --skill context-optimization -a codex`. Or copy the skill folder (context-engineering/context-optimization in seb1n/awesome-ai-agent-skills) into .agents/skills/context-optimization in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add seb1n/awesome-ai-agent-skills --skill context-optimization -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/context-optimization, .gemini/skills/context-optimization, .github/skills/context-optimization and .opencode/skills/context-optimization in your project.
SKILL.md names no scripts, command-line tools or credentials: Context Optimization is instructions for the agent only.
SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Context Optimization is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.
About 2.9k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with Context Optimization: Context Doctor (jzOcb/context-doctor, 119 stars), Caveman Learn Token Fixes (JuliusBrussee/caveman, 110k stars), OmniRoute Context CLI (diegosouzapw/OmniRoute, 74k stars) and Subagent Brief Discipline (LichAmnesia/lich-skills, 234 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
seb1n (a GitHub user) maintains it in seb1n/awesome-ai-agent-skills, which has 206 GitHub stars. The repository holds 91 skills in this directory. The repository was last updated on August 9, 2026.
Source: seb1n/awesome-ai-agent-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.