Skip to content

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

Merged
drabaioli merged 4 commits into
mainfrom
gh_issue_22_worktree_resume
Jul 1, 2026
Merged

Add cdd-worktree-resume for multi-machine worktree pickup#39
drabaioli merged 4 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>
Comment thread doc/knowledge_base/claude-driven-development.md Outdated
Comment thread doc/knowledge_base/roadmap.md Outdated
- cdd-worktree-resume no longer launches Claude Code; it recreates the
  worktree, cd's into it, and leaves the user to start the resume-side
  command themselves. Header, trailing message, docs, and both CLAUDE.md
  workflow sections updated to match.
- worktree-resume-assert.sh now uses the stubbed `claude` as a negative
  guard (asserts it is never invoked) instead of asserting a launch.
- Compact the repetitive §2.8 multi-machine paragraph into the bullet and
  trim the roadmap [x] item, per review.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@drabaioli

Copy link
Copy Markdown
Owner Author

Also addressed the additional request from review to not launch Claude Code at the end of resume (dc4204f): cdd-worktree-resume now recreates the worktree, cds into it, and prints the next-step hint, leaving you to start Claude Code yourself. The resume smoke test now uses the stubbed claude as a negative guard (asserting it is never invoked), and the §2.8 / roadmap / both CLAUDE.md workflow sections were updated to match.

Comment thread template/CLAUDE.md Outdated
…asing

Reword the resume description positively ("...and cd's into it, ready for
you to run ...") in both CLAUDE.md files, process doc §2.8, and the
cdd-worktree.sh header, instead of stating what the helper does not do.
Test assertions and the runtime next-step hint are left as-is.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@drabaioli drabaioli merged commit 6267594 into main Jul 1, 2026
1 check passed
@drabaioli drabaioli deleted the gh_issue_22_worktree_resume branch July 1, 2026 12:17
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