Craft

6 min read

The boring parts of a command-line tool

Exit codes, help text, colour that turns itself off, and other details that make a tool feel finished.

The interesting part of a command-line tool is what it does. The part people remember is everything around it.

Say what you did

Every command in Tern prints exactly what changed. Not done, not success: the flag name, the old value and the new one.

Respect the pipe

If output is going to another program, drop the colour and the decoration. If a person is reading it, add them back. Check whether standard output is a terminal, once, at the start.

Exit codes are an interface

Zero means it worked. One means you did something wrong. Two means the tool did. Write it down in the help text and never change it.

Written by

Iri Halvorsen, software engineer in Bergen

mail iri

Found a bug in my thinking? Tell me.

$ subscribe --notes

New notes by email, when there are any. About one a month.

Iri Halvorsen

Software engineer

Bergen, Norway

Open to work from January 2027

Colophon

Set in Geist and Geist Mono

Built in Framer

No tracking, no cookie banner

buildlog_

© 2026 Iri Halvorsen. All demo work is fictional.

exit 0

Create a free website with Framer, the website builder loved by startups, designers and agencies.