Quay lại danh sách
Claude Code NativeĐộ khó: beginner

/compact

Free up context window by summarising the conversation so far — essential for long sessions to prevent context overflow.

Dùng được với:Claude

Khi nào dùng

Use proactively before starting a new phase of work in the same session, or when Claude starts losing track of earlier context.

Ví dụ sử dụng

/compact
/compact focus on the database migration work
/compact keep the API contract decisions

Select Model

<skill name="/compact">
<purpose>
# /compact — Claude Code Built-in Command

## What It Does
Summarises the conversation history to **free up context window space**, while preserving rules, skills, and memory files. The summary replaces the raw conversation, keeping Claude focused without losing critical context.

## Usage
```
/compact
```

### With focus instructions
```
/compact focus on the authentication refactor decisions
/compact keep the API endpoint list and discard the debugging tangents
```

Focus instructions guide what the summary prioritises — useful when the session covered multiple unrelated topics.

## What Survives Compaction
- Rules from `CLAUDE.md` and `.claude/settings.json`
- Loaded skills (re-activated on demand)
- Memory files (`MEMORY.md` / `~/.claude/MEMORY.md`)

## When to Use
- Before starting a new phase of work in the same session
- When you see Claude referencing old context incorrectly
- When `/context` shows the window is getting full
- Pro tip: use `/compact` before asking Claude to implement a new feature in a long session

## Alternative
If you want a completely fresh context: use `/clear` instead (starts a new conversation; previous is accessible via `/resume`).
</purpose>
</skill>

Skill liên quan