What a small tool prints

Most of the tools I built this year are small. A few hundred lines, one job. What made each one work wasn't what it did. It was deciding who reads its output, and where they read it.

Between October 2025 and October 2026 I wrote a lot of small tools for my own work. Some grew into bigger things. Most stayed small, and this piece is about four of those.

They’re in date order, and each one taught me one thing. Looking back, it was the same thing four times. A small tool is mostly its output. The code that does the work is the easy part. The hard part is the line it prints, the list it shows, or the error it returns, and who’s on the other end.

From the summer on, coding agents wrote much of this code under my direction. That made the question sharper, not softer. An agent will happily write a tool that does the right thing and prints it in a way nobody can use. Deciding the output, and who it’s for, stayed my job.

Plan the refactor in the shape of the thing

The oldest two tools are from October and November 2025, and both were for planning a refactor before moving any files. One prints a folder tree with the noise filtered out. It’s 218 lines. The other is a two-pane editor in React: the tree as it is on the left, a copy of it on the right that I drag files around in. That one is 1,048 lines.

A refactor plan in prose, something like “move the grid pieces under table, pull the helpers into shared”, reads fine and hides everything. Which helpers? Does the sort function go with the grid or the helpers? What’s left in the old folder afterwards? Prose lets you leave all of that unanswered.

A tree doesn’t. Every file has to be somewhere. When I drag the last file out of a folder, I can see the folder is empty. And when I’m done, the difference between the two panes is the plan, file by file. Try it: move a few files into the new folders.

NOW

  • src/grid/
  • src/utils/

PLAN

        Pick or drag a file, then drop it on a folder in the plan. The moves it implies collect here.

        0 moves

        The figure adds the list of moves underneath, because that’s how I read the right pane: as a set of from → to lines I could review before touching anything. The reader of this tool was me, a day before the refactor, and what I needed was a plan I couldn’t be vague in.

        The printer has a different reader: anyone, or anything, that needs a codebase’s shape at a glance. Unfiltered, a tree of a real project is mostly noise, so the filtering is most of the tool.

        stdout for data, stderr for people

        In August I ported my checkout tool from bash to a TypeScript library. The bash version did its job, but a desktop app needed to call it, and you can’t import a bash script. After the port, the command line became a thin layer over exported functions, and the same nine commands exist in both. The story of that tool, and of checking the port with a byte-for-byte diff, is in the parallel checkouts piece. This section is about one detail of it: prompts.

        The CLI asks questions. Which copy to switch to, which base branch to use. That’s fine at a prompt. It’s a bug the moment anything else calls the same function, and three things do:

        • Me, in a terminal. I want the question.
        • A shell substitution, cd $(ws switch --print-path). Whatever lands on stdout becomes the argument to cd. A question printed there gets passed to cd as a folder name.
        • The desktop app, which imports the function. There’s no terminal at all. A prompt waiting on stdin would hang the app’s main process forever, and nothing on screen would say why.

        So two rules. Questions go to stderr, never stdout, so stdout carries only data. And a question is asked only when an option is missing and stdin is a terminal. With no terminal, the function throws a typed error at once, naming the missing option, and the caller decides what to do.

        Toggle the option on each row.

        Terminalws switchTTY
        switchWorkspace(opts)
        stderr
        ? Which copy › search-filter
        stdout
        ~/work/stack-search-filter
        Shellcd $(ws switch --print-path)TTY
        switchWorkspace(opts)
        stderr
        ? Which copy › search-filter
        stdout → cd
        ~/work/stack-search-filter
        Desktop appimport { switchWorkspace }no TTY
        switchWorkspace(opts)
        nobody
        no TTY, so no prompt
        returns
        throws MissingOption('name')

        The app has no terminal. Without the name, the function throws at once instead of waiting for an answer nobody can type. Tick “name given” on that row.

        The rule fits in a few lines. This is a sketch, not the tool’s source:

        async function ask<T>(given: T | undefined, question: Question<T>): Promise<T> {
          if (given !== undefined) return given;           // the caller decided
          if (!process.stdin.isTTY) throw new MissingOption(question.name);
          return prompt(question, { output: process.stderr });  // never stdout
        }

        The shell case is the subtle one. In cd $(…), stdout is captured but stdin and stderr are still the terminal. So the question still shows up, I still answer it, and only the path reaches cd. The same function works in all three places, and none of them needs a flag that says which place it’s in.

        The library is about 2,000 lines, written in one commit. I typed it by hand only 8 times in recent shell history. Most of its calls come from agent skills and the desktop app, which is the point: its main readers aren’t people.

        Sort by what it costs to get back

        Every task I work on gets its own full copy of a three-repo app. In October that caught up with me. The laptop had 11 GB free out of 494. A first report found about 217 GiB I could get back, and 105 GiB of it was one thing: Angular build caches, repeated across 31 copies.

        The obvious cleanup sorts by size and deletes the biggest things first. That’s the wrong order. The question that matters is what each thing costs to get back:

        • Tier 1 is caches. They rebuild themselves on the next build, and the only cost is that build being slower once.
        • Tier 2 costs more. node_modules in copies I haven’t touched for a while, old screenshot runs, container images, a VM image. Getting those back means a fresh install or a re-run, so the script takes them only past an age limit: 21 days idle by default, and it keeps the newest 5 screenshot runs.

        Over both tiers sits one rule: if a copy has a dev server listening, skip it entirely. Whatever is running is in use, however old its files look.

        search-filterskipped: server runningordersloginexportskipped: server runninggrid-perfdialogsdepstooltipsreportsiconsi18nhotfix
        reclaimed: 0.0 GiB of 91.7 (illustrative)

        The default run only reports. Pick a tier to see what it would take, or point at a copy.

        The figure uses twelve made-up copies, but the shape is the real one. One kind of tile, repeated in every copy, is most of the area. On the real machine that was the build cache: 105 of the 217 GiB.

        The output is the main design choice here too. The script’s default is report. It walks the work folder, sizes everything, sorts it into tiers and prints what it would take. Nothing is deleted without --yes. When the script decides a whole copy should go, it doesn’t delete the folder itself. It calls the checkout tool’s own remove, which archives the copy before deleting anything.

        165 lines. The smallest tool here, and the one that gave back the most.

        A 20-character reader

        The last one is barely a tool. Claude Code runs a script of your choice to draw its status line, and mine prints four things on one line: the working directory, the model, a short label for how hard it’s thinking (mapped from the model id), and a context bar.

        The bar is 20 characters wide, with a percentage after it, coloured with ANSI codes. Something like this, though the real one has colour:

        stack-search-filter  ·  opus  ·  deep  ████████████░░░░░░░░ 61%

        This one has the narrowest reader of the four: me, glancing at it for half a second while an agent works. That rules almost everything out. No units, no labels for the fields, nothing that needs reading twice. The directory matters because with about 30 copies on disk, the first question is always which one I’m in. The bar matters because I’d rather see a session running out of context than find out when it does.

        The pattern

        None of this is new. Unix has said “stdout for data” for fifty years, and “dry-run by default” is in every careful script. What changed for me this year is who’s reading. A tool’s output used to go to me. Now it goes to a shell, a desktop app, a skill or an agent at least as often, and each one breaks in a different way when the output is wrong.

        So I start small tools from the other end now. First what it prints, and for whom. Then what it must never print, or never do without asking. The code that does the work comes last, and these days an agent usually writes it.