agentleFS
gurinderugurinderu/craft/skills/nix-review/SKILL.md

nix-review

Skill1 starsChanged 43 days agoMITView on GitHub

Nix code-review rubric — the flake quality gate (nix flake check, formatter --check, statix, deadnix, nix build/eval), a severity-tiered checklist (purity, reproducibility, injection, packaging, dev-env, modules; language-independent severity, classes and sweeps come from review-rules), the Approve/Warning/Block verdict (at most Warning when the gate could not be established; INCOMPLETE only when the review itself could not run), the "what proves what" table, and posting findings on a PR (defects only; doubtful ones go to the human first). Use when reviewing Nix code or a flake, checking for impure derivations or IFD, or deciding if a change is mergeable. Its review workflow needs Claude Code's Workflow tool (not in Codex or OpenCode); the rubric applies anywhere. Triggers: nix review, review flake, statix, deadnix, nix flake check, impure derivation, IFD.

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 3 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If the workflow fails with at workflow.js:<line>:<column>, that place is in the bundled engine: node "<this skill's base …

    line 17
  2. Very specific:

    If gh is missing, unauthenticated, offline, or finds no PR → fall straight through to the local gate (never fail on detection).

    line 71
  3. Distinctive:

    Read the diff and report findings anyway, but the verdict is Warning: say the gate was not established locally, name what was missing, …

    line 111
  4. Distinctive:

    If any signal is red (a local run, or a red CI check that runs it), stop and report — don't review further.

    line 119
  5. Very specific:

    Read flake.lock to resolve the real revisions for inputs the diff touches.

    line 128
  6. Very specific:

    Import-from-derivation (IFD) forcing eval-time builds, or --impure reliance (REP-002)

    line 178
  7. Distinctive:

    Every finding (lens or seed) is checked before it can be Confirmed:

    line 254
  8. Very specific:

    Mechanical first: if a tool can decide the finding (a statix/deadnix rule, a failing nix eval), the verifier re-runs it scoped to the cited …

    line 256

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Nix Review

The rubric for reviewing Nix changes: run the mechanical gate first, then read the diff against the severity checklist, then issue a verdict. This is the knowledge; the craft:nix-reviewer agent applies it to an actual diff and reports back.

The review entry point is the craft:review workflow (the craft CLI's review, driven from Claude Code): it sends each changed Nix file to the Nix profile, scout-scales depth to the diff, fans out the lenses below, grounds findings in tool output, and verifies each one. This skill is the rubric its Nix lenses (on the review's task agent) and the craft:nix-reviewer agent, run by hand, apply. If the workflow fails with at workflow.js:<line>:<column>, that place is in the bundled engine: node "<this skill's base directory>/../../integrations/shared/engine-source-map.mjs" review workflow.js:<line>:<column> gives it in the plugin's source. Once a workflow run has ended (completed, failed or stopped — not while you may still resume it), fold its real cost into the records it filed: sh "<this skill's base directory>/../../integrations/shared/craft-cli.sh" runs enrich-cost --run-id <wf_…>, with the run id the Workflow completion names. Best-effort: if it fails, say so in one line and go on.

The workflow recalls the project's active decisions, open questions and project rules for the diff's paths itself, on every launch; priorDecisions (the object argument, never a string, each record with its kind) only adds records the store may not hold yet and never replaces that recall (→ memory, "Before a review"): a finding the project already rejected comes back under Rejected before with who, when and why, one it deferred under Known and deferred, and one a project rule covers (a judge agreed its concern is exactly what the rule accepts; never a Critical) under Covered by project rules, instead of being raised as new. A finding the same judges say goes against an active decision or rule stays in the verdict, listed under Contradicts project memory with the record's id, and is a defect whatever other doubt sign it carries — unless its line is marked not confirmed: then it is a doubt to check (verify it before fixing), and with comment it is also listed under Doubtful, the record named first.

With comment the workflow posts only defects on the PR; a doubtful finding (not confirmed, raised by the compat, intent or api-boundary lens, a design question naming no harm, about rollback, rollout, old replicas, migration or a breaking change, or outside the changed lines) is listed under Doubtful — for the reviewer, not posted and waits for the human: show him that list, and act on his choice for each — ask the author, post as a defect, or do not post — as craft:addressing-findings says (its doubtful findings section).

When to Use

  • Reviewing a diff / PR of Nix code (flakes, packages, NixOS modules, dev shells)
  • Deciding whether changes are safe to commit or merge
  • A self-check before opening a PR

Step 1 — Establish the gate (CI informs, never certifies)

The mechanical gate is non-negotiable: formatter --check, statix check, deadnix, nix flake check, and nix build / nix eval must be green before human-style review is worth doing. You establish each signal yourself, by running its command. CI informs, it never certifies: a green CI check is reported (CI green for <check>), but the signal it covers stays unknown until your own run computes it, and no verdict — Approve least of all — rests on it. A red CI check that runs the command still blocks (required or not — most repos have no branch protection; required-ness governs whether RED blocks a merge, and never turns GREEN into a signal you did not compute).

With no flake.nix, nix flake check, nix eval and nix build have no flake to evaluate: the gate is the linters (step 3) and the formatter (step 2). Both linters run clean — nothing to gate, no gap; one missing, timed out or broken — NOT ESTABLISHED, at most Warning. The formatter check applies whenever the repository names a formatter, with a flake or without, and a red one blocks; with no formatter named it is skipped, and that is no gap.

Establish each signal:

  1. Detect the PR's CI for the current branch:
    gh pr checks --json name,state,bucket,link
    If gh is missing, unauthenticated, offline, or finds no PR → fall straight through to the local gate (never fail on detection).
  2. Formatter — only when the repository names one (see above). If a conclusive check (required or not) whose name matches (alejandra, nixpkgs-fmt, fmt, format) is conclusive:
    • failed → gate red → Block;
    • green → report CI green for <check> · PR #N; the signal stays unknown — run it locally;
    • absent/pending → run locally:
      alejandra --check .        # or: nixpkgs-fmt --check $(find . -name '*.nix')
  3. Linters — always run locally, whatever CI shows (a green CI check only informs):
    statix check
    deadnix --fail
  4. Flake check / build / eval (a flake only) — if a conclusive check (required or not) matching flake-check, nix build, or nix eval is conclusive:
    • failed → gate red → Block;
    • green → report CI green for <check> · PR #N; the signal stays unknown — run it locally;
    • absent/pending → run locally:
      nix flake check
      nix build                  # or: nix build .#<target>
  5. The gate could not be established — the third outcome. No red CI check covers it and nothing could execute locally: nix is not on PATH, flakes are disabled, evaluation cannot fetch its locked inputs (offline, an input unreachable), and no linter (statix, deadnix, a formatter) is installed either. Nothing was evaluated — that is neither red nor green. A green CI check does not change that: it is reported beside a gate that stays NOT ESTABLISHED.

    What happenedGate statusVerdict
    Ran locally and passedPASSEDcontinue
    Failed (a local run, or a red CI check that runs it)FAILEDBlock
    Could not run locally (a green CI check, if any, only informs)NOT ESTABLISHEDWarning at most — never Approve

    Read the diff and report findings anyway, but the verdict is Warning: say the gate was not established locally, name what was missing, report the CI you saw beside it, and say the change is UNVERIFIED, not clean. A Confirmed CRITICAL/HIGH found by reading still wins — that is a Block. A partly unknown gate (statix ran, nix flake check did not) caps the same way: at most Warning, the gap named in the ## Gate line. An unestablished gate is never INCOMPLETE: INCOMPLETE means the review itself could not run (no diff to read, the lenses failed).

If any signal is red (a local run, or a red CI check that runs it), stop and report — don't review further. A green gate — green by your own runs — is the floor, not the ceiling.

Step 1.5 — Resolve flake input context

Review against the input versions the project actually locks, not against nixpkgs-in-the-abstract. An attribute available on nixpkgs 24.05 may have been renamed or removed on the 23.11 this flake locks. Before judging input usage:

  • Read flake.lock to resolve the real revisions for inputs the diff touches.
  • For any nontrivial input the diff exercises, check usage against that revision's API / option set. Version-specific misuse of a NixOS option or nixpkgs attribute is DEP-001 (Medium).
  • Known-stale or floating inputs are a separate axis, caught by REP-001 in Step 2.

Best-effort: skip if there are no external-input changes.

Step 2 — Severity checklist

Review the diff against these tiers. This skill owns only the review process; cite the owning skill for each fix. Each item has a stable ID in the rules.md catalog — cite it in a finding (e.g. INJ-001) so the finding is addressable and dedup-able; novel issues without a catalog ID are still welcome. The tiers are defaults: every finding names its harm, and the harm cap of the review-rules skill (severity.md) bounds its severity — read that skill alongside this one for severity, finding classes and the search sweeps.

  • Purity / reproducibility → nix-packaging, nix-flakes
  • Command injection / untrusted interpolation → nix-packaging
  • Packaging correctness (hashes, meta) → nix-packaging
  • Dev-env config (allowUnfree, overlays) → nix-dev-env
  • NixOS / HM modules (secrets, options) → nixos
  • Maintainability (deadnix, statix, anti-idioms) → nix-dev-env
  • Flake input management → nix-flakes

CRITICAL — block on sight

Security / injection

  • Untrusted value interpolated directly into a build phase or shell script without sanitization (INJ-001)

Purity & secrets

  • Secret embedded as a plaintext string inside a derivation or store path instead of managed by agenix/sops-nix (MOD-001)

HIGH — block unless justified

Purity

  • Impure builtin used in a derivation (builtins.currentTime, builtins.getEnv, <nixpkgs> channel path) — breaks reproducibility (PUR-001)
  • Fetcher missing a fixed output hash (fetchgit/fetchurl without sha256/hash) (PUR-002)

Reproducibility

  • Flake input unpinned or channel-based (no flake.lock entry / follows missing) (REP-001)

Packaging

  • Wrong or missing dependency hash (cargoHash/vendorHash/npmDepsHash) (PKG-001)

MEDIUM — warn, may merge

Reproducibility

  • Import-from-derivation (IFD) forcing eval-time builds, or --impure reliance (REP-002)

Packaging

  • Missing meta (description/license/mainProgram) on a package (PKG-002)

Dev-env

  • allowUnfree/config set in flake.nix but not propagated to nix develop (DEV-001)

Modules

  • NixOS/HM option without a type or default; non-cross-platform assumption (MOD-002)

Dependencies

  • Flake input pin stale or floating where it should be locked (DEP-001)

LOW — optional, never blocks

Maintainability

  • Dead code (deadnix) / anti-idiom (statix) / needless rec/with (MNT-001) — raised only when a harm is named (review-rules severity.md)

Review lenses

The workflow fans the rubric out into independent lenses, each reviewing ONE slice blind to the others (higher recall than one broad pass):

LensSliceOwning skill for the fix
purityimpure builtins, missing hashes, channel pathsnix-packaging
reproducibilityIFD, unpinned inputs, --impure reliancenix-flakes
injectionuntrusted interpolation in build/shell scriptsnix-packaging
packaginghash correctness, meta completenessnix-packaging
dev-envallowUnfree propagation, overlays, shell confignix-dev-env
modulesNixOS/HM option types, defaults, secrets managementnixos
maintainabilitydeadnix, statix, needless rec/with, structural simplificationnix-dev-env
dependenciesstale/floating inputs, version-specific misusenix-flakes
intentdoes the change do what the brief/spec says?specs

Confidence tiers — surface, don't censor

  • Confirmed — located and survived verification; drives the verdict.
  • Suspected — borderline or unverified; surfaced for the author, never changes the verdict.

Report everything you suspect. Borderline findings go to Suspected, not the bin.

Tool grounding (seed findings)

Beyond the gate, the workflow runs real tools scoped to the diff and feeds their output in as seed findings (each still verified): statix check (anti-idioms), deadnix --fail (dead code), nix flake check --all-systems (eval errors, cycle detection), and nix build --dry-run (missing dependencies). Optional tools degrade gracefully when absent. Each seed carries, beside its catalog ruleId, the tool's own rule name as toolRule (the statix code, such as W04) — what tells two lints under one catalog rule (MNT-001) apart. deadnix and the formatter print no rule name, so their seeds carry no toolRule and match a past decision outright only by line, lens and the same title (deadnix names the binding there). A deadnix or statix seed's title is the tool's message verbatim; the report lists the titles of seeds without a toolRule (deadnix always, statix when it printed no code) under Tool finding titles (verbatim) — a decision on one is recorded with the title listed there; a formatter seed is the whole file — line 0, the fixed title "File not formatted: <path>" — and matches by file, lens and title. Two tool seeds at one spot with different titles and no rule name are never merged; another title goes to the match judge and stays raised when the judge gives no verdict.

Premise grounding — cite it or drop the claim

Most findings rest on a premise not visible at the line they cite: "that flake input provides this", "the module default is X", "no other module sets it", "the fetcher is already pinned upstream". Nix makes this especially easy to get wrong — the truth usually lives in a locked input's own source or in a module merged from elsewhere, not in the file under review.

Pin every off-site premise to a file:line you actually opened (the locked input's source included — nix flake metadata / the store path) and report it in the finding's whereChecked. A premise you did not open is not admissible: open it, or drop the claim and report only what the cited line shows. This binds rejection as much as confirmation — dismissing a finding on an unopened "the module already sets that" discards a real bug silently.

An unpinnable off-site premise costs a finding its Confirmed tier — it drops to Suspected, never to refuted. Unsupported is not disproven.

Verification protocol

Every finding (lens or seed) is checked before it can be Confirmed:

  • Mechanical first: if a tool can decide the finding (a statix/deadnix rule, a failing nix eval), the verifier re-runs it scoped to the cited file and the tool's output overrides judgement in both directions. Tool-reported seeds can never be refuted on reasoning alone — only by the tool demonstrably no longer reporting them.
  • Adversarial: skeptics try to REFUTE it (default to refuted when uncertain — except tool-reported seeds, per above). One skeptic by default; three-vote consensus for Critical/High.
  • Self-verification (anti-hallucination): re-read the cited file:line — does the code actually say what the finding claims? A wrong citation drops the finding. A path only reachable from an example overlay or test derivation (not a real build) does NOT drop it — it demotes the confirmed severity one notch.

Step 3 — Verdict

VerdictWhen
Approve ✅every gate signal green by your own runs (a green CI check never counts), no Confirmed CRITICAL/HIGH/MEDIUM
Warning ⚠️Confirmed MEDIUM at most over a gate green by your own runs, or a gate NOT ESTABLISHED or partly unknown (Step 1, item 5) with nothing Confirmed CRITICAL/HIGH — Suspected items listed but don't block
Block ⛔gate red (a local run, or a red CI check that runs the command), or any Confirmed CRITICAL/HIGH
INCOMPLETE 🚫the review itself could not run — no diff to read, or the lenses failed — so nothing was judged; never for a gate that could not be established

Report findings as severity · file:line · [rule-id] · what · why · fix. Cite the rules.md catalog ID when the finding maps to one (e.g. PUR-001); novel findings need no ID. Be specific and cite the line; a finding without a location isn't actionable.

"Gate green / red" is read from Step 1 — green only from your own run; red from your own run or a red CI check that runs the command. Cite which in the ## Gate line of the output, and report a green CI check there as CI green for <check> beside a signal that stays unknown. When the gate could not be established, in whole or in part, the ## Gate line says so (NOT ESTABLISHED — nix not on PATH, with the CI you saw) and the verdict is at most Warning, never Approve.

Proving a claim — what proves what

ClaimProof (run it)Not proof
flake evaluatesnix flake check → exit 0"looks fine"
package buildsnix build .#<pkg> → exit 0eval passing
formatter cleanalejandra --check . / nixpkgs-fmt --check → exit 0"I ran fmt earlier"
no dead codedeadnix --fail → exit 0"looks unused"
no anti-idiomsstatix check → exit 0code review alone
hash correctnix build succeeds with hash presenthash field exists
input pinnedflake.lock entry present for inputfollows set
no IFDnix flake check without --impure → exit 0"shouldn't be IFD"
secret not in storeruntime secret management confirmed (agenix/sops-nix)"looks encrypted"
bug fixedre-run the case that reproduced it → passescode changed

A green CI check (required or not) for the same command is not proof of that command: report it (CI green for <check>) and still produce the fresh signal yourself (see Step 1 — Establish the gate). A red one is proof the command fails.

Boundaries

  • How to package a derivation correctly → nix-packaging (this rubric only flags that it's wrong).
  • How to manage flake inputs / lock files → nix-flakes.
  • How to configure a dev shell → nix-dev-env.
  • How to write NixOS/HM modules or manage secrets → nixos.
  • This skill judges; it does not rewrite. Propose the fix, let the author apply it.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.