short version: /compact swaps your conversation for a summary Claude writes and keeps the same session going. /clear starts a new conversation with an empty context. your project memory (CLAUDE.md and friends) still loads, and the old conversation is still reachable through /resume.
the longer version matters, because the two look alike in the prompt bar and behave really differently. i've watched people (me included) pick the wrong one mid task and lose a decision that took an hour to reach.
what /compact does
Anthropic's command reference describes /compact [instructions] as freeing up context "by summarizing the conversation so far," with optional focus instructions. run /compact focus on the API changes and the summary leans toward what you named. you can also compact part of a conversation from /rewind with "Summarize from here" or "Summarize up to here." the automatic pass Claude Code runs near the limit is the same operation, you just don't get to steer it.
after a compaction, the docs list what comes back on its own. the system prompt and output style still apply. project root CLAUDE.md, unscoped rules and auto memory get re-injected from disk. up to five recently modified files Claude touched get re-read, and a file over 5,000 tokens comes back only as a path. invoked skills return within a per skill cap. path scoped rules and nested CLAUDE.md files aren't re-injected right away, they reload on demand when Claude touches a matching file again. context that hooks added earlier, and anything that only lived in the conversation, survives only as whatever the summary kept.
a cost detail people miss: the costs page notes that /compact "reads the conversation it summarizes, so compacting a large context is itself a large request."
what /clear does
/clear (aliases /reset and /new) starts a new conversation with empty context. the commands overview says it "starts fresh on a new task while keeping project memory," so your CLAUDE.md is still there in the new session. the same costs page says that when you want a fresh start instead of continuity, "/clear costs nothing."
the question i get most is whether /clear is permanent. Anthropic's sources don't fully agree. the help center article on models and limits warns /clear can't be undone. the command reference says you can get back to the previous conversation with /resume, and that in the same Claude Code process the rewind menu shows a "previous session" entry. my read: the old transcript is still there to go back to, but nothing from it carries into the new session unless you bring it. if something matters, write it down first.
how to tell which one happened
if you write hooks, they're easy to tell apart. SessionStart fires with source set to compact after a compaction and clear after /clear, and PreCompact fires first with a manual or auto trigger. that's how tools that manage context, mine included, know which boundary they just crossed.
which one should you use?
Anthropic's own session management guide puts the trade off better than i can. compaction is "lossy, but you didn't have to write anything yourself." with /clear you write down what matters and start clean, which is more work, but "the resulting context is what you decided was relevant." their rule of thumb: /compact when you're mid task and the session is bloated, /clear when you're starting something new.
that leaves a gap for long tasks where you want both: a clean window plus the decisions from the last two hours. that's where most community tooling lives. some people do it by hand: ask for a handoff note, /clear, paste it back. claude-auto-handoff automates that by having Haiku write the brief before running /clear. claude-mem works from the memory side, capturing what your agent did and injecting relevant bits into later sessions. context-mode cuts how much tool output lands in your context at all, so you hit either command less often.
where my thing fits (i built this, so grain of salt)
i built aigent-OS, an MIT licensed, local only setup for Claude Code. it comes in two sizes.
the small one: the context-capsule plugin. if you just want the handoff note thing without doing it by hand, this is it. run /capsule (or /refresh) and Claude writes a resume ready checkpoint file of your session. then run /clear yourself, or let auto compact happen, and the next session gets a short pointer to the capsule so it picks up where you left off. plain Node scripts, zero npm dependencies, no network. install from inside Claude Code:
/plugin marketplace add wrg32786/aigent-os
/plugin install context-capsule@aigent-os
the full one: managed Auto-Refresh. this automates the clean window path end to end. at a context threshold (80% by default, set with AIGENT_PRESSURE_THRESHOLD_PCT) it asks Claude to write a capsule, waits for one exact acknowledgement, sends a single /clear, confirms through SessionStart that a fresh session really started, and resumes from the capsule. no acknowledgement, no clear. memory is plain markdown in git, so you can diff what the agent remembers. needs Claude Code, Node 18+ and bash (Git Bash on Windows):
git clone https://github.com/wrg32786/aigent-os.git && cd aigent-os && bash install.sh --dry-run
the dry run prints the planned changes and writes nothing. if it looks right, run bash install.sh, open a new terminal and run aigent. one heads up: if you install in the cloned folder, point origin at your own private repo first, because it commits and pushes your memory folder at each capsule cycle when there's a remote.
honest status: managed Auto-Refresh is stable as of v1.1.0. the public evidence is 11 of 11 clean cycles on one Windows machine during release testing, which is single seat evidence, not a reliability claim. the rc.1 bug where a long session could stall at the clear step, plus two ack edge cases (#90, #91), are fixed in v1.1.0. and i'm not claiming it beats compaction. it trades a model written summary for a checkpoint you can open and read.
docs and getting started: https://wrg32786.github.io/aigent-os/
FAQ
does /clear delete my CLAUDE.md or project files?
no. it clears the conversation. project memory loads again in the new session and your files aren't touched.
can i get back to a conversation after /clear?
per the command reference, yes, through /resume or the rewind menu's previous session entry in the same process.
which is cheaper?
/clear. compacting has to read the whole conversation to summarize it.
does /compact keep my files in context?
it re-reads up to five recently modified files Claude worked on. any file over 5,000 tokens comes back as a path reference only.
can i keep context across /clear without installing a whole framework?
yeah, that's what the context-capsule plugin is for. two commands to install, and it's manual trigger only, so nothing clears unless you do it.
Top comments (0)