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