compact

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Compact Context

紧凑上下文

Proactively compress the current conversation context to optimize token usage.
主动压缩当前对话上下文以优化Token使用。

When to Use

使用场景

  • Before starting a new task in a long session
  • When working on multiple unrelated features
  • At natural workflow checkpoints (after commits, PR creation)
  • When context indicator shows high usage
  • 在长会话中开始新任务前
  • 处理多个不相关功能时
  • 在自然工作流检查点(提交后、创建PR后)
  • 当上下文指示器显示使用量过高时

Actions

操作步骤

  1. Summarize completed work - What was done, key decisions made
  2. Preserve essential context - Active file paths, current task, blockers
  3. Clear redundant history - Old exploration, superseded plans
  4. Update memory - Save important patterns to
    .claude/memory/
  1. 总结已完成工作 - 已完成内容、做出的关键决策
  2. 保留必要上下文 - 活跃文件路径、当前任务、阻碍因素
  3. 清除冗余历史 - 旧的探索内容、已被取代的方案
  4. 更新记忆 - 将重要模式保存至
    .claude/memory/

Best Practices

最佳实践

  • Use
    /compact
    at natural breakpoints, not mid-task
  • After compacting, briefly restate the current objective
  • Check that critical file paths are still accessible
  • If working on a bug, preserve error messages and stack traces
  • 在自然断点使用
    /compact
    ,不要在任务进行中使用
  • 压缩后,简要重述当前目标
  • 确认关键文件路径仍可访问
  • 如果处理Bug,保留错误信息和堆栈跟踪

Context Preservation Checklist

上下文保留检查清单

Before compacting, ensure you've saved:
  • Current branch and uncommitted changes status
  • Active file paths being modified
  • Any error messages or stack traces
  • Key decisions and their rationale
  • Pending items from todo list
压缩前,确保已保存:
  • 当前分支和未提交更改状态
  • 正在修改的活跃文件路径
  • 任何错误信息或堆栈跟踪
  • 关键决策及其理由
  • 待办事项列表中的未完成项

Example Usage

使用示例

User: /compact
Claude: Compacting context...
User: /compact
Claude: Compacting context...

Session Summary

Session Summary

  • Implemented employee export feature
  • Fixed validation bug in SaveEmployeeCommand
  • Created unit tests for EmployeeHelper
  • Implemented employee export feature
  • Fixed validation bug in SaveEmployeeCommand
  • Created unit tests for EmployeeHelper

Active Context

Active Context

  • Branch: feature/employee-export
  • Files: Employee.Application/Commands/ExportEmployees/
  • Current task: Add pagination to export
  • Branch: feature/employee-export
  • Files: Employee.Application/Commands/ExportEmployees/
  • Current task: Add pagination to export

Cleared

Cleared

  • Exploration of unrelated notification code
  • Superseded implementation approaches
Ready to continue with pagination implementation.
undefined
  • Exploration of unrelated notification code
  • Superseded implementation approaches
Ready to continue with pagination implementation.
undefined

IMPORTANT Task Planning Notes

重要任务规划说明

  • Always plan and break many small todo tasks
  • Always add a final review todo task to review the works done at the end to find any fix or enhancement needed
  • 始终规划并拆分多个小型待办任务
  • 始终添加一个最终审查待办任务,在结束时回顾已完成工作,查找任何需要修复或增强的内容