From cwf
Generates next-session.md or phase-handoff.md from cwf-state.yaml, plan.md, lessons.md, and logs to preserve context across agent sessions or phases. Triggers on 'cwf:handoff'.
npx claudepluginhub corca-ai/claude-plugins --plugin cwfThis skill uses the workspace's default tool permissions.
Preserve execution continuity across boundaries by generating handoff documents (`next-session.md` or `phase-handoff.md`) from project state and artifacts. Reads `cwf-state.yaml` for session history and `master-plan.md` (when available) for next-session scope.
Creates isolated Git worktrees for feature branches with prioritized directory selection, gitignore safety checks, auto project setup for Node/Python/Rust/Go, and baseline verification.
Executes implementation plans in current session by dispatching fresh subagents per independent task, with two-stage reviews: spec compliance then code quality.
Dispatches parallel agents to independently tackle 2+ tasks like separate test failures or subsystems without shared state or dependencies.
Preserve execution continuity across boundaries by generating handoff documents (next-session.md or phase-handoff.md) from project state and artifacts. Reads cwf-state.yaml for session history and master-plan.md (when available) for next-session scope.
cwf:handoff # Full: generate next-session.md + register
cwf:handoff --register # Register current session in cwf-state.yaml only
cwf:handoff --phase # Generate phase-handoff.md (HOW context for next phase)
Read cwf-state.yaml:
workflow.current_stage and workflow.stages — where we aresessions — full session historysession_defaults — expected artifactsDetermine the current session by:
.cwf/projects/cwf-state.yaml sessionsRead the current session's artifacts (if they exist):
plan.md — session scope and goals
## Deferred Actions section if present (unchecked items: - [ ])lessons.md — accumulated learnings
retro.md — retrospective (if available)
Before consuming runtime session logs, run a best-effort Codex sync:
bash {CWF_PLUGIN_DIR}/scripts/codex/sync-session-logs.sh --cwd "$PWD" --quiet || true
Runtime session logs (optional but recommended when available)
.cwf/sessions/*.claude.md, .cwf/sessions/*.codex.md, .cwf/sessions/*.mdIf master-plan.md exists (search via Glob in .cwf/projects/):
Fall back to cwf-state.yaml stages and user input:
workflow.stages for the stage progressionmaster-plan.md is preferred but optional — the skill must work generically for any project using CWF.
Write next-session.md in the current session artifact directory.
Use plan-protocol.md as the canonical source:
Handoff Document (milestone sessions) for required section structureExecution Contract (Mention-Only Safe) for mandatory contract clausesDo not replicate or improvise template structure from recent examples.
Prepare source material for each canonical section:
skills/ directory and trigger list), not a hardcoded skill catalog.Render the canonical 9 sections in protocol order (no section omission):
If next-session.md already exists, edit in place instead of overwriting.
Before updating cwf-state.yaml, verify:
plan-protocolWhen --phase flag is used, generate a phase-to-phase context transfer document instead of next-session.md. Phase handoff captures HOW (protocols, rules, must-reads, constraints) while plan.md captures WHAT (spec, steps, files).
Prerequisite flow: Phase 1.1 (Load Project State) and Phase 1.2 (Identify Current Session) execute normally. Phase 1.3 reads only lessons.md for protocol-relevant entries. Phase 2 is skipped entirely.
Identify the source and target phases from context:
If ambiguous, use AskUserQuestion:
What phase are you transitioning from and to?
Example: "clarify + design → implementation"
The agent executing this skill holds the clarify/gather context in its active conversation. Extract the following from conversation history and session artifacts:
.cwf/sessions/*.claude.md, .cwf/sessions/*.codex.md, .cwf/sessions/*.mdlessons.md entries and explicit user instructionsplan.md criteria or add phase-specific onesWrite to .cwf/projects/{session-dir}/phase-handoff.md:
# Phase Handoff: {source phase} → {target phase}
> Source phase: {e.g., clarify + design discussion}
> Target phase: {e.g., implementation}
> Written: {date via `date +%Y-%m-%d`}
## Context Files to Read
1. `AGENTS.md` — shared project rules and protocols (cross-agent, when present)
2. `cwf-state.yaml` — current project state (when present)
3. {additional files from 3b.2}
## Design Decision Summary
{Key design choices with rationale from 3b.2}
## Protocols to Follow
{Numbered list of rules and behavioral protocols from 3b.2}
## Do NOT
{Bulleted list of explicit prohibitions from 3b.2}
## Implementation Hints
{Practical guidance from 3b.2}
## Success Criteria
```gherkin
{BDD criteria from 3b.2}
```
Present the generated document to the user and ask for confirmation:
Phase handoff generated. Review the document above.
Use AskUserQuestion with options: "Confirm", "Edit and regenerate", "Cancel".
If "Edit and regenerate": apply user feedback, regenerate, and re-confirm.
Resolve the current session entry in cwf-state.yaml before updating artifacts, summary, or completed_at:
dir (primary), then by id (fallback).id, title, dir, branch, artifacts: []
(and stage_checkpoints: [] when used in the project)."Create missing session entry now" | "Edit fields first" | "Cancel registration"."Create missing session entry now":
append the draft entry to sessions, then continue to 4.2/4.2b."Edit fields first", run this loop:
id, title, dir, branch.artifacts: []
(and stage_checkpoints: [] when used in the project).id must not duplicate an existing session id,
dir must not duplicate an existing session dir."Insert this session entry with edited values?"
with options:
"Confirm insert" | "Edit again" | "Cancel registration"."Edit again", repeat this step."Confirm insert", append the edited entry and continue to 4.2/4.2b."Cancel registration", stop registration and report that artifacts were not updated."Cancel registration" from the initial decision:
stop registration and report that artifacts were not updated.next-session.md to the artifacts listsummary if not already setcompleted_at to today's date (via date +%Y-%m-%d)live section: set all scalar fields to "" and lists to []When --phase flag is used:
phase-handoff.md to the current session's artifacts list in cwf-state.yamlcompleted_at — the session continues into the next phasesummary — the session is not finishedcheck-session.sh checks
session-end artifacts, not mid-session artifactsWhen --register flag is used, skip Phase 3 (generation) and only update the session entry in cwf-state.yaml.
Propagate unresolved items from the current session to next-session.md to prevent context loss across session boundaries.
plan.md): Extract unchecked items (- [ ]) from the ## Deferred Actions sectionlessons.md): Identify entries with unimplemented resolution proposals (keywords: "구현은 별도 세션", "스코프 밖", "future", "deferred", "separate session", "out of scope")retro.md): Identify action items not yet addressed in this sessionAdd a section to next-session.md after "Lessons from Prior Sessions":
## Unresolved Items from {current session ID}
### From Deferred Actions
- [ ] {item 1}
- [ ] {item 2}
### From Lessons
- [ ] {lesson title}: {unimplemented proposal}
### From Retro
- [ ] {action item description}
- [ ] [carry-forward] {item})Add handoff to cwf-state.yaml current session's stage_checkpoints list.
Execute the session artifact checker:
bash {CWF_PLUGIN_DIR}/scripts/check-session.sh --impl
Report results. If any artifacts are missing, list them and suggest fixes.
plan-protocol.md Handoff Document section for format. Do not copy-paste a recent next-session.md — derive from the protocol.skills/ directory, not a hardcoded skill list.next-session.md from a prior run), use Edit to update — not Write. Write replaces entire file contents and destroys prior work.completed_at is not set and Phase 4b/5 are skipped.phase-handoff.md to the user for review before finalizing.next-session.md must include "Execution Contract (Mention-Only Safe)".artifacts, summary, or completed_at until a matching sessions entry exists (find-or-create with user confirmation).