{"slug": "137-steps-a-model-in-3-of-them-turning-agent-work-into-a-go-cli", "title": "137 steps, a model in 3 of them: turning agent work into a Go CLI", "summary": "A developer rebuilt infrastructure-upgrade automation as an open source Go CLI called cli-over-llm, whose binary is named yacol, and reports that its flows now contain 137 steps in which a model appears in only 3, with regex rules in a YAML file answering first and the model seeing only lines no rule matched. The CLI enforces a max_model_share cap on the fraction of test cases only the model can answer, and a yacol ratchet command lowers that cap when a new rule takes cases from the model. The coding agent now runs the CLI rather than performing upgrades by hand, and when a step fails the instruction is to fix the CLI and rerun it rather than finish the step manually.", "body_md": "# 137 steps, a model in 3 of them: turning agent work into a Go CLI\n\nMy coding agent used to run my infrastructure upgrades from a skill file, a little differently every time. Now a Go CLI runs them, and the agent's job is to run the CLI and fix it when it breaks.\n\nMy coding agent used to do my infrastructure upgrades by hand. It read a long skill file, ran the commands, judged the output and wrote the PRs. It did it a little differently every time. Two weeks ago I started moving that work into a Go CLI. Today its flows have 137 steps, and a model appears in 3 of them. The agent still runs every upgrade. It just runs the CLI now, and when the CLI is wrong, it fixes the CLI.\n\nI rebuilt the pattern from scratch as my own open source software factory, [cli-over-llm](https://github.com/NahumLitvin/cli-over-llm). The binary is `yacol`, yet another CLI over LLM. Its sample job is labeling release notes, so it runs on any laptop. I never type its commands. I ask the agent in plain words, and the agent runs `yacol`.\n\n## The rule\n\nThe rule came from me, mid-session. The agent had proposed one more LLM \"repair round\" to fix labels its last LLM call guessed wrong. I wrote:\n\nPrompts and LLMs are manual work, and very expensive. They are the fallback for things code cannot handle.\n\nA model call costs money every time. It starts fresh, with no memory of the last run. Code does the same thing every time, and a rerun is free. So the order is fixed. Code goes first. The model gets only what code can't answer. Each model answer is a bug report against the code.\n\n## Rules first, model last\n\nThe example repo labels release note lines as breaking, deprecation, dependency, feature or fix. That's a job people paste into a chat window. Here, regex rules in a YAML file answer first. The model only sees lines no rule matched, and only with `-model`. Its answer must be one of the same five labels. Anything else is an error.\n\n```\nfunc Order() []string {\n\treturn slices.SortedFunc(maps.Keys(Registry), func(a, b string) int {\n\t\treturn cmp.Or(cmp.Compare(rank(a), rank(b)), cmp.Compare(a, b))\n\t})\n}\n```\n\nEvery classifier registers with a class, `Code` or `Model`, and the zero value counts as `Model`. Code always runs first. A line nothing can answer is `unknown`, and the CLI exits 1. A pipeline never reads \"no answer\" as \"nothing breaks\".\n\nThe corpus file carries a cap: `max_model_share`, the fraction of test cases only the model can answer. A test fails when the share goes over it. `yacol ratchet` lowers the cap when a new rule takes cases from the model. Raising it by hand is possible, but it's a one-line diff a reviewer can't miss.\n\n## The agent runs the CLI, and fixes the CLI\n\nThis is the part that changed how I work. The agent's instructions say: you operate the CLI, you do not do its job.\n\n```\nflowchart TB\n  subgraph run[\"agent runs the CLI\"]\n    direction LR\n    a[\"yacol run\"] -->|exit 0| b[\"report as printed\"]\n  end\n  subgraph fix[\"the CLI failed\"]\n    direction LR\n    c[\"yacol case: red\"] --> d[\"one rule\"] --> e[\"yacol check\"]\n  end\n  run -->|unknown or wrong| fix\n  fix -->|rerun| run\n```\n\nWhen an upgrade went wrong without hurting anything, my instruction was short: fix the CLI and rerun it. Never finish the step by hand. A step finished by hand is a step the next run will need a human for again.\n\nThe example repo caught this on its first real run. I pointed it at a sample changelog. It labeled the Markdown heading `## v2.0.0` as an unknown release note. The fix went through the loop. A red test with that exact line, a two-word change to skip headings, green, rerun.\n\n## A failed step is where the rerun starts\n\nThe loop only pays off if a rerun is cheap. So a job is a flow, a YAML list of steps:\n\n```\nsteps:\n  - {id: notes, kind: triage, args: {file: examples/patch-notes.md, block: breaking}}\n  - {id: deploy, kind: exec, cmd: [echo, deploying]}\n  - {id: soak, kind: soak, cmd: [\"true\"], args: {every: 1s, for: 3s}}\nrevert:\n  - {id: rollback, kind: exec, cmd: [echo, rolling back]}\n```\n\n`yacol flow` writes each finished step to a state file next to the flow. Say `notes` fails on a line no rule knows. The agent fixes the CLI and runs the same command again. Finished steps print `skip`, and the run picks up at the failed step. Edit a step and it runs again: the done mark is a hash of the whole step. Every step's arguments are checked before the first one runs. A typo in step 3 can't leave steps 1 and 2 half applied.\n\nThe last step is a soak. One green check right after a deploy proves little. A soak runs its check every interval for the whole window. One red check fails the step.\n\nA flow that changes something has to say how it can go wrong before it loads. Every step kind is read-only or mutating, and a kind with no class counts as mutating. A flow with a mutating step needs a revert list and an STPA block. For each mutating step it names the unsafe type, when it happens, and the step that guards it. STPA has four types: not provided, provided, wrong timing, wrong duration.\n\n```\nstpa:\n  hazard: users run a release that breaks them\n  unsafe:\n    - {action: deploy, type: provided, when: the notes carry a breaking change, guard: notes}\n    - {action: deploy, type: wrong-duration, when: it fails minutes after it looked healthy, guard: soak}\n```\n\nLeave one out and `yacol flow` refuses the file. When I [put STPA questions in my agent's prompt](https://www.catchkill9.dev/posts/stpa-in-my-agent.html), they tied a plain checklist except on timing. Here they're a schema the flow has to pass, and the timing and duration types sit next to every change. `-dry-run` runs only the read-only steps. Each outcome of the example flow is a replay golden: success, resume, breach, revert and more. The flow runs against recorded command results, and the transcript is a file in the repo.\n\n## I measured it\n\nWriting rules is work, so I wanted a number. I had the model label all 17 test lines 3 times each with `claude -p`. Every answer, cost and duration went into a recording. `yacol bench` replays it against the rules.\n\nThe model surprised me. It was right every time it answered, and it never gave one line two different labels. On this corpus the case for code isn't accuracy. A pass cost $5.35 and 4 minutes of model call time, against nothing and under a millisecond. Most of the 31 cents per call is my agent context, which `claude -p` loads on every call. And 3 of 51 calls (6%) came back with no answer. Each rule takes its lines from the model for good. Seven rules took it from every line down to 12%.\n\n## Maintenance is subcommands too\n\nThe same rule applies to the repo itself. A skill file that says \"run lint, then tests, then coverage\" is prose. An agent reads it some of the time. So those steps are subcommands of the binary:\n\n| Command | Does | \n|---|---|\n| `yacol case LABEL LINE` | Adds a test case, exits 1 when no rule covers it, and drops the model flag once one does | \n| `yacol ratchet` | Lowers the model-share cap to the current share | \n| `yacol check` | Lint, tests, 90% coverage floor, deadcode, govulncheck | \n\nCI runs `go run . check`. So does the pre-push hook. So does the agent. One list of gates, in Go, with tests. The skills shrank to \"run this, act on the exit code\". Two things still come from outside the binary. One is the right label for a new line, from me or a model answer I confirmed. The other is the regex for the new rule.\n\n`yacol check` failed twice on its first day. Once on an unchecked `os.RemoveAll`, once on coverage at 88.6% under the floor. Both were real.\n\n## Packages that can't lean on each other\n\nA CLI that replaces judgment has to stay boring. So the package lines are enforced:\n\n- `depguard` rules make imports one-way. The rules package can't import`os` . The maintenance package can't import the model package or the runner that calls it, so no maintenance command reaches a model.\n- An architecture test walks the AST and fails if any package other than its owner names `claude` or`go` as a binary, or imports`os/exec` .\n- A golden file lists every classifier with its class, so adding one is a one-line diff to review.\n- One exec function starts every process, so the timeout default lives in one place. In Go, [a zero timeout means already expired](https://www.catchkill9.dev/posts/go-zero-timeout-is-expired.html) , not no timeout.\n- `deadcode` must print nothing.\n\n## Where I was wrong\n\nIn the real CLI, I added a lint rule banning `exec.Command` outside the one exec function. Lint said 0 issues, and I almost took that as proof.\n\nSo I dropped in a throwaway file that breaks the rule, and ran the linter again. Still 0 issues. An older exclusion, meant for two other patterns, had switched off the whole linter outside two packages. golangci-lint excludes per linter, not per pattern. One `text:` line fixed it. Now every new rule gets broken on purpose once before I believe it.\n\n## What I kept\n\nThe agent didn't get less useful. It moved up a level. It used to be the worker. Now it's the operator and the maintainer. It runs the CLI. When the CLI can't do something, it teaches the CLI. Each fix makes the next run need it a little less.\n\n*Nahum Litvin, Lead Platform Engineer.*", "url": "https://wpnews.pro/news/137-steps-a-model-in-3-of-them-turning-agent-work-into-a-go-cli", "canonical_source": "https://www.catchkill9.dev/posts/cli-over-llm.html", "published_at": "2026-11-28 00:00:00+00:00", "updated_at": "2026-11-28 18:45:13.135783+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "ai-products"], "entities": ["cli-over-llm", "yacol", "NahumLitvin", "Go", "GitHub"], "also_reported_by": [], "takeaway": "Route deterministic cases to code first and let the model handle only unmatched input, then enforce a max_model_share cap in tests and lower it with yacol ratchet as rules absorb cases — the author's flows reached 137 steps with a model in 3.", "recommendation": {"advice": "Move repeatable agent steps into a deterministic CLI, have the agent run the CLI and fix it on failure instead of finishing steps by hand, and cap model-only test cases with a ratcheting threshold.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/137-steps-a-model-in-3-of-them-turning-agent-work-into-a-go-cli", "markdown": "https://wpnews.pro/news/137-steps-a-model-in-3-of-them-turning-agent-work-into-a-go-cli.md", "text": "https://wpnews.pro/news/137-steps-a-model-in-3-of-them-turning-agent-work-into-a-go-cli.txt", "jsonld": "https://wpnews.pro/news/137-steps-a-model-in-3-of-them-turning-agent-work-into-a-go-cli.jsonld"}}