Skip to content

EnterWorktree ignores chamber.config default_base (branches off main, not dev) #1

Description

@echochamber

Problem

The built-in Claude Code EnterWorktree tool — which ~/.claude/CLAUDE.md tells agents to prefer — creates worktrees with its own worktree.baseRef (default fresh = origin/<default-branch> = main). It does not go through wtutils.sh / chamber.config, so it ignores the per-repo default_base.

The wt-add shell path (wtutils.sh) does honor it (wtutils.sh reads default_base ~line 103 and passes it to git worktree add -b … "$base" ~line 267). So the two worktree-creation paths disagree.

Symptom (how it bit us)

In manapool/manabot-alpha, chamber.config declares "default_base": "origin/dev" and feature PRs target dev. But every worktree made via EnterWorktree branched off main. Since main runs ahead of dev by all the dev→main promotion merges, every PR's commit list was polluted with ~25 Merge pull request #N from manapoolinc/dev commits. (File diffs were fine; commit list was noise.) Workaround was git rebase --onto origin/dev $(git merge-base HEAD origin/main) on each branch.

Secondary: the chamber.config post-create hooks (e.g. pnpm install --frozen-lockfile) also don't run for EnterWorktree-created worktrees — deps had to be installed manually each time.

Desired fix

Make EnterWorktree-created worktrees honor chamber.config:

  1. Base the new branch on the repo's default_base (e.g. origin/dev) instead of main.
  2. Run the chamber hooks (pnpm install, config symlinks) post-create.

Likely approach (investigate): a PostToolUse hook on EnterWorktree (there's already an EnterWorktree|ExitWorktree matcher running worktree-cwd-notify.sh) that, when the new worktree's base ≠ default_base, re-bases it (git reset --hard <default_base> / git rebase --onto) and runs the post-create hooks. worktree.baseRef only supports fresh/head, so it can't target an arbitrary branch directly — hence the post-create reconciliation. Alternatively, reconsider whether the CLAUDE.md guidance should point at wt-add for repos with a non-default integration branch.

Acceptance: EnterWorktree in manabot-alpha produces a branch based on origin/dev (clean PR, 1 commit) with deps installed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions