Skip to main content
Sifr ships two code-quality commands that operate independently of the compiler: sifr fmt for deterministic source formatting and sifr lint for suppressible policy-rule diagnostics. Neither command runs the type-checker or produces binaries, so both are fast to invoke in editors, pre-commit hooks, and CI pipelines.

sifr fmt — format source files

sifr fmt formats .sifr source files using the same parser, AST, and formatter that the Sifr language server uses for editor formatting. The formatter is syntax-aware, deterministic, and idempotent — running it twice produces the same output as running it once.
When no files are supplied, sifr fmt formats the current directory. File and directory inputs discover .sifr files, respect formatter excludes, and honour .gitignore by default.

Common usage

Flags

Configuration in sifr.toml

Place formatter configuration under the [format] section of sifr.toml.
Supported keys:
Ruff-only keys such as target-version and extension are rejected — Sifr formats .sifr source only. Unknown keys fail deterministically so typos surface immediately.

Formatter pragmas

The formatter respects inline pragma comments at Sifr syntax boundaries:

Style conventions

The formatter canonicalises Sifr’s ownership-qualifier syntax. For example:
Editor formatting is LSP-first. Editors should invoke sifr lsp --stdio and request formatting through standard LSP methods — not call sifr fmt directly. See the LSP page for details.

sifr lint — run policy diagnostics

sifr lint runs Sifr-owned policy rules against your source. It operates independently of the compiler — it does not type-check, does not produce binaries, and does not make hard compiler errors suppressible.
When no files are provided, sifr lint checks the current directory. Targets may be individual files, directories, or - for stdin.

Common usage

Flags

Available rules

These are Sifr-owned rule IDs. Python rule IDs, Ruff prefixes, and # noqa comments have no effect in sifr lint.

Configuration in sifr.toml

Place lint configuration under the [lint] section of sifr.toml.

Suppressing a diagnostic inline

Suppress a policy diagnostic on a specific line with a # sifr: ignore[rule-id] comment:
Blanket suppressions (without a rule ID) are rejected. Unknown rule IDs in suppression comments are themselves reported as policy diagnostics. Use --ignore-suppressions to run lint as if no inline comments were present.

Fixing violations automatically

sifr lint --fix writes all available safe fixes to disk. Use --diff first to preview what would change:
Hard compiler diagnostics are never auto-fixed. Only suppressible policy rules are eligible.

Exit codes