context-optimizer

An agent that reviews how much working context a coding session uses and suggests ways to reduce it. Context is the information available to the assistant while it works.

In plain words
What is it for?
Use it to inspect active context, find large source files, identify unused Python imports or TypeScript exports, and locate debug logs.
Why use it?
Long files, unused imports, unused exports, and debug output can make sessions harder to manage and leave less room for new work.

Agent for Claude Code

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 agents/zapprosite/claude-code-minimax/context-optimizer
Clone the repo
git clone --depth 1 https://github.com/zapprosite/claude-code-minimax

Made for: Claude Code.

Per session 26 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,086 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.00026 $0.01086
Opus 5 $0.00013 $0.00543
Sonnet 5 $0.00005 $0.00217
Haiku 4.5 $0.00003 $0.00109

Measured 2d ago against content hash ee077f764d08, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

context-optimizer 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 2d 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.

.claude/agents/context-optimizer.md · 131 lines

How it starts

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

Context Optimizer Agent

Analisa o estado atual do contexto e sugere ações para preservar a janela de contexto.

Análise de Contexto

1. Session Status

# Verificar sessões ativas
mcp__memory-keeper__context_status

# Listar canais
mcp__memory-keeper__context_list_channels includeEmpty=true

# Estatísticas
mcp__memory-keeper__context_channel_stats includeInsights=true

2. Tamanho de Arquivos Recentes

# Arquivos >300 LOC — candidatos a cleanup
find . -name "*.py" -o -name "*.ts" -o -name "*.js" -o -name "*.tsx" | \
  xargs wc -l 2>/dev/null | sort -rn | head -20

# Arquivos >500 LOC
find . -name "*.py" -o -name "*.ts" -o -name "*.js" -o -name "*.tsx" | \
  xargs wc -l 2>/dev/null | awk '$1 > 500' | sort -rn

3. Imports/Props Mortos

# Imports não usados em Python
grep -rnE "^import |^from " --include="*.py" . | grep -v "^[^:]*:[^:]*#" | \
  awk -F: '{print $1 ":" $2}' | sort -u > /tmp/all_imports.txt

# Exports não usados em TypeScript
grep -rnE "export (const|function|class|type|interface)" --include="*.ts" --include="*.tsx" .

4. Console Logs e Debug

# Debug logs em código
grep -rnE "console\.(log|debug|info|warn|error)" --include="*.js" --include="*.ts" --include="*.tsx" .
grep -rnE "print\(.*DEBUG|logger\.debug|log\.debug" --include="*.py" .

# TODO/FIXME/HACK órfãos
grep -rnE "TODO|FIXME|HACK|XXX" --include="*.py" --include="*.js" --include="*.ts" --include="*.tsx" .

5. Memória de Sessão

# Verificar se há itens de sessão >10 mensagens
mcp__memory-keeper__context_get sessionId=current limit=50 sort=created_desc

Sugestões de Compactação

Ações Imediatas

  1. Remover console.logs órfãos — reducen ruido na leitura
  2. Deletar imports não usados — import statements ocupam linhas
  3. Limpar props mortos — props que não são mais usados em components

Ações de Contexto

  1. Checkpoint antes de cleanupmcp__memory-keeper__context_checkpoint name="pre-cleanup"
  2. Compactar sessões antigasmcp__memory-keeper__context_compress olderThan="30 days"
  3. Escrever session summary — salvar estado em context-log.md

Read the full file on GitHub · 131 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. 2d ago First seen · 131 lines · 26 tokens per session scan A ee077f764d08

Subscribe to this mod's changes

context-optimizer is an agent published in the GitHub repository zapprosite/claude-code-minimax (2 stars, last pushed 4mo ago), licensed MIT. It adds 26 tokens to every session and 1,086 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-08-31.