Session checkpoint

From majesticlabs-dev/majestic-marketplace · View interactive version

Session checkpoint is an AI agent skill from the GitHub repository majesticlabs-dev/majestic-marketplace. Save session state to ledger file for continuity across crashes, context switches, or /clear + reload cycles.

How to use this skill

Skill file

Session Checkpoint

Audience: Agents and developers needing to preserve session state during long-running workflows.

Goal: Snapshot current session state to a ledger file for crash recovery, context refresh, and cross-session continuity.

Key insight: /clear + ledger reload provides fresh context with full signal preservation, avoiding the cumulative degradation of repeated /compact cycles.

Config Dependency

Requires session.ledger: true in .agents.yml:

session:
  ledger: true
  ledger_path: .agents/session_ledger.md  # optional, defaults to .agents/session_ledger.md

Note: The ledger is per-worktree (ephemeral session state). Handoffs go to main worktree (permanent, for Skill("learn")).

Process

Step 1: Check Config

SESSION = config_read("session", "{}")

If session.ledger is false or missing:

Step 2: Determine Ledger Path

Use session.ledger_path from config, or default to .agents/session_ledger.md.

Ensure the directory exists:

mkdir -p .agents

Step 3: Gather State

From the provided context, extract:

  1. Goal - What is being worked on (success criteria if known)
  2. Constraints/Assumptions - Known limitations or decisions
  3. Key Decisions - Important choices made during this work
  4. State:
  1. Open Questions - Unresolved items (mark as UNCONFIRMED if uncertain)
  2. Working Set - Key files, IDs, or commands relevant to current work

Step 4: Write Ledger

Write to the ledger file using this format:

# Session Ledger

_Last updated: <timestamp>_

## Goal
<goal and success criteria>

## Constraints/Assumptions
- <constraint 1>
- <constraint 2>

## Key Decisions
- <decision 1>
- <decision 2>

## State

### Done
- <completed item 1>
- <completed item 2>

### Now
<current focus>

### Next
<planned next step>

## Open Questions
- <question 1>
- <question 2> `UNCONFIRMED`

## Working Set
- Files: <key files>
- IDs: <relevant IDs>
- Commands: <useful commands>

Step 5: Return Confirmation

Return a brief confirmation:

Checkpoint saved to .agents/session_ledger.md
- Goal: <brief goal>
- State: <done count> done, now: <current>, next: <next>

When to Checkpoint

Context Threshold Triggers

Skip Checkpointing For

Integration Points

Other agents or skills can invoke checkpointing:

Before risky operations

Before starting major refactor, apply `session-checkpoint` skill to save current state.

After milestones

After completing each major step, apply `session-checkpoint` skill with current progress.

At context thresholds

If context usage exceeds 70%, apply `session-checkpoint` skill before continuing.

Post-Clear Recovery Protocol

When resuming after /clear with a ledger file:

  1. Auto-load ledger - Read the ledger file to restore context
  2. Validate UNCONFIRMED items - Any assumption marked UNCONFIRMED needs verification
  3. Ask 1-3 validation questions before continuing work:
  1. Resume from "Now" section after validation

UNCONFIRMED Marker Usage

Mark assumptions as UNCONFIRMED when:

Clear + Ledger vs Repeated Compaction

Prefer /clear + ledger reload over multiple /compact cycles:

| Approach | Context Quality | Signal Loss |

|----------|-----------------|-------------|

| Single /compact | Good | Minimal |

| Multiple /compact cycles | Degraded | Cumulative - each cycle loses detail |

| /clear + ledger reload | Fresh | None - ledger preserves full signal |

Guideline: After 2-3 compactions in a session, checkpoint to ledger and /clear for fresh context with preserved state.

Ledger vs Handoff vs Tasks

| Tool | Purpose | Persistence | Trigger |

|------|---------|-------------|---------|

| session-checkpoint | Crash recovery, quick state save | File (.agents/session_ledger.md) | Skill-triggered |

| /handoff | Cross-session continuity | File (main worktree .agents/handoffs/) | User/ship-triggered |

| Tasks | Session task tracking | File (~/.claude/tasks/) | Agent-triggered |

Use session-checkpoint for:

Use /handoff for:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.