Skip to content

Add cdd-worktree-resume for multi-machine worktree pickup#39

Open
drabaioli wants to merge 2 commits into
mainfrom
gh_issue_22_worktree_resume
Open

Add cdd-worktree-resume for multi-machine worktree pickup#39
drabaioli wants to merge 2 commits into
mainfrom
gh_issue_22_worktree_resume

Conversation

@drabaioli

Copy link
Copy Markdown
Owner

Summary

Adds cdd-worktree-resume [<branch>], a fourth command on the shared worktree helper, for picking up a task started on another machine. It recreates a worktree tracking an existing remote branch (no handoff required) and launches plain Claude Code so the resume-side commands (/cdd-process-pr, /cdd-merge-base, /cdd-pre-pr) can run. With no argument it lists remote feature branches not already checked out and prompts for one.

Scope is deliberately worktree + branch recreation only — the handoff and per-task state record are local-per-machine and are not synced. That's sound because the resume-side commands read PR/branch state from git and gh, and cdd-state set no-ops when the record is absent. Cross-machine sync of the handoff and state record is tracked as separate follow-up work.

Changes

  • tools/cdd-worktree.sh — new cdd-worktree-resume function + header docs. Additive: no change to the layout or any existing command, so a newer helper stays backward-compatible with every project version.
  • scripts/worktree-resume-assert.sh (new) — local-bare-repo-as-origin smoke covering explicit resume (tracking worktree + claude launch), already-exists (return 0, no relaunch), and discovery mode (numbered selection).
  • .github/workflows/template-smoke.yml — runs the new smoke; existing bash -n/shellcheck globs already cover the new script.
  • Docs: process doc §2.8 (four commands + multi-machine note) and §2.13, roadmap (item ticked + handoff/state-sync follow-up added), README, CLAUDE.md, template/CLAUDE.md.

Verification

All /cdd-pre-pr gates pass: command-set drift clean, prompt seams clean, install smoke, worktree-resume smoke, end-to-end bootstrap smoke, demo seed-overlay smoke, bash -n clean. No upstream drift.

Closes #22

🤖 Generated with Claude Code

drabaioli and others added 2 commits June 30, 2026 22:56
Recreate a worktree on a second machine that has only a clone: fetch
origin, attach the existing remote branch (no -b new branch, no handoff
required), and launch plain Claude Code so the user can run a resume-side
command (/cdd-process-pr, /cdd-merge-base, /cdd-pre-pr). With no argument,
list remote feature branches not already checked out and prompt for one.

Scope is worktree + branch recreation only: the handoff (<branch>.md) and
state record (<branch>.state.json) stay local per machine and are not
synced. That is safe because the resume-side commands read PR/branch state
from git and gh, not the handoff, and cdd-state set no-ops when absent.
Cross-machine sync of those artifacts is recorded as remaining Phase-13
work (the refs/cdd/<branch> design sketch in the roadmap).

- tools/cdd-worktree.sh: new cdd-worktree-resume + "Provides" header entry
- scripts/worktree-resume-assert.sh: local-bare-repo-as-origin smoke with a
  stubbed claude; wired into template-smoke.yml
- process doc §2.8 (four commands + multi-machine note) and §2.13 refinement
- roadmap Phase 13: split #22 into landed worktree-resume + deferred sync
- README + both CLAUDE.md workflow sections; CLAUDE.md build/test list

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Discovery built candidates from `%(refname:short)` and stripped an
`origin/` prefix to drop the origin/HEAD symref. That short form is
"origin/HEAD" on git 2.34 (strips to "HEAD", excluded) but just "origin"
on newer git (CI), which slipped past the HEAD check and became a bogus
first candidate — `git worktree add --track -b origin origin/origin` then
failed, so discovery mode exited 1 in CI.

Iterate full refnames (`%(refname)`) and strip the full
`refs/remotes/origin/` prefix instead; refs/remotes/origin/HEAD is stable
across git versions, so the symref is excluded everywhere.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recreate a worktree on a new machine

1 participant