agentleFS
ROCmROCm/rocprofiler-systems-skills/skills/static-analysis/SKILL.md

static-analysis

Skill5 starsChanged 16 days agoMITView on GitHub

Run static analysis tools on changed files and generate a report

  • Installs packages

12 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use build-keil, can-debug and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • ZhongYechengSkill

    build-keil

    当需要通过 Keil MDK 命令行编译嵌入式工程,调用自带脚本解析工程文件、执行构建并定位固件产物时使用。

    Also in 3 projects that use this

  • ZhongYechengSkill

    can-debug

    当需要调试 CAN 总线通信时使用,支持通过 USB-CAN 适配器监听、发送 CAN 帧和扫描节点。

    Also in 3 projects that use this

  • iPlug2Skill

    build-cmake

    Build an iPlug2 plugin project using CMake with Ninja, Xcode, or Visual Studio generators

    Also in 3 projects that use this

  • +9 more from ZhongYecheng

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run available static analysis tools on changed files and produce a structured report.

    line 8
  2. Distinctive:

    Ask user or detect automatically:

    line 49
  3. Distinctive:

    If running in VS Code with MCP:

    line 115
  4. Very specific:

    When invoked from pr-review:

    line 293
  5. Distinctive:

    When run standalone, output the full report to the user.

    line 313

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Static Analysis Skill

Run available static analysis tools on changed files and produce a structured report.

When to Use

ContextTrigger
StandaloneUser asks to run static analysis, linters, or check code quality
PR ReviewInvoked by pr-review before manual code review
Pre-commitUser wants to check code before committing

Workflow

┌─────────────────────────────────────────────────────────────────┐
│                  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     │
└─────────────────────────────────────────────────────────────────┘

Phase 1: Get Changed Files

Determine Scope

Ask user or detect automatically:

ScopeCommandUse When
PR changesgit diff --name-only <base>...HEADReviewing a PR
Stagedgit diff --name-only --cachedPre-commit check
Unstagedgit diff --name-onlyCheck current work
All uncommittedgit diff --name-only HEADLocal changes review
Specific filesUser-provided listTargeted 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

Filter by Language

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' ' ')

Phase 2: Detect Available Tools

# 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"

Check for compile_commands.json (C++)

# 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

Use IDE Diagnostics (if available)

If running in VS Code with MCP:

Use mcp__ide__getDiagnostics to get real-time diagnostics

Phase 3: Run Tools on Changed Files

C++ Tools

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

Python Tools

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

Shell Tools

shellcheck:

if [ -n "$sh_files" ] && which shellcheck >/dev/null 2>&1; then
    shellcheck $sh_files 2>&1
fi

CMake Tools

cmake-lint:

if [ -n "$cmake_files" ] && which cmake-lint >/dev/null 2>&1; then
    cmake-lint $cmake_files 2>&1
fi

Phase 4: Generate Report

Severity Mapping

ToolCheck/CodeSeverity
clang-tidybugprone-*, clang-analyzer-*Critical (100)
clang-tidyperformance-*Should Fix (50)
clang-tidymodernize-*, readability-*Nitpick (20)
cppcheckerrorCritical (100)
cppcheckwarningMust Fix (80)
cppcheckstyle, performanceShould Fix (50)
ruffE (error), F (pyflakes)Must Fix (80)
ruffW (warning)Should Fix (50)
ruffC, N (convention, naming)Nitpick (20)
pylintE, F (error, fatal)Critical (100)
pylintW (warning)Should Fix (50)
pylintC, R (convention, refactor)Nitpick (20)
mypyerrorMust Fix (80)
shellcheckerrorMust Fix (80)
shellcheckwarningShould Fix (50)
shellcheckinfo, styleNitpick (20)

Report Format

# 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

🟠 Must Fix (X)

2. performance-unnecessary-copy-initialization

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

🟡 Should Fix (X)

...


🔵 Nitpicks (X)

...


Tools Not Available

The following tools were not found and could not be run:

  • cppcheck - Install with: apt install cppcheck
  • mypy - Install with: pip install mypy

No Issues Found

✅ 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

Standalone Usage

When run standalone, output the full report to the user.

Example invocations:

  • "run static analysis" → analyze all uncommitted changes
  • "run static analysis on staged files" → pre-commit check
  • "run clang-tidy on the PR" → C++ analysis only
  • "check code quality" → full analysis with report

Tool Installation Reference

ToolLanguageInstall Command
clang-tidyC++apt install clang-tidy or comes with LLVM
cppcheckC++apt install cppcheck
ruffPythonpip install ruff
pylintPythonpip install pylint
mypyPythonpip install mypy
shellcheckShellapt install shellcheck
cmake-lintCMakepip install cmakelint

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.