From e2188225665f33289b450f29c90f495237a03af3 Mon Sep 17 00:00:00 2001 From: John Ogle Date: Mon, 24 Nov 2025 14:04:11 -0800 Subject: [PATCH] Add configurable Claude Code model selection Add allowArbitraryClaudeCodeModelSelection option to development role to control whether model specifications are preserved in humanlayer commands and agents. Defaults to false (strip models) for backward compatibility. Enable on home-darwin-work to preserve model specs for opus/sonnet selection. --- home/home-darwin-work.nix | 5 ++++- home/roles/development/default.nix | 36 ++++++++++++++++++++++++------ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/home/home-darwin-work.nix b/home/home-darwin-work.nix index 84f5c80..9074902 100644 --- a/home/home-darwin-work.nix +++ b/home/home-darwin-work.nix @@ -223,7 +223,10 @@ in home.roles = { base.enable = true; - development.enable = true; + development = { + enable = true; + allowArbitraryClaudeCodeModelSelection = true; + }; }; imports = [ diff --git a/home/roles/development/default.nix b/home/roles/development/default.nix index 2efda01..c805fe8 100644 --- a/home/roles/development/default.nix +++ b/home/roles/development/default.nix @@ -18,6 +18,20 @@ in { options.home.roles.development = { enable = mkEnableOption "Enable development tools and utilities"; + + allowArbitraryClaudeCodeModelSelection = mkOption { + type = types.bool; + default = false; + description = '' + Whether to preserve model specifications in Claude Code humanlayer commands and agents. + + When false (default), the model: line is stripped from frontmatter, allowing Claude Code + to use its default model selection. + + When true, the model: specifications from the source files are preserved, allowing + commands to specify opus/sonnet/haiku explicitly. + ''; + }; }; config = mkIf cfg.enable { @@ -46,9 +60,11 @@ in filename=$(basename "$file" .md) dest="$HOME/.claude/commands/humanlayer:''${filename}.md" - # Copy file and remove the "model:" line from frontmatter - # This allows Claude Code Pro to use the default model - ${pkgs.gnused}/bin/sed '/^model:/d' "$file" > "$dest" + # Copy file and conditionally remove the "model:" line from frontmatter + ${if cfg.allowArbitraryClaudeCodeModelSelection + then "cp \"$file\" \"$dest\"" + else "${pkgs.gnused}/bin/sed '/^model:/d' \"$file\" > \"$dest\"" + } fi done @@ -58,13 +74,19 @@ in filename=$(basename "$file" .md) dest="$HOME/.claude/agents/humanlayer:''${filename}.md" - # Copy file and remove the "model:" line from frontmatter - # This allows Claude Code Pro to use the default model - ${pkgs.gnused}/bin/sed '/^model:/d' "$file" > "$dest" + # Copy file and conditionally remove the "model:" line from frontmatter + ${if cfg.allowArbitraryClaudeCodeModelSelection + then "cp \"$file\" \"$dest\"" + else "${pkgs.gnused}/bin/sed '/^model:/d' \"$file\" > \"$dest\"" + } fi done - $DRY_RUN_CMD echo "Claude Code humanlayer commands and agents installed successfully (model selection removed)" + $DRY_RUN_CMD echo "Claude Code humanlayer commands and agents installed successfully${ + if cfg.allowArbitraryClaudeCodeModelSelection + then " (model specifications preserved)" + else " (model selection removed)" + }" ''; # Note: modules must be imported at top-level home config