<< All versions

Skill v1.0.0

currentAutomated scan100/100
evgeniy-mikhailove/rlm-claude-code-os/session-context-mastery
──Details
PublishedNovember 15, 2026 at 06:06 AM
Content Hashsha256:a7747f4ed96d52e9...
Git SHA0618f6138c74
──Files
Files (1 file, 3.6 KB)
SKILL.md3.6 KBactive
SKILL.md · 118 lines · 3.6 KB

name: session-context-mastery description: Master context window management for long Claude Code sessions. Use when starting complex multi-hour tasks, when sessions approach context limits, or when output quality degrades mid-session. Covers context budgeting, rewind strategy, compaction, subagent handoffs, and CLAUDE.md progressive disclosure. From Boris Cherny (Claude Code creator) and Thariq (Anthropic). id: session-context-mastery runtime: claude-only canonical_path: ~/.claude/skills/session-context-mastery/SKILL.md updated: 2026-05-18 tags: [context, session, compaction, rewind, budgeting, claude-code] source: shanraisshan/claude-code-best-practice metadata: version: "1.0.0"


Session Context Mastery

Prevent context rot. Manage the 200k window deliberately.

Context Budget Zones

ZoneFill %StateAction
Green0–30%Full capabilityNone
Yellow30–50%Slight degradation beginsMonitor
Orange / Dumb Zone50–70%Noticeable quality lossCompact or delegate
Red70%+High context rot riskRewind or clear

Rule: Compact or rewind before hitting 50% on complex tasks.

Three Strategies

1. Rewind (Precision Tool)

When: A tool call went wrong or context got polluted with bad output.

Ctrl+Z / /rewind
  • Rewind to the point before the failed attempt
  • Never try to fix a bad outcome on top of polluted context
  • Before rewinding: ask subagent to "summarize findings from this section" first

2. Compact (Mid-Task Compression)

When: Context is filling but task isn't done yet.

/compact
  • Lossy — appropriate for mid-task, non-critical context
  • Claude summarizes what's happened, preserves goal state
  • Best for: long research sessions, iterative debugging

3. Clear (Fresh Start)

When: Task is complete, or you need a fully clean slate.

/clear
  • Complete reset — use only between major tasks
  • Write key findings to files BEFORE clearing

Subagent Handoff Protocol

Delegate intermediate work instead of filling main context:

  1. Give subagent only the specific task + only relevant files
  2. Subagent works in isolation (fresh 200k context)
  3. Subagent returns ONLY the conclusion — not the reasoning trail
  4. You integrate the conclusion (small) not the process (large)

Keeps main context at 30-40% even for complex multi-step tasks.

CLAUDE.md Progressive Disclosure

Split large CLAUDE.md into modular rule files:

.claude/
CLAUDE.md # Entry point — short, links others
rules/
security.md # Load only for security tasks
n8n-patterns.md # Load only for n8n work
api-contracts.md # Load only for API work

Reference with glob: @.claude/rules/security.md loads only when needed.

Target: <2,000 lines of focused context per task.

compact vs clear — Decision

SituationUse
Mid-task, continuing the same goal/compact
Task complete, switching topics/clear
Last output was wrong/polluted/rewind
About to start fresh project/clear

Warning Signs of Context Rot

  • AI starts repeating itself or looping
  • Suggestions contradict earlier decisions in the same session
  • Code quality noticeably drops without explanation
  • AI "forgets" conventions established earlier in the session

Act immediately: compact, rewind, or delegate to subagent.

Session Start Checklist

  • [ ] Clear context from previous session (unless explicitly continuing)
  • [ ] Load ONLY files relevant to this specific task
  • [ ] Set explicit goal for this session in first message
  • [ ] For multi-session projects: load STATE artifacts (see gsd-workflow skill)
All versions