Skip to content

feat: symlink root CLAUDE.md into each worktree on create#106

Merged
ikeikeikeike merged 1 commit into
mainfrom
feat/symlink-claudemd-into-worktree
Jul 15, 2026
Merged

feat: symlink root CLAUDE.md into each worktree on create#106
ikeikeikeike merged 1 commit into
mainfrom
feat/symlink-claudemd-into-worktree

Conversation

@ikeikeikeike

@ikeikeikeike ikeikeikeike commented Jul 15, 2026

Copy link
Copy Markdown
Member

bough create targets are launched via claude --worktree, which cd's into the
worktree root — a non-git container whose git walk-up cannot reach the monorepo
root. So the root CLAUDE.md never loaded for a worktree session; it started
with no project guidance at all.

Mirror the existing linkWorktreeSkills step (5b): link
<worktreeRoot>/CLAUDE.md -> <monorepoRoot>/CLAUDE.md (absolute), reusing the
ensureSymlink helper. Only when the monorepo root has a regular-file
CLAUDE.md; a hand-authored real file already in the worktree is left untouched.

verify result
go build / golangci-lint OK / 0 issues
unit suite (internal/ cmd/ pkg/) 21 ok / 0 FAIL
real bough create e2e absolute symlink in worktree root, content matches, idempotent

New test: TestLinkWorktreeClaudeMd (create + missing-root no-op + real-file guard).

`bough create` cd-targets are launched via `claude --worktree`, which cd's
into the worktree root — a non-git container whose git walk-up cannot reach
the monorepo root. So the root CLAUDE.md never loaded for a worktree session:
the session started with no project guidance at all.

Mirror the existing linkWorktreeSkills step: link
<worktreeRoot>/CLAUDE.md -> <monorepoRoot>/CLAUDE.md (absolute) in create
step 5b, reusing the ensureSymlink helper. Best-effort and only when the
monorepo root has a regular-file CLAUDE.md; a hand-authored real file already
in the worktree is left untouched (ensureSymlink refuses to clobber a
non-symlink).

Adds TestLinkWorktreeClaudeMd (create + no-op-when-missing + real-file guard).
@ikeikeikeike
ikeikeikeike merged commit bf9f818 into main Jul 15, 2026
11 checks passed
@ikeikeikeike
ikeikeikeike deleted the feat/symlink-claudemd-into-worktree branch July 15, 2026 09:14
Comment thread internal/cli/create.go
// git walk-up cannot reach the monorepo root — so without explicit symlinks
// the worktree session would load neither the root CLAUDE.md nor the project
// skills. Both best-effort.
linkWorktreeClaudeMd(stderr, monorepoRoot, worktreeRoot)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retrospective review: this wires linkWorktreeClaudeMd into bough create only, the same shape as issue #61 — which PR #112 had to fix for linkWorktreeArtifacts by relinking every discovered worktree dir in runBackfill too. That artifacts fix landed after this PR merged but didn't extend to CLAUDE.md, so bough backfill (the documented non-destructive repair command) never relinks a worktree's CLAUDE.md — any worktree bootstrapped before this feature shipped, or created outside bough create, keeps starting every Claude session with no root guidance indefinitely. Symlink mechanics themselves (absolute target, idempotent repoint, real-file guard, missing-root no-op) all checked out fine. Fixed in PR #117, which adds the equivalent linkWorktreeClaudeMd call to runBackfill.

ikeikeikeike added a commit that referenced this pull request Jul 16, 2026
fix: retrospective review fixes for merged PR #106
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.

1 participant