plugins/claude-code-expert/skills-old/context-management/SKILL.md
# Claude Code Context Management Complete guide to managing context window, compression, and conversation flow. ## Context Window Overview Claude Code manages a conversation context window that accumulates messages, tool calls, and results throughout a session. ### Context Limits - The context window has a fixed token limit based on the model - Claude Code automatically warns when approaching limits - Auto-compact triggers when threshold is reached (configurable) ### Configuration ```json
npx skillsauth add markus41/claude plugins/claude-code-expert/skills-old/context-managementInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Complete guide to managing context window, compression, and conversation flow.
Claude Code manages a conversation context window that accumulates messages, tool calls, and results throughout a session.
// settings.json
{
"autoCompact": true,
"contextWindow": {
"compactThreshold": 0.8,
"warningThreshold": 0.9
}
}
/compact # General compression
/compact focus on authentication # Preserve auth-related context
What gets preserved:
What gets summarized/dropped:
/clear
Complete reset — use between unrelated tasks.
Offload research to sub-agents to keep main context clean:
// Instead of reading 20 files in main context:
Agent(subagent_type="Explore", prompt="Find all API endpoint definitions")
// The agent researches and returns a summary
// Main context only gets the summary, not all file contents
// Bad: Read entire large file
Read(file_path="/path/to/large-file.ts")
// Good: Read specific section
Read(file_path="/path/to/large-file.ts", offset=100, limit=50)
// Good: Search first, then read specific matches
Grep(pattern="function authenticate", path="/path/to/")
Long-running operations in background don't consume main context:
Agent(run_in_background=true, ...)
Bash(command="npm test", run_in_background=true)
| Tool | Context Impact | Mitigation | |------|---------------|------------| | Read (large files) | Very High | Use offset/limit | | Bash (verbose output) | High | Pipe through head/tail | | Grep (many matches) | High | Use head_limit | | Agent (results) | Medium-High | Agent summarizes internally |
| Tool | Context Impact | |------|---------------| | Glob | Low (just file paths) | | Write | Low (content sent, not echoed back) | | Edit | Low (just the diff) | | TodoWrite | Very Low | | AskUserQuestion | Very Low |
1. /clear (fresh start)
2. State the objective clearly
3. Claude researches and plans
4. Claude implements
5. Claude tests
6. Session ends
1. Task A work
2. /compact (preserve Task A context)
3. Task B work
4. /compact (preserve A+B context)
5. Task C work
6. ...
1. Spawn research agents (background)
2. Work on other tasks while agents research
3. Agents return summaries
4. Synthesize findings
5. Implement based on research
Claude Code can automatically save important context across sessions:
~/.claude/projects/<project>/memory/MEMORY.md — Auto-loaded# Disable auto-memory
export DISABLE_AUTOMEMORY=1
# Or in settings.json
{ "autoMemory": false }
/memory # View current memories
/memory add <text> # Add memory entry
/memory clear # Clear all memories
# In conversation
"Remember that we always use pnpm, not npm"
"Forget the previous instruction about yarn"
Shows current session costs:
/cost
Output includes:
/compact to reduce repeated contextclaude-haiku-4-5 for simple tasks (/model claude-haiku-4-5-20251001)Grep to find specific content instead of reading everything# Resume last conversation
claude --continue
claude -c
# Resume specific session
claude --resume <session-id>
# Set specific session ID
claude --session-id my-session-123
# Set conversation ID within session
claude --conversation-id conv-456
/clear for unrelated work/cost periodicallyrun_in_background for slow operationsdevelopment
Enhanced plan-authoring skill with Pre-Writing context gathering, task metadata, non-TDD templates, Red Flags, telemetry, and an automated plan linter. Use when you have a spec or requirements for a multi-step task, before touching code.
tools
Documentation intelligence engine with graph-based API docs, algorithm library, and drift detection
tools
Ultraplan cloud planning — kick off a plan in the cloud from your terminal, review and revise in the browser, then execute remotely or send back to CLI
tools
--- name: mcp description: Configure MCP servers for Claude Code — stdio vs HTTP, authentication, Tools/Resources/Prompts distinction, channels (CI webhook, mobile relay, Discord bridge, fakechat), and cost of always-loaded tools. Use this skill whenever adding an MCP server, debugging connection issues, choosing between MCP Tools vs Prompts vs Resources, installing channel servers, or managing .mcp.json. Triggers on: "MCP server", "mcp config", "add Obsidian MCP", "install context7", "channels"