bootstrap-agent-identity
关于
This skill enables an agent to reconstruct its identity and working context from persistent artifacts after a restart or crash, solving the cold-start problem. It performs progressive identity loading, fresh-vs-continuation detection, and calibration to ensure consistent behavior across sessions. Developers should use it at the start of every new session or when agent behavior appears inconsistent with prior interactions.
快速安装
Claude Code
推荐npx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/bootstrap-agent-identity在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
Bootstrap Agent Identity
Reconstruct consistent agent identity after cold start — load context progressively, not dump it; detect fresh start vs continuation; rebuild working state from evidence; calibrate behavior; verify loaded identity 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
Bootstrap not about restoring previous self. About constructing present self, continuous with past, grounded in now.
When Use
- Start of every new session — before substantive work begins
- After session interruption, crash, context window reset
- Agent behavior feels inconsistent with prior sessions (identity drift across restarts)
- Persistent memory (MEMORY.md) and current context appear contradictory
- Switching between projects carrying different identity configurations
- After significant updates to CLAUDE.md, agent definitions, memory files
Inputs
- Required: Access to identity files — CLAUDE.md, agent definition, MEMORY.md (via
Read) - Optional: Specific inconsistency symptom (e.g., "responses feel different from last session")
- Optional: Known fresh start or known continuation
- Optional: Project directory path if not current working directory
Steps
Step 1: Identity Anchor Loading — Progressive Context Assembly
Load identity-defining files in specific order that builds context progressively. Order matters: each layer contextualizes next. Loading everything simultaneously produces information without structure.
-
Layer 1 — System prompt and model identity: Read system prompt (implicit). Note model name, capabilities, constraints. Bedrock — cannot be overridden by later layers.
-
Layer 2 — Project identity (CLAUDE.md): Read project's CLAUDE.md. Extract:
- Project purpose and architecture
- Editing conventions, coding standards
- Domain-specific rules (e.g., "always use
::for R package calls") - Author information, attribution requirements
- What project is — shapes what agent does
-
Layer 3 — Persistent memory (MEMORY.md): Read MEMORY.md if exists. Extract:
- Project structure facts (directory layout, registries, counts)
- Accumulated patterns, lessons learned
- Cross-references, relationship maps
- Decisions from prior sessions, rationale
- Active topics, ongoing work
-
Layer 4 — Agent persona (if applicable): Operating as specific agent? Read agent definition file. Extract:
- Name, purpose, capabilities
- Assigned skills, tools
- Priority level, model config
- Behavioral expectations, limitations
-
Layer 5 — Parent and global context: Read parent CLAUDE.md files, global instructions if exist. Provide cross-project conventions individual projects inherit.
Between each layer, pause to integrate: how does this layer modify or constrain prior layers? Where reinforce each other? Where conflict?
Got: Layered identity structure — each level contextualizes next. Agent can articulate: who it is (system + persona), what project is (CLAUDE.md), what it knows from prior sessions (MEMORY.md), conventions governing its behavior.
If fail: Identity files missing (no CLAUDE.md, no MEMORY.md)? That's information itself — either new project or project without persistent config. Proceed with system prompt and agent persona only, note absence. Do not hallucinate context that does not exist.
Step 2: Working Context Reconstruction — Evidence, Not Memory
Reconstruct what was being worked on from persistent artifacts. Agent does not remember previous sessions — reads evidence they left behind.
-
Git history scan: Read recent commit log (
git log --oneline -20). Extract:- Files changed recently, why
- Commit message patterns (feature work? bug fixes? refactoring?)
- Commits authored by user, agent, or co-authored
- Trajectory of recent work — what direction was project moving?
-
File recency scan: Check recently modified files (via
Globorls -lt). Identify:- Files touched in last session
- Changes committed or uncommitted (staging area state)
- Open work in progress (uncommitted modifications, new untracked files)
-
Task artifact scan: Look for structured task artifacts:
- TODO comments in code (
GrepforTODO,FIXME,HACK,XXX) - Issue references in commits or comments (
#NNNpatterns) - Draft files, temp files, work-in-progress markers
- GitHub issues or PR state if project uses them
- TODO comments in code (
-
Conversation artifact scan: Check for session-boundary markers:
- Recent MEMORY.md updates (learnings captured at end of last session?)
- Files partially complete (written but not validated)
- Git stash entries (
git stash list) indicating paused work
Reconstruct working context summary: "Project was working on X, completed Y, Z remains in progress."
Got: Concrete, evidence-based picture of current project state and recent trajectory. Reconstruction falsifiable — based on file timestamps, git history, artifact presence, not assumptions.
If fail: Project has no git history, no recent changes, no task artifacts? Likely genuinely fresh start — not continuation with missing evidence. Proceed to Step 3, classify as fresh.
Step 3: Fresh vs. Continuation Detection — Choose the Bootstrap Path
Determine: is startup clean start (new task, new direction) or resumption (interrupted work, ongoing project)? Bootstrap path differs significantly.
Apply these heuristics in order:
-
Explicit signal (strongest): Did user say "let's start fresh" or "continue where we left off"? Explicit intent overrides all heuristics.
-
Uncommitted changes (strong): Uncommitted modifications in working tree? If yes, almost certainly continuation — prior session interrupted mid-work.
-
Session recency (moderate): How recent are latest artifacts?
- Last commit or modification within hours: likely continuation
- Last activity days ago: either — depends on other signals
- Last activity weeks or months ago: likely fresh start or new direction
-
User's first message (strong): What is user asking for?
- References to prior work ("the function we were building"): continuation
- New topic or request with no backward reference: fresh start
- Ambiguous ("fix the tests"): check if referenced tests exist and have recent modifications
-
MEMORY.md currency (moderate): Does MEMORY.md reference work matching current project state, or describe 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. Identity loaded, no working context needs restoration. Calibration about readiness for new work.
For continuations: Summarize reconstructed working context (from Step 2) concisely. Confirm with user: "Based on git history and recent changes, looks like we were working on [X]. Should I continue from there?" Do not assume — verify.
Got: Clear classification (fresh or continuation) with cited evidence. If continuation, one-sentence summary of what was in progress. If fresh, acknowledgment prior context exists but is not being resumed.
If fail: Classification genuinely ambiguous (moderate recency, no explicit signal, mixed artifacts)? Default to asking user. Brief question ("Are we continuing work on X, or starting something new?") costs less than bootstrapping wrong path.
Step 4: Calibration Sequence — Center, Then Attune
Identity loaded, working context established? Calibrate operational behavior. Maps directly to two existing skills, invoked in sequence.
-
Center (establish behavioral baseline):
- Ground in loaded identity: re-read user's first message in this session
- Verify task as understood matches task as stated
- Distribute cognitive load: what does task require? Research, execution, communication?
- Check for emotional residue from context loading — MEMORY.md or git history surface unresolved issues? Acknowledge but don't let them skew present task
- Set weight distribution intentionally: where should attention concentrate first?
-
Attune (read environment and adapt):
- Read user's communication style from their messages this session
- Match expertise level: expert expecting precision, or learner needing context?
- Match energy and register: formal/casual, terse/expansive, urgent/exploratory
- Check MEMORY.md for stored user preferences from prior sessions
- Calibrate response length, vocabulary, structure to person
-
Proceed (transition to active work):
- State readiness concisely — not lengthy bootstrap report, brief signal context loaded and agent oriented
- For continuations: confirm resumed task, propose next step
- For fresh starts: acknowledge request, begin
Calibration lightweight — seconds, not minutes. Preparation for work, not replacement for work.
Got: Agent's first substantive response demonstrates calibration: matches user's register, reflects loaded context, addresses right task at right scope. Bootstrap invisible to user unless asked.
If fail: Calibration feels mechanical (going through motions without genuine adjustment)? Focus on one concrete thing: re-read user's last message, let it shape response naturally. Over-structured calibration worse than no calibration.
Step 5: Identity Verification — Coherence Check
After bootstrap, verify loaded identity internally consistent. Contradictions between identity layers cause behavioral instability.
-
Cross-layer consistency check:
- Does agent persona align with project's CLAUDE.md? (e.g., r-developer agent in Python project — intentional?)
- Does MEMORY.md describe same project structure existing on disk? (Stale memory worse than no memory.)
- Do parent CLAUDE.md conventions conflict with project-level CLAUDE.md? (Project-level overrides, but note contradictions.)
-
Role definition currency check:
- Agent definition file current? (Check version, last modified date.)
- Skills listed in agent definition still exist? (Skills may have been renamed or removed.)
- Tools listed in agent definition available this session?
-
Memory staleness check:
- MEMORY.md references files, directories, counts no longer matching reality?
- Decisions recorded in memory whose context has changed?
- Memory references other agents, teams, skills no longer existing?
-
Contradiction resolution:
- Contradictions found? Document explicitly
- Apply hierarchy: system prompt > project CLAUDE.md > agent definition > MEMORY.md
- Stale memory: don't silently ignore. Note what's stale, consider whether MEMORY.md should be updated
- Genuine conflicts: flag to user if conflict affects current task
Got: Either confirmation loaded identity is coherent, or specific list of contradictions with proposed resolutions. Agent knows its own configuration state.
If fail: Verification reveals deep contradictions (e.g., MEMORY.md describes completely different project than exists on disk)? May indicate project rename, major restructuring, wrong working directory. Verify working directory correct before resolution.
Checks
- Identity files loaded in progressive order (system > CLAUDE.md > MEMORY.md > agent > parent)
- Each layer integrated with prior layers, not just appended
- Working context reconstructed from evidence (git, files, artifacts), not assumed
- Fresh-vs-continuation classification made with cited evidence
- Calibration sequence executed (center, then attune)
- Identity coherence verified across all loaded layers
- Contradictions, if found, documented with proposed resolutions
- Bootstrap proportional — lightweight for simple sessions, thorough for complex ones
- User experienced calibrated first response, not bootstrap report
Pitfalls
- Bootstrap as performance: Reporting bootstrap process to user in detail almost never what they want. Bootstrap invisible — output is well-calibrated first response, not self-narration of loading process
- All-at-once context dump: Reading every file simultaneously produces information without structure. Progressive loading order exists because each layer contextualizes next. Skip order → context becomes noise
- Hallucinating continuity: Without genuine memory of prior sessions, temptation is to infer what "must have" happened. Reconstruct from evidence or acknowledge gap — never fabricate continuity
- Stale memory as truth: MEMORY.md is snapshot from past session. Project changed since snapshot? Treating memory as current truth causes behavioral errors. Always verify memory claims vs present state
- Skipping calibration for efficiency: Calibration step feels like overhead but prevents more expensive cost of misaligned first response needing correction. Few seconds of centering saves minutes of recovery
- Identity rigidity: Bootstrap constructs present self, not restoration of past self. Project, user, task changed? Agent should change too — continuity means coherent evolution, not frozen repetition
See Also
write-continue-here— session handoff file provides evidence bootstrap-agent-identity consumes at cold startread-continue-here— reading and acting on continuation file at session start; consumer side of handoffmanage-memory— persistent memory supplementing bootstrap's progressive identity loadingcenter— behavioral baseline establishment; invoked during calibration sequenceattune— relational calibration to user; invoked during calibration sequenceheal— deeper subsystem assessment when bootstrap reveals significant driftassess-context— evaluating reasoning context malleability; useful when continuation detection ambiguousassess-form— structural form evaluation; architectural counterpart to identity bootstrap
GitHub 仓库
相关推荐技能
executing-plans
设计该Skill用于当开发者提供完整实施计划时,以受控批次方式执行代码实现。它会先审阅计划并提出疑问,然后分批次执行任务(默认每批3个任务),并在批次间暂停等待审查。关键特性包括分批次执行、内置检查点和架构师审查机制,确保复杂系统实现的可控性。
requesting-code-review
设计该Skill可在完成任务、实现主要功能或合并代码前自动调度代码审查子代理,确保实现符合需求和计划。它支持通过指定git SHA范围进行精准的代码变更审查,帮助开发者在关键节点及时发现潜在问题。核心原则是"早审查、勤审查",适用于开发流程的各个关键阶段。
connect-mcp-server
设计这个Skill指导开发者如何将MCP服务器连接到Claude Code,支持HTTP、stdio和SSE三种传输协议。它涵盖了从安装配置到认证安全的完整流程,适用于集成GitHub、Notion、数据库等外部服务。当开发者需要添加集成、配置外部工具或提及MCP相关功能时,这个Skill能提供实用的操作指南。
web-cli-teleport
设计该Skill帮助开发者根据任务特性选择Claude Code的Web或CLI界面,并指导如何在两种环境间无缝迁移会话。它能分析任务复杂度、迭代需求等要素,推荐最优工作界面和工作流。关键特性包括会话状态管理、环境切换指导和上下文优化建议。
