cli-module_skill

This skill helps you design and use custom CLI commands with dependency injection and Typer, improving automation and app tooling.
  • Python

83

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill psincraian/myfy --skill cli-module

  • SKILL.md6.3 KB

Overview

This skill provides a CliModule for creating custom CLI commands with full dependency injection and Typer integration. It lets you define async or sync command handlers, command groups, and rich argument/option parsing while services are injected automatically. Use it to add maintainable, discoverable application commands that reuse your app's DI container.

How this skill works

Define commands with the @cli.command() decorator; function parameters are classified automatically as DI dependencies, Typer arguments, or options based on type and default values. Command groups are created via cli.group(...) and support nested commands. The module reads CLI configuration from MYFY_CLI_ environment variables and integrates Typer features like progress bars, enums, and custom help texts.

When to use it

  • Add administrative or maintenance commands to a myfy application (migrations, seed, reset).
  • Create CLI entry points that need application services like DB sessions or config injected.
  • Implement complex argument parsing, flags, enums, or file imports using Typer features.
  • Group related commands (e.g., db:seed, db:reset) for discoverability and organization.

Best practices

  • Write concise docstrings for each handler — they become command help text.
  • Keep commands focused: one clear responsibility per command.
  • Prefer DI-injected services instead of creating connections inside commands.
  • Use Typer for complex arguments/options to get automatic help and validation.
  • Handle errors and exit codes explicitly (raise typer.Exit(1) on failure).
  • Use typer.progressbar and styled output for long-running tasks and status.

Example use cases

  • Seed a database with test users via an injected UserService: myfy app seed-users --count 20.
  • Count or query records using an injected AsyncSession: myfy app count-users.
  • Import data from files with typed arguments and dry-run option: myfy app import-data file.csv --dry-run.
  • Group DB utilities under db:seed and db:reset with confirmation flags and force option.
  • Create deployment or maintenance commands that accept enums, versions, and flags (deploy production -v 1.2.3 --skip-tests).

FAQ

Yes. Both async and sync handlers are supported; async is recommended for IO-bound work.

How are parameters classified between DI and CLI args?

Primitive types without defaults become positional arguments, primitives with defaults become options, typer.Argument/Option are respected, and complex types are treated as DI dependencies.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational