Skip to main content

/context-snapshot - Efficient Session State Capture

Generate a minimal context snapshot capturing essential session state for handoff, designed to fit under 500 tokens while preserving critical continuity information.

Usage

# Generate snapshot for current session
/context-snapshot

# Save to file
/context-snapshot --save

# Include specific tracks
/context-snapshot --tracks E,C

# Full snapshot (more detail, ~1000 tokens)
/context-snapshot --full

# JSON format
/context-snapshot --json

Output Format (~400 tokens)

# Context Snapshot
**Generated:** 2026-01-02T00:30:00Z | **Session:** session-8-integration-deployment

## Current State
- **Focus:** Track E.1 Integration Testing
- **Last Completed:** E.1.5 (Activation limit test)
- **In Progress:** None
- **Blocked:** C.2.1 (SSL certificate pending)

## Track Summary
| Track | Status | Next Task |
|-------|--------|-----------|
| E | 80% | E.2.1 Rate limiting |
| C | 60% | C.1.3 SSL cert |
| D | 100% | Complete |

## Key Files Modified
- `tests/e2e/test_signup_activation_flow.py` (new)
- `tests/e2e/test_cross_platform_validation.py` (new)
- `tests/e2e/test_webhook_reliability.py` (new)
- `tests/e2e/test_offline_mode.py` (new)
- `tests/e2e/test_activation_limits.py` (new)

## Critical Decisions
1. Track E.1 complete - 5 E2E test files, 70 tests total
2. Integration Testing at 80% - E.2 Security Testing next
3. Production Deployment still blocking (60%)

## Resume Command
```bash
/pilot --track E --task E.2.1

Full Context

  • Session Log: docs/session-logs/SESSION-LOG-2026-01-01.md
  • PILOT Plan: internal/project/plans/PILOT-PARALLEL-EXECUTION-PLAN.md

## Options

| Option | Description |
|--------|-------------|
| `--save` | Save to `context-storage/snapshots/SNAPSHOT-YYYY-MM-DD-HHMMSS.md` |
| `--tracks X,Y` | Include only specific tracks |
| `--full` | Full snapshot (~1000 tokens) |
| `--json` | JSON output format |
| `--token-limit N` | Target token count (default: 500) |

## Token Optimization

The snapshot is optimized for minimal token usage while preserving:

| Information | Tokens | Priority |
|-------------|--------|----------|
| Current focus | ~50 | P0 - Critical |
| Track status table | ~100 | P0 - Critical |
| Key files (5 max) | ~75 | P1 - Important |
| Critical decisions (3 max) | ~100 | P1 - Important |
| Resume command | ~25 | P0 - Critical |
| Context links | ~50 | P2 - Reference |
| **Total** | **~400** | |

## Implementation

```python
# scripts/context_snapshot.py
def generate_snapshot(
session_log: str,
pilot_plan: str,
token_limit: int = 500
) -> str:
"""Generate minimal context snapshot."""
snapshot = {
'current_state': extract_current_state(session_log),
'track_summary': extract_track_status(pilot_plan),
'key_files': get_recent_files(limit=5),
'decisions': get_critical_decisions(limit=3),
'resume_command': generate_resume_command(),
}
return render_snapshot(snapshot, token_limit)

Snapshot Storage

context-storage/
├── snapshots/
│ ├── SNAPSHOT-2026-01-01-220000.md
│ ├── SNAPSHOT-2026-01-01-230000.md
│ └── SNAPSHOT-2026-01-02-003000.md
└── latest-snapshot.md # Symlink to most recent

Use Cases

  1. Session Handoff: Pass context to new session or agent
  2. Context Recovery: Resume after context window limit
  3. Status Reporting: Quick project status summary
  4. Checkpoint Creation: Pre-commit state capture
  • /cx - Full context capture (larger)
  • /cxq - Context query
  • /pilot --dashboard - Progress dashboard
  • /export - Full session export

Success Output

When snapshot generation completes:

✅ COMMAND COMPLETE: /context-snapshot
Tokens: ~<count>
Tracks: <list>
Saved: <path or "displayed only">

Completion Checklist

Before marking complete:

  • Current state extracted
  • Track summary generated
  • Key files listed
  • Resume command included

Failure Indicators

This command has FAILED if:

  • ❌ Session log not found
  • ❌ PILOT plan not accessible
  • ❌ Token limit exceeded significantly
  • ❌ Save failed (if --save)

When NOT to Use

Do NOT use when:

  • Need full context export (use /export)
  • No active session to snapshot
  • Need detailed history (use /audit-trail)

Anti-Patterns (Avoid)

Anti-PatternProblemSolution
Skip key filesMissing contextInclude modified files
Ignore token limitToo verboseStick to ~500 tokens
Forget resume commandHard to continueAlways include resume

Principles

This command embodies:

  • #2 First Principles - Essential state only
  • #6 Clear, Understandable - Minimal, focused output
  • #3 Complete Execution - All sections generated

Full Standard: CODITECT-STANDARD-AUTOMATION.md


Command Version: 1.0.0 Created: 2026-01-02 Author: CODITECT Process Refinement