Skip to content

Commit 81236e6

Browse files
recuu-pfegclaude
andcommitted
fix: mark CLAUDE.md as assume-unchanged after inject_memory
Prevents inject_memory's TOBAN_MEMORY block from being committed. Only applies when CLAUDE.md already existed (new files are tracked). Agent can still read the injected memories. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6b4ce6c commit 81236e6

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/agent-templates.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ export async function executeActions(
306306
break;
307307
}
308308

309-
// Safety check: verify diff contains real code changes (not just CLAUDE.md / .toban-messages.md)
309+
// Safety check: verify diff contains real code changes
310310
const diffFiles = gitExec(
311311
`git diff ${baseBranch}..${worktreeBranch} --name-only`,
312312
{ cwd: repoDir, stdio: "pipe" }
@@ -653,6 +653,15 @@ ${diffForReview}
653653
injected = memories.length;
654654
}
655655

656+
// Mark CLAUDE.md as assume-unchanged so inject_memory additions don't get committed
657+
// Agent can still read the file, but git won't track the memory block changes
658+
if (injected > 0 && hasClaudeMd) {
659+
try {
660+
const { execSync: gitExec2 } = await import("node:child_process");
661+
gitExec2("git update-index --assume-unchanged CLAUDE.md", { cwd: ctx.config.workingDir, stdio: "pipe" });
662+
} catch { /* non-fatal — worktree may not support this */ }
663+
}
664+
656665
if (injected > 0 || !hasClaudeMd) {
657666
ui.info(`[${phase}] ${label}: ${injected} memories${!hasClaudeMd ? " + dir structure" : ""}`);
658667
}

0 commit comments

Comments
 (0)