Install
openclaw skills install @lzyyj/context-rotationopenclaw skills install @lzyyj/context-rotationContext management is the assistant's job, not the user's. The user should never have to manually start a fresh session or run /compact because the context window filled up.
This skill defines a repeatable protocol: when context pressure rises or the task changes, the assistant writes a HANDOFF.md handoff plus memory updates, then tells the user it is safe to continue in a new session — which will pick up seamlessly.
Trigger rotation when any of these is true:
session_status).embedded run timeout) — often caused by an oversized context.Do not rotate mid-task just because context is high: first ask "is finishing better than rotating here?" Rotate at a natural boundary.
| File | Purpose | Lifecycle |
|---|---|---|
HANDOFF.md (workspace root) | In-flight state: current task, decisions, active context, environment rules | Clear/delete once the task is done |
memory/YYYY-MM-DD.md | Raw daily log | Keep forever |
MEMORY.md | Curated long-term memory (distilled) | Keep forever |
memory/archive/ | Completed projects | Keep forever |
Names are conventions — adapt to your setup, but keep the split between in-flight state (HANDOFF) and durable memory.
Run these steps in order when a trigger fires.
HANDOFF.md (overwrite the whole file)Suggested template:
# 🤝 HANDOFF.md — session handoff (generated YYYY-MM-DD HH:MM)
> This is the handoff base for a context rotation. New sessions should read this
> first, then MEMORY.md and memory/YYYY-MM-DD.md.
## 🎯 Current task: <name> (in progress / done)
<2–5 sentences, framed from the user's point of view.>
### Changes made so far
<Exact file paths + what changed, down to functions/fields. Flag anything
"not built / not tested" as a known risk.>
### Next steps
- [ ] <a concrete, runnable next step>
### Key decisions
<Decision + why, one or two lines each.>
## 📌 Other active context
<Parallel project status, environment facts, important accounts/instances.>
## 🚨 Environment rules (read every session)
<Path hazards, commands, version locks, glossary.>
Guidelines:
memory/YYYY-MM-DD.mdAppend a rotation entry (time, trigger reason, what you did) so the daily log stays complete.
MEMORY.md (when warranted)memory/archive/, keep an index line in MEMORY.md.MEMORY.md directly.Say something like: "Context is tidied into HANDOFF.md — you can open a new session." The new session reads HANDOFF.md automatically. The user copies and pastes nothing.
Persist this in the assistant's always-loaded instructions (e.g. AGENTS.md) so every fresh session restores state:
SOUL.md / USER.md (persona + user profile), if present.memory/YYYY-MM-DD.md (today + yesterday).MEMORY.md.HANDOFF.md exists, read it and resume from its "Next steps" section.Check on long conversations (and before any big new task):
Context: 179k/200k (90%) → over the 80% line → rotate.| Signal | Meaning | Action |
|---|---|---|
| Status shows context > 80% | Window filling up | Rotate |
Run timeout (e.g. embedded run timeout: timeoutMs=...) | A single run exceeded its limit, often due to a bloated context | Check context; rotate |
| User: "let's switch to X" | Task change | Rotate the current task's state first, then start the new one |
| User: "I forget what we were doing" | Handoff failed | Read HANDOFF.md + yesterday's memory, rebuild context |
HANDOFF.md is in-flight state, not long-term memory. Clear it (> HANDOFF.md or delete) once the task is done, or a new session will read a stale task.HANDOFF.md. Reference where a key lives (e.g. "key is in auth-profiles.json") instead of pasting it.