Why I Still Write Small Command-Line Tools

Most of the useful programs I have written in the last few years do not have a window, a menu, or an account. They take a file or a few arguments, do one job, and print something I can pipe into the next step. I still write tools like that, even though it is unfashionable, because they fit the way I actually work: in a terminal, with other small programs, on more than one machine.

A shell prompt on a monitor
Image: Ehud Neuhaus, CC0 1.0

A small tool has a clear edge

A laptop keyboard on a programming desk
Image: Wonderlane, CC0 1.0

A command-line tool with a single purpose is easy to test and easy to throw away. If it is wrong, I notice immediately. If it is right, I can use it from a script, from a key binding, or from a directory I will not remember in six months. A graphical tool, or a web form, tends to grow settings pages and hidden state. That can be warranted, but it is a poor default for a problem I will have again next Tuesday.

I also like that a small program can be read in one sitting. When I return to it after a year, I can usually see what it does without reconstructing a framework. That is the same pleasure I take in reading other people’s code: a short, honest file is a kindness to the next reader, who is often me.

What I will not put in a one-off script

Not everything belongs in a twenty-line utility. If a job needs a careful interface for someone else, or has to hold on to years of data, I will reach for a larger system, and sometimes for a hosted service — until the reasons in when to leave a cloud service and host it yourself start to pile up. The command line is not a moral position. It is a good shape for tools I will compose.

The practical habit is to write the first version in the language I can maintain when I am tired, to keep the flags few, and to put a sentence at the top of the file saying what the tool is for. I keep a short list of these programs in the same place I keep other notes, which is part of how I keep a personal knowledge base without the ceremony. When a tool has been used three times, it has earned a name and a home in the path. Until then, it can stay in a scratch folder.

I do not think everyone should work this way. I do think that if you already live in a terminal, writing a small, sharp program is still one of the most satisfying ways to solve a recurring annoyance, and one of the least likely to leave you with a project you are obliged to keep feeding.