LinuxCommandLibrary

snakefmt

Format Snakemake workflow files

TLDR

Format Snakefile

$ snakefmt [Snakefile]
copy
Check formatting
$ snakefmt --check [Snakefile]
copy
Format directory
$ snakefmt [workflow/]
copy
Show diff
$ snakefmt --diff [Snakefile]
copy
Set line length
$ snakefmt -l [100] [Snakefile]
copy
Format stdin
$ cat [Snakefile] | snakefmt -
copy
Verbose output
$ snakefmt -v [Snakefile]
copy

SYNOPSIS

snakefmt [--check] [--diff] [-l length] [options] files

DESCRIPTION

snakefmt is an opinionated code formatter for Snakemake workflow files. It enforces a consistent style across Snakefiles and associated rules files, handling both standard Python syntax and Snakemake-specific extensions like rule, checkpoint, and module blocks.
The formatter is built on top of Python's black formatter, using the same default line length of 88 characters and similar formatting philosophy. It understands Snakemake's domain-specific syntax, correctly formatting rule parameters like input, output, params, and shell while preserving semantic meaning.
Check mode (--check) verifies formatting without modifying files, returning a non-zero exit code if changes are needed, which is useful for CI pipelines. Diff mode (--diff) previews the exact changes that would be made before committing to them.

PARAMETERS

--check

Check only, no changes.
--diff
Show changes.
-l, --line-length N
Max line length.
-v, --verbose
Verbose output.
--include PATTERN
Include pattern.
--exclude PATTERN
Exclude pattern.
-
Read from stdin.

CAVEATS

Snakemake-specific. May need adjustment for complex rules. Black-based formatting style.

HISTORY

snakefmt was created for the Snakemake workflow management system. It brings consistent formatting to bioinformatics pipelines.

SEE ALSO

snakemake(1), black(1), python(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community