بنقرة واحدة
static-analysis
Run static analysis tools on changed files and generate a report
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Run static analysis tools on changed files and generate a report
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Given a TheRock nightly build (URL or run-id), return the rocm-systems pin_sha used in that build
Check whether a given rocm-systems commit is included in a specific TheRock nightly build
Find the first TheRock nightly build that includes a given rocm-systems commit
Reviews Pull Requests or local diffs with an 8-agent fan-out covering static analysis, dead code, code smells + quality (naming, complexity, single-responsibility, magic numbers), language rules (C++/Python/CMake), architecture, simplification, performance (hot-path classification, allocations, locks, I/O), and undefined behaviour (signed overflow, lifetime, strict aliasing, data races, sanitizer coverage; C/C++/unsafe-Rust only). Use when the user asks to "review this PR", "review the diff", "audit this branch", "/pr-review", or when staging changes before push.
Walk through a PR review interactively, one finding at a time. Generate review via pr-review, then for each issue present analysis + proposed inline comment, let user accept/edit/skip, accumulate into a PENDING GitHub review, submit at end.
Use when user wants to list, analyze, review, or summarize GitHub PR comments on a pull request number or URL
| name | static-analysis |
| description | Run static analysis tools on changed files and generate a report |
Run available static analysis tools on changed files and produce a structured report.
| Context | Trigger |
|---|---|
| Standalone | User asks to run static analysis, linters, or check code quality |
| PR Review | Invoked by pr-review before manual code review |
| Pre-commit | User wants to check code before committing |
┌─────────────────────────────────────────────────────────────────┐
│ Phase 1: Get Changed Files │
│ Determine scope (PR, staged, or all changes) │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Phase 2: Detect Available Tools │
│ Check which tools are installed on the system │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Phase 3: Run Tools on Changed Files │
│ Execute each tool, capture output │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Phase 4: Generate Report │
│ Parse output, categorize by severity, format report │
└─────────────────────────────────────────────────────────────────┘
Ask user or detect automatically:
| Scope | Command | Use When |
|---|---|---|
| PR changes | git diff --name-only <base>...HEAD | Reviewing a PR |
| Staged | git diff --name-only --cached | Pre-commit check |
| Unstaged | git diff --name-only | Check current work |
| All uncommitted | git diff --name-only HEAD | Local changes review |
| Specific files | User-provided list | Targeted analysis |
# Get base branch (for PR scope)
base_branch=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')
[ -z "$base_branch" ] && base_branch="main"
# Get changed files based on scope
case "$scope" in
pr) changed_files=$(git diff --name-only "$base_branch"...HEAD) ;;
staged) changed_files=$(git diff --name-only --cached) ;;
all) changed_files=$(git diff --name-only HEAD) ;;
esac
cpp_files=$(echo "$changed_files" | grep -E '\.(cpp|cc|cxx|c|hpp|h)$' | tr '\n' ' ')
py_files=$(echo "$changed_files" | grep -E '\.py$' | tr '\n' ' ')
sh_files=$(echo "$changed_files" | grep -E '\.(sh|bash)$' | tr '\n' ' ')
cmake_files=$(echo "$changed_files" | grep -E '(CMakeLists\.txt|\.cmake)$' | tr '\n' ' ')
# C++ tools
which clang-tidy >/dev/null 2>&1 && echo "clang-tidy: available"
which cppcheck >/dev/null 2>&1 && echo "cppcheck: available"
# Python tools
which ruff >/dev/null 2>&1 && echo "ruff: available"
which pylint >/dev/null 2>&1 && echo "pylint: available"
which mypy >/dev/null 2>&1 && echo "mypy: available"
# Shell tools
which shellcheck >/dev/null 2>&1 && echo "shellcheck: available"
# CMake tools
which cmake-lint >/dev/null 2>&1 && echo "cmake-lint: available"
# Required for clang-tidy
if [ -f "build/compile_commands.json" ]; then
echo "compile_commands.json: build/"
elif [ -f "compile_commands.json" ]; then
echo "compile_commands.json: ./"
else
echo "compile_commands.json: NOT FOUND (clang-tidy may not work)"
fi
If running in VS Code with MCP:
Use mcp__ide__getDiagnostics to get real-time diagnostics
clang-tidy:
if [ -n "$cpp_files" ] && which clang-tidy >/dev/null 2>&1; then
compile_db=""
[ -f "build/compile_commands.json" ] && compile_db="-p build/"
[ -f "compile_commands.json" ] && compile_db="-p ."
for file in $cpp_files; do
[ -f "$file" ] && clang-tidy "$file" $compile_db 2>&1
done
fi
cppcheck:
if [ -n "$cpp_files" ] && which cppcheck >/dev/null 2>&1; then
cppcheck --enable=warning,style,performance $cpp_files 2>&1
fi
ruff (recommended - fast):
if [ -n "$py_files" ] && which ruff >/dev/null 2>&1; then
ruff check $py_files 2>&1
fi
pylint:
if [ -n "$py_files" ] && which pylint >/dev/null 2>&1; then
pylint --output-format=text $py_files 2>&1
fi
mypy:
if [ -n "$py_files" ] && which mypy >/dev/null 2>&1; then
mypy $py_files 2>&1
fi
shellcheck:
if [ -n "$sh_files" ] && which shellcheck >/dev/null 2>&1; then
shellcheck $sh_files 2>&1
fi
cmake-lint:
if [ -n "$cmake_files" ] && which cmake-lint >/dev/null 2>&1; then
cmake-lint $cmake_files 2>&1
fi
| Tool | Check/Code | Severity |
|---|---|---|
| clang-tidy | bugprone-*, clang-analyzer-* | Critical (100) |
| clang-tidy | performance-* | Should Fix (50) |
| clang-tidy | modernize-*, readability-* | Nitpick (20) |
| cppcheck | error | Critical (100) |
| cppcheck | warning | Must Fix (80) |
| cppcheck | style, performance | Should Fix (50) |
| ruff | E (error), F (pyflakes) | Must Fix (80) |
| ruff | W (warning) | Should Fix (50) |
| ruff | C, N (convention, naming) | Nitpick (20) |
| pylint | E, F (error, fatal) | Critical (100) |
| pylint | W (warning) | Should Fix (50) |
| pylint | C, R (convention, refactor) | Nitpick (20) |
| mypy | error | Must Fix (80) |
| shellcheck | error | Must Fix (80) |
| shellcheck | warning | Should Fix (50) |
| shellcheck | info, style | Nitpick (20) |
# Static Analysis Report
**Scope:** [PR #123 / staged changes / all uncommitted]
**Files analyzed:** X files
**Tools run:** clang-tidy, ruff, shellcheck
## Summary
| Severity | Count |
|----------|-------|
| 🔴 Critical | X |
| 🟠 Must Fix | X |
| 🟡 Should Fix | X |
| 🔵 Nitpick | X |
**Total issues:** X
---
## 🔴 Critical Issues (X)
### 1. bugprone-use-after-move
**File:** `src/parser.cpp:42`
**Tool:** clang-tidy
**Severity:** Critical (100)
**Message:**
'data' used after it was moved
**Context:**
```cpp
auto result = std::move(data);
process(data); // Bug: data was moved
File: src/handler.cpp:78
Tool: clang-tidy
Severity: Should Fix (50)
Message:
The copy 'config' is only used as const reference; consider making it a const reference
...
...
The following tools were not found and could not be run:
cppcheck - Install with: apt install cppcheckmypy - Install with: pip install mypy✅ No issues detected by static analysis tools.
## Integration with pr-review
When invoked from `pr-review`:
1. `pr-review` calls `static-analysis` with PR scope
2. `static-analysis` runs tools and generates report
3. Report is included in PR review under "Static Analysis Results"
4. Issues are merged with manual review findings by severity
```markdown
## How pr-review uses this skill:
1. Invoke static-analysis skill with scope=pr
2. Get the generated report
3. Include report in Phase 4 (Code Review) findings
4. Critical/Must Fix issues from tools → Must Fix in review
5. Should Fix from tools → Should Fix in review
6. Nitpicks from tools → Nitpick in review
When run standalone, output the full report to the user.
Example invocations:
| Tool | Language | Install Command |
|---|---|---|
| clang-tidy | C++ | apt install clang-tidy or comes with LLVM |
| cppcheck | C++ | apt install cppcheck |
| ruff | Python | pip install ruff |
| pylint | Python | pip install pylint |
| mypy | Python | pip install mypy |
| shellcheck | Shell | apt install shellcheck |
| cmake-lint | CMake | pip install cmakelint |