テンプレート一覧に戻る
Rust CLI
Rust + clap のCLIツール開発向けCLAUDE.md。安全で高速なシステムCLI開発に最適です。
上級rustcliclapsystems
CLAUDE.md
# プロジェクト名
Rust で構築されたCLIツール。
## 技術スタック
- **言語**: Rust (2024 edition)
- **CLIフレームワーク**: clap 4.x (derive)
- **エラー処理**: anyhow / thiserror
- **出力**: colored / indicatif(プログレスバー)
- **テスト**: assert_cmd + predicates
## コマンド
| コマンド | 用途 |
|---------|------|
| `cargo run -- <args>` | 直接実行 |
| `cargo test` | テスト実行 |
| `cargo build --release` | リリースビルド |
| `cargo clippy` | Lint実行 |
| `cargo fmt` | フォーマット |
| `cargo install --path .` | ローカルインストール |
## ディレクトリ構造
| パス | 役割 |
|-----|------|
| `src/main.rs` | エントリーポイント・clap定義 |
| `src/commands/` | サブコマンド実装 |
| `src/lib.rs` | コアロジック |
| `src/config.rs` | 設定管理 |
| `tests/` | インテグレーションテスト |
## コーディング規約
- clap deriveマクロでCLI引数定義
- `Result<T, E>` で明示的なエラー処理
- `anyhow` でアプリエラー、`thiserror` でライブラリエラー
- stdinとstdoutのパイプ対応
- 終了コードはsysexit準拠
- clippy warningゼロ維持
## Git規約
- ブランチ: `feature/`, `fix/`, `chore/`
- コミットメッセージ: Conventional Commits形式