Read yourself into this project and restore any saved session state. Fast, direct file reads.
Environment Requirements:
find /c, 2>nul) - causes filesystem scanning on Git Bashwc -l for counting, 2>/dev/null for error suppression$ARGUMENTS
--verbose: Deep bootstrap - also reads all *.md in root + docs/--diff: Show what changed since last save--git: Auto-update plan steps from recent commits--status: Just show status (skip restore prompt)/sync [--verbose|--diff|--git|--status]
|
+--> Default (no args): FULL BOOTSTRAP
| |
| +- Read project context (README, AGENTS, CLAUDE)
| +- Read saved state (.claude/session-cache.json)
| +- Restore tasks via TaskCreate
| +- Resolve plan path (Step 0)
| +- Read plan (<plan-path>)
| +- Acknowledge memory context (already auto-loaded)
| +- Show unified status
| +- Suggest next action
|
+--> --verbose: DEEP BOOTSTRAP
| |
| +- Everything above, plus:
| +- Read all *.md in project root
| +- Read all *.md in docs/
|
+--> --diff: CHANGE DETECTION
| |
| +- Compare current state vs saved state
| +- Show new commits since save
| +- Show file changes since save
|
+--> --git: AUTO-UPDATE FROM COMMITS
| |
| +- Parse recent git commits
| +- Match to plan steps
| +- Update step status
|
+--> --status: STATUS ONLY
|
+- Show current status
+- Skip restore prompt
+- Read-only quick view
/syncFull bootstrap with state restoration.
Determine the plan file location before reading:
.claude/session-cache.json) and has a plan.file value, prefer that path.claude/settings.local.json for a plansDirectory key.claude/settings.json for plansDirectory<plansDirectory>/PLAN.mddocs/PLAN.mdUse the resolved path in all subsequent file reads and output.
Read these files simultaneously (skip any that don't exist):
| File | Purpose |
|---|---|
README.md |
Project overview |
AGENTS.md |
Agent instructions |
CLAUDE.md |
Project-specific rules |
<plan-path> |
Current plan (resolved in Step 0) |
.claude/session-cache.json |
Saved session state |
If .claude/session-cache.json exists:
1. Parse saved tasks array from JSON
2. For each task, call TaskCreate with:
- subject
- description
- activeForm
3. Build ID mapping: savedIndex → newTaskId
4. For each task with blockedBy, call TaskUpdate:
- Map saved indices to new task IDs
- Set blockedBy relationships
5. For each task, call TaskUpdate to set status:
- "completed" | "in_progress" | "pending"
6. Note time since last save
7. If session_id present, note it for --resume suggestion in output
8. If git.pr_number/pr_url present, note for --from-pr suggestion in output
Note: Tasks do not persist across sessions automatically, which is why this restore step is needed.
Discover extensions:
docs/*.md
commands/*.md OR .claude/commands/*.md
skills/*/SKILL.md OR .claude/skills/*/SKILL.md
agents/*.md OR .claude/agents/*.md
CRITICAL: Use Git Bash syntax ONLY. Never use Windows cmd syntax (find /c, 2>nul) - these will cause filesystem scanning.
Run these commands to get git state:
# Current branch
git branch --show-current 2>/dev/null
# Count uncommitted files - MUST use wc -l (works in Git Bash on Windows)
git status --porcelain 2>/dev/null | wc -l
# Latest commit
git log -1 --format="%h %s" 2>/dev/null
Why this matters on Windows:
find /c in Git Bash = Unix find searching C: drive (WRONG)wc -l in Git Bash = count lines (CORRECT)2>/dev/null but NOT 2>nulMEMORY.md is auto-loaded into the system prompt by Claude Code - do NOT re-read the file. Instead, check your system prompt for the memory content you already have, and surface it:
## Last Session section written by /save)This costs zero extra tokens while confirming the safety net is working.
Format and display unified status.
Project Synced: [project-name]
## Session Restored
| Field | Value |
|-------|-------|
| **Last saved** | 2 hours ago |
| **Branch** | feature/auth |
| **Previous session** | abc123... |
| **Notes** | "Stopped at callback URL issue" |
Note: Previous session row only shown when session_id is present in saved state.
## Plan Status
**Goal**: Add user authentication with OAuth2
| Step | Status |
|------|--------|
| Step 1: Research OAuth providers | Done |
| Step 2: Set up Google OAuth app | Done |
| Step 3: Implement OAuth flow | **Current** |
| Step 4: Add token refresh | Pending |
| Step 5: Write integration tests | Pending |
Progress: 40% (2/5)
## Restored Tasks
| Status | Task |
|--------|------|
| Done | Set up OAuth credentials |
| **In Progress** | Fix callback URL handling |
| Pending | Add token refresh logic |
## Git
| Field | Value |
|-------|-------|
| **Branch** | feature/auth |
| **Uncommitted** | 3 files |
| **Last commit** | abc123f feat: Add OAuth config |
| **PR** | #42 - https://github.com/user/repo/pull/42 |
Note: PR row only shown when pr_number/pr_url are present in saved state.
## Memory
[If MEMORY.md has content, summarise key points - especially any `## Last Session` section]
[If MEMORY.md is empty: "No memory notes from previous sessions."]
Note: MEMORY.md is auto-loaded into the system prompt. This section surfaces
what's already in context - no file read needed.
## Quick Reference
| Category | Items |
|----------|-------|
| **Commands** | /save, /sync, /review, /testgen... |
| **Skills** | 30 available |
| **Agents** | 23 available |
## Next Steps
1. **Continue**: Fix callback URL handling
2. **Check diff**: /sync --diff to see changes since save
3. **Resume conversation**: `claude --resume abc123...` (when session_id present)
4. **PR context**: `claude --from-pr 42` (when PR is linked)
Note: Next Steps items 3-4 are only shown when the corresponding data exists in saved state.
Project Synced: [project-name]
## Summary
[1-2 paragraph narrative based on README.md and AGENTS.md]
## Quick Reference
| Category | Items |
|----------|-------|
| **Project** | [name] - [purpose] |
| **Key Docs** | [list of docs/*.md] |
| **Commands** | [list of /commands] |
| **Skills** | [count] available |
| **Agents** | [count] available |
| **Plan** | No active plan |
| **Saved State** | None |
| **Memory** | [summary of MEMORY.md content, or "Empty"] |
| **Git** | [branch], [N] uncommitted |
## Next Steps
1. **Ready for new task** - No pending work detected
2. **Create a plan** - Use native /plan for implementation planning
3. **Save before leaving** - /save "notes" to persist state
/sync --verboseDeep context loading for onboarding or complex tasks.
| Location | Files Read |
|---|---|
| Project root | All *.md files |
docs/ |
All *.md files |
Same as default, plus:
## Documentation Loaded
| File | Summary |
|------|---------|
| CONTRIBUTING.md | Contribution guidelines |
| CHANGELOG.md | Recent changes |
| docs/ARCHITECTURE.md | System architecture |
| docs/WORKFLOWS.md | Development workflows |
| ... | ... |
/sync --diffShow what changed since last save.
Changes Since Last Save
## Time
| Field | Value |
|-------|-------|
| **Saved** | 2025-12-13 10:30 AM |
| **Now** | 2025-12-13 12:45 PM |
| **Elapsed** | 2 hours 15 minutes |
## Git Changes
| Type | Count |
|------|-------|
| **New commits** | 3 |
| **Files changed** | 7 |
| **Insertions** | +142 |
| **Deletions** | -38 |
### Recent Commits
| Hash | Message |
|------|---------|
| def456 | fix: Handle redirect edge case |
| abc123 | feat: Add callback validation |
| 789xyz | test: Add OAuth flow tests |
## Plan Changes
| Field | Saved | Current |
|-------|-------|---------|
| **Current step** | Step 3 | Step 3 |
| **Progress** | 40% | 40% |
| **Status** | No change | - |
## Task Changes
| Change | Task |
|--------|------|
| **Completed** | Fix callback URL handling |
| **New** | Add error handling for token refresh |
/sync --gitAuto-update plan steps from recent commits.
| Commit Pattern | Plan Update |
|---|---|
feat: Add OAuth... |
Mark matching step complete |
fix: Token refresh... |
Mark matching step in-progress |
test: OAuth flow... |
Mark matching test step complete |
Git Sync
## Matches Found
| Commit | Plan Step | Action |
|--------|-----------|--------|
| abc123 "feat: Add OAuth config" | Step 2 | Marked complete |
| def456 "fix: Callback handling" | Step 3 | Marked in-progress |
## Updated <plan-path>
| Step | Previous | New |
|------|----------|-----|
| Step 2 | In Progress | Done |
| Step 3 | Pending | In Progress |
/sync --statusQuick read-only status view. No restore prompt.
Status
## Plan
**Goal**: Add user authentication with OAuth2
**Progress**: 40% (2/5)
**Current**: Step 3 - Implement OAuth flow
## Tasks
| Status | Count |
|--------|-------|
| Completed | 1 |
| In Progress | 1 |
| Pending | 1 |
## Memory
[Summary of MEMORY.md content, or "Empty"]
## Git
| Field | Value |
|-------|-------|
| **Branch** | feature/auth |
| **Uncommitted** | 3 files |
Warning: No README.md found - project overview unavailable
Info: No docs/ directory - documentation not set up
Info: Fresh project - no Claude configuration found
Consider: Create CLAUDE.md for project-specific rules
Warning: Saved state is 12 days old
Options:
1. Restore anyway (tasks may still be relevant)
2. Start fresh: /save --archive
Warning: Branch changed since save
| Field | Value |
|-------|-------|
| **Saved on** | feature/old-branch |
| **Current** | feature/new-branch |
Restore anyway? Tasks may not apply to current branch.
| Command | Relationship |
|---|---|
/sync |
This command - Read state in |
/save |
Complementary - Persist state out |
Native /plan |
Claude Code's planning mode |
Session Start
/sync <- Read project, restore state
During Work
/sync --status <- Quick status check
/sync --diff <- What changed?
/sync --git <- Update from commits
Session End
/save "notes" <- Persist before leaving
| Flag | Effect |
|---|---|
| (none) | Full bootstrap + restore + status |
--verbose |
Also read all *.md in root + docs/ |
--diff |
Show changes since last save |
--git |
Auto-update plan from commits |
--status |
Status only, skip restore prompt |
/save writes files