writing-nix
This skill provides rules for writing clean, efficient Nix code, focusing on module design, explicit bindings, and performance patterns.
Install
mkdir -p .claude/skills/writing-nix && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/6787" && unzip -o skill.zip -d .claude/skills/writing-nix && rm skill.zipInstalls to .claude/skills/writing-nix
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Write idiomatic and maintainable Nix code. Use when creating or refactoring Nix expressions, Home Manager or NixOS modules, overlays, packages, and flake outputs, especially when deciding module merge semantics, binding locality, option defaults, and conditional structure.Key capabilities
- →Enforces explicit module system merging over decorative abstractions
- →Applies linting rules for Nix bindings like let/inherit
- →Validates module options using mkDefault/mkForce priority
- →Identifies anti-patterns like with and rec in expressions
- →Optimizes performance via strict folds and file set operations
How it works
It applies a structured reference-based checklist (module style, bindings, assertions, anti-patterns) to evaluate and refactor Nix expressions for clarity and maintainability.
Inputs & outputs
When to use writing-nix
- →Writing NixOS modules
- →Refactoring flake outputs
- →Optimizing Nix expressions
- →Implementing Home Manager configurations
About this skill
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
- Read repository docs for local constraints and layout. Treat them as authoritative; use this skill's defaults where repository canon is silent.
- Identify the task shape and load only the relevant reference files:
- references/module-style.md: module templates,
option design, merge priority,
mkDefault,mkForce, andmkMerge. - references/bindings.md:
letlocality, single-use bindings,inherit (...), and bulky inline expressions. - references/assertions-and-warnings.md: when to fail evaluation, when to warn, and when simpler typing is better.
- references/anti-patterns.md:
with,rec, chained conditionals, and other style hazards that should usually block a proposed refactor. - references/performance-patterns.md:
strict folds and
genericClosure, path coercion vslib.fileset, string handling, attribute-path lookups, and import-cost awareness.
- references/module-style.md: module templates,
option design, merge priority,
- Apply the narrowest ruleset needed. Do not bulk-load every reference file unless the task truly spans them.
Always Prefer
- Explicit
lib.usage, a justified localinherit (...), or expression-localwithwhen it is narrower and clearer than repeated prefixes. - Local bindings over hoisted helper names.
- Module-system merging over hand-written
if/else. - Small, intentional option surfaces.
- Normal assignments,
mkDefault, andmkForceused intentionally by merge priority.
Style Authority
- Treat repository contributor docs as authority for local Nix conventions.
- Use this skill as default guidance where repository canon is silent.
- If two repository-local sources conflict, call out conflict before editing.
- Avoid top-level, block-level, and wide-scope
with. Expression-localwithis acceptable for a single value when it reduces noisy repetition and keeps scope obvious, such astype = with lib.types; nullOr (either str path);. - Do not request a style fix solely because new code uses expression-local
with lib.types;in onetype = ...;assignment. - 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).
When not to use it
- →When writing short, disposable scripts where full module rigor is overkill
- →When forced to work within strict external style requirements that contradict this guide
Prerequisites
Limitations
- →Does not automatically fix logic errors in the code
- →Requires manual selection of the relevant reference file for large projects
- →Style rules may conflict with established legacy codebases
How it compares
It prioritizes 'boring' and explicit Nix over complex abstractions, directly reducing evaluation debt and dependency confusion.
Compared to similar skills
writing-nix side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| writing-nix (this skill) | 1 | 2mo | No flags | Advanced |
| ansible-fix | 0 | 5mo | Review | Beginner |
| cloudflare-manager | 25 | 9mo | Review | Intermediate |
| storage-networking | 6 | 7mo | Review | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
ansible-fix
diegosouzapw
ALWAYS use this skill immediately after running 'ansible-galaxy init' to create a new Ansible role. Also use when the user asks to fix ansible-lint errors or when ansible-lint output shows fixable issues like yaml[comments], schema[meta], meta-incorrect, name[play], or role-name[path] violations.
cloudflare-manager
qdhenry
Comprehensive Cloudflare account management for deploying Workers, KV Storage, R2, Pages, DNS, and Routes. Use when deploying cloudflare services, managing worker containers, configuring KV/R2 storage, or setting up DNS/routing. Requires CLOUDFLARE_API_KEY in .env and Bun runtime with dependencies installed.
storage-networking
pluginagentmarketplace
Master Kubernetes storage management and networking architecture. Learn persistent storage, network policies, service discovery, and ingress routing.
aws-solution-architect
alirezarezvani
Design AWS architectures for startups using serverless patterns and IaC templates. Use when asked to design serverless architecture, create CloudFormation templates, optimize AWS costs, set up CI/CD pipelines, or migrate to AWS. Covers Lambda, API Gateway, DynamoDB, ECS, Aurora, and cost optimization.
terraform-module-library
wshobson
Build reusable Terraform modules for AWS, Azure, and GCP infrastructure following infrastructure-as-code best practices. Use when creating infrastructure modules, standardizing cloud provisioning, or implementing reusable IaC components.
cloud-architect
sickn33
Expert cloud architect specializing in AWS/Azure/GCP multi-cloud infrastructure design, advanced IaC (Terraform/OpenTofu/CDK), FinOps cost optimization, and modern architectural patterns. Masters serverless, microservices, security, compliance, and disaster recovery. Use PROACTIVELY for cloud architecture, cost optimization, migration planning, or multi-cloud strategies.