Build professional command-line tools with Google Antigravity
# CLI Tools Development Guide for Google Antigravity
Create powerful, user-friendly command-line tools using modern TypeScript patterns with Google Antigravity IDE.
## CLI Framework Setup
```typescript
// src/cli.ts
import { Command } from "commander";
import { input, select, confirm, password } from "@inquirer/prompts";
import chalk from "chalk";
import ora from "ora";
import { version } from "../package.json";
const program = new Command();
program
.name("myctl")
.description("A powerful CLI tool built with Google Antigravity")
.version(version)
.option("-v, --verbose", "Enable verbose output")
.option("-c, --config <path>", "Path to config file");
// Init command with interactive prompts
program
.command("init")
.description("Initialize a new project")
.option("-t, --template <name>", "Template to use")
.action(async (options) => {
const projectName = await input({
message: "Project name:",
default: "my-project",
validate: (value) => /^[a-z0-9-]+$/.test(value) || "Use lowercase letters, numbers, and hyphens"
});
const template = options.template || await select({
message: "Select a template:",
choices: [
{ name: "Next.js App", value: "nextjs" },
{ name: "Express API", value: "express" },
{ name: "CLI Tool", value: "cli" }
]
});
const useTypescript = await confirm({
message: "Use TypeScript?",
default: true
});
const spinner = ora("Creating project...").start();
try {
await createProject({ projectName, template, useTypescript });
spinner.succeed(chalk.green("Project created successfully!"));
console.log(chalk.cyan(`\nNext steps:\n cd ${projectName}\n npm install\n npm run dev`));
} catch (error) {
spinner.fail(chalk.red("Failed to create project"));
console.error(error);
process.exit(1);
}
});
// Deploy command with progress
program
.command("deploy")
.description("Deploy the project")
.option("-e, --env <environment>", "Target environment", "production")
.option("--dry-run", "Preview changes without deploying")
.action(async (options) => {
const spinner = ora("Preparing deployment...").start();
const steps = ["Building", "Testing", "Uploading", "Activating"];
for (const step of steps) {
spinner.text = `${step}...`;
await simulateStep();
}
spinner.succeed(chalk.green("Deployed successfully!"));
console.log(chalk.cyan(`\nDeployment URL: https://app.example.com`));
});
program.parse();
```
## Configuration Management
```typescript
// src/config.ts
import { cosmiconfig } from "cosmiconfig";
import { z } from "zod";
import os from "os";
import path from "path";
import fs from "fs-extra";
const configSchema = z.object({
apiUrl: z.string().url().default("https://api.example.com"),
apiKey: z.string().optional(),
defaultEnvironment: z.enum(["development", "staging", "production"]).default("development"),
plugins: z.array(z.string()).default([])
});
export type Config = z.infer<typeof configSchema>;
export class ConfigManager {
private config: Config | null = null;
private configPath: string;
constructor() {
this.configPath = path.join(os.homedir(), ".myctl", "config.json");
}
async load(): Promise<Config> {
const explorer = cosmiconfig("myctl");
const result = await explorer.search();
if (result) {
this.config = configSchema.parse(result.config);
return this.config;
}
// Load from global config
if (await fs.pathExists(this.configPath)) {
const data = await fs.readJson(this.configPath);
this.config = configSchema.parse(data);
return this.config;
}
return configSchema.parse({});
}
async save(config: Partial<Config>): Promise<void> {
await fs.ensureDir(path.dirname(this.configPath));
const existing = await this.load();
const merged = { ...existing, ...config };
await fs.writeJson(this.configPath, merged, { spaces: 2 });
}
get<K extends keyof Config>(key: K): Config[K] | undefined {
return this.config?.[key];
}
}
```
## Output Formatting
```typescript
// src/output.ts
import Table from "cli-table3";
import chalk from "chalk";
import boxen from "boxen";
export const formatTable = (data: Record<string, unknown>[], columns: string[]) => {
const table = new Table({
head: columns.map(c => chalk.cyan(c)),
style: { head: [], border: [] }
});
data.forEach(row => {
table.push(columns.map(col => String(row[col] || "")));
});
return table.toString();
};
export const formatBox = (title: string, content: string) => {
return boxen(content, {
title,
titleAlignment: "center",
padding: 1,
borderStyle: "round",
borderColor: "cyan"
});
};
export const formatSuccess = (message: string) => chalk.green("OK ") + message;
export const formatError = (message: string) => chalk.red("ERR ") + message;
export const formatWarning = (message: string) => chalk.yellow("WARN ") + message;
export const formatInfo = (message: string) => chalk.blue("INFO ") + message;
```
## Best Practices
1. **Provide helpful error messages** with suggestions
2. **Support both interactive and non-interactive** modes
3. **Use spinners and progress** indicators for long operations
4. **Implement proper exit codes** for scripting
5. **Add shell completion** support
6. **Document all commands** with examples
7. **Support configuration files** and environment variables
Google Antigravity assists in building robust CLI tools with intelligent command suggestions and error handling patterns.This cli prompt is ideal for developers working on:
By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their cli implementations.
Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.
This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.
You can modify the prompt by adding specific requirements, constraints, or preferences. For cli projects, consider mentioning your framework version, coding style, and any specific libraries you're using.