Agent skill
rustfeed-quality
rustfeed プロジェクトのコード品質チェック(cargo fmt、clippy、test、doc)を実行します。コード品質確認、コミット前チェック、CI/CD検証時に使用します。
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/rustfeed-quality
SKILL.md
Rustfeed コード品質チェック
このスキルは rustfeed プロジェクトのコード品質を確保するためのチェック手順を提供します。
コミット前の必須チェック
コードをコミットする前に、必ず以下のチェックを実行してください:
1. フォーマットチェック
cargo fmt --check
目的: コードが Rust 標準のフォーマットに従っているか確認
修正方法(エラーが出た場合):
cargo fmt
2. Lintチェック(Clippy)
cargo clippy --all-targets --all-features -- -D warnings
目的: Rust のベストプラクティスに従っているか、潜在的なバグがないか確認
Clippyの警告レベル:
-D warnings: 警告をエラーとして扱う(CIと同等の厳密さ)--all-targets: テストコードも含めてチェック--all-features: 全てのfeatureフラグでチェック
よくある警告と修正方法:
| 警告 | 説明 | 修正 |
|---|---|---|
unused_imports |
使われていないインポート | 削除する |
dead_code |
使われていない関数/変数 | 削除または #[allow(dead_code)] |
needless_return |
不要な return |
削除する |
clone_on_copy |
Copyトレイトで .clone() |
.clone() を削除 |
3. テスト実行
# 全テスト実行
cargo test
# 特定のテストのみ
cargo test test_fetch_feed
# 詳細表示
cargo test -- --nocapture
目的: 既存機能が壊れていないか、新機能が正しく動作するか確認
4. ドキュメント生成チェック
cargo doc --no-deps --document-private-items
目的: rustdoc コメントが正しくパースされるか確認
オプション:
--no-deps: 依存クレートのドキュメントは生成しない(高速化)--document-private-items: privateアイテムも含める
クイック品質チェック(一括実行)
全てのチェックを一度に実行する場合:
cargo fmt --check && \
cargo clippy --all-targets --all-features -- -D warnings && \
cargo test && \
cargo doc --no-deps --document-private-items
成功条件: 全てのコマンドがエラーなく完了する
ビルドチェック
リリースビルド
cargo build --release
目的: 最適化ビルドが成功するか確認
全ターゲットビルド
cargo build --all-targets
目的: CLI、TUI、テスト、ベンチマークが全てビルドできるか確認
パフォーマンス測定
ベンチマーク実行(未実装の場合はスキップ)
cargo bench
ビルド時間測定
cargo clean
cargo build --timings
# target/cargo-timings/ にレポートが生成される
依存関係チェック
未使用の依存確認(cargo-udeps使用)
# cargo-udepsのインストール(初回のみ)
cargo install cargo-udeps
# 未使用依存のチェック
cargo +nightly udeps
セキュリティ監査(cargo-audit使用)
# cargo-auditのインストール(初回のみ)
cargo install cargo-audit
# 脆弱性チェック
cargo audit
トラブルシューティング
ビルドエラーが出る場合
# 1. クリーンビルド
cargo clean
cargo build
# 2. Cargo.lockを再生成
rm Cargo.lock
cargo build
# 3. rustupを最新に
rustup update
テストが失敗する場合
# 詳細なエラー出力
cargo test -- --nocapture --test-threads=1
# 特定のテストのみデバッグ
RUST_LOG=debug cargo test test_name -- --nocapture
Clippyの警告を一時的に無効化
// 関数レベル
#[allow(clippy::similar_names)]
fn my_function() { /* ... */ }
// ファイルレベル
#![allow(clippy::module_inception)]
注意: 本当に必要な場合のみ使用し、理由をコメントで説明する
CI/CD環境での実行
GitHub Actionsなどで実行する場合:
- name: Run quality checks
run: |
cargo fmt --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test
cargo doc --no-deps
ベストプラクティス
- コミット前に必ずチェック: fmt → clippy → test の順で実行
- Clippyの警告はゼロにする: 警告を放置しない
- テストカバレッジを意識: 主要なパスには必ずテストを書く
- ドキュメントを書く: 公開API には必ず rustdoc を追加
参考コマンド
# コンパイル時間の詳細表示
cargo build -Z timings
# 依存関係ツリー表示
cargo tree
# 重複依存の確認
cargo tree --duplicates
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?