品質チェックを実行
実行環境の設定ファイルを自動検出し、変更ファイルに対して最適なlintツールを実行します。プロジェクト全体や特定ファイルのコード品質を確認したい場合に使用します。
/plugin marketplace add B16B1RD/cc-zen-workflow/plugin install b16b1rd-zen-workflow@B16B1RD/cc-zen-workflow品質チェック(lint)を実行し、結果を報告する
このコマンドを実行したら、以下のフェーズを順番に実行してください。
| 引数 | 説明 |
|---|---|
[path] | チェック対象のファイルまたはディレクトリ(省略時は変更ファイル) |
zen-config.yml から lint コマンドを取得:
commands:
lint: "npm run lint" # 明示的に設定されている場合
設定ファイルの読み取り:
# zen-config.yml を読み取り
cat zen-config.yml
commands.lint が null でない場合、その値を使用。
プロジェクトファイルを検出して lint コマンドを決定:
| ファイル | 検出条件 | lint コマンド |
|---|---|---|
package.json | scripts.lint が存在 | npm run lint |
pyproject.toml | ファイルが存在 | ruff check . |
Cargo.toml | ファイルが存在 | cargo clippy -- -D warnings |
go.mod | ファイルが存在 | golangci-lint run |
Makefile | lint ターゲットが存在 | make lint |
検出優先順位:
zen-config.yml の commands.lint(明示的設定)package.json の scripts.lintpyproject.toml → ruff check .Cargo.toml → cargo clippy -- -D warningsgo.mod → golangci-lint runMakefile の lint ターゲット# package.json の scripts を確認
cat package.json | jq -r '.scripts.lint // empty'
# または各言語のファイル存在確認
ls package.json pyproject.toml Cargo.toml go.mod Makefile 2>/dev/null
警告: lint コマンドを検出できませんでした
以下のいずれかを設定してください:
1. zen-config.yml に commands.lint を追加
2. package.json の scripts に lint を追加
3. Makefile に lint ターゲットを追加
対応している自動検出:
- Node.js: package.json の scripts.lint
- Python: ruff check(pyproject.toml 検出時)
- Rust: cargo clippy(Cargo.toml 検出時)
- Go: golangci-lint run(go.mod 検出時)
処理を終了。
指定されたパスをそのまま使用:
対象: {path}
パスが存在しない場合:
エラー: 指定されたパス '{path}' が見つかりません
対処:
1. パスが正しいか確認
2. ファイル/ディレクトリが存在するか確認
変更ファイルを検出(優先順位順):
# 1. リモート main からの変更(origin/main が存在する場合)
git diff --name-only origin/main...HEAD
# 2. ローカル main からの変更(origin が存在しない場合)
git diff --name-only main...HEAD
# 3. 作業ツリーの変更(main ブランチが存在しない場合)
git diff --name-only HEAD
# 4. ステージング済みファイル
git diff --name-only --cached
フォールバックロジック:
origin/main が存在 → origin/main...HEAD の差分origin/main が存在しない → main...HEAD の差分main も存在しない → HEAD からの差分 + ステージング変更ファイルがない場合:
変更ファイルがありません。プロジェクト全体をチェックします。
プロジェクト全体(カレントディレクトリ)を対象とする。
品質チェックを実行しています...
コマンド: {lint_command}
対象: {target_path または "変更ファイル ({count} files)"}
# 検出されたコマンドを実行
{lint_command} {target_files}
注意:
npm run lint はプロジェクト設定に従うruff check はパスを引数として受け付けるコマンドの終了コードと出力を記録:
品質チェック完了
結果: 問題は検出されませんでした
対象: {target_description}
コマンド: {lint_command}
品質チェック完了
結果: {error_count} 件のエラー、{warning_count} 件の警告が検出されました
{lint_output}
---
修正案:
修正案の提示:
エラー内容を分析し、可能であれば修正案を提示:
自動修正が可能な場合:
自動修正を実行しますか?
コマンド: {fix_command}
例: npm run lint -- --fix
ruff check --fix
cargo clippy --fix
オプション:
- はい、自動修正を実行
- いいえ、手動で修正
手動修正が必要な場合: 各エラーについて具体的な修正案を提示。
品質チェック結果サマリー
| 項目 | 結果 |
|------|------|
| 対象 | {target} |
| エラー | {error_count} |
| 警告 | {warning_count} |
| 所要時間 | {duration} |
次のステップ:
1. エラーを修正
2. 再度 `/zen:lint` を実行
3. 問題がなければ `/zen:pr:create` で PR 作成
品質チェック結果を作業メモリに記録する。
実行条件: Issue に紐づいた作業ブランチ(issue-{number} パターンを含むブランチ)の場合のみ自動実行される。main/master ブランチや Issue 番号を含まないブランチでは実行されない。
ブランチ名から Issue 番号を抽出:
issue_number=$(git branch --show-current | grep -oE 'issue-[0-9]+' | grep -oE '[0-9]+')
Issue 番号が見つからない場合は、作業メモリ更新をスキップ。
# コメント ID を取得
comment_id=$(gh api repos/{owner}/{repo}/issues/{issue_number}/comments \
--jq '.[] | select(.body | contains("🧘 zen 作業メモリ")) | .id')
# コメントが見つかった場合のみ更新
if [ -n "$comment_id" ]; then
gh api repos/{owner}/{repo}/issues/comments/{comment_id} \
-X PATCH \
-f body="{updated_body}"
fi
作業メモリに以下を自動追記:
### 品質チェック履歴
#### {timestamp}: /zen:lint 実行
- **結果**: {status}(問題なし / エラーあり)
- **エラー**: {error_count}件
- **警告**: {warning_count}件
- **対象**: {target}
注意:
エラー: lint コマンドの実行に失敗しました
コマンド: {lint_command}
エラー内容: {error_message}
考えられる原因:
- 必要なツールがインストールされていない
- 設定ファイルに問題がある
- パス指定が不正
対処:
1. コマンドが利用可能か確認
2. 設定ファイルを確認
3. 手動でコマンドを実行して確認
エラー: {tool_name} が見つかりません
インストール方法:
- npm: npm install -g {tool_name}
- pip: pip install {tool_name}
- cargo: cargo install {tool_name}
# scripts.lint を確認
npm run lint
# 自動修正(対応している場合)
npm run lint -- --fix
一般的な lint ツール:
eslint {files}prettier --check {files}biome check {files}# ruff を使用
ruff check {files}
# 自動修正
ruff check --fix {files}
その他のツール:
flake8 {files}mypy {files}black --check {files}# clippy を使用
cargo clippy -- -D warnings
# フォーマットチェック
cargo fmt --check
# golangci-lint を使用
golangci-lint run {files}
# または go vet
go vet {files}
git コマンドzen-config.yml, package.json)