performance-optimization
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePerformance Optimization Skill
性能优化技能
Comprehensive guidance for optimizing Claude Code performance. This skill covers storage management, context window optimization, and troubleshooting common performance issues.
本技能为Claude Code性能优化提供全面指导,涵盖存储管理、上下文窗口优化以及常见性能问题的故障排查。
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
关键词: 缓慢、性能、延迟、存储、清理、缓存、上下文、压缩、清空、会话、Agent、冗余、优化、速度
在以下场景使用本技能:
- Claude Code运行缓慢
- 存储不断累积
- 上下文窗口即将占满
- 规划性能维护工作
- 学习高效使用的最佳实践
Quick Reference
快速参考
Immediate Actions for Slowdowns
运行缓慢的即时处理方案
| Symptom | Quick Fix | Command |
|---|---|---|
| General slowness | Clean storage | |
| Input lag | Reset context | |
| API errors | Check status | |
| Unknown cause | Full diagnostic | |
| 症状 | 快速修复方法 | 命令 |
|---|---|---|
| 整体运行缓慢 | 清理存储 | |
| 输入延迟 | 重置上下文 | |
| API错误 | 检查状态 | |
| 原因不明 | 全面诊断 | |
Performance Commands
性能相关命令
| Command | Purpose |
|---|---|
| Analyze storage usage |
| Remove old session files |
| Remove old agent files |
| Comprehensive cleanup |
| Full diagnostic |
| View recent sessions |
| Session statistics |
| API status check |
| Context window analysis |
| 命令 | 用途 |
|---|---|
| 分析存储使用情况 |
| 删除旧会话文件 |
| 删除旧Agent文件 |
| 全面清理缓存 |
| 全面性能诊断 |
| 查看近期会话 |
| 会话统计信息 |
| API状态检查 |
| 上下文窗口分析 |
Core Concepts
核心概念
1. Storage Management
1. 存储管理
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 historyKey insight: The folder grows indefinitely with usage. Heavy users can accumulate 1GB+ of session data.
projects/See: for detailed guidance.
references/storage-management.mdClaude Code将会话历史存储在目录下:
~/.claude/text
~/.claude/
├── projects/ # 会话历史(可能会变得很大!)
│ └── {project-hash}/
│ ├── {session-id}.jsonl # 会话记录
│ └── agent-{id}.jsonl # 子Agent会话记录
├── todos/ # 待办事项状态
├── statsig/ # 分析缓存
└── history.jsonl # 命令历史关键提示: 文件夹会随着使用不断增大,重度用户可能会累积1GB以上的会话数据。
projects/参考: 详细指导请查看。
references/storage-management.md2. Context Window Management
2. 上下文窗口管理
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:
- - Complete context reset
/clear - - Intelligent summarization
/compact - - View token usage
/cost
See: for detailed guidance.
references/context-management.mdClaude Code使用200K token的上下文窗口,当窗口被占满时性能会下降:
| 使用占比 | 状态 | 操作建议 |
|---|---|---|
| < 50% | 健康 | 无需操作 |
| 50-75% | 监控 | 考虑压缩上下文 |
| 75-85% | 警告 | 运行/clear或/compact命令 |
| > 85% | 严重 | 立即采取行动 |
关键命令:
- - 完全重置上下文
/clear - - 智能摘要压缩
/compact - - 查看Token使用情况
/cost
参考: 详细指导请查看。
references/context-management.md3. Known Issues
3. 已知问题
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 theagent or queryclaude-code-issue-researcherfor updated tracking.docs-management: "performance issues"
| 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: for detailed tracking.
references/known-issues.md多个GitHub问题记录了已知的性能问题:
注意: 以下问题编号为当前时间点的参考,可能已被关闭、合并或替代。如需了解最新问题,请启动Agent,或查询claude-code-issue-researcher获取更新的跟踪信息。docs-management: "performance issues"
| 问题编号 | 描述 | 临时解决方案 |
|---|---|---|
| #10881 | 长会话中性能下降 | 定期重启 |
| #14552 | 高上下文占比时输入延迟 | 占比达75%时使用/clear命令 |
| #14476 | 即使在30k Token时也出现性能倒退 | 更新至最新版本 |
| #1497 | 键盘响应问题 | 重启Claude Code |
参考: 详细跟踪请查看。
references/known-issues.mdBest Practices
最佳实践
Daily Maintenance
日常维护
- Start fresh when possible - New session = fresh context
- Use /clear between major tasks - Don't let context rot
- Monitor storage periodically - Run weekly
/check-claude-storage
- 尽可能开启新会话 - 新会话意味着全新的上下文
- 在主要任务之间使用/clear命令 - 避免上下文冗余堆积
- 定期监控存储 - 每周运行
/check-claude-storage
Heavy Usage Patterns
重度使用场景
- Use subagents for large operations - Isolates context bloat
- Break large tasks into sessions - Smaller = faster
- Clean storage weekly -
/cleanup-sessions 7
- 使用子Agent处理大型操作 - 隔离上下文冗余
- 将大型任务拆分为多个会话 - 会话越小速度越快
- 每周清理存储 - 运行
/cleanup-sessions 7
Performance Optimization
性能优化技巧
- Keep CLAUDE.md lean - Large memory files slow startup
- Use progressive disclosure - Load context on-demand
- Prefer focused queries - Specific > broad
- 保持CLAUDE.md文件精简 - 大内存文件会拖慢启动速度
- 使用渐进式披露 - 按需加载上下文
- 优先使用精准查询 - 具体查询优于宽泛查询
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 recommendationstext
Claude Code运行缓慢
│
├─> 检查存储:/check-claude-storage
│ └─> 如果超过500MB:/cleanup-sessions 7
│
├─> 检查上下文:/check-context
│ └─> 如果处于警告及以上状态:/clear或/compact
│
├─> 检查API状态:/check-api-status
│ └─> 如果状态降级:等待或降低负载
│
└─> 全面诊断:/diagnose-performance
└─> 按照建议操作Related Skills
相关技能
| Skill | Relationship |
|---|---|
| For official Claude Code documentation |
| For CLAUDE.md optimization |
| 技能 | 关联关系 |
|---|---|
| 用于获取官方Claude Code文档 |
| 用于CLAUDE.md文件优化 |
References
参考资料
Load these for detailed guidance:
- - Context window optimization
references/context-management.md - - Storage cleanup strategies
references/storage-management.md - - GitHub issues and workarounds
references/known-issues.md
加载以下文档获取详细指导:
- - 上下文窗口优化
references/context-management.md - - 存储清理策略
references/storage-management.md - - GitHub问题及临时解决方案
references/known-issues.md
Version History
版本历史
- v1.0.0 (2025-12-26): Initial release
- Core performance guidance
- Command reference
- Best practices
- Reference documents
- v1.0.0 (2025-12-26): 初始版本
- 核心性能指导
- 命令参考
- 最佳实践
- 参考文档
Last Updated
最后更新
Date: 2025-12-26
Model: claude-opus-4-5-20251101
日期: 2025-12-26
模型: claude-opus-4-5-20251101