Auto-generated CLI patterns using Google Fire with class-based structure, docstring parsing, and nested classes. Use when building Python CLI applications, creating Fire CLIs, implementing auto-generated commands, designing class-based CLIs, or when user mentions Fire, Google Fire, CLI generation, docstring commands, nested command groups, or Python command-line tools.
View on GitHubvanman2024/cli-builder
cli-builder
plugins/cli-builder/skills/fire-patterns/SKILL.md
January 22, 2026
Select agents to install to:
npx add-skill https://github.com/vanman2024/cli-builder/blob/main/plugins/cli-builder/skills/fire-patterns/SKILL.md -a claude-code --skill fire-patternsInstallation paths:
.claude/skills/fire-patterns/# fire-patterns
Provides patterns for building Python CLI applications using Google Fire with automatic command generation from class methods, docstring-based help text, nested class structures for command groups, and rich console output integration.
## Core Patterns
### 1. Class-Based Fire CLI with Docstring Parsing
Fire automatically generates CLI commands from class methods and extracts help text from docstrings:
```python
import fire
from rich.console import Console
console = Console()
class MyCLI:
"""A powerful CLI tool with auto-generated commands"""
def __init__(self):
self.version = "1.0.0"
self.config = {}
def init(self, template='basic'):
"""Initialize a new project
Args:
template: Project template to use (default: basic)
"""
console.print(f"[green]✓[/green] Initializing project with {template} template...")
return {"status": "success", "template": template}
def deploy(self, environment, force=False, mode='safe'):
"""Deploy to specified environment
Args:
environment: Target environment (dev, staging, prod)
force: Force deployment without confirmation (default: False)
mode: Deployment mode - fast, safe, or rollback (default: safe)
"""
console.print(f"[cyan]Deploying to {environment} in {mode} mode[/cyan]")
if force:
console.print("[yellow]⚠ Force mode enabled - skipping confirmation[/yellow]")
return {"environment": environment, "mode": mode, "forced": force}
if __name__ == '__main__':
fire.Fire(MyCLI)
```
**Usage:**
```bash
python mycli.py init --template=react
python mycli.py deploy production --force
python mycli.py deploy staging --mode=fast
python mycli.py --help # Auto-generated from docstrings
```
### 2. Nested Class Structure for Command Groups
Organize related commands using nested classes:
```python
import fire
from rich.console import Console
cons