Spectre review

From sxs-collaboration/spectre · View interactive version

Spectre review is an AI agent skill from the GitHub repository sxs-collaboration/spectre. **Current branch**: !`git branch --show-current`

How to use this skill

Skill file

SpECTRE Code Review

Arguments: $ARGUMENTS

Current branch: !git branch --show-current

Perform a thorough code review of SpECTRE changes. Follow every step below

precisely. The full SpECTRE code rules reference (provide to review agents):

!tail -n +5 .claude/rules/Cxx.md

Step 1: Parse Arguments & Acquire Diff

Parse $ARGUMENTS:

gh pr diff <N> --repo sxs-collaboration/spectre and

`gh pr view <N> --repo sxs-collaboration/spectre --json

title,body,headRefName,baseRefName`

changes, plus git diff and git diff --cached for uncommitted changes. If

no diff, fall back to git diff HEAD~1.

Save the diff. Extract the list of changed files categorized by type (C++

.cpp/.hpp/.tpp, Python .py, CMake CMakeLists.txt, other).

Create a task list tracking all review steps.

Step 2: Formatting Checks (run in parallel)

C++ (clang-format)

For each changed C++ file:

  1. Parse diff hunk headers (@@ +START,COUNT @@) to get changed line ranges
  2. Expand each range by +/-4 lines (clamped to file bounds)
  3. Run: clang-format -style=file --lines=START:END [--lines=...] FILEPATH
  4. Diff against original. Collect any formatting differences.

Python (black + isort)

For each changed .py file (excluding external/):

black --check --diff FILEPATH
isort --check-only --diff FILEPATH

Step 3: CI Pre-Checks on Changed Files (run in parallel)

Check each changed file for issues that SpECTRE CI (tools/FileTestDefs.sh,

tools/CheckFiles.sh) will flag. Only check lines/patterns introduced in the

diff, not pre-existing issues.

All files: lines >80 chars (excluding URLs, NOLINT, #include, \snippet,

\image, \link, import); missing MIT license header; no final newline; tabs;

trailing whitespace; carriage returns

C++ files (.cpp/.hpp/.tpp):

remove const from the declaration (keep in definition)

Test files:

CMake: New C++ files in a directory must be listed in that directory's

CMakeLists.txt; removed files must be removed; entries should be alphabetical.

LLM Comments: Identify comments that seem like notes from a coding agent

during its thinking process.

Include Order (C++ files in diff)

Verify:

  1. (Tests) "Framework/TestingFramework.hpp" first, then blank line
  2. (.cpp with .hpp) Corresponding .hpp, then blank line
  3. STL/external <headers> alphabetical
  4. Blank line
  5. SpECTRE "headers" alphabetical

Commit Messages (local mode only)

Check no commit starts with (case-insensitive): fixup, wip, fixme, deleteme,

rebaseme, testing, rebase.

Step 4: Code Review (2 Parallel Agents)

Launch 2 parallel agents. Provide each with the full diff and the

SpECTRE code rules reference shown above.

Agent A: Style, Patterns & Idioms

Instructions for the agent:

EagerMath)

operation, a loop that looks like it reimplements an existing utility), use

grep -r in src/DataStructures/Tensor/EagerMath/, src/DataStructures/,

src/NumericalAlgorithms/, or src/Utilities/ to find an existing utility

explanation

Agent B: Bugs, Logic, Tests & Documentation

Instructions for the agent:

context

race conditions, incorrect template instantiations, virtual inheritance issues

(most-derived must init virtual bases)

tests/Unit/Foo/Test_Bar.cpp)

(a - b where a ~ b).

inputs (e.g., near coordinate boundaries, poles, or special points).

numbers accumulates round-off.

(a*x^3 + b*x^2 + c*x + d), instead use Horner's method,

evaluate_polynomial() from src/Utilities/Math.hpp

(-b +/- sqrt(b^2 - 4ac)) / 2a loses precision.

correction to a large value drops the correction entirely.

of log(1+x), expm1(x) instead of exp(x)-1, hypot(x,y) instead of

sqrt(x*x+y*y).

Step 5: clang-tidy (if requested, run in parallel)

If "clang-tidy" was in arguments:

  1. Check for build/compile_commands.json. If missing, report that clang-tidy

requires a configured build directory and skip.

  1. For each changed .cpp file: clang-tidy -p build/ FILEPATH 2>&1
  2. Filter output to only warnings on lines in the diff.

Step 6: Code Coverage (if requested, run in parallel)

If "coverage" was in arguments:

Read references/coverage-steps.md and follow those instructions exactly.

Step 7: Self-Review Prune

Combine all findings from steps 2-6. Review each finding and REMOVE only clear

non-issues:

Assign each remaining finding a confidence score (0-100). Remove findings

below 50. Keep all findings scoring 50 or above -- err on the side of including

borderline issues rather than missing real ones.

Step 8: Lightweight Model Critique

Spawn an agent using the cheapest available model (Claude Code: haiku;

Codex: gpt-5.4-mini). Provide it with:

Ask the critique agent to:

  1. Score each finding 0-100 for "is this a real, actionable issue?"
  2. Flag any remaining false positives with reasoning
  3. Note if important issues seem to be missing
  4. Return scores and feedback

After receiving the critique agent's feedback:

40-60

Step 9: Final Report

Read references/report-template.md and present the report in that format.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.