Code: the Unix philosophy
The Unix philosophy (McIlroy, 1978; Raymond, "The Art of Unix Programming", 2003): one program, one job, text as the interface, composition, silence on success, loud failure, policy apart from mechanism; two heuristics and three judges.
About the package
The school. A program is small and busy with one job. Big things are assembled from small ones, joined by plain text: the output of one is the input of another. When there is nothing to say, the program is silent; when it cannot do its job, it refuses at once and loudly.
The authors. Douglas McIlroy; Eric Raymond. Source: M. D. McIlroy, E. N. Pinson, B. A. Tague, "UNIX Time-Sharing System: Foreword", Bell System Technical Journal, 1978; Eric S. Raymond, "The Art of Unix Programming", Addison-Wesley, 2003 (the rules of modularity, composition, separation, silence, repair). The norms below retell the ideas in our own words; they are not quotes.
When to take it. Command-line utilities, scripts, services, libraries called from other programs; agents' tools.
When not to take it. Interactive applications with windows: they have their own school of interface; the rule of silence for them is not about stdout.
Norms
| Norm | What holds | Level | Enforcer |
|---|---|---|---|
| UNX-R01 | One program, one job | SHOULD | judge judges/one-thing.md |
| UNX-R02 | Silence on success | SHOULD | check silent-library |
| UNX-R03 | Failure is loud | SHOULD | check swallowed-errors |
| UNX-R04 | Text as the interface, honest exit codes | SHOULD | judge judges/text-interface.md |
| UNX-R05 | Policy apart from mechanism | MAY | judge judges/policy-mechanism.md |
All norms are in observe mode: the checks print findings and pass, the judges are a procedure for the reviewer. A check you trust on your code is moved by the owner to mode: enforce in the norm's page, and then a finding fails shtuk check.
How to connect
shtuk install <path>/apps/standard/packages/code-unix --dir <project>
shtuk check --dir <project>
shtuk run code-unix review # a prompt for the reviewer over the uncommitted change
shtuk run code-unix review --diff main..HEAD
shtuk run code-unix review src/a.ts src/b.py
The package requires norms-core and code-lib (the shared code-parsing library and shared settings). It is installed on top of Basic.
Settings
Which code to read is the shared page /norms/code.md of the code-lib package: roots (roots), exclusions (exclude), languages, whether to read tests. This package's thresholds are the page /norms/code/code-unix.md:
| Key | Default | What it means |
|---|---|---|
rustLetUnderscore | false | count let _ = call(); in Rust as a swallowed error (UNX-R03) |
strictPass | false | also count except SpecificError: pass in Python (UNX-R03) |
The same page has its own exclude list (path masks from the project root). One place is released by the comment code-allow: <check name> on its line or the line above.
Honestly about the checks
The checks are rough heuristics: regular expressions and bracket parsing for TypeScript/JavaScript, Python and Rust, with no parsers and no dependencies. They err both ways, which is why they stand in observe. The meaning of a norm is held by the judge; the heuristic only shows where to look. 2 checks, 3 judges.
Norms 5
| ID | Norm | Level | Mode | Enforcer |
|---|---|---|---|---|
| UNX-R01 | A program, a command or a module does one job, which is described by one phrase without "and"; a new job is a new program or command, not a flag on the old one. |
SHOULD | observes | judge |
| UNX-R02 | Library code prints nothing to stdout; the program's entry point prints, and only what was asked for. |
SHOULD | observes | sensor |
| UNX-R03 | An error is not swallowed silently: an empty catch, except Exception: pass, Err(_) => {} are allowed only with a comment saying why it can be forgotten. |
SHOULD | observes | sensor |
| UNX-R04 | A program's output is fit to be the input of another: data goes to stdout line by line or as JSON on a flag, messages and trouble go to stderr; exit code 0 only on success. |
SHOULD | observes | judge |
| UNX-R05 | What to do (rules, thresholds, choices) is written apart from how to do it (the mechanism): in settings, in data or in a separate module. |
MAY | observes | judge |
"Blocks": the enforcer stops a violation. "Observes": it only notes it. Level MUST means required; SHOULD means yes by default.
Actions 3
| Name | What it does | File | When |
|---|---|---|---|
| silent-library | Silence on success norm UNX-R02 | checks/silent_library.ts | check |
| swallowed-errors | Failure is loud norm UNX-R03 | checks/swallowed_errors.ts | check |
| review | A prompt for a reviewing agent over the package norms: by diff or by files | actions/review.ts | shtuk run |
shtuk check runs the checks; shtuk run code-unix <name> runs any action. "After install" actions run by themselves only if the package comes from a trusted source.
Pages 6
They go into the project at these paths.
- /norms/code/
- Settings: Code: the Unix philosophy page
- /norms/rules/code-unix/
- One program, one job UNX-R01
- Silence on success UNX-R02
- Failure is loud UNX-R03
- Text as the interface, honest exit codes UNX-R04
- Policy apart from mechanism UNX-R05
Package files 7
They go into .shtukbase/packages/code-unix/; actions run from there.