From context-analyzer
Optimizes Claude Code session context by explaining major consumers like metadata, images, file reads, and bash output, with strategies including screenshot compression, /compact usage, and reduced re-reads.
npx claudepluginhub jbdamask/john-claude-skills --plugin context-analyzerThis skill uses the workspace's default tool permissions.
Claude Code sessions have a finite context window. Understanding what consumes context and how to minimize waste keeps sessions productive longer. This skill provides patterns and strategies for context-efficient workflows.
Manage Claude Code context window — usage, compaction, optimization. Triggers "context window/usage/limit", "running out of context", "compact", "clear context".
Optimizes Claude Code performance using storage cleanup, context management commands, and diagnostics for slowdowns, lag, and full contexts.
Optimizes Claude Code session context and token usage via compaction, MCP audits, prompt scoping, and subagent delegation. Use when sessions slow, context degrades, or budget depletes.
Share bugs, ideas, or general feedback.
Claude Code sessions have a finite context window. Understanding what consumes context and how to minimize waste keeps sessions productive longer. This skill provides patterns and strategies for context-efficient workflows.
Every interaction in a Claude Code session adds to context. The main consumers, ranked by typical impact:
Every message carries a JSON envelope with sessionId, uuid, cwd, gitBranch, version, and other fields. This is not directly controllable but is the largest single category.
Hook progress events and streaming data accumulate significantly in long sessions. Not directly controllable.
Screenshots pasted into chat are encoded as base64 PNG, inflating size ~33% over raw bytes. A single full-screen PNG screenshot can consume 500 KB to 2 MB of context.
Every Read tool invocation returns the full file content into context. Re-reading the same file multiple times multiplies its impact.
Claude-in-Chrome screenshots are JPEG (~50-80 KB each) but accumulate in browser-heavy sessions.
File content included in Edit and Write operations.
Command output returned to context. Usually small per-call but adds up with heavy Bash usage.
CLAUDE.mdCLAUDE.md/compact after browser automation sequences with many screenshots/compact after completing a distinct phase of work/compact when switching between different parts of the codebasehead or tail when full output is unnecessary--quiet or --silent flags where availableEdit replaces specific strings (small payload)Write sends the entire file content (large payload)To analyze what's consuming context in a specific project, run:
/context-analyzer:analyze-context
This parses the project's JSONL chat history files in ~/.claude/projects/ and produces a detailed breakdown with per-category sizes, most re-read files, and targeted recommendations.
For programmatic access, the analysis script supports JSON output:
python3 ${CLAUDE_PLUGIN_ROOT}/scripts/analyze_context.py --json
Problem: Claude reads types.ts or api.ts every time it needs to reference types.
Fix: Add key type definitions or API surface to CLAUDE.md.
Problem: Each PNG screenshot is 500 KB-2 MB in base64. Fix: Crop to the relevant area and resize before pasting.
Problem: 20+ screenshots from scroll-screenshot-click sequences fill context.
Fix: Run /compact after browser testing. Use read_page (accessibility tree) instead of screenshots when visual verification isn't needed.
Problem: Full test suite output or build logs dumped to context.
Fix: Pipe through tail -20 or grep for failures only.
Problem: DEVLOG.md or similar grows over time and is read at session start.
Fix: Keep it under 5 KB or move to Claude Code memory (~/.claude/projects/.../memory/).
For detailed analysis methodology and report interpretation, see:
references/analysis-methodology.md — How the analysis script categorizes context consumption