/cc-skills-nix:nix-treefmt-formatterfrom cc-skills-nix
treefmt-nix formatter for Nix flakes — `formatter.nix` via `treefmt-nix.lib.evalModule` (build.wrapper + build.check), lint→format ordering with priorities (deadnix→nixfmt, shellcheck→shfmt, ruff-check→ruff-format), and the format check wired into `nix flake check` via passthru.tests. Apply when writing or editing formatter.nix / treefmt config in a flake; when adding a language formatter (Go, Python, shell, YAML, TOML, Markdown, just); when `nix fmt` misbehaves, formats vendored files, or skips files (excludes, on-unmatched, default excludes); when CI passes `nix flake check` but formatting is actually broken (check never ran); when deadnix deletes wanted lambda args. Do NOT use for non-treefmt formatting setups, editor/IDE format-on-save config, or choosing code style rules of a language.
Ships in cc-skills-nix. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
One formatter.nix gives you nix fmt (format everything) and a format check that makes nix flake check fail on unformatted code. Requires inputs.treefmt-nix (with inputs.nixpkgs.follows = "nixpkgs").
In a blueprint repo, the file lives at <prefix>/formatter.nix and is auto-wired: it becomes the flake formatter output and the package formatter, whose passthru.tests land in checks.<sys>.pkgs-formatter-*. Without blueprint, export build.wrapper as formatter.<sys> and build.check under checks yourself.
{ flake, inputs, pkgs, ... }:
let
mod = inputs.treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs = {
# nix — deadnix strips dead code, then nixfmt formats
deadnix.enable = true;
deadnix.no-lambda-pattern-names = true; # don't break callPackage-style { pkg1, pkg2, ... } patterns
deadnix.priority = 1;
nixfmt.enable = true;
nixfmt.priority = 2;
# add per-language blocks here (see reference)
};
};
wrapper = mod.config.build.wrapper;
in
wrapper // { passthru = wrapper.passthru // { tests.check = mod.config.build.check flake; }; }
build.check is treefmt-nix's own check derivation (function: source tree → package): it copies the tree, git init && git add && git commit, runs treefmt, and fails printing the diff if git detects changes. Hermetic, so one nix flake check covers builds, tests and formatting in a single CI job. Older repos hand-roll the same thing as a pkgs.runCommand copying ${flake} — equivalent, just more code to maintain.
treefmt-nix.lib.mkWrapper pkgs settings is the wrapper-only shorthand; use evalModule when you also want build.check (or build.configFile) from one evaluation.
passthru.tests, not meta.testsBlueprint (and nixpkgs convention) collects package tests from passthru.tests only. A formatter ending in
formatter // { meta = formatter.meta // { tests = { check = check; }; }; } # WRONG
evaluates fine, nix flake check stays green — and the check never runs. Symptom: nix eval .#checks.<sys> --apply builtins.attrNames lists pkgs-formatter but no pkgs-formatter-check. Fix is the last line of the template above. Verify after any edit:
nix eval .#checks.x86_64-linux --apply builtins.attrNames # must contain "pkgs-formatter-check"
nix build .#checks.x86_64-linux.pkgs-formatter-check -L # must actually run treefmt
priority orders lint before format. treefmt runs formatters sharing files in ascending global priority, ties broken by name: deadnix (1) → nixfmt (2); shellcheck (1) → shfmt (2); ruff-check (1) → ruff-format (2). Every program module exposes programs.<name>.priority (also includes, excludes, package).settings.formatter.<name>.pipeline does not exist. Many real formatter.nix files carry pipeline = "nix" lines; neither treefmt v2 nor treefmt-nix defines that option — inert config, silently dropped. Ordering comes from priority alone.settings.excludes for repo-wide globs (settings.global.excludes is the renamed old spelling — still works, warns); programs.<name>.excludes per formatter; and enableDefaultExcludes (default true) already excludes *.lock, *.patch, package-lock.json, go.mod/go.sum, .gitignore/.gitattributes, LICENSE — don't re-add those, and set it false if you actually want them formatted.settings.excludes = [ ".specify/**" ".agents/**" ".claude/**" ]; — otherwise every upstream refresh becomes a format conflict.includes for non-*.sh files: [ "*.sh" "*.bash" "*.envrc" "*.envrc.*" ] (add "bin/*" if you keep scripts there), on BOTH shellcheck and shfmt.settings.on-unmatched = "warn" (levels debug…fatal) to see them; "fatal" turns uncovered files into a hard error.nix fmt walks git ls-files --cached --others --exclude-standard — tracked plus untracked non-ignored files. The check is stricter: its copy of flake contains only tracked files, so an untracked file can be formatted locally yet invisible to the check until git add.projectRootFile defaults to .git/config in treefmt-nix; blueprint-style repos set "flake.nix". The wrapper finds the root by walking up, so nix fmt works from any subdirectory.treefmt is on PATH: perSystem.self.formatter (blueprint) or build.wrapper.treefmt in CI without nix? treefmt --ci = --no-cache --fail-on-change plus CI-suited settings. Stale cache locally: treefmt --clear-cache.Per-language programs blocks (go, python, shell, yaml, json, toml, markdown, just, lua) and the non-blueprint wiring: references/languages.md.
What SKILL.md sets; muted values are Claude Code's defaults
6 skills in this plugin
/nix-blueprintnumtide/blueprint — Nix flake framework that maps a fixed directory structure to flake outputs with zero glue code. Apply when a repo's flake.nix calls `inputs.blueprint { ... }`; when deciding where a package, devshell, host, module, check or template file must live; when a package/devshell/host is missing from `nix flake show` or `nix build` says the attribute doesn't exist; when adding the `prefix` option; when writing packages/<name>/default.nix, devshell.nix or modules/<class>/<name>.nix. Do NOT use for generic Nix flakes without blueprint (hand-written outputs, flake-parts, flake-utils), for nixpkgs contributions, or for NixOS module semantics unrelated to file placement. Prefer nix-project-scaffold for creating a NEW project, nix-treefmt-formatter for formatter.nix internals, and nixos-host-provisioning for adding hosts with disko/facter./nix-oci-imageBuilding and publishing OCI/Docker container images from Nix — dockerTools.buildLayeredImage over a buildEnv (app + cacert), non-root numeric User for Kubernetes runAsNonRoot, version-derived tags, and pushing with skopeo (docker-archive → OCI) to registries like Zot that reject `docker push`. Apply when adding a container image output to a flake; when writing packages/docker/*.nix or dockerTools code; when a Nix-built image fails TLS (missing CA bundle), lacks PATH, or runs as root; when pushing ./result to a private/homelab registry fails; when wiring an image build+push recipe into a justfile or CI. Do NOT use for Dockerfile-based builds, docker-compose, or Kubernetes manifest authoring.Other plugins' skills for the same job
npx claudepluginhub aldoborrero/skills --plugin cc-skills-nix