@@ -247,7 +247,7 @@ describe("WorktreeManager worktree link/include processing", () => {
247247 await seedGit . addConfig ( "commit.gpgsign" , "false" ) ;
248248 await writeFile (
249249 path . join ( seedDir , ".gitignore" ) ,
250- ".env\n.envrc\nnode_modules/\n" ,
250+ ".claude/\n. env\n.envrc\nCLAUDE.local.md \nnode_modules/\n" ,
251251 ) ;
252252 await writeFile ( path . join ( seedDir , ".worktreelink" ) , "# secrets\n.envrc\n" ) ;
253253 await writeFile ( path . join ( seedDir , ".worktreeinclude" ) , ".env\n" ) ;
@@ -264,6 +264,12 @@ describe("WorktreeManager worktree link/include processing", () => {
264264
265265 await writeFile ( path . join ( localDir , ".env" ) , "secret\n" ) ;
266266 await writeFile ( path . join ( localDir , ".envrc" ) , "export FOO=1\n" ) ;
267+ await mkdir ( path . join ( localDir , ".claude" ) ) ;
268+ await writeFile (
269+ path . join ( localDir , ".claude" , "settings.local.json" ) ,
270+ "{}\n" ,
271+ ) ;
272+ await writeFile ( path . join ( localDir , "CLAUDE.local.md" ) , "local rules\n" ) ;
267273 await mkdir ( path . join ( localDir , "node_modules" , "dep" ) , {
268274 recursive : true ,
269275 } ) ;
@@ -306,6 +312,30 @@ describe("WorktreeManager worktree link/include processing", () => {
306312 expect ( await dirExists ( path . join ( info . worktreePath , "node_modules" ) ) ) . toBe (
307313 false ,
308314 ) ;
315+ expect ( await dirExists ( path . join ( info . worktreePath , ".claude" ) ) ) . toBe (
316+ false ,
317+ ) ;
318+
319+ const localInstructions = await lstat (
320+ path . join ( info . worktreePath , "CLAUDE.local.md" ) ,
321+ ) ;
322+ expect ( localInstructions . isSymbolicLink ( ) ) . toBe ( true ) ;
323+ } ) ;
324+
325+ it ( "links .claude when explicitly configured" , async ( ) => {
326+ await writeFile (
327+ path . join ( localDir , ".worktreelink" ) ,
328+ "# secrets\n.envrc\n.claude\n" ,
329+ ) ;
330+ const manager = new WorktreeManager ( {
331+ mainRepoPath : localDir ,
332+ worktreeBasePath : worktreeBaseDir ,
333+ } ) ;
334+
335+ const info = await manager . createWorktree ( { baseBranch : "main" } ) ;
336+
337+ const linked = await lstat ( path . join ( info . worktreePath , ".claude" ) ) ;
338+ expect ( linked . isSymbolicLink ( ) ) . toBe ( true ) ;
309339 } ) ;
310340} ) ;
311341
0 commit comments