Stanza

Getting Started

Install Stanza, then run a first check and fix.

Install

Stanza is the npm package @ryuugg/stanza. The install pulls the native binary for your os, cpu and libc from one of its platform packages, such as @ryuugg/stanza-darwin-arm64.

npx @ryuugg/stanza --check src    # run once without installing
npm i -g @ryuugg/stanza           # put stanza on your PATH

The binaries cover macOS and Linux. There is no Windows binary: run Stanza inside WSL.

First Run

Check

Given this file at src/publish.ts:

src/publish.ts
function publish(draft: Draft) {
  if (!draft.title) throw new Error("title required");
  const slug = slugify(draft.title);
  if (exists(slug)) throw new Error(`${slug} is taken`);
  save(draft, slug);
  notify(draft.author);
}

stanza --check src reports what it would change, and changes nothing:

Output
src/publish.ts:3:3: after-guard: add a blank line after the guard above, a new step starts here
src/publish.ts:5:3: after-guard: add a blank line after the guard above, a new step starts here

It exits 1 when it finds something and 0 when the files are clean. Output and Exit Codes covers every line it can print.

Fix

stanza --fix src applies every rule it can decide on its own, in place:

function publish(draft: Draft) {
  if (!draft.title) throw new Error("title required");

  const slug = slugify(draft.title);
  if (exists(slug)) throw new Error(`${slug} is taken`);

  save(draft, slug);
  notify(draft.author);
}

Each guard now closes its step. A few rules only report, since fixing them needs a judgment Stanza leaves to you; Rules lists which.

Check Again

Run stanza --check src again. It prints nothing and exits 0.

Run It Automatically

  • Claude Code formats each Write before it lands, each Edit right after, and the rest when a turn ends.
  • Codex fixes each file it patches, and every changed file when a turn ends, yours included.
  • Pre-Commit Hook checks what is staged before each commit.
  • Editors formats a buffer on save.
  • Existing Codebases holds new changes to the rules without reformatting old code.

On this page