Skip to content

Issue-113: give spawned worktree branches task-identifying names - #122

Draft
jodavis-claude wants to merge 2 commits into
feature/ADR-296-concurrencyfrom
dev/claude/Issue-113
Draft

Issue-113: give spawned worktree branches task-identifying names#122
jodavis-claude wants to merge 2 commits into
feature/ADR-296-concurrencyfrom
dev/claude/Issue-113

Conversation

@jodavis-claude

Copy link
Copy Markdown
Collaborator

Work item: Issue-113 — concurrent implementation was creating worktrees/branches with opaque, Claude-Code-generated agent-<8-hex> / worktree-agent-<8-hex> names, making it hard to tell at a glance which worktree belongs to which task, or which ones are stale.

Changes:

  • plugins/dev-team/skills/concurrent-orchestrate/SKILL.md — step 1c.3 renames a freshly spawned workflow-orchestrate worktree's branch from Claude Code's opaque worktree-agent-<8hex> to worktree-<task_id> immediately after the spawn call returns (run from the orchestrator's own non-worktree checkout), with a stale-leftover disambiguation fallback on name collision. Step 1e.2 applies the analogous watch-<task_id> rename for auto-started dev-team:watch-pr monitor spawns. Added a new top-level "Worktree naming" section documenting the convention, why the directory itself is left unrenamed, and that the fix is forward-looking only (existing on-disk worktrees are unaffected).
  • plugins/dev-team/commands/watch-pr.md — the manual /watch-pr spawn now applies the same watch-<work-item-id> branch rename (with the same disambiguation fallback), so a manually-started monitor is just as identifiable as an auto-started one.

Design decisions:

  • Rename the branch only, never the worktree directory itself — avoids the risk of moving a path that may be a live subagent's own working directory, while still satisfying the exit criterion via git worktree list branch-name visibility alone.
  • Verified in a throwaway sandbox repo that git branch -m on a branch checked out in another worktree, run from the main checkout, does not disturb that worktree (status/HEAD/commits all continued to work normally) — confirming orchestrator-side rename is safe.
  • Did not use the WorktreeCreate hook, since its input schema for task-identifying data was unverified/conflicting, and the orchestrator-side rename achieves the same goal without depending on it.
  • Used a distinct literal prefix (worktree-/watch-) rather than reusing git-repo.working-branches.task's template, so ensure-working-branch never mistakes the renamed branch for one that already exists and needs pulling.
  • Existing already-on-disk raw-hash worktrees are left unchanged; this fix only affects newly spawned worktrees going forward.

Closes #113

Testing completed: No application/Python code changed — only agent-instruction prose in SKILL.md/command markdown files. Confirmed via dev-team:missing-test-harness and CONTRIBUTING.md that this repo has no test harness for documentation/prose changes, so none was invented. No .feature/Gherkin E2E harness exists in this repo, so no E2E scenarios were added.

Rename the branch (never the directory) of every isolation:"worktree"
spawn immediately after the spawn call returns, from the outside
(orchestrator's own checkout), before the spawned session does
anything: worktree-<task_id> for workflow-orchestrate implement runs
(concurrent-orchestrate step 1c.3), watch-<task_id> for watch-pr
monitor runs (concurrent-orchestrate step 1e.2 and the manual
/watch-pr command). This makes `git worktree list`'s branch column
identify the task at a glance, including for worktrees still idle on
their just-renamed branch before ensure-working-branch computes its
own readable branch name - directly addressing the "hard to tell
which ones are stale" half of the issue.

Directory names are left untouched (renaming a live subagent's own
cwd was judged too risky and unnecessary - the branch name alone
already satisfies git worktree list at-a-glance identifiability).
ensure-working-branch's own branch-naming template and the
worktree-freshness hard stop are both unmodified; empirically
verified that renaming a branch checked out in another worktree from
the main checkout does not disturb that worktree's later git
operations. Existing raw-hash worktrees already on disk and the
WorktreeCreate hook approach are out of scope for this change.
@github-actions

Copy link
Copy Markdown

build-and-test: Python test results

Status: ✅ Passed

Test log

watch-pr's step 2 was checking out working_branch before step 3 read HEAD to
record watch_worktree_branch, so it captured working_branch instead of the
just-renamed watch-<task_id> monitor branch. This left every renamed monitor
branch permanently orphaned (never recorded, never cleaned up) and made the
later `git branch -D <watch_worktree_branch>` cleanup target the wrong branch.

Fix: capture watch_worktree_path/watch_worktree_branch in step 2 before the
checkout switches HEAD away from the renamed branch, and record the already-
captured values in step 3. Updated the doc text in concurrent-orchestrate's
SKILL.md and commands/watch-pr.md that incorrectly claimed step 3 handled
this correctly. Also added an explicit hard-stop instruction for rename
failures other than a name collision, in both rename sites and the manual
/watch-pr command, matching this repo's existing fault-tolerance convention.
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.

2 participants