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.
This commit is contained in:
2025-11-24 14:04:11 -08:00
parent e88f3580e9
commit e218822566
2 changed files with 33 additions and 8 deletions

View File

@@ -223,7 +223,10 @@ in
home.roles = { home.roles = {
base.enable = true; base.enable = true;
development.enable = true; development = {
enable = true;
allowArbitraryClaudeCodeModelSelection = true;
};
}; };
imports = [ imports = [

View File

@@ -18,6 +18,20 @@ in
{ {
options.home.roles.development = { options.home.roles.development = {
enable = mkEnableOption "Enable development tools and utilities"; 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 { config = mkIf cfg.enable {
@@ -46,9 +60,11 @@ in
filename=$(basename "$file" .md) filename=$(basename "$file" .md)
dest="$HOME/.claude/commands/humanlayer:''${filename}.md" dest="$HOME/.claude/commands/humanlayer:''${filename}.md"
# Copy file and remove the "model:" line from frontmatter # Copy file and conditionally remove the "model:" line from frontmatter
# This allows Claude Code Pro to use the default model ${if cfg.allowArbitraryClaudeCodeModelSelection
${pkgs.gnused}/bin/sed '/^model:/d' "$file" > "$dest" then "cp \"$file\" \"$dest\""
else "${pkgs.gnused}/bin/sed '/^model:/d' \"$file\" > \"$dest\""
}
fi fi
done done
@@ -58,13 +74,19 @@ in
filename=$(basename "$file" .md) filename=$(basename "$file" .md)
dest="$HOME/.claude/agents/humanlayer:''${filename}.md" dest="$HOME/.claude/agents/humanlayer:''${filename}.md"
# Copy file and remove the "model:" line from frontmatter # Copy file and conditionally remove the "model:" line from frontmatter
# This allows Claude Code Pro to use the default model ${if cfg.allowArbitraryClaudeCodeModelSelection
${pkgs.gnused}/bin/sed '/^model:/d' "$file" > "$dest" then "cp \"$file\" \"$dest\""
else "${pkgs.gnused}/bin/sed '/^model:/d' \"$file\" > \"$dest\""
}
fi fi
done 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 # Note: modules must be imported at top-level home config