Session Cleanup
Run all four phases in order. Report a brief summary after each.
Phase 1: Vault Update
All paths come from agent-os.config.json.
Detect the project
Read ~/.claude/cache/session-context.json for detectedProject and vaultProjectPath.
If null, infer from conversation context (files touched, topics discussed).
Update project README
Read <vaultPath>/<vaultProjectPath>/README.md.
Update with significant changes, decisions, or new context from this session.
If the project's status changed (e.g., went from active to complete, or a major milestone was hit), update the status: field in the README frontmatter. The session-start index reads this field, so keeping it current matters.
Create session note
Create <vaultPath>/Sessions/YYYY-MM-DD-<topic>.md with:
---
date: YYYY-MM-DD
tags: [session, {project-tag}]
project: {vault-folder-name}
---
The project: field MUST match the vault folder name exactly (e.g., Agent-OS, Job-Search). This feeds the session-start project index. Use "general" if no specific project applies.
Include: what was done (bullets), current state, next steps. Keep it concise -- under 30 lines of content. Only add Decisions or Blockers sections if they have content.
Phase 2: Auto Memory
Memory directory comes from agent-os.config.json.
- Read
MEMORY.md-- add new projects, tools, or environment facts discovered this session - Correct anything that turned out wrong
- Keep concise (max ~200 lines, loaded into every session prompt)
- Don't duplicate info the project index already captures (status, summary, last session -- those come from vault READMEs automatically)
Phase 3: Error Learnings
If errors or new patterns occurred this session, suggest running /retro for thorough capture.
For quick cleanup without a full retro: only add to error-patterns.md if there was a genuinely new, likely-to-recur error pattern. Follow the existing format:
### [Short descriptive title]
**What happened:** [Specific error]
**Rule:** [What to do instead]
If no new errors, report "No new patterns" and move on.
Phase 4: Git Sync
For each project repo worked on:
git statusto check for uncommitted changes- If changes exist: stage relevant files, commit with descriptive message
- Push to remote
- Avoid committing
.env, secrets, caches,node_modules - If clean, report "Already up to date"
Output
Print one-line summary per phase:
Cleanup complete:
Vault: Updated <project>/README.md + created session note
Memory: Added N entries to MEMORY.md (or: No changes)
Errors: No new patterns (or: Added N patterns / Suggest /retro)
GitHub: Pushed to repo-name (or: Already up to date)
Rules
- All paths come from agent-os.config.json -- never hardcode user-specific paths
- Always ask before pushing to remote (unless user explicitly pre-authorized)
- Never commit .env files or secrets