
Adding Cli Command
If you're building a Typer CLI and want consistency across commands, this gives you three battle-tested templates: single commands that take arguments directly, command groups for subcommands like `db migrate`, and destructive operations with confirmation flows. It handles the registration boilerplate in `__init__.py` and enforces conventions like using Annotated types, proper exit codes, and routing all output through a display module. The destructive template is solid, it won't let you forget the `--force` flag or confirmation prompt. One constraint: it assumes you've already got a storage and display module set up. Good for teams that want their CLI commands to look like they were written by the same person.
- GitHub stars
- 1.3K
- last updated
- Jun 8, 2026
Install
$ npx -y skills add https-deeplearning-ai/sc-agent-skills-files --skill adding-cli-command --agent claude-codeInstalls into .claude/skills of the current project.
Files
Adding CLI Commands
Templates and workflow for adding or updating Typer CLI commands.
<cli_app> refers to the name of your CLI application (e.g., task, myapp, todo).
Workflow
- Identify command type (single command, command group, or destructive)
- Create file in
src/<cli_app>/commands/<command>.py - Use appropriate template below
- Register in
src/<cli_app>/commands/__init__.py
Template A: Single Command
For commands taking arguments directly (<cli_app> add "item").
import typer
from typing import Annotated
from <cli_app>.storage import add_task
from <cli_app>.display import display
from <cli_app>.constants import EXIT_INVALID_INPUT
app = typer.Typer()
@app.command()
def add(
title: Annotated[str, typer.Argument(help="task title")],
priority: Annotated[str, typer.Option("--priority", "-p", help="priority level")] = "low",
):
"""Add a new task."""
if not title.strip():
display.error("Title cannot be empty")
raise typer.Exit(EXIT_INVALID_INPUT)
task = add_task(title=title, priority=priority)
display.success(f"Added '{task.title}'")
Template B: Command Group
Sponsors
Details
- Repository
- github.com/https-deeplearning-ai/sc-agent-skills-files
- Categories
- DevOps & CI/CD, AI & Agent Building, CLI & Terminal
- First seen
- Jun 11, 2026