claude-code: add support for output styles

Adds an option to populate the output_styles directory,
which is used by Claude Code to make custom output styles available.
This commit is contained in:
Rane 2026-02-22 14:44:34 +11:00 committed by Austin Horstman
parent 920c07c691
commit bff85cb66b
5 changed files with 73 additions and 1 deletions

View file

@ -293,6 +293,29 @@ in
example = lib.literalExpression "./hooks";
};
outputStyles = lib.mkOption {
type = lib.types.attrsOf (lib.types.either lib.types.lines lib.types.path);
default = { };
description = ''
Custom output styles for Claude Code.
The attribute name becomes the base of the output style filename.
The value is either:
- Inline content as a string
- A path to a file
In both cases, the contents will be written to .claude/output-styles/<name>.md
'';
example = lib.literalExpression ''
{
concise = ./output-styles/concise.md;
detailed = '''
# Detailed Output Style
Contents will be used verbatim for the detailed output format.
''';
}
'';
};
skills = lib.mkOption {
type = lib.types.attrsOf (lib.types.either lib.types.lines lib.types.path);
default = { };
@ -520,7 +543,13 @@ in
lib.nameValuePair ".claude/skills/${name}/SKILL.md" (
if lib.isPath content then { source = content; } else { text = content; }
)
) cfg.skills;
) cfg.skills
// lib.mapAttrs' (
name: content:
lib.nameValuePair ".claude/output-styles/${name}.md" (
if lib.isPath content then { source = content; } else { text = content; }
)
) cfg.outputStyles;
};
};
}

View file

@ -17,4 +17,6 @@
claude-code-commands-path = ./commands-path.nix;
claude-code-skills-path = ./skills-path.nix;
claude-code-mixed-content = ./mixed-content.nix;
claude-code-output-styles = ./output-styles.nix;
claude-code-output-styles-not-set = ./output-styles-not-set.nix;
}

View file

@ -0,0 +1,12 @@
{
programs.claude-code = {
enable = true;
settings = {
theme = "dark";
};
};
nmt.script = ''
assertPathNotExists home-files/.claude/output-styles
'';
}

View file

@ -0,0 +1,25 @@
{
programs.claude-code = {
enable = true;
outputStyles = {
inline-style = ''
# Inline Output Style
This is an inline output style for testing.
It should be written to .claude/output-styles/inline-style.md
'';
path-style = ./test-output-style.md;
};
};
nmt.script = ''
assertFileExists home-files/.claude/output-styles/inline-style.md
assertFileExists home-files/.claude/output-styles/path-style.md
assertFileContent home-files/.claude/output-styles/path-style.md \
${./test-output-style.md}
assertFileRegex home-files/.claude/output-styles/inline-style.md \
'This is an inline output style for testing'
'';
}

View file

@ -0,0 +1,4 @@
# Test Output Style
This is a test output style loaded from a file path.
Used to verify path support functionality for output styles.