sc-pr-check について
sc-pr-checkは、PR作成前にローカルCIチェックを実行するスキルです。プロジェクトのツールを検出して指定したチェックを実行し、対話的な修正と再実行を支援します。
主な機能
- 01プロジェクトツールの自動検出
- 02lint、フォーマット、テスト、型、安全性、ビルド、E2Eチェック
- 03チェック選択とクイック実行
- 04対話式または自動の修正
- 05結果の集約と再実行
活用シーン
- 01PR作成前のローカル検証
- 02開発中にテストやlintだけを実行
- 03dry-runで検出されたチェックを確認
- 04修正後にすべてのチェックを再実行
MCP 対応
PAL MCPをテストのデバッグ、安全性レビュー、コミット前検証に利用でき、Rube MCPを使って結果をSlackに投稿したりJiraを更新したりできます。
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ tony363/ superclaude --skill sc-pr-checkインストール後、Claude Code で/sc-pr-checkを入力して読み込まれたか確認します。
詳細
PR 作成前チェックのスキル
PR を作成する前に、ローカルで包括的な CI チェックを実行します。プロジェクトのツールを自動検出し、すべてのチェックを実行して、失敗した場合は対話形式での修正を提案します。
クイックスタート
# Run all detected checks
/sc:pr-check
# Run specific check categories
/sc:pr-check --only lint,test
# Quick mode - skip slow checks (e2e, security)
/sc:pr-check --quick
# Fix mode - auto-fix what's possible
/sc:pr-check --fix
# Dry run - show what would be checked
/sc:pr-check --dry-run
動作フロー
- 検出 - プロジェクトのツール(言語、リンター、フォーマッター、テストランナー、セキュリティスキャナー)を特定します
- 計画 - 検出されたツールに基づいてチェックの順序を作成します
- 実行 - チェックを順番に実行し、出力をストリーミングします
- 修正 - 失敗した場合、チェックの種類ごとに対話形式で修正を提案します
- 再実行 - 修正後、すべてのチェックが成功するか、ユーザーが終了するまで再実行します
- 報告 - 結果と適用した修正をまとめます
フラグ
| フラグ | 型 | デフォルト | 説明 |
|---|---|---|---|
--only | 文字列 | all | カンマ区切り:lint、format、test、security、types、e2e、build |
--quick | bool | false | 時間のかかるチェック(e2e、セキュリティスキャン)をスキップします |
--fix | bool | false | 確認を求めず、修正可能な問題を自動修正します |
--dry-run | bool | false | 実行せずに検出したチェックを表示します |
--strict | bool | false | 警告をエラーとして扱います |
フェーズ 1:プロジェクトツールの検出
設定ファイルとパッケージマニフェストを調べて、プロジェクトのツールを自動検出します。
検出マトリックス
| チェックの種類 | Python | JavaScript/TypeScript | Go | Rust |
|---|---|---|---|---|
| リンター | ruff, flake8, pylint | eslint, biome | golangci-lint | clippy |
| フォーマッター | ruff format, black | prettier, biome | gofmt | rustfmt |
| 型チェック | mypy, pyright | tsc | (組み込み) | (組み込み) |
| テスト | pytest, unittest | jest, vitest, mocha | go test | cargo test |
| セキュリティ | bandit, pip-audit | npm audit, snyk | govulncheck | cargo audit |
| ビルド | - | tsc, vite build | go build | cargo build |
| E2E | - | playwright, cypress | - | - |
検出戦略
# Python detection
[ -f "pyproject.toml" ] || [ -f "setup.py" ] || [ -f "requirements.txt" ]
# JavaScript/TypeScript detection
[ -f "package.json" ] || [ -f "tsconfig.json" ]
# Go detection
[ -f "go.mod" ]
# Rust detection
[ -f "Cargo.toml" ]
# Check for specific tools in config files
grep -q "ruff" pyproject.toml 2>/dev/null # Ruff
[ -f ".eslintrc*" ] || grep -q "eslint" package.json 2>/dev/null # ESLint
検出結果
## Project Tooling Detected
| Category | Tool | Config | Status |
|----------|------|--------|--------|
| Language | Python 3.12 | pyproject.toml | OK |
| Linter | Ruff | pyproject.toml [tool.ruff] | OK |
| Formatter | Ruff Format | pyproject.toml [tool.ruff] | OK |
| Type Check | mypy | pyproject.toml [tool.mypy] | OK |
| Tests | pytest | pyproject.toml [tool.pytest] | OK |
| Security | bandit | .bandit | OK |
| E2E | playwright | playwright.config.ts | OK |
Running 7 checks...
フェーズ 2:チェックの実行
依存関係に応じた順序でチェックを実行します。
| 手順 | チェック | 理由 |
|---|---|---|
| 1 | リンター | まず構文やスタイルのエラーを検出します(最速) |
| 2 | フォーマッター | 一貫したフォーマットを保証します |
| 3 | 型チェッカー | 実行時エラーの前に型エラーを検出します |
| 4 | ユニット/統合テスト | 正しさを検証します |
| 5 | セキュリティスキャン | 脆弱性を検出します |
| 6 | ビルド | コンパイルを検証します |
| 7 | E2E テスト | 統合全体を検証します(最も時間がかかり、--quick ではスキップされます) |
実行パターン
各チェックについて、次の手順を実行します。
- 手順番号とチェック名を表示します:
[1/7] Running Ruff linter... - タイムアウトを設定してコマンドを実行します
- 終了コードと出力を取得します
- 成功した場合:緑色のチェックマークを表示し、次に進みます
- 失敗した場合:修正フローに進みます
フェーズ 3:対話形式での修正
チェックが失敗した場合、失敗の種類を特定し、対象を絞った修正を提案します。
リントの失敗
[1/7] Ruff linter... FAILED (3 errors)
src/api/routes.py:15:1 F401 unused import
src/models/user.py:8:5 E712 comparison to True
src/utils/helpers.py:22:80 E501 line too long
Actions:
[f] Auto-fix with `ruff check . --fix` (fixes 2 of 3)
[m] Manually fix remaining issues
[s] Skip and continue
[q] Quit
テストの失敗
[4/7] Tests... FAILED (2 failures)
FAILED tests/test_api.py::test_create_user - AssertionError
FAILED tests/test_auth.py::test_login_expired - TimeoutError
Actions:
[a] Analyze and fix failing tests
[r] Re-run failed tests only
[s] Skip and continue
[q] Quit
セキュリティの失敗
[5/7] Security scan... FOUND 2 issues
HIGH: SQL injection risk in src/api/users.py:45 (B608)
LOW: Assert used in production code src/utils/debug.py:12 (B101)
Actions:
[a] Analyze and remediate issues
[i] Show details for each finding
[s] Skip and continue
[q] Quit
修正の種類に関するリファレンス
| チェック | 自動修正可能 | 手動での修正が必要 |
|---|---|---|
| リント | ほとんどのスタイルの問題 | ロジックエラー、未使用コードに関する判断 |
| フォーマット | すべてのフォーマット | なし |
| 型チェック | なし | 型注釈、キャスト |
| テスト | 一部のアサーション修正 | ロジックの不具合、モックの更新 |
| セキュリティ | 一部のパターン | アーキテクチャの変更 |
| ビルド | 依存関係のインストール | コードエラー |
| E2E | セレクターの更新 | フローの変更 |
フェーズ 4:修正後の再実行
修正を適用した後、次の手順を実行します。
- 失敗したチェックだけでなく、すべてのチェックを再実行します
- すべてのチェックが成功するか、ユーザーが終了するまで修正ループを続けます
- セッション中に適用したすべての修正を記録します
フェーズ 5:結果レポート
## PR Check Results
**Status**: ALL PASSED | X FAILED
**Duration**: Ns
### Check Results
| Step | Check | Status | Duration |
|------|-------|--------|----------|
| 1/7 | Ruff linter | PASSED | 1.2s |
| 2/7 | Ruff formatter | PASSED | 0.8s |
| 3/7 | Type check | PASSED | 3.4s |
| 4/7 | Tests (48 passed) | PASSED | 12.1s |
| 5/7 | Security scan | PASSED | 2.3s |
| 6/7 | Build | PASSED | 5.6s |
| 7/7 | E2E tests | SKIPPED | --quick |
### Fixes Applied (if any)
- Auto-fixed 3 lint errors (ruff --fix)
- Fixed test assertion in test_create_user
- Remediated B608 SQL injection in users.py
### Next Steps
- Run `/sc:git commit` to commit changes
- Run `/sc:readme` to update documentation
- Create PR with `gh pr create`
MCP 連携
PAL MCP
| ツール | 使用するタイミング | 目的 |
|---|---|---|
mcp__pal__debug | テストの失敗 | 失敗したテストの根本原因を分析します |
mcp__pal__codereview | セキュリティの指摘 | セキュリティ修正を検証します |
mcp__pal__precommit | 最終検証 | 複数モデルによるコミット前チェック |
PAL の使用パターン
# Pre-commit validation after all checks pass
mcp__pal__precommit(
path="/path/to/repo",
step="Validating all changes before PR",
findings="Lint, test, security, type check results",
confidence="high"
)
# Debug complex test failure
mcp__pal__debug(
step="Investigating intermittent test failure in test_auth",
hypothesis="Race condition in async test setup",
confidence="medium"
)
Rube MCP
| ツール | 使用するタイミング | 目的 |
|---|---|---|
mcp__rube__RUBE_MULTI_EXECUTE_TOOL | 通知 | 結果を Slack に投稿し、Jira を更新します |
ツールの連携
- Bash - リンター、フォーマッター、テストランナー、セキュリティスキャナーを実行します
- Glob - ツールの特定に使う設定ファイルを検出します
- Grep - 失敗時の出力を解析し、設定パターンを探します
- Read - 失敗したテストファイルやセキュリティに関する検出結果を読み込みます
- Edit - 自動修正を適用します
関連するスキル
/sc:test- テストの実行とカバレッジの詳細/sc:log-fix- ログ分析によるデバッグ/sc:git- Git ワークフローの操作/sc:analyze- コード品質のより詳細な分析
コメント
Markdown 対応