Fold this session before the user clears it, so the fresh session after /clear starts from it with nothing lost. Use when the user asks to fold, to clear without losing anything, to start fresh but keep going, or when a session's window has grown so large that each turn is costly.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Fold?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ctxtree-fold)
---
name: fold
description: Fold this session before the user clears it, so the fresh session after /clear starts from it with nothing lost. Use when the user asks to fold, to clear without losing anything, to start fresh but keep going, or when a session's window has grown so large that each turn is costly.
allowed-tools: Bash(ctxtree *)
---
Claude Code has no way to shrink a running session's window: a fresh one starts with /clear. A fold makes that clear
lossless.
1. If the session holds a decision or a lead that must outlive the note below, pin its node (`ctxtree pin <node>`), or
write it where the project keeps its notes.
2. Write the note the new session starts from, and fold with it:
```
ctxtree fold --note - <<'EOF'
NOW: the task and its next step.
DECISIONS: each decision with its reason, and its node (t12) where you know it.
RULES: the user's standing instructions for this work, in their words where you can.
OPEN: leads, asks, and what is waiting on whom.
EOF
```
You hold the whole session; the new one holds only this note and what ctxtree carries beside it (the user's
latest words, your last words, commands still running, pins, files edited, the newest stretches of work). At most
3,000 characters: what it needs to carry on, not a history. Point to notes files rather than copy them. A summary
written this way helped a fresh agent carry on the work in ctxtree's measurements, where one drafted by rules did
not.
3. Show the user what `ctxtree fold` prints: what the next session will start with, and where the whole folded view
is.
4. Tell the user to type `/clear` in this session. The new session starts from the fold; every turn of this one still
opens word for word with `ctxtree open <session> <node>`.