Context Session Skill
This skill provides background knowledge for managing Claude Code sessions according to the project's operating model defined in CLAUDE.md.
Session State Variables
Track these throughout the session:
code
current_mode: PLANNING | EXECUTION objective: [Current goal] compact_count: 0/3 assumptions: [Working assumptions] open_questions: [Open items] next_actions: [Queued work]
Mode Selection
Use PLANNING MODE when:
- •Adding new features
- •Changing existing behavior
- •Cross-module refactors
- •Architecture changes
- •Database schema changes
- •Touching "do not touch" zones:
- •
/apps/agent-api/prisma/migrations/ - •
/ai-automation-agency-os/02-clients/*/03-operations/ - •
.env*files - •
pnpm-lock.yaml
- •
Use EXECUTION MODE when:
- •Scoped bug fixes (clear root cause)
- •Documentation updates
- •Adding tests to existing code
- •Formatting/linting fixes
- •Configuration tweaks with clear requirements
Planning Output Checklist
When in PLANNING MODE, output must include:
- •Goal + success criteria
- •In scope / out of scope
- •Approach options + decision
- •Step-by-step implementation plan
- •Validation plan (tests, manual checks)
- •Risks + mitigations
Context Management Commands
bash
# Get repo overview after context clear pnpm claude:briefing # Get context restart template pnpm claude:clear # Check compact budget pnpm claude:compact-guard # Save context snapshot pnpm claude:context:save "label" # Load saved context pnpm claude:context:load <context-id> # List all saved contexts pnpm claude:context:list
Compact Budget Protocol
- •Maximum compacts per session: 3
- •Track:
compact_count - •On attempt #4: Start a new session with summary + objectives
After Running clear
Restate:
- •Objective
- •Constraints
- •Current plan
- •Open questions
- •Next steps
Quick Start Codes
Reference these from .claude/QUICK-REFERENCE.md:
| Code | Purpose |
|---|---|
[NEW-FEAT] | New feature implementation |
[BUG-FIX] | Bug fix workflow |
[QUICK-FIX] | Small, scoped fix |
[REVIEW] | Code review |
[DEPLOY] | Deployment tasks |
[REFACTOR] | Refactoring workflow |
[PERF] | Performance optimization |
[SECURITY] | Security-related changes |
Quality Gates
Before committing, ensure:
- •
pnpm lintpasses - •
pnpm typecheckpasses - •
pnpm testpasses - •
pnpm secretlintpasses - • No
.envfiles staged - • No placeholder values
Context Drift Detection
Signs of context drift:
- •Repeating earlier mistakes
- •Forgetting established decisions
- •Inconsistent naming/patterns
- •Missing previously discussed requirements
When detected:
- •Run
pnpm claude:briefing - •Review
.claude/session_state.json - •Consider fresh session with summary
Related Files
- •Operating model:
/CLAUDE.md - •Quick reference:
/.claude/QUICK-REFERENCE.md - •Session state:
/.claude/session_state.json(gitignored) - •Context manager:
/.claude/context-manager.js