Skip to content
TypeScript

fix(server): commit prompts no longer repeat CLAUDE.md when it matches AGENTS.md (#22848)

Theo Browne1d9060b9afa0
diff --git a/apps/server/src/git/GitManager.test.ts b/apps/server/src/git/GitManager.test.ts
index d7b39efde3c..7bfc2c80277 100644
--- a/apps/server/src/git/GitManager.test.ts
+++ b/apps/server/src/git/GitManager.test.ts
@@ -2557,6 +2557,42 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
}),
);
+ it.effect("includes CLAUDE.md for Claude writers only when it differs from AGENTS.md", () =>
+ Effect.gen(function* () {
+ const repoDir = yield* makeTempDir("t3code-git-manager-");
+ yield* initRepo(repoDir);
+ NodeFS.writeFileSync(NodePath.join(repoDir, "AGENTS.md"), "Use imperative subjects.\n");
+ NodeFS.copyFileSync(NodePath.join(repoDir, "AGENTS.md"), NodePath.join(repoDir, "CLAUDE.md"));
+ NodeFS.writeFileSync(NodePath.join(repoDir, "README.md"), "hello\n");
+ const commitInstructions: Array<string | undefined> = [];
+
+ const { manager } = yield* makeManager({
+ serverSettings: {
+ textGenerationModelSelection: {
+ instanceId: ProviderInstanceId.make("claudeAgent"),
+ model: "claude-sonnet-4-5",
+ },
+ },
+ textGeneration: {
+ generateCommitMessage: (input) => {
+ commitInstructions.push(input.policy?.commitInstructions);
+ return Effect.succeed({ subject: "Update readme", body: "" });
+ },
+ },
+ });
+
+ yield* runStackedAction(manager, { cwd: repoDir, action: "commit" });
+
+ NodeFS.writeFileSync(NodePath.join(repoDir, "CLAUDE.md"), "Mention the Claude provider.\n");
+ NodeFS.writeFileSync(NodePath.join(repoDir, "README.md"), "hello again\n");
+ yield* runStackedAction(manager, { cwd: repoDir, action: "commit" });
+
+ expect(commitInstructions[0]).toContain("Local AGENTS.md:\nUse imperative subjects.");
+ expect(commitInstructions[0]).not.toContain("Local CLAUDE.md:");
+ expect(commitInstructions[1]).toContain("Local CLAUDE.md:\nMention the Claude provider.");
+ }),
+ );
+
it.effect("falls back when the dedicated source control writer is unavailable", () =>
Effect.gen(function* () {
const repoDir = yield* makeTempDir("t3code-git-manager-");
diff --git a/apps/server/src/git/GitManager.ts b/apps/server/src/git/GitManager.ts
index 333b5a3fe1a..bb180042c03 100644
--- a/apps/server/src/git/GitManager.ts
+++ b/apps/server/src/git/GitManager.ts
@@ -863,7 +863,10 @@ export const make = Effect.gen(function* () {
? [["Recent commit subjects from this repository:", ...subjects].join("\n")]
: []),
...(agentInstructions ? [`Local AGENTS.md:\n${agentInstructions}`] : []),
- ...(claudeInstructions ? [`Local CLAUDE.md:\n${claudeInstructions}`] : []),
+ // CLAUDE.md is often a symlink or copy of AGENTS.md; skip the duplicate.
+ ...(claudeInstructions && claudeInstructions !== agentInstructions
+ ? [`Local CLAUDE.md:\n${claudeInstructions}`]
+ : []),
].join("\n\n");
if (!examples) {
return repositoryConventionsTextGenerationPolicy;