context_optimization

context_optimization is a skill for Claude Code, Codex from ApexIQ/skillsmith. It costs 18 tokens per session (357 once invoked), scanned A, original, MIT.

A set of techniques for keeping an AI coding agent focused as a project conversation grows. It uses short project maps, targeted file searches, summaries, and saved decision notes instead of loading everything into its context.

In plain words
What is it for?
Use it to map an unfamiliar repository, find only the relevant parts of large logs or codebases, summarize progress, and record project decisions for later sessions.
Why use it?
Long conversations can bury important instructions and make the agent lose track of earlier decisions. These techniques reduce irrelevant context and preserve key information in files.

Skill for Claude CodeCodex

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

Good fit Use it to map an unfamiliar repository, find only the relevant parts of large logs or codebases, summarize progress, and record project decisions for later sessions.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/apexiq/skillsmith/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 ApexIQ/skillsmith --skill context_optimization
Clone the repo
git clone --depth 1 https://github.com/ApexIQ/skillsmith

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/apexiq/skillsmith/context_optimization/github.svg)](https://agentmods.dev/skills/apexiq/skillsmith/context_optimization)
Your own site
<a href="https://agentmods.dev/skills/apexiq/skillsmith/context_optimization"><img src="https://agentmods.dev/badge/skills/apexiq/skillsmith/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/apexiq/skillsmith/context_optimization"><img src="https://agentmods.dev/badge/skills/apexiq/skillsmith/context_optimization.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 18 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 357 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.
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.00018 $0.00357
Opus 5 $0.00009 $0.00179
Sonnet 5 $0.00004 $0.00071
Haiku 4.5 $0.00002 $0.00036

Measured 8d ago against content hash 9fe932fd72d7, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, 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 8d 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.

src/skillsmith/templates/.agent/skills/agentic_lifecycle/context_optimization/SKILL.md · 40 lines

What it actually says

Context Optimization

"Context Rot" occurs when an Agent's context window fills with irrelevant history, causing it to forget early instructions or hallucinate. Use these strategies to stay sharp.

1. The "Repo Map" Strategy

Don't read every file. Use high-level maps.

  • Tree: Run tree or ls -R to understand structure.
  • Signatures: Read only function signatures/classes (using grep or outline tools) before reading full implementations.

2. Summarize & Flush

If the conversation gets too long (> 20 turns):

  1. Summarize: Compress all recent progress into .agent/STATE.md.
  2. Flush: Recommend the user start a new session/chat window.

    "I have updated STATE.md. Please start a new chat and upload STATE.md to continue with a fresh context."

3. Target "Need-to-Know"

  • Don't dump an entire 1000-line log into context.
  • Do grep the log for "Error" or "Exception".
  • Don't read node_modules or venv.

4. Artifact-Driven Memory

Never rely on "I told you 5 messages ago."

  • If a decision is made, write it down in .agent/decisions/ADR-001.md or .agent/PROJECT.md.
  • File contents are permanent; Chat history is ephemeral.
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. 8d ago First seen · 40 lines · 18 tokens per session scan A 9fe932fd72d7

Subscribe to this mod's changes

context_optimization is a skill published in the GitHub repository ApexIQ/skillsmith (5 stars, last pushed 5mo ago), licensed MIT. It adds 18 tokens to every session and 357 once invoked, about $0.0001 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-09-03.

Related

Other skills, from other repositories

memory-search

PROACTIVELY search conversation history and semantic memory BEFORE starting new work. Use at the START of any non-trivial task to recall prior decisions, avoid repeating past discussions, and reuse what was already learned. Also use when the user asks to "search memory", "what did we discuss", "remember when", "find…

23blocks-OS/ai-maestro-plugins · 90 tokens

session-handoff

Context transfer between AI sessions. Trigger when the user wants to save the context, resume a task, or hand off the work to another session.

christopherlouet/claude-base · 33 tokens

memory-search

Use this skill only when the user explicitly asks to query the EvoFlux application database with SQL for structured analysis that ordinary recall cannot answer: aggregating tool failures across sessions, filtering by role, agent, or time range, reconstructing a complete execution chain, or checking a remembered claim…

evoelsewhere/evoflux · 90 tokens

learner

Post-debugging knowledge extraction — captures non-obvious, codebase-specific learnings that pass quality gates. Invoke after resolving tricky bugs or discovering surprising behavior.

XeldarAlz/everything-claude-unity · 34 tokens

context-management

Strategies for managing AI agent context windows including optimization, summarization, retrieval-augmented generation, progressive disclosure, and pruning. Use when the user is hitting context limits, building long-running agents, implementing RAG, optimizing token usage, or designing systems that need to manage…

VersoXBT/claude-initial-setup · 66 tokens

knowledge-persistence

Patterns for learning from corrections, capturing instincts, extracting stable patterns, and building cross-session knowledge. Use when the user corrects you, when you discover a recurring pattern, or when insights should persist beyond the current session.

VersoXBT/claude-initial-setup · 48 tokens