performance-optimization
Best practices for Claude Code performance optimization, context management, storage cleanup, and troubleshooting slowdowns
What this skill does
# Performance Optimization Skill
Comprehensive guidance for optimizing Claude Code performance. This skill covers storage management, context window optimization, and troubleshooting common performance issues.
## When to Use This Skill
**Keywords:** slow, performance, lag, storage, cleanup, cache, context, compact, clear, sessions, agents, bloat, optimization, speed
**Use this skill when:**
- Claude Code is running slowly
- Storage is accumulating
- Context window is getting full
- Planning performance maintenance
- Learning best practices for efficient usage
## Quick Reference
### Immediate Actions for Slowdowns
| Symptom | Quick Fix | Command |
|---------|-----------|---------|
| General slowness | Clean storage | `/cleanup-sessions 7` |
| Input lag | Reset context | `/clear` |
| API errors | Check status | `/check-api-status` |
| Unknown cause | Full diagnostic | `/diagnose-performance` |
### Performance Commands
| Command | Purpose |
|---------|---------|
| `/user-config storage` | Analyze storage usage |
| `/user-config cleanup-sessions [days]` | Remove old session files |
| `/user-config cleanup-agents [days]` | Remove old agent files |
| `/user-config prune-cache [days]` | Comprehensive cleanup |
| `/diagnose-performance` | Full diagnostic |
| `/list sessions` | View recent sessions |
| `/user-config session-stats` | Session statistics |
| `/check-api-status` | API status check |
| `/check-context` | Context window analysis |
## Core Concepts
### 1. Storage Management
Claude Code stores conversation history in `~/.claude/`:
```text
~/.claude/
├── projects/ # Session history (can grow large!)
│ └── {project-hash}/
│ ├── {session-id}.jsonl # Conversation transcripts
│ └── agent-{id}.jsonl # Subagent transcripts
├── todos/ # Todo state
├── statsig/ # Analytics cache
└── history.jsonl # Command history
```
**Key insight:** The `projects/` folder grows indefinitely with usage. Heavy users can accumulate 1GB+ of session data.
**See:** `references/storage-management.md` for detailed guidance.
### 2. Context Window Management
Claude Code uses a 200K token context window. Performance degrades as it fills:
| Usage | Status | Action |
|-------|--------|--------|
| < 50% | Healthy | No action |
| 50-75% | Monitor | Consider compacting |
| 75-85% | Warning | Run /compact or /clear |
| > 85% | Critical | Immediate action |
**Key commands:**
- `/clear` - Complete context reset
- `/compact` - Intelligent summarization
- `/cost` - View token usage
**See:** `references/context-management.md` for detailed guidance.
### 3. Known Issues
Several GitHub issues document known performance problems:
> **Note:** Issue numbers below are point-in-time references and may have been closed,
> merged, or superseded. For current issues, spawn the `claude-code-issue-researcher`
> agent or query `docs-management: "performance issues"` for updated tracking.
| Issue | Description | Workaround |
|-------|-------------|------------|
| #10881 | Performance degrades in long sessions | Restart periodically |
| #14552 | Input lag at high context | Use /clear at 75% |
| #14476 | Regression even at 30k tokens | Update to latest version |
| #1497 | Keyboard responsiveness issues | Restart Claude Code |
**See:** `references/known-issues.md` for detailed tracking.
## Best Practices
### Daily Maintenance
1. **Start fresh when possible** - New session = fresh context
2. **Use /clear between major tasks** - Don't let context rot
3. **Monitor storage periodically** - Run `/check-claude-storage` weekly
### Heavy Usage Patterns
1. **Use subagents for large operations** - Isolates context bloat
2. **Break large tasks into sessions** - Smaller = faster
3. **Clean storage weekly** - `/cleanup-sessions 7`
### Performance Optimization
1. **Keep CLAUDE.md lean** - Large memory files slow startup
2. **Use progressive disclosure** - Load context on-demand
3. **Prefer focused queries** - Specific > broad
## Troubleshooting Flowchart
```text
Claude Code is slow
│
├─> Check storage: /check-claude-storage
│ └─> If >500MB: /cleanup-sessions 7
│
├─> Check context: /check-context
│ └─> If WARNING+: /clear or /compact
│
├─> Check API: /check-api-status
│ └─> If degraded: Wait or reduce load
│
└─> Full diagnostic: /diagnose-performance
└─> Follow recommendations
```
## Related Skills
| Skill | Relationship |
|-------|-------------|
| `docs-management` | For official Claude Code documentation |
| `memory-management` | For CLAUDE.md optimization |
## References
Load these for detailed guidance:
- `references/context-management.md` - Context window optimization
- `references/storage-management.md` - Storage cleanup strategies
- `references/known-issues.md` - GitHub issues and workarounds
## Version History
- **v1.0.0** (2025-12-26): Initial release
- Core performance guidance
- Command reference
- Best practices
- Reference documents
---
## Last Updated
**Date:** 2025-12-26
**Model:** claude-opus-4-5-20251101
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.