python-cli-ops
PythonでCLIアプリケーションのパターンを構築するためのSkill。
📜 元の英語説明(参考)
CLI application patterns for Python. Triggers on: cli, command line, typer, click, argparse, terminal, rich, console, terminal ui.
🇯🇵 日本人クリエイター向け解説
PythonでCLIアプリケーションのパターンを構築するためのSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o python-cli-ops.zip https://jpskill.com/download/5921.zip && unzip -o python-cli-ops.zip && rm python-cli-ops.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/5921.zip -OutFile "$d\python-cli-ops.zip"; Expand-Archive "$d\python-cli-ops.zip" -DestinationPath $d -Force; ri "$d\python-cli-ops.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
python-cli-ops.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
python-cli-opsフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-17
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Python CLI パターン
Typer と Rich を使用したモダンな CLI 開発。
基本的な Typer アプリ
import typer
app = typer.Typer(
name="myapp",
help="My awesome CLI application",
add_completion=True,
)
@app.command()
def hello(
name: str = typer.Argument(..., help="Name to greet"),
count: int = typer.Option(1, "--count", "-c", help="Times to greet"),
loud: bool = typer.Option(False, "--loud", "-l", help="Uppercase"),
):
"""Say hello to someone."""
message = f"Hello, {name}!"
if loud:
message = message.upper()
for _ in range(count):
typer.echo(message)
if __name__ == "__main__":
app()
コマンドグループ
import typer
app = typer.Typer()
users_app = typer.Typer(help="User management commands")
app.add_typer(users_app, name="users")
@users_app.command("list")
def list_users():
"""List all users."""
typer.echo("Listing users...")
@users_app.command("create")
def create_user(name: str, email: str):
"""Create a new user."""
typer.echo(f"Creating user: {name} <{email}>")
@app.command()
def version():
"""Show version."""
typer.echo("1.0.0")
# Usage: myapp users list
# myapp users create "John" "john@example.com"
# myapp version
Rich 出力
from rich.console import Console
from rich.table import Table
from rich.progress import track
from rich.panel import Panel
import typer
console = Console()
@app.command()
def show_users():
"""Display users in a table."""
table = Table(title="Users")
table.add_column("ID", style="cyan")
table.add_column("Name", style="green")
table.add_column("Email")
users = [
(1, "Alice", "alice@example.com"),
(2, "Bob", "bob@example.com"),
]
for id, name, email in users:
table.add_row(str(id), name, email)
console.print(table)
@app.command()
def process():
"""Process items with progress bar."""
items = list(range(100))
for item in track(items, description="Processing..."):
do_something(item)
console.print("[green]Done![/green]")
エラー処理
import typer
from rich.console import Console
console = Console()
def error(message: str, code: int = 1):
"""Print error and exit."""
console.print(f"[red]Error:[/red] {message}")
raise typer.Exit(code)
@app.command()
def process(file: str):
"""Process a file."""
if not os.path.exists(file):
error(f"File not found: {file}")
try:
result = process_file(file)
console.print(f"[green]Success:[/green] {result}")
except ValueError as e:
error(str(e))
クイックリファレンス
| 機能 | Typer 構文 |
|---|---|
| 必須引数 | name: str |
| オプション引数 | name: str = "default" |
| オプション | typer.Option(default, "--flag", "-f") |
| 引数 | typer.Argument(..., help="...") |
| 真偽値フラグ | verbose: bool = False |
| Enum 選択 | color: Color = Color.red |
| Rich 機能 | 使用法 |
|---|---|
| テーブル | Table() + add_column/row |
| プログレス | track(items) |
| 色 | [red]text[/red] |
| パネル | Panel("content", title="Title") |
その他のリソース
./references/typer-patterns.md- 高度な Typer パターン./references/rich-output.md- Rich のテーブル、プログレス、書式設定./references/configuration.md- 設定ファイル、環境変数
アセット
./assets/cli-template.py- 完全な CLI アプリケーションテンプレート
関連項目
関連スキル:
python-typing-ops- CLI 引数の型ヒントpython-observability-ops- CLI アプリケーションのロギング
補完スキル:
python-env- 配布用の CLI をパッケージ化する
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Python CLI Patterns
Modern CLI development with Typer and Rich.
Basic Typer App
import typer
app = typer.Typer(
name="myapp",
help="My awesome CLI application",
add_completion=True,
)
@app.command()
def hello(
name: str = typer.Argument(..., help="Name to greet"),
count: int = typer.Option(1, "--count", "-c", help="Times to greet"),
loud: bool = typer.Option(False, "--loud", "-l", help="Uppercase"),
):
"""Say hello to someone."""
message = f"Hello, {name}!"
if loud:
message = message.upper()
for _ in range(count):
typer.echo(message)
if __name__ == "__main__":
app()
Command Groups
import typer
app = typer.Typer()
users_app = typer.Typer(help="User management commands")
app.add_typer(users_app, name="users")
@users_app.command("list")
def list_users():
"""List all users."""
typer.echo("Listing users...")
@users_app.command("create")
def create_user(name: str, email: str):
"""Create a new user."""
typer.echo(f"Creating user: {name} <{email}>")
@app.command()
def version():
"""Show version."""
typer.echo("1.0.0")
# Usage: myapp users list
# myapp users create "John" "john@example.com"
# myapp version
Rich Output
from rich.console import Console
from rich.table import Table
from rich.progress import track
from rich.panel import Panel
import typer
console = Console()
@app.command()
def show_users():
"""Display users in a table."""
table = Table(title="Users")
table.add_column("ID", style="cyan")
table.add_column("Name", style="green")
table.add_column("Email")
users = [
(1, "Alice", "alice@example.com"),
(2, "Bob", "bob@example.com"),
]
for id, name, email in users:
table.add_row(str(id), name, email)
console.print(table)
@app.command()
def process():
"""Process items with progress bar."""
items = list(range(100))
for item in track(items, description="Processing..."):
do_something(item)
console.print("[green]Done![/green]")
Error Handling
import typer
from rich.console import Console
console = Console()
def error(message: str, code: int = 1):
"""Print error and exit."""
console.print(f"[red]Error:[/red] {message}")
raise typer.Exit(code)
@app.command()
def process(file: str):
"""Process a file."""
if not os.path.exists(file):
error(f"File not found: {file}")
try:
result = process_file(file)
console.print(f"[green]Success:[/green] {result}")
except ValueError as e:
error(str(e))
Quick Reference
| Feature | Typer Syntax |
|---|---|
| Required arg | name: str |
| Optional arg | name: str = "default" |
| Option | typer.Option(default, "--flag", "-f") |
| Argument | typer.Argument(..., help="...") |
| Boolean flag | verbose: bool = False |
| Enum choice | color: Color = Color.red |
| Rich Feature | Usage |
|---|---|
| Table | Table() + add_column/row |
| Progress | track(items) |
| Colors | [red]text[/red] |
| Panel | Panel("content", title="Title") |
Additional Resources
./references/typer-patterns.md- Advanced Typer patterns./references/rich-output.md- Rich tables, progress, formatting./references/configuration.md- Config files, environment variables
Assets
./assets/cli-template.py- Full CLI application template
See Also
Related Skills:
python-typing-ops- Type hints for CLI argumentspython-observability-ops- Logging for CLI applications
Complementary Skills:
python-env- Package CLI for distribution