v1/SKILL.md
Session initialization and lifecycle management: bootstraps session context, organizes files, generates CLAUDE.md, manages soul purpose lifecycle with completion protocol and active context harvesting. Use when user says /start, /init, bootstrap session, initialize session, or organize project.
npx skillsauth add anombyte93/atlas-session-lifecycle startInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Single entry point for project initialization and soul purpose lifecycle management. Two modes, auto-detected. User runs
/start— that is all.
This skill has two operational modes:
session-context/ does NOT exist. First-run bootstrap: captures soul purpose, organizes files, generates CLAUDE.md, integrates Claude /init, onboards Ralph Loop.session-context/ DOES exist. Lifecycle management: refreshes CLAUDE.md via Claude /init, assesses soul purpose status, optionally verifies with doubt agent, harvests active context on closure.Mode is auto-detected from directory state. No flags, no arguments. User just runs /start.
These hold at all times, in both modes:
/start. No hooks, no proactive triggers.~/claude-session-init-templates/. Copy only.session-context/ files exist, do NOT overwrite unless explicitly instructed~/claude-session-init-templates/ — they are immutableif session-context/ does NOT exist:
→ Init Mode
else:
→ Reconcile Mode
Run this check silently at the start:
[ -d session-context ] && echo "MODE=reconcile" || echo "MODE=init"
No flags, no arguments. The directory state is the only signal.
If Reconcile Mode was detected, validate session-context/ integrity before proceeding:
# Count expected files in session-context/
for f in CLAUDE-activeContext.md CLAUDE-decisions.md CLAUDE-patterns.md CLAUDE-soul-purpose.md CLAUDE-troubleshooting.md; do
[ -f "session-context/$f" ] && [ -s "session-context/$f" ] && echo "OK: $f" || echo "MISSING: $f"
done
If any files are MISSING or zero-length:
~/claude-session-init-templates/ existsThis ensures Reconcile Mode always has valid files to work with, even if a previous Init was interrupted.
All skill operations MUST be delegated to Task agents. The main conversation thread acts as a thin orchestrator only.
Reading and writing large files (session-context files, CLAUDE.md, source code) directly in the main conversation causes context death spirals — compact, re-read files to restore context, fills context, compact, repeat forever. Task agents have their own context windows and do not pollute the main thread.
/init (must wait for CLAUDE.md to exist)/initSteps marked [DELEGATE TO AGENT] below MUST be executed via Task agents. Steps marked [MAIN THREAD] run directly in the orchestrator conversation.
Source: ~/claude-session-init-templates/
These are IMMUTABLE template files. Copy them, never edit them:
CLAUDE-activeContext.md — Session state trackerCLAUDE-decisions.md — Architecture decision logCLAUDE-patterns.md — Code patterns and conventionsCLAUDE-soul-purpose.md — Soul purpose placeholderCLAUDE-troubleshooting.md — Issue resolution guideCLAUDE-mdReference.md — CLAUDE.md template (rename to CLAUDE.md on copy)Triggered when
session-context/does NOT exist.
Use the AskUserQuestion tool to ask:
question: "What is the soul purpose of this project?"
header: "Purpose"
options: []
multiSelect: false
Store the response verbatim as SOUL_PURPOSE.
Run these checks silently (do NOT report to user):
# Is this a git repo?
git rev-parse --git-dir 2>/dev/null && echo "GIT=true" || echo "GIT=false"
# Does session-context/ already exist?
[ -d session-context ] && echo "SESSION_CTX=exists" || echo "SESSION_CTX=missing"
# Does CLAUDE.md already exist?
[ -f CLAUDE.md ] && echo "CLAUDE_MD=exists" || echo "CLAUDE_MD=missing"
# Count root-level files (excluding directories, hidden files, CLAUDE.md)
ls -1p | grep -v / | grep -v "^CLAUDE" | wc -l
Set internal flags:
IS_GIT: true/false (determines git mv vs mv)HAS_SESSION_CTX: true/false (skip bootstrap if exists)HAS_CLAUDE_MD: true/false (generate vs update)ROOT_FILE_COUNT: number (skip organization if <= 10)Pre-flight: Validate template directory
# Verify templates exist before copying
ls ~/claude-session-init-templates/CLAUDE-activeContext.md \
~/claude-session-init-templates/CLAUDE-decisions.md \
~/claude-session-init-templates/CLAUDE-patterns.md \
~/claude-session-init-templates/CLAUDE-soul-purpose.md \
~/claude-session-init-templates/CLAUDE-troubleshooting.md \
~/claude-session-init-templates/CLAUDE-mdReference.md 2>/dev/null | wc -l
If count is not 6, STOP and tell the user:
"Template directory ~/claude-session-init-templates/ is missing or incomplete. Expected 6 template files. Please ensure templates are installed before running /start."
Do NOT proceed with bootstrap if templates are missing.
Dispatch a Task agent with these instructions:
Agent task: Create session-context/ directory and populate with templates.
If session-context/ does NOT exist:
mkdir -p session-context
Copy templates into session-context/:
cp ~/claude-session-init-templates/CLAUDE-activeContext.md session-context/
cp ~/claude-session-init-templates/CLAUDE-decisions.md session-context/
cp ~/claude-session-init-templates/CLAUDE-patterns.md session-context/
cp ~/claude-session-init-templates/CLAUDE-troubleshooting.md session-context/
cp ~/claude-session-init-templates/CLAUDE-soul-purpose.md session-context/
If old CLAUDE- files exist at root* (from previous /start runs):
Migrate them into session-context/ instead of overwriting:
# Only move if they exist at root AND session-context/ versions don't exist
for f in CLAUDE-activeContext.md CLAUDE-decisions.md CLAUDE-patterns.md CLAUDE-troubleshooting.md CLAUDE-soul-purpose.md; do
[ -f "$f" ] && [ ! -f "session-context/$f" ] && mv "$f" session-context/
[ -f "$f" ] && [ -f "session-context/$f" ] && rm "$f" # remove root copy if session-context version exists
done
Write soul purpose to session-context/CLAUDE-soul-purpose.md:
Open session-context/CLAUDE-soul-purpose.md and replace its contents with:
# Soul Purpose
{{SOUL_PURPOSE}}
Ensure SOUL_PURPOSE is fully resolved to the user's actual text.
VERIFY: Run ls session-context/ — should see 5 files.
Agent returns: Confirmation that 5 files exist in session-context/ and soul purpose was written.
Skip this step entirely if ROOT_FILE_COUNT <= 10 (project is already clean).
Dispatch a Task agent with these instructions:
Agent task: Scan all files at root level. Auto-detect categories by extension and naming. Build a proposed move map.
Category Map:
| Pattern | Target Directory | Subcategory Logic |
|---------|-----------------|-------------------|
| .sh, .bash | scripts/ | By purpose: ssh/, setup/, diagnostics/, fixes/ |
| .ps1 | scripts/ | By purpose: ssh/, setup/, diagnostics/, network/, fixes/ |
| .py, .js, .ts | scripts/ | By purpose or src/ if app code |
| .md (README-, GUIDE-, HOW-) | docs/guides/ | |
| .md (REPORT-, AUDIT-, SUMMARY-) | docs/reports/ | |
| .md (QUICK-START*, SETUP-) | docs/quickstart/ | |
| .md (CONTRACT-, FULFILLMENT-) | docs/contract/ | |
| .md (HANDOVER-, HANDOFF-, CLIENT-) | docs/handover/ | |
| .txt (quick-start, setup) | docs/quickstart/ | |
| .txt (diagnostic, report) | docs/reports/ | |
| .json, .yaml, .toml | config/ | Unless framework-required at root |
| .log | logs/ | |
Files that ALWAYS stay at root:
CLAUDE.md (Claude Code requirement)README.md (convention)LICENSE, LICENSE.mdcontract.md (or primary SOW/spec file)package.json, package-lock.json, pnpm-lock.yaml (Node.js convention).gitignore, .env, .env.exampleMakefile, Dockerfile, docker-compose.ymltsconfig.json, vite.config.*, next.config.*Subcategory detection for scripts:
connect, ssh, remote → scripts/ssh/setup, install, create, init → scripts/setup/diagnose, analyze, scan, audit → scripts/diagnostics/network, process, close → scripts/network/fix, repair, permission → scripts/fixes/scripts/misc/Agent returns: A move map as a data structure:
{
"source_file": "target_directory",
...
}
Present the proposed moves to the user using AskUserQuestion:
question: "Here's the proposed file organization. [SHOW MAP AS TABLE]. Approve or edit?"
header: "Organize"
options:
- label: "Approve"
description: "Move all files as proposed"
- label: "Edit"
description: "I want to change some placements before moving"
- label: "Skip"
description: "Don't reorganize, just bootstrap session context"
multiSelect: false
If "Edit": Ask which files to change, update the map, re-present. If "Skip": Jump to Init Step 7. If "Approve": Continue to Init Step 6.
Dispatch a Task agent with the approved move map and the IS_GIT flag.
Agent task: Create all target directories, then move files.
Create all target directories first:
# Extract unique directories from the move map and create them
mkdir -p [all unique target directories]
Move files using appropriate command:
IS_GIT=true AND file is tracked: Use git mv source targetIS_GIT=false OR file is untracked: Use mv source targetExecute all moves. Do NOT ask for confirmation (user already approved in Step 5).
VERIFY: ls each target directory to confirm files landed correctly.
Agent returns: Summary of moves executed and verification results.
Dispatch a Task agent with HAS_CLAUDE_MD flag, SOUL_PURPOSE, and current directory structure.
If CLAUDE.md does NOT exist:
Copy from template and populate:
cp ~/claude-session-init-templates/CLAUDE-mdReference.md ./CLAUDE.md
Then fill in the [placeholder] sections:
[Project Name] → Infer from directory name or ask user[Primary objective] → Use SOUL_PURPOSE--completion-promise from soul purpose contextIf CLAUDE.md already exists:
Ask user (via main thread) which update approach they prefer:
question: "CLAUDE.md exists. How should I update the path references?"
header: "Update mode"
options:
- label: "Patch paths (Recommended)"
description: "Find-and-replace old file paths with new locations. Preserves all content."
- label: "Rebuild structure section"
description: "Regenerate the Project Structure section from actual directory state. Preserves everything else."
- label: "Skip"
description: "Don't touch CLAUDE.md"
multiSelect: false
For either update mode, the agent MUST ensure these governance sections exist in CLAUDE.md:
1. Project Structure — Reflects actual directory layout
2. Structure Maintenance Rules — The following block MUST be present:
## Structure Maintenance Rules
> These rules ensure the project stays organized across sessions.
- **CLAUDE.md** stays at root (Claude Code requirement)
- **Session context** files live in `session-context/` - NEVER at root
- **Scripts** (.sh, .ps1, .py, .js, .ts) go in `scripts/<category>/`
- **Documentation** (.md, .txt guides/reports) go in `docs/<category>/`
- **Config** files (.json, .yaml, .toml) go in `config/` unless framework-required at root
- **Logs** go in `logs/`
- When creating new files, place them in the correct category directory
- Do NOT dump new files at root unless they are actively being worked on
- Periodically review root for stale files and move to correct category
3. Session Context Files — References use session-context/ prefix:
## Session Context Files (MUST maintain)
After every session, update these files in `session-context/` with timestamp and reasoning:
- `session-context/CLAUDE-activeContext.md` - Current session state, goals, progress
- `session-context/CLAUDE-decisions.md` - Architecture decisions and rationale
- `session-context/CLAUDE-patterns.md` - Established code patterns and conventions
- `session-context/CLAUDE-troubleshooting.md` - Common issues and proven solutions
4. Immutable Template Rules — Append at bottom if not present:
## IMMUTABLE TEMPLATE RULES
> **DO NOT** edit the template files in `~/claude-session-init-templates/`
> Templates are immutable source-of-truth. Only edit the copies in your project.
5. Ralph Loop — Add section (will be populated in Step 9):
## Ralph Loop
**Mode**: pending
Agent returns: Confirmation that CLAUDE.md exists with all 5 governance sections.
Now that project structure exists and CLAUDE.md is in place, run Claude's built-in /init command.
Why this ordering: Claude's /init analyzes the codebase and enriches CLAUDE.md. Our bootstrap (Steps 1-7) creates the structure that /init needs to analyze. Running /init after bootstrap means it has meaningful content to work with.
Before running /init: [DELEGATE TO AGENT] Cache the current governance sections from CLAUDE.md:
## Structure Maintenance Rules, ## Session Context Files, ## IMMUTABLE TEMPLATE RULES, ## Ralph LoopExecute:
/init
After /init completes: [DELEGATE TO AGENT] Verify governance sections are still present AND correct:
This replaces the old auto-launch behavior. Explain Ralph Loop to the user, then let them choose.
Show this explanation:
"Ralph Loop is an iterative execution loop that works toward your soul purpose autonomously, checking its own work with doubt agents. It's useful for complex multi-step projects where you want Claude to keep pushing forward without constant prompting."
Reference: https://github.com/snarktank/ralph
Then present options using AskUserQuestion:
question: "How would you like to configure Ralph Loop for this project?"
header: "Ralph Loop"
options:
- label: "Automatic"
description: "Ralph Loop launches every time /start runs"
- label: "Manual"
description: "Installed but only runs when you invoke it yourself"
- label: "Skip"
description: "Not installed. Can be added later by editing CLAUDE.md"
multiSelect: false
After user chooses: Update the ## Ralph Loop section in CLAUDE.md:
## Ralph Loop
**Mode**: automatic | manual | skip
Use the exact value the user chose (lowercase). This is done via a Task agent editing CLAUDE.md.
If Ralph Loop mode = "automatic":
Extract Ralph Loop variables from CLAUDE.md:
If variables present, bind automatically.
If variables missing, use safe defaults inferred from SOUL_PURPOSE.
Immediately invoke:
/ralph-wiggum:ralph-loop
Run using:
SOUL_PURPOSE value as part of mission contextDo not explain what you are doing. Do not restate configuration. Proceed directly into Ralph Loop execution.
If Ralph Loop mode = "manual" or "skip":
Report completion:
"Session initialized. Soul purpose set. Project organized. Run
/startagain any time to check progress or manage lifecycle."
[DELEGATE TO AGENT]Write initial state to session-context/CLAUDE-activeContext.md:
# Active Context
**Last Updated**: {{TODAY_DATE}}
**Current Goal**: {{SOUL_PURPOSE}}
## Current Session
- **Started**: {{TODAY_DATE}}
- **Focus**: {{SOUL_PURPOSE}}
- **Status**: Initialized
## Progress
- [x] Session initialized via /start (Init Mode)
- [ ] Begin working on soul purpose
## Notes
- Soul purpose established: {{TODAY_DATE}}
- Ralph Loop preference: {{RALPH_MODE}}
This ensures the first Reconcile run finds meaningful content instead of an empty template.
Triggered when
session-context/already exists.
Run Claude's /init first to refresh CLAUDE.md from the current codebase state.
Why this ordering: In Reconcile Mode, the codebase already exists with structure. Let /init refresh CLAUDE.md before we layer our governance and lifecycle checks on top.
Before running /init: [DELEGATE TO AGENT] Cache the current governance sections from CLAUDE.md:
## Structure Maintenance Rules, ## Session Context Files, ## IMMUTABLE TEMPLATE RULES, ## Ralph LoopExecute:
/init
After /init completes: [DELEGATE TO AGENT] Verify governance sections are still present AND correct:
Dispatch a Task agent to read and summarize:
Agent task: Read the following files and return a structured summary:
session-context/CLAUDE-soul-purpose.md — Extract the current soul purpose text, any [CLOSED] markers, and the active purposesession-context/CLAUDE-activeContext.md — Extract current state, open tasks, blockers, recent progressAgent returns: A concise summary (no more than 30 lines) containing:
Using ONLY the summary returned by the agent in Step 2, classify the soul purpose status. This is pure reasoning — no file reads, no agents, no extra cost.
Classify as one of:
| Classification | Criteria |
|---------------|----------|
| clearly_incomplete | Open tasks remain, active blockers present, success criteria not met |
| probably_complete | Success criteria appear met, no open TODOs, artifacts exist |
| uncertain | Mixed signals — some done, some unclear |
clearly_incomplete → Skip to Step 7 (Ralph Loop check). Soul purpose is clearly not done — no need to ask.probably_complete or uncertain → Continue to Step 4 (doubt agent suggestion).This step ONLY runs for probably_complete or uncertain assessments.
Present to the user:
"Soul purpose appears potentially complete. Want me to run a doubt verification before we decide?"
question: "Would you like to run a doubt agent to verify completion before deciding?"
header: "Verification"
options:
- label: "Yes, verify"
description: "Run doubt agent with soul purpose and current artifacts"
- label: "No, skip"
description: "I'll decide without verification"
multiSelect: false
If "Yes, verify": See Doubt Agent Escalation section below for execution details. If "No, skip": Continue to Reconcile Step 5.
This step ONLY runs for probably_complete or uncertain assessments. (The clearly_incomplete path skips directly to Step 7.)
Present the self-assessment result (and doubt agent result, if run) to the user. Then offer the decision:
question: "Based on the assessment, what would you like to do with the current soul purpose?"
header: "Soul Purpose Lifecycle"
options:
- label: "Close"
description: "Mark soul purpose as complete. Harvest active context to durable files."
- label: "Continue"
description: "Keep working on current soul purpose. No changes."
- label: "Redefine"
description: "Harvest current context, then set a new soul purpose."
multiSelect: false
If "Continue": No changes. Skip to Reconcile Step 7 (Ralph Loop check). If "Close": Run the Active Context Harvesting flow (Reconcile Step 6), then ask for optional new soul purpose. If "Redefine": Run the Active Context Harvesting flow (Reconcile Step 6), then immediately ask for new soul purpose.
This step ONLY runs if user chose "Close" or "Redefine".
See the full Active Context Harvesting section below. Dispatch a harvest agent to execute the flow.
Read the ## Ralph Loop section from CLAUDE.md (this is a small section, safe to read directly).
| Mode | Action |
|------|--------|
| automatic | Launch Ralph Loop immediately (same as Init Step 10) |
| manual | Report: "Ralph Loop is available. Invoke it manually when ready." |
| skip | Report: "Session reconciled. Soul purpose status checked." |
| Not found | Report: "No Ralph Loop preference set. Run /start on a fresh project to configure." |
Used in Reconcile Step 3. The AI reads the agent's summary of CLAUDE-soul-purpose.md and CLAUDE-activeContext.md and checks:
| Signal | Assessment |
|--------|-----------|
| Open tasks remain, active blockers present | clearly_incomplete |
| Success criteria appear met, no open TODOs, artifacts exist | probably_complete |
| Mixed signals, some done / some unclear | uncertain |
This is pure reasoning on the agent summary. No file reads, no tool calls, no extra cost.
Only triggered when user explicitly accepts verification in Reconcile Step 4.
What to pass to the doubt agent:
How to invoke:
Task(subagent_type="doubt-agent", prompt="Verify whether this soul purpose is complete. Soul purpose: [text]. Success criteria: [criteria]. Current state: [summary from Step 2]. Self-assessment: [classification]. Challenge the assessment — look for gaps, untested assumptions, missing deliverables.")
What to do with the result: Present the doubt agent's findings to the user alongside the self-assessment in Reconcile Step 5. The user makes the final call.
Triggered when user closes or redefines a soul purpose (Reconcile Step 6).
Early exit check: Before dispatching the harvest agent, check if session-context/CLAUDE-activeContext.md is still in its template state (contains only boilerplate headings with no substantive content). If so, skip the harvest ceremony entirely:
"No active context to harvest — working memory is empty. Proceeding with closure."
Skip directly to archiving the soul purpose and clearing active context.
Dispatch a harvest Task agent with these instructions:
1. Read session-context/CLAUDE-activeContext.md fully.
2. Scan for durable content in three categories:
session-context/CLAUDE-decisions.mdsession-context/CLAUDE-patterns.mdsession-context/CLAUDE-troubleshooting.md3. Apply Promotion Rules (filter strictly):
4. Agent returns to main thread: A structured summary of proposed promotions, organized by target file.
5. Present proposed promotions to the user [MAIN THREAD]:
"I found the following durable content in active context. Here's what I propose to promote:"
To CLAUDE-decisions.md:
- [Decision 1 summary]
To CLAUDE-patterns.md:
- [Pattern 1 summary]
To CLAUDE-troubleshooting.md:
- [Issue 1 summary]
question: "Approve these promotions to durable context files?"
header: "Harvest"
options:
- label: "Approve all"
description: "Promote all listed content"
- label: "Edit"
description: "I want to change what gets promoted"
- label: "Skip"
description: "Don't promote anything, just clear active context"
multiSelect: false
6. Execute promotions [DELEGATE TO AGENT]:
session-context/session-context/CLAUDE-activeContext.md back to its template state (copy from ~/claude-session-init-templates/CLAUDE-activeContext.md)session-context/CLAUDE-soul-purpose.md with [CLOSED] marker and date:## [CLOSED] — {{date}}
{{previous soul purpose text}}
7. Handle next soul purpose:
If a new soul purpose is provided, write it to the top of session-context/CLAUDE-soul-purpose.md (above the archived entries):
# Soul Purpose
{{NEW_SOUL_PURPOSE}}
---
## [CLOSED] — {{date}}
{{previous soul purpose text}}
One-time onboarding during Init Mode only (Init Step 9).
"Ralph Loop is an iterative execution loop that works toward your soul purpose autonomously, checking its own work with doubt agents. It's useful for complex multi-step projects where you want Claude to keep pushing forward without constant prompting."
Reference: https://github.com/snarktank/ralph
/start runsChoice saved to CLAUDE.md under a ## Ralph Loop section:
## Ralph Loop
**Mode**: automatic | manual | skip
On Reconcile Mode, the skill reads this preference and acts accordingly. No re-asking. User edits CLAUDE.md directly to change preference.
Claude's built-in /init command analyzes the codebase and generates/updates CLAUDE.md. Our skill layers governance (session-context, soul purpose, lifecycle rules) on top of what /init produces.
| Mode | Order | Reason |
|------|-------|--------|
| Init | Our bootstrap THEN /init | /init needs structure to analyze. Our bootstrap creates that structure first. |
| Reconcile | /init first THEN our reconciliation | Codebase already exists. Let /init refresh CLAUDE.md before we layer governance. |
/init as a step in its flow/init output enriches CLAUDE.md with codebase-aware content/init runs, the skill verifies that all 5 governance sections are still present:
/init removed or overwrote any governance section, restore it via a Task agent/init may regenerate CLAUDE.md entirelytools
Fast save-point: sync all session-context files and MEMORY.md with current progress. Zero questions, zero delay. Use when user says /sync, save progress, save state, sync context, or /sync --full for capability inventory.
testing
Gracefully close, pause, or verify a session: harvest promotable content, save progress, archive soul purpose, settle AtlasCoin bounty. Use when user says /stop, wrap up, done for the day, finishing up, close session, pause, verify, or end session.
devops
Use when hitting the same error after 2+ fix attempts, when multiple symptoms share a common system, or when fixes feel like whack-a-mole. Forces architectural reassessment over symptom-patching. Also use proactively when a fix touches infrastructure-level config.
tools
Session initialization and lifecycle management: bootstraps session context, organizes files, generates CLAUDE.md, manages soul purpose lifecycle with completion protocol and active context harvesting. Use when user says /start, /init, bootstrap session, initialize session, or organize project.