Article summary
Who uses websites anymore? Not me. I delegate all of my usage to LLMs now so that I can focus on my real passions: funny cat videos and WW2 facts. As such, how can I expect anyone else to use my web app except through a powerful AI intermediary?
The Simplicity of CLI Tools
Yes, I know about MCP servers (more on those tradeoffs later). And I know agents can use browsers now. But nothing beats the simplicity and maturity of CLI tools. You should probably make one for your web app even if you’re not going to release it. Here are some ways I use mine:
- Adding users to my web app and adjusting permissions and access
- Troubleshooting complicated queries
- Uploading and downloading files for testing
- Searching and filtering through content
- Driving features of the web app that I don’t want to create a UI for
The best part is that an agent can inspect your web app’s API and generate a self-contained CLI. Go is a great choice: its Cobra framework includes Markdown documentation generation, which is useful for agents. If you already have a well-defined API, exposing it through CLI commands is largely mechanical work.
Authentication Flow
The one big part of creating a CLI that requires attention and care is the authentication flow to access your API. Assuming you already have a secure way to authenticate, reuse it. The CLI can direct the user to a browser to log in and approve access, then receive an access token for API calls. For headless environments, OAuth device authorization is one established option; its temporary approval codes are separate from the access token. The access token should expire. Also, keep in mind that many serious security incidents start from a user’s machine, so this token should be stored securely (for example, in the macOS Keychain or 1Password).
I see it written in many places that agents appreciate having certain flags on your CLI. But they can tackle advanced mathematics now, so you can bet they’ll figure out your CLI. In truth, these are just flags that make it easy to write scripts, which is exactly what your agent will be doing in many cases. I definitely recommend:
- An output-format flag, including support for JSONL that streams one record per line
- A
--yesflag to approve confirmations, or a--non-interactiveflag to prevent prompts - A
--quietflag to reduce how much output the LLM has to parse - A timeout flag to limit execution time
I find that a good CLI helps me explore and use my web app when working with an agent. It’s certainly faster than having it use a browser and feels a bit more under control than just having it make curl requests against your API (though that works surprisingly well). For example, it’s easier to build in some sort of local throttling if you have a CLI, or to make certain actions impossible.
Distributing a CLI to your users is a totally different ballgame than using it for development, of course. And this requires evolving your API carefully, making upgrades easy, and treating it like any other desktop app that you might distribute. Surprisingly, distributing a CLI can be simpler than walking nontechnical users through configuring an MCP connection. But a remotely hosted MCP server lets you update tool implementations centrally, reducing how often users need to install client updates. Changes to tool names, schemas, or behavior still require care.
The Future
I absolutely believe that all websites in the future will be accessible this way and that it’s critical you make something like this for yourself and your users. Things are changing quite quickly in the software field, but we can be sure that future developments will have agents doing more for us. A web app that agents can’t readily access may as well not exist.