Skill
Core
Context-Window Self-Clearing
Default-off orchestrator contract for checkpoint-before-reset context compaction/clearing at deterministic pressure thresholds — snapshot-first continuity across Claude Code and Codex.
Overview
The context-window-self-clearing skill preserves Datarim task continuity while orchestrated Claude Code or Codex sessions compact or clear their context window. It applies only to orchestrator-launched sessions that explicitly enable context-window automation — it is default-off.
Key Concepts
- Checkpoint before reset — the active task snapshot is read first; the task-description path, last completed snapshot stage, snapshot path, and snapshot digest are bound into a private transaction before any reset instruction is sent.
- Deterministic pressure thresholds — two arms, and the stricter verdict wins. The primary absolute arm counts working-set tokens: below 200,000 is
no_op, 200,000–279,999 isselective_drop(compaction), 280,000 and above isfull_clear(overridable viaDR_CTX_SOFT_TOKENS/DR_CTX_HARD_TOKENS). The retained percentage arm: below 75% isno_op, 75–89% isselective_drop, 90–100% isfull_clear. A percentage alone hides its denominator, so a larger window is never a licence to accumulate more; a missing token count is a gap to close, not evidence of low pressure. A policy may select a mode only at or above its declared floor, never below 50. - Fixed instructions only — selective compaction and full clear use a closed set of reset instructions; nothing is improvised per session.
- Transactional continuity — after a full clear the session revalidates the snapshot digest and resumes via
/dr-next; after compaction a matching post-compact marker completes the transaction exactly once. A failed or crashed claim is ambiguous and is reconciled, never replayed automatically. - Trust boundary — HMAC tags protect private-state integrity, ordering, replay, and pane correlation; automation requires the runtime trust settings to be explicitly enabled. Raw pane, prompt, assistant, notify, or rollout content is never persisted.
Canonical source
Full contract in the Datarim repo: skills/context-window-self-clearing/SKILL.md. Continuity source of truth: the snapshot-replay skill.