Command-line interfaces (CLIs) are the backbone of modern development. They automate tedious tasks, orchestrate complex deployments, and provide a shared language for teams. But building, distributing, and maintaining them is often a thankless job filled with boilerplate code, argument parsing headaches, and versioning nightmares.
What if you could skip all that? What if you could define a CLI command with a few lines of code and have it instantly deployed, scaled, and secured for your team?
Welcome to cli.do, the agentic way to build CLIs. This isn't just about creating a script; it's about exposing your complex business logic and automated workflows as a simple, powerful CLI as an API.
In this tutorial, we'll show you how to transform a simple script into a powerful, shareable command-line tool in under five minutes. Let's dive in.
Before we build, let's clarify what we mean by "agentic." Traditional CLIs are often self-contained binaries. An agentic CLI built with cli.do is different. It's a lightweight client that communicates with an Agent—a piece of code running on a scalable, managed platform.
Think of it as turning your business logic into its own intelligent endpoint. You define the logic once, and cli.do handles the rest:
We're going to build a common and essential tool: a deploy command. This CLI will take a project name and an environment, then kick off a deployment process.
First, let's install the @do-sdk/agent, which provides the core building blocks for creating your agentic workflow.
npm install @do-sdk/agent
Now for the magic. Create a new TypeScript file (e.g., my-cli.ts) and add the following code. This is where you define the entire functionality of your CLI tool.
import { Agent } from '@do-sdk/agent';
// Define your CLI command as an Agent on the cli.do service
const cli = new Agent('cli.do');
// Create a 'deploy' command with project and environment arguments
cli.on('deploy', {
project: { type: 'string', required: true, description: 'The name of the project to deploy.' },
env: { type: 'string', default: 'staging', description: 'The target environment (e.g., staging, production).' },
}, async (args) => {
console.log(`Deploying ${args.project} to ${args.env}...`);
// Your real deployment logic goes here.
// This could be triggering a GitHub Action, calling a cloud provider API,
// or running a shell script.
// await triggerDeployment(args.project, args.env);
// Return a structured response to the user
return { status: 'success', message: `Deployment of ${args.project} to ${args.env} initiated.` };
});
// Your CLI is now live!
Let's break that down:
That's it. You're done. There's no build step, no distribution, and no configuration files. Your agent is now live and your command is immediately callable through the universal .do client.
Open your terminal and run it:
# Run the command with the required project flag
> do cli deploy --project my-app
Deploying my-app to staging...
{
"status": "success",
"message": "Deployment of my-app to staging initiated."
}
Now, let's override the default environment:
# Deploy to production
> do cli deploy --project my-app --env production
Deploying my-app to production...
{
"status": "success",
"message": "Deployment of my-app to production initiated."
}
What happens if you miss a required argument? cli.do handles it automatically.
> do cli deploy
Error: Missing required argument: --project
You also get beautiful, auto-generated help text for free.
> do cli deploy --help
Usage: do cli deploy [options]
Options:
--project <string> The name of the project to deploy. (required)
--env <string> The target environment (e.g., staging, production). (default: "staging")
--help Display help for command
In just a few minutes, you built and deployed a robust, shareable command-line tool. This simple example showcases the power of agentic workflows.
You can turn virtually any workflow into a powerful CLI: running data analysis, managing customer support tasks, generating reports, or interacting with any internal system. If you can define it in code, you can expose it as an agentic CLI.
Q: What is cli.do?
A: cli.do is an Agentic Workflow Platform service that allows you to effortlessly create and manage command-line interfaces (CLIs) as APIs. It enables you to expose your business logic and automated workflows as simple, distributable tools.
Q: How does cli.do differ from traditional CLI builders?
A: Unlike traditional libraries that require manual setup, argument parsing, and deployment, cli.do abstracts the entire process. You define your command's logic as code, and we automatically generate, host, and scale the CLI, making it instantly available.
Q: Who can use the CLIs I build?
A: You have full control. CLIs can be kept private for internal team use, shared with specific users, or made public. Access is managed through the .do platform's robust authentication and authorization system.
Q: What kind of workflows can I turn into a CLI?
A: Anything you can code! From running data analysis scripts and triggering cloud deployments to managing customer support tasks or generating reports. If you can define it as an agentic workflow, you can expose it as a powerful CLI.
Ready to stop writing boilerplate and start building powerful developer tools the agentic way?