From 548a88b3aa5b223893490104b6d815ad702cfd79 Mon Sep 17 00:00:00 2001 From: "Thing-han, Lim" <15379156+potsrevennil@users.noreply.github.com> Date: Tue, 20 Oct 2026 13:44:55 +0800 Subject: [PATCH 1/2] chore(git): add a trimmed git config for Claude Code sessions Agents run git dozens of times per session, and git's defaults are written for people. users/home/git/agent.gitconfig includes the normal config and turns on short status, and turns off hint text, the pager and color. Claude Code is to select it via GIT_CONFIG_GLOBAL in its settings env, so interactive git is unchanged. Co-Authored-By: Claude Opus 5.5 --- users/home/git/agent.gitconfig | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 users/home/git/agent.gitconfig diff --git a/users/home/git/agent.gitconfig b/users/home/git/agent.gitconfig new file mode 100644 index 0000000..69ad298 --- /dev/null +++ b/users/home/git/agent.gitconfig @@ -0,0 +1,32 @@ +# Git config for AI agent sessions: everything from the normal config, with output trimmed +# for token cost. Claude Code selects it via GIT_CONFIG_GLOBAL in ~/.claude/settings.json; +# interactive shells never read it. +[include] + path = ~/.config/git/config + +# Short status with the branch line, instead of the long form with hint paragraphs. +[status] + short = true + branch = true + +# Hint paragraphs written for people learning git. +[advice] + statusHints = false + detachedHead = false + addEmptyPathspec = false + commitBeforeMerge = false + resolveConflict = false + skippedCherryPicks = false + +[fetch] + output = compact + +[merge] + stat = false + +# Agents read raw output: no pager (delta), no color codes. +[core] + pager = cat + +[color] + ui = never From 6696bc567dbca43580cdd24eba58e955369845af Mon Sep 17 00:00:00 2001 From: "Thing-han, Lim" <15379156+potsrevennil@users.noreply.github.com> Date: Tue, 20 Oct 2026 13:50:30 +0800 Subject: [PATCH 2/2] fix(git): make the agent config fail safe and trim more hints - Link a Nix store copy to ~/.config/git-agent/config, so it exists whatever branch the main checkout is on (a missing GIT_CONFIG_GLOBAL silently drops the whole global config, identity included) and an agent's `git config --global` fails instead of editing this file. - Include ~/.gitconfig too: GIT_CONFIG_GLOBAL replaces both global files. - Silence push-rejected, set-upstream, force-delete-branch and default-branch-name hints. - Drop the pager and color overrides: agents' output is never a TTY, so they changed nothing. Co-Authored-By: Claude Opus 5.5 --- users/home.nix | 2 ++ users/home/git/agent.gitconfig | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/users/home.nix b/users/home.nix index fd63049..810ffb1 100644 --- a/users/home.nix +++ b/users/home.nix @@ -124,6 +124,8 @@ xdg.configFile = { "git".source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/git"; + # A store copy, not out-of-store: see the header of the file. + "git-agent/config".source = ./home/git/agent.gitconfig; "nvim".source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/kapi-vim"; } // pkgs.lib.optionalAttrs (! lite) { "wezterm".source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/wezterm"; diff --git a/users/home/git/agent.gitconfig b/users/home/git/agent.gitconfig index 69ad298..8112873 100644 --- a/users/home/git/agent.gitconfig +++ b/users/home/git/agent.gitconfig @@ -1,8 +1,15 @@ # Git config for AI agent sessions: everything from the normal config, with output trimmed # for token cost. Claude Code selects it via GIT_CONFIG_GLOBAL in ~/.claude/settings.json; # interactive shells never read it. +# +# home-manager links a Nix store copy to ~/.config/git-agent/config (users/home.nix), so it +# exists whatever branch the main checkout is on, and `git config --global` from an agent +# fails instead of editing this tracked file. Edits take effect after `make home`. +# +# GIT_CONFIG_GLOBAL replaces both global files, so include both (a missing one is skipped). [include] path = ~/.config/git/config + path = ~/.gitconfig # Short status with the branch line, instead of the long form with hint paragraphs. [status] @@ -17,6 +24,10 @@ commitBeforeMerge = false resolveConflict = false skippedCherryPicks = false + pushUpdateRejected = false + setUpstreamFailure = false + forceDeleteBranch = false + defaultBranchName = false [fetch] output = compact @@ -24,9 +35,5 @@ [merge] stat = false -# Agents read raw output: no pager (delta), no color codes. -[core] - pager = cat - -[color] - ui = never +# No pager, color or delta overrides: agents' output is never a TTY, so git already skips +# them.