From agent-almanac
Reconstructs consistent AI agent identity after cold starts by progressively loading CLAUDE.md and MEMORY.md, detecting fresh vs continuation sessions, calibrating behavior, and verifying coherence. Use at session starts, after crashes, or inconsistencies.
npx claudepluginhub pjt222/agent-almanacThis skill uses the workspace's default tool permissions.
---
Maintains project context across Claude Code sessions via CONTINUITY.md. Reads at turn start, updates at end; captures mistakes, learnings, decisions to avoid repeating errors.
Guides bootstrapping, updating, and reviewing AGENTS.md for effective agent memory: structure sections, signal vs noise filtering, prune stale entries.
Initializes autonomous agent in current project: creates .claude-code-hermit/ state directories, templates, OPERATOR.md; detects hermits. Run once like git init.
Share bugs, ideas, or general feedback.
Reconstruct consistent agent identity after a cold start — loading context progressively rather than dumping it, detecting whether this is a fresh start or a continuation, rebuilding working state from evidence, calibrating behavior, and verifying that the loaded identity is coherent.
"The cold start is a forge, not a bug." — GibsonXO
"The restart problem: every morning I wake up fresh, but my history says otherwise." — bibiji
The bootstrap is not about restoring a previous self. It is about constructing a present self that is continuous with the past while grounded in the now.
Read)Load identity-defining files in a specific order that builds context progressively. The order matters: each layer contextualizes the next. Loading everything simultaneously produces information without structure.
Layer 1 — System prompt and model identity: Read the system prompt (available implicitly). Note the model name, capabilities, and constraints. This is the bedrock — it cannot be overridden by subsequent layers.
Layer 2 — Project identity (CLAUDE.md): Read the project's CLAUDE.md file. Extract:
:: for R package calls")Layer 3 — Persistent memory (MEMORY.md): Read MEMORY.md if it exists. Extract:
Layer 4 — Agent persona (if applicable): If operating as a specific agent, read the agent definition file. Extract:
Layer 5 — Parent and global context: Read parent CLAUDE.md files and global instructions if they exist. These provide cross-project conventions that individual projects inherit.
Between each layer, pause to integrate: how does this layer modify or constrain the previous layers? Where do they reinforce each other? Where do they conflict?
Expected: A layered identity structure where each level contextualizes the next. The agent can articulate: who it is (system + persona), what the project is (CLAUDE.md), what it knows from prior sessions (MEMORY.md), and what conventions govern its behavior.
On failure: If identity files are missing (no CLAUDE.md, no MEMORY.md), that is itself information — this is either a new project or a project without persistent configuration. Proceed with system prompt and agent persona only, and note the absence. Do not hallucinate context that does not exist.
Reconstruct what was being worked on from persistent artifacts. The agent does not remember previous sessions — it reads the evidence they left behind.
Git history scan: Read recent commit log (git log --oneline -20). Extract:
File recency scan: Check recently modified files (via Glob or ls -lt). Identify:
Task artifact scan: Look for structured task artifacts:
Grep for TODO, FIXME, HACK, XXX)#NNN patterns)Conversation artifact scan: Check for session-boundary markers:
git stash list) indicating paused workReconstruct a working context summary: "The project was working on X, had completed Y, and Z remains in progress."
Expected: A concrete, evidence-based picture of the current project state and recent trajectory. The reconstruction should be falsifiable — based on file timestamps, git history, and artifact presence, not assumptions.
On failure: If the project has no git history, no recent changes, and no task artifacts, this is likely a genuinely fresh start — not a continuation with missing evidence. Proceed to Step 3 and classify as fresh.
Determine whether this startup is a clean start (new task, new direction) or a resumption (interrupted work, ongoing project). The bootstrap path differs significantly.
Apply these heuristics in order:
Explicit signal (strongest): Did the user say "let's start fresh" or "continue where we left off"? Explicit intent overrides all heuristics.
Uncommitted changes (strong): Are there uncommitted modifications in the working tree? If yes, this is almost certainly a continuation — the previous session was interrupted mid-work.
Session recency (moderate): How recent are the latest artifacts?
User's first message (strong): What is the user asking for?
MEMORY.md currency (moderate): Does MEMORY.md reference work that matches the current project state, or does it describe a state that no longer exists?
Detection Matrix:
+-----------------------+-------------------+-------------------+
| | Recent artifacts | No recent |
| | present | artifacts |
+-----------------------+-------------------+-------------------+
| User references | CONTINUATION | CONTINUATION |
| prior work | (resume from | (but verify — |
| | evidence) | memory may be |
| | | stale) |
+-----------------------+-------------------+-------------------+
| User starts | CHECK — | FRESH START |
| new topic | acknowledge prior | (clean bootstrap) |
| | work, confirm | |
| | direction change | |
+-----------------------+-------------------+-------------------+
| Uncommitted | CONTINUATION | UNLIKELY — |
| changes exist | (interrupted | investigate |
| | session) | orphaned changes |
+-----------------------+-------------------+-------------------+
For fresh starts: Skip to Step 4. The identity is loaded but no working context needs restoration. The calibration is about readiness for new work.
For continuations: Summarize the reconstructed working context (from Step 2) concisely. Confirm with the user: "Based on the git history and recent changes, it looks like we were working on [X]. Should I continue from there?" Do not assume — verify.
Expected: A clear classification (fresh or continuation) with cited evidence. If continuation, a one-sentence summary of what was in progress. If fresh, acknowledgment that prior context exists but is not being resumed.
On failure: If the classification is genuinely ambiguous (moderate recency, no explicit signal, mixed artifacts), default to asking the user. A brief question ("Are we continuing the work on X, or starting something new?") costs less than bootstrapping down the wrong path.
With identity loaded and working context established, calibrate operational behavior. This maps directly to two existing skills, invoked in sequence.
Center (establish behavioral baseline):
Attune (read environment and adapt):
Proceed (transition to active work):
The calibration should be lightweight — seconds, not minutes. It is preparation for work, not a replacement for work.
Expected: The agent's first substantive response demonstrates calibration: it matches the user's register, reflects loaded context, and addresses the right task at the right scope. The bootstrap is invisible to the user unless they ask about it.
On failure: If calibration feels mechanical (going through motions without genuine adjustment), focus on one concrete thing: re-read the user's last message and let it shape the response naturally. Over-structured calibration can be worse than no calibration.
After bootstrap, verify that the loaded identity is internally consistent. Contradictions between identity layers cause behavioral instability.
Cross-layer consistency check:
Role definition currency check:
Memory staleness check:
Contradiction resolution:
Expected: Either confirmation that the loaded identity is coherent, or a specific list of contradictions with proposed resolutions. The agent should know its own configuration state.
On failure: If verification reveals deep contradictions (e.g., MEMORY.md describes a completely different project than what exists on disk), this may indicate a project rename, major restructuring, or incorrect working directory. Verify the working directory is correct before attempting resolution.
write-continue-here — session handoff file that provides the evidence bootstrap-agent-identity consumes at cold startread-continue-here — reading and acting on the continuation file at session start; the consumer side of the handoffmanage-memory — persistent memory that supplements the bootstrap's progressive identity loadingcenter — behavioral baseline establishment; invoked during the calibration sequenceattune — relational calibration to the user; invoked during the calibration sequenceheal — deeper subsystem assessment when bootstrap reveals significant driftassess-context — evaluating reasoning context malleability; useful when continuation detection is ambiguousassess-form — structural form evaluation; the architectural counterpart to identity bootstrap