Cli building

From siviter-xyz/dot-agent · View interactive version

Cli building is an AI agent skill from the GitHub repository siviter-xyz/dot-agent. Build command-line interfaces with async-first design, composable commands, and proper output formatting. Use when creating CLI tools, commands, or interactive terminal applications.

How to use this skill

Skill file

CLI Building

Guidelines for building command-line interfaces with modern patterns and best practices.

When to Use

Core Principles

Framework Selection

TypeScript/JavaScript

stricli (@bloomberg/stricli, recommended for modern async-first CLIs):

oclif (alternative):

Python

cyclopts (recommended for async-first):

typer (when fully async support available):

Command Architecture

Composable Commands

Design commands as reusable modules:

Strategy Pattern

Use strategy pattern for:

Output Formatting

Async Patterns

Async-First Design

All I/O should be async:

Error Handling

Handle async errors properly:

Command Structure

Basic Command

// stricli example
import { createCli } from '@bloomberg/stricli';

async function myCommand() {
  // Async implementation
}

const cli = createCli({
  name: 'my-cli',
  commands: {
    'my-command': myCommand
  }
});

cli.run();
# cyclopts example
from cyclopts import App

app = App()

@app.default
async def my_command():
    # Async implementation
    pass

if __name__ == '__main__':
    app()

Best Practices

  1. Async by default: All operations should be async
  2. Composable design: Build reusable command modules
  3. Strategy pattern: Use for workflow branching
  4. Proper formatting: Unicode symbols and color with NO_COLOR support
  5. Error handling: Clear error messages and exit codes
  6. Type safety: Use TypeScript types or Python type hints
  7. Testing: Test commands in isolation

References

For detailed guidance, see:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.