| name | check-last-plan |
| description | Persist plan context across sessions via background caching |
| command | /check-last-plan |
| linked_agent | plan-persistence-agent |
| status | active |
| auto_generated | false |
| generation_date | Fri Dec 12 2025 00:00:00 GMT+0000 (Coordinated Universal Time) |
Check Last Plan Skill
Purpose: Automatically cache and retrieve plan context across Claude Code sessions.
Activation:
- Automatic: Session start (retrieves cached plan)
- Automatic: ExitPlanMode tool call (caches current plan)
- Manual:
/check-last-plancommand
Token Budget: ~200 tokens (minimal overhead)
Unified Architecture Pattern
This skill demonstrates the canonical pattern for skill/command/agent integration in Claude-Optim:
| Component | Role | Activation |
|---|---|---|
| Skill (this file) | Passive reference, protocol definition | Context loading |
Command (/check-last-plan) |
Explicit user invocation | Manual |
Agent (plan-persistence-agent) |
Active background execution | Auto on hooks |
Library (lib/plan-persistence.sh) |
Core bash functions | Sourced by hooks |
Relationship
Skill (defines WHAT and WHY)
├── Command (HOW to invoke manually)
├── Agent (WHEN to run automatically)
└── Library (IMPLEMENTATION details)
Use this pattern as reference when creating new skill/command/agent trios.
Problem
Plans created in plan mode are lost when sessions end. Users must manually track what was planned and re-establish context in new sessions.
Impact:
- Cold start problem for ongoing work
- Context loss across sessions
- Manual effort to recall plan state
- Duplicate planning if forgotten
Solution
Automatically cache plans when exiting plan mode, and surface them at session start.
Cache Architecture
Location: ~/.claude/cache/last-plan.json
Structure:
{
"plan_id": "lucky-orbiting-allen",
"plan_path": "~/.claude/plans/lucky-orbiting-allen.md",
"plan_content": "...",
"cached_at": "2025-12-12T20:00:00Z",
"project_path": "/Users/laurie/.claude",
"project_encoded": "-Users-laurie--claude"
}
Design Decision: Global cache with project identifier (see architectural critique in plan file).
Protocol
On Session Start
session-start.shcallscheck_cached_plan()- Source
lib/plan-persistence.sh - Call
has_recent_plan_cache - If true and project matches: export
CACHED_PLAN_ID - Output:
[PLAN-FOUND] Previous plan: {plan_id}
On ExitPlanMode
tool-monitor.shdetects ExitPlanMode tool call- Source
lib/plan-persistence.sh - Find current plan file via
get_latest_plan_file - Call
cache_current_plan "$plan_path" - Log to
.hooks.log:[PLAN-PERSISTENCE] Cached plan: {plan_id}
On /check-last-plan
- Read
~/.claude/cache/last-plan.json - Display plan summary (id, cached time, project)
- Show plan content (or summary)
- Offer to continue with plan or start fresh
Usage
Manual Invocation
/check-last-plan
Automatic Activation
This skill activates automatically when:
- Session starts (retrieves cached plan if exists for current project)
- ExitPlanMode tool is called (caches current plan)
Library Functions
source ~/.claude/lib/plan-persistence.sh
# Cache a plan
cache_current_plan "/path/to/plan.md"
# Retrieve for current project
plan_json=$(retrieve_cached_plan)
# Retrieve any plan (global)
plan_json=$(retrieve_any_cached_plan)
# Check if cache exists
if has_recent_plan_cache; then
echo "Plan available for current project"
fi
# Diagnose
./lib/plan-persistence.sh diagnose
Examples
Session Start Output
[RL++] System ready | 12 agents, 27 skills, efficiency enforced
[CIPS] Instance d05e8075 (Gen 12, 0 msgs) | .claude (main, 2 changes)
[PLAN-FOUND] Previous plan: lucky-orbiting-allen
Run /check-last-plan to review or continue.
/check-last-plan Output
=== Cached Plan ===
ID: lucky-orbiting-allen
Project: /Users/laurie/.claude
Cached: 2025-12-12T20:00:00Z (2 hours ago)
## Plan Summary
Create a unified skill/command/agent trio that persists plan context...
Continue with this plan? (The plan file is at ~/.claude/plans/lucky-orbiting-allen.md)
Integration
With session-start.sh
# Check for cached plan from previous session
check_cached_plan() {
if [[ -f "$LIB_DIR/plan-persistence.sh" ]]; then
source "$LIB_DIR/plan-persistence.sh"
if has_recent_plan_cache; then
local plan_id
plan_id=$(jq -r '.plan_id' "$PLAN_CACHE" 2>/dev/null)
log_info "Previous plan cache found: $plan_id"
export CACHED_PLAN_ID="$plan_id"
fi
fi
}
With tool-monitor.sh
"ExitPlanMode")
monitor_exitplanmode "$tool_args"
;;
With CLAUDE.md
Registered in Skills System section and Slash Commands table.
Metrics
Token Budget: ~200 tokens (session start check + display)
Success Criteria
- Plans automatically persist across sessions
- No manual caching required
- Session start shows plan availability
/check-last-planworks as documented- Pattern documented as reference for future trios
Tracking
Logged to ~/.claude/.hooks.log with:
[PLAN-PERSISTENCE] Cached plan: {id}- On ExitPlanMode[SESSION-START] Previous plan cache found: {id}- On session start
Notes
- Cache expires after 24 hours (configurable in library)
- Project-aware: default retrieval only matches current project
- Global access via
retrieve_any_cached_plan()for cross-project queries - Cross-platform: macOS (BSD) and Linux (GNU) stat formats handled
Related
lib/plan-persistence.sh- Core implementationcommands/check-last-plan.md- Slash command definitionagents/plan-persistence-agent.md- Agent definitionhooks/session-start.sh- Integration point (retrieval)hooks/tool-monitor.sh- Integration point (caching)
Skill Status: Active Maintainer: CIPS Core Team Last Updated: 2025-12-12 Architecture Pattern: Unified skill/command/agent reference implementation