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.
Code: the Unix philosophy
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.