handoff
Skill metrics: Emit a start event to the activity log:
echo "{\"type\":\"skill\",\"event\":\"start\",\"skill\":\"handoff\",\"ts\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"}" >> docs/sessions/.activity-log.jsonl
Generate a comprehensive handoff for ending a development session:
Phase 0: Validate Prerequisites
Before starting, verify:
docs/sessions/directory exists (create if missing)- No conflicting session file for today's date
If the directory is missing, create it silently and proceed.
1. Capture Current State
Analyze:
- Current branch:
git branch --show-current - Git status (uncommitted changes?)
- Open PRs:
gh pr list --author @me --state open - Current sprint spec (if exists:
docs/sprints/sprint-*.md) — extract sprint goal, capacity used, and any decisions logged this session - Last entries in @docs/progress.md
2. Document Progress
If work was done this session, ensure it's captured:
- Sprint spec updated with progress
- Any decisions documented
- Blockers noted
3. Generate Session File
Save a structured session file to docs/sessions/session-YYYY-MM-DD.md.
The file MUST start with YAML frontmatter for /resume searchability:
---
date: YYYY-MM-DD
sprint: [current sprint number]
sprint_goal: "[sprint goal — one sentence from sprint spec]"
sprint_capacity: "[sessions used/total — e.g., 5/8]"
branch: [branch-name]
stories: [comma-separated story IDs worked on]
status: [completed | in-progress | blocked]
---
# Session Handoff — [YYYY-MM-DD]
## Git State
- **Branch:** [branch-name]
- **Uncommitted changes:** [yes/no — list if yes]
- **PR Status:** [Open #123 / Merged / Not created]
## Work Completed
- [x] [Task/story completed]
- [ ] [Task in progress — what's done, what remains]
## Key Decisions
- [Decision]: [Rationale]
## Blockers / Issues
- [Issue]: [Status]
## Files Accessed This Session
### Modified
- [path/to/file]: [what changed and why]
### Read (context-relevant)
- [path/to/file]: [why this file was important to understand]
### Investigated (can skip on resume)
- [path/to/file]: [explored but not relevant to current work]
## Test Status
- Passing: [count]
- Failing: [count]
- Coverage: [percentage if available]
## Next Steps (Minimal First Action)
1. [The single next thing to do — be very specific]
2. [Second priority]
3. [Third priority]
## Files to Load on Resume
- @[path] — [why this file is needed]
## Activity Summary
<!-- Populated from activity log if available -->
## Warnings / Gotchas
- [Any issues the next session should be aware of]
4. Create Next Session Prompt
Generate a ready-to-use prompt for the next session:
## Next Session Start Prompt
Continue development.
### Context
- Last session: [date]
- Current story: [ID] - [title]
- Branch: [branch-name]
- PR Status: [Open #123 awaiting review / Not created / Merged]
- Status: [in progress / between sprints]
### Immediate Next Steps
1. [First thing to do]
2. [Second thing]
3. [Third thing]
### Files to Review
- @[path] - [why]
### Warnings/Gotchas
- [Any issues discovered]
4.5. Document Quality Check
After generating the session file, dispatch a fresh sub-agent to test it from a reader's perspective:
- Agent type: Explore (read-only, forked context)
- Input: ONLY the generated session file — no conversation history
- Instructions: "You are a developer starting a new session tomorrow with only this handoff file. (1) Can you understand what was done? (2) Are next steps specific enough to act on immediately? (3) Is any critical context missing? (4) Would you need to re-explore anything that could have been captured here?"
Review findings. Fix genuine gaps before finalizing.
5. Commit and PR Reminder
- If uncommitted changes: suggest commit message and push
- If sprint complete but no PR: suggest creating PR
- If PR approved but not merged: suggest merging
5.5. PR Session Summary
gh pr comment --body "### Session Summary ($(date +%Y-%m-%d))
- **Decisions made:** [what was decided and why]
- **Alternatives rejected:** [approaches considered but not taken]
- **AI limitations encountered:** [what the AI struggled with or got wrong]"
If the user declines, skip without further prompting.
6. Update Persistent Files
Ensure these are current:
- @docs/progress.md: recent sprints updated
- @CLAUDE.md "Current Focus" is accurate
Skill metrics: Emit a completion event:
echo "{\"type\":\"skill\",\"event\":\"end\",\"skill\":\"handoff\",\"outcome\":\"success\",\"ts\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"}" >> docs/sessions/.activity-log.jsonl
Output the session summary and next session prompt.