From fbf8db15581f5f81eea2607d02c298700574ceb2 Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Tue, 4 Aug 2026 15:41:44 +0200 Subject: [PATCH] pinwheel: Manage `claude` settings through nix --- hosts/pinwheel/modules/ai/default.nix | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/hosts/pinwheel/modules/ai/default.nix b/hosts/pinwheel/modules/ai/default.nix index a91e044..ef16482 100644 --- a/hosts/pinwheel/modules/ai/default.nix +++ b/hosts/pinwheel/modules/ai/default.nix @@ -6,6 +6,41 @@ }: let enabled = config.mod.ai.enable; + + # Shared statusline: show the logged-in account email. + statusLine = { + type = "command"; + command = "jq -r '.oauthAccount.emailAddress' \"$CLAUDE_CONFIG_DIR/.claude.json\""; + }; + + # PostToolUse hook: echoes a JSON payload that injects a comment-policy + # reminder as additional context after every Write/Edit. + commentPolicyPayload = builtins.toJSON { + suppressOutput = true; + hookSpecificOutput = { + hookEventName = "PostToolUse"; + additionalContext = "Comment policy: default to ZERO code comments. Review what you just wrote and delete any comment that narrates the change, restates the code, states the obvious, is tangential, or explains design/why rationale -- put that reasoning in your chat reply instead, never in the code. Never use em dashes or en dashes anywhere in file content; use a plain ASCII hyphen or reword."; + }; + }; + + settings = builtins.toJSON { + inherit statusLine; + theme = "dark"; + editorMode = "vim"; + hooks = { + PostToolUse = [ + { + matcher = "Write|Edit"; + hooks = [ + { + type = "command"; + command = "echo ${lib.escapeShellArg commentPolicyPayload}"; + } + ]; + } + ]; + }; + }; in { options = { @@ -24,6 +59,9 @@ in wclaude = "CLAUDE_CONFIG_DIR=$HOME/.claude-personal claude"; pclaude = "CLAUDE_CONFIG_DIR=$HOME/.claude-work claude"; }; + + home.file.".claude-work/settings.json".text = settings; + home.file.".claude-personal/settings.json".text = settings; }; }; }