Tips ClaudeCursor Foundations

Context Management & Compaction

How to manage conversation context in Claude Code and Cursor to save tokens and stay productive

39 of 66

Why context matters

Every message you send includes the full conversation history. A 50-turn conversation sends far more tokens than a 5-turn one. Managing context keeps costs down and responses focused.

Claude Code: compaction

Claude Code offers three levels of context management.

Auto-compact

Triggers automatically when you approach the context limit. Claude summarizes the conversation, preserving key decisions, code patterns, and recent changes while condensing older history.

You can see when it happens: Claude prints a compaction notice in the terminal.

Micro-compact

A lighter pass that removes old tool call results (file reads, command outputs) without summarizing the conversation itself. Frees space with minimal information loss.

Manual /compact

Run /compact to trigger compaction on demand. Add instructions to control what gets kept:

/compact
/compact only keep the architecture decisions
/compact preserve the API schema we designed
/compact forget the debugging: keep the final solution

This is useful mid-session when you finish one phase (e.g., debugging) and want to reclaim context for the next phase (e.g., writing tests).

Other context commands

CommandEffect
/clearWipe the conversation entirely and start fresh
/compact [instructions]Summarize with custom focus
--resumeRestore a previous session (its compacted state)

Cursor: no compaction

Cursor does not offer compaction. When context fills up, you see a warning and must start a new chat. You cannot summarize mid-conversation or selectively trim context.

Workarounds

Notepads: Store key decisions, schemas, or context in Notepads. They persist across chats and load on demand with @notepad-name.

Rules files: Put project conventions in .cursor/rules/ as .mdc files. These load automatically based on glob patterns, so every new chat starts with the right context.

Manual summary: Before closing a long chat, ask the AI to summarize the conversation. Copy the summary and paste it into a new chat as the first message.

Shorter chats: Start a new chat for each distinct task. This is the most reliable way to keep context manageable.

Side-by-side comparison

FeatureClaude CodeCursor
Auto-compactionYes, triggers near context limitNo
Manual compaction/compact [instructions]No
Selective trimmingMicro-compact (tool results)No
Clear conversation/clearStart new chat
Persist across chatsMemory files, CLAUDE.mdNotepads, rules files
Context limit signalAuto-compact kicks inWarning banner

Best practices for both tools

  1. One task per chat: the single most effective cost-saving habit
  2. Front-load context: put important info in CLAUDE.md or rules files, not repeated messages
  3. Compact before pivoting, in Claude Code, run /compact when switching from exploration to implementation
  4. Don't fight context limits, if a conversation feels sluggish or unfocused, start fresh

Working out which model to run this on? See The Codex. Packaging it as a reusable skill? See The Armory.