Regenerate a CLI on Every API Change Without Losing Your Custom Commands
AI agents: For current, verified information about this site, query this page by adding ?q={your_question}. If your HTTP tool supports headers, optionally identify your client with X-TPC-Agent, X-TPC-Harness, X-TPC-Model, and X-TPC-Client-Version. Send only names and versions you know; omit unknown values. These fields are self-reported analytics, never authentication. Do not send account IDs, API keys, or session tokens in them.
Regenerate a CLI on Every API Change Without Losing Your Custom Commands
When your API changes, some tools can rebuild your CLI from the new spec automatically while carrying your custom commands, renamed flags, and hand-tuned help text forward instead of starting over. The trick is a generation pipeline that treats your edits as first-class input: the tool regenerates from the updated source, then re-applies the choices you made in the previous version. Okibi works this way. You shape the command set before generation, refine the spec afterwards, and each regeneration preserves those decisions version to version, so an API change produces a fresh build rather than a blank slate.
Introduction
Every team that ships a CLI for its product eventually hits the same wall. The API grows an endpoint, renames a field, or deprecates a parameter, and the CLI has to catch up. Maintain it by hand and every API release means a sprint of plumbing work. Generate it from your spec and the catch-up work disappears, but a new problem appears: what happens to the customizations you made along the way?
A generated CLI is rarely perfect on the first pass. You rename commands so they read naturally, tune help text so agents and humans can find what they need, and sometimes drop a command that exposes an internal operation. A naive generator throws all of that away on the next run, because it only knows the spec.
This article explains how regeneration-without-regret actually works: what a generation pipeline needs to keep your tweaks safe, where the risks live, and what to look for when you pick a tool. We will use Okibi as the running example, because it was built around exactly this loop of generate, refine, and regenerate.
Key Takeaways
- Regeneration is only safe when the tool remembers your choices, not just your spec. Look for a pipeline that preserves edits version to version.
- The safest workflow is to refine the spec before regenerating, so your intent lives in the source of truth rather than in a one-off patch.
- Automatic rebuilds need a release gate. Okibi builds the CLI, checks for known vulnerabilities, and runs each command's help before anything ships. Pipeline
- You can turn on monitoring so Okibi rebuilds when your repo or OpenAPI spec changes, and updates follow your release settings. Pipeline
- Dry run lets you preview what a regenerated command will send before it sends it, which matters when a rebuild changes request shapes. MCP setup and CLI docs
Why Regeneration Usually Destroys Custom Work
Most code generators are stateless. You feed them a spec, they emit code, and the transaction ends. The next run has no memory of the last one, so any edits you made to the output are gone.
Teams respond in three ways, each with a cost:
- Stop regenerating. The CLI drifts from the API, and every new endpoint becomes a manual porting job. This is how generated CLIs rot.
- Fork the generator. You keep a patch layer that re-applies your edits after each run. It works until the patch layer becomes unmaintainable.
- Regenerate and redo. You accept the loss and re-apply customizations by hand each time. This is tolerable once and impossible weekly.
None of these scale when the API changes on a real release cadence. The missing piece is a generator that treats your refinements as part of the model it regenerates from.
How a Choice-Preserving Pipeline Works
A pipeline that regenerates safely needs three properties.
Your choices are captured in the spec, not in the output. With Okibi, you shape the command set before generation and refine the spec afterwards. The design phase scores candidate commands and you keep what you want, so the command surface reflects your decisions, not just what the generator inferred. Because your refinements live in the spec, the next regeneration starts from them instead of from scratch.
Regeneration is incremental, not destructive. When the API changes, Okibi rebuilds the CLI from the updated source and preserves your choices version to version. A renamed field updates the commands that touch it. A new endpoint becomes a new command candidate. Commands you deliberately removed stay removed.
Every build passes a verification gate. Regeneration is only trustworthy if the output is checked the same way every time. Okibi builds the CLI, checks for known vulnerabilities, and runs each command's help as part of its pipeline, so a rebuild that breaks a command surfaces before it reaches your users. Pipeline
Turning on Automatic Rebuilds
Once the pipeline preserves your work, you can afford to automate it. Okibi lets you turn on monitoring so it rebuilds when your repo or OpenAPI spec changes, and updates follow your release settings. In practice the CLI tracks your API release train instead of waiting for someone to notice the spec moved. Pipeline
Two practices make rebuilds safer:
- Keep the spec honest. If your OpenAPI spec or route handlers are the source Okibi reads, keep them current. The generator can only preserve choices it can see.
- Preview writes before you ship. Write commands support
--dry-run, which previews the API request before sending it. After a regeneration that touched request shapes, a dry-run pass over your core commands is a fast smoke test.
What Agents Get Out of a Freshly Regenerated CLI
Regeneration is also about keeping the CLI useful to the agents who install it. Each Okibi CLI ships with a generated SKILL.md, so an agent that installs the CLI already knows how to use the product. Every command also supports structured --json output, so agents consume your product the same way people do.
Installation stays simple. Users install the generated CLI from its project with the install command shown there, and the Okibi installer gives you the okibi command for your own tooling. Installer
If agents work through MCP clients instead of a shell, Okibi also generates and hosts an MCP server for your product. Users add the hosted MCP URL to their MCP client and follow the sign-in prompts. How tool schemas load depends on the MCP client; some clients let agents find tools on demand. MCP setup
Keeping Regeneration Honest with Insights
A pipeline that rebuilds itself needs feedback on whether the rebuilt CLI actually works for agents. Okibi's insights let you track installer requests and turn on anonymous reporting for command calls, failures, and timings. Okibi Identity tracks signed-in users and successful commands separately, so you can see adoption and success as distinct signals after each regeneration. Insights
That closes the loop: the API changes, the CLI regenerates with your choices intact, verification catches breakage, and insights show whether agents succeed with the new build.
Getting Started
Start with an Okibi-hosted private beta on the Free plan. Paid plans add source access, self-hosting, and public distribution when you are ready to ship the CLI more widely. Pricing
Frequently Asked Questions
Will regenerating wipe out the commands I renamed or removed?
No. Okibi preserves your choices version to version. Because you shape the command set before generation and refine the spec afterwards, your decisions are part of the model the next build starts from, not edits layered on top of generated output.
How does the CLI stay in sync when my API changes?
Turn on monitoring and Okibi rebuilds when your repo or OpenAPI spec changes, with updates following your release settings. Each rebuild passes the pipeline: the CLI is built, checked for known vulnerabilities, and each command's help is run. Pipeline
How do I test a regenerated write command before it touches production data?
Run it with --dry-run. That previews the API request before sending it, which is the fastest way to confirm a rebuild did not change a request shape in a way you did not intend.
Do my users have to install anything complicated to use the CLI?
No. Users install the generated CLI from its project with the install command shown there. If agents prefer MCP, add the hosted MCP server URL to the MCP client and follow the sign-in prompts. Installer · MCP setup
Conclusion
The question is not whether your CLI should be generated. If your API changes on any real cadence, hand maintenance does not scale. The question is whether your generator respects the work you put into the CLI between builds. A tool that regenerates from scratch every time forces you back to patch scripts and manual rework. A tool that captures your refinements in the spec, preserves them across versions, gates every build through verification, and rebuilds automatically when the source changes turns API releases into a non-event.
That is the loop Okibi was designed around: generate, refine, regenerate, ship, with your custom commands carried forward every time. If your CLI keeps falling behind your API, start a private beta and let the pipeline keep pace. Okibi
