writing-nix

编写高效、可维护的 Nix 代码,遵循声明式、显式和隔离性原则,避免使用 with 和递归属性等反模式,通过合理的模块设计与选项类型定义实现配置的可扩展性,结合惰性求值与源码过滤优化性能,采用标准格式与命名规范提升代码一致性。

快捷安装

在终端运行此命令,即可一键安装该 Skill 到您的 Claude 中

npx skills add khaneliman/khanelinix --skill "writing-nix"

Writing Nix

Write boring, explicit Nix that follows this skill’s opinionated style. Prefer module merge semantics, narrow scopes, and simple attrset composition over decorative abstractions.

Quick Start

  1. Read repository docs only for hard constraints or project-specific layout. Do not weaken the style rules in this skill unless the user explicitly asks.
  2. Identify the task shape and load only the relevant reference files:
  3. Apply the narrowest ruleset needed. Do not bulk-load every reference file unless the task truly spans them.

Always Prefer

  • Explicit lib. usage, or a justified local inherit (...).
  • Local bindings over hoisted helper names.
  • Module-system merging over hand-written if/else.
  • Small, intentional option surfaces.
  • Normal assignments, mkDefault, and mkForce used intentionally by merge priority.

Style Authority

  • Treat this skill as the default style guide for Nix code.
  • Use repository docs for hard constraints, integration details, or required module layout, not to dilute the style guidance here.
  • If a repository’s local conventions conflict with this skill, call out the conflict explicitly instead of silently blending the styles.
  • Avoid with lib;.
  • Keep edits surgical; do not clean up unrelated Nix while touching a module.

Validation

After edits, run the most relevant repo checks available for the task (nix fmt, focused eval/build/test, or module-specific validation).

Output Contract

Report:

CHANGES MADE:
- <file>: <what changed and why>

THINGS I DIDN'T TOUCH:
- <file>: <why intentionally unchanged>

POTENTIAL CONCERNS:
- <risk or follow-up checks>