drannarosen/research-workflow/scientific-code-reviewer

Claude Code and agent skill by drannarosen/research-workflow

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Review existing research code. Lenses: PHYSICS (units, dimensions, bounds, conservation, limits), NUMERICS (cancellation, overflow, silent non-convergence, tolerances, conditioning, symplecticity, CFL), ROBUSTNESS (swallowed exceptions), DATA I/O (format, units metadata, precision, portability), CRAFT (structure, docstrings that match the code). Don't use for JAX tracing mechanics (→ jax-code-validator), figures (→ figure-review), or validating your own method's order (→ numerical-method-validation).

Install

npx vskill@latest install drannarosen/research-workflow/scientific-code-reviewer

SKILL.md

The same SKILL.md was published earlier as drannarosen/research-workflow/scientific-code-reviewer.

Scientific Code Reviewer

Review existing code for whether it computes the right physics, stably. Report a concise issue list with file:line; expand to a per-quantity table only on request. Apply the lens(es) the change touches and say which you skipped.

A review reports findings to the researcher. A fix that is purely numerical and leaves the physics unchanged (expm1, a convergence flag, a guard) can be suggested directly. A fix that would change the physics — a new closure, a softening choice, a boundary condition, a tolerance that decides pass or fail, a replacement formula — is a proposal with its motivation, not a correction (→ researcher-in-the-loop, the assumption ledger (research-records)).

Physics lens

  • Name the unit system first. CGS, SI, or a documented code-unit system (e.g. G = 1; or M☉, pc,

Myr with G = 4.498e-3 pc³ M☉⁻¹ Myr⁻²). Documented code units are not a defect. Flag an SI constant in code that claims CGS or code units (G = 6.674e-11 next to c = 3e10), and an undocumented bare constant.

  • Dimensional analysis on each key equation: dimensions of both sides match; "dimensionless"

quantities really are.

  • Physical bounds: can mass, density, temperature, or opacity go negative? Can a speed exceed c?

Are r → 0 and other singularities handled?

  • Conservation: energy, linear and angular momentum, mass, and problem-specific invariants

(Jacobi integral). For simulation engines, expect an automated test asserting the invariant within a stated tolerance over a long integration, not an eyeballed plot.

  • Limits and references: known analytic solutions and limiting cases (M → 0, r → ∞, t → 0) are

cheap and belong in review; flag a new physics term that lacks its analytic-limit test. A missing comparison to a reference code or published result is a milestone item to note, not a review defect, while the code is in development (validation stages → verification-gate). Much real astrophysics (SSE fits, SCF, cluster metrics) has only semi-analytic or literature comparisons; accept those rather than demanding an analytic solution that doesn't exist.

  • Formulas with no derivation or citation (often AI-written) get the dimensional and limit checks

before anything else (→ derivation-before-implementation).

Numerics lens

  • Cancellation: a - b with a ≈ b; 1 - cos(x) → 2*sin(x/2)**2; exp(x) - 1 → expm1;

log(1 + x) → log1p; sqrt(a**2 + b**2) - a for a ≫ b → b**2 / (sqrt(a**2 + b**2) + a).

  • Overflow / underflow: exp(x) overflows float64 for x ≳ 709; float factorials overflow past

n = 170 (use gammaln for ratios); CGS products like G*M**2 can exceed float32 range. Prefer log space.

  • Iterations: every solver loop has a tolerance, an iteration cap, and a reported convergence

status. Returning the last iterate on non-convergence is a silent failure.

  • Tolerances: a hard-coded rtol=1e-12 needs a reason and a convergence study showing it's

needed; tiny is not automatically good. A small residual is not a small error: the bound is ‖e‖/‖x‖ ≤ κ·‖r‖/‖b‖.

  • Conditioning: near-singular systems detected or regularized; decomposition matched to the

matrix (Cholesky for SPD, QR/SVD for least squares).

  • Structure preservation: an integrator claimed symplectic or time-reversible really is; a naively

adaptive timestep breaks symplecticity and turns bounded energy error into drift; close encounters are regularized or softened consistently in both forces and energy diagnostics.

  • Stability: explicit schemes respect CFL; stiff problems use implicit or IMEX methods.
  • Precision: float64 for core physics; explicit float32 flagged unless justified; floating

comparisons use tolerances, not ==.

Teaching code: a naive Euler integrator in a lecture example is advisory, not a defect, unless the code is tagged research or production.

Output

## Scientific review: <file>
Unit system: <CGS | SI | code units (stated) | mixed>
Lenses: physics ✓ · numerics ✓
- L42 [physics] no guard for r <= 0 → assert, or propose a softening (researcher's choice)
- L87 [numerics] 1 - cos(theta) at small angle → 2*sin(theta/2)**2
- Conservation: energy test exists (|ΔE/E| < 1e-8 over 1e3 t_dyn) ✓

Robustness lens: no silent failure

A swallowed exception silently corrupts a result. except: pass (or except Exception: pass) turns a solver that diverged, a fit that failed, a file that didn't load, or an array that went NaN into a clean-looking run that produces a wrong number, and because it doesn't crash, nobody investigates. A caught error is handled, logged with context and re-raised, or allowed to propagate. How to respond (retry, fallback with a logged warning, re-raise with context) depends on the failure; what matters is that the failure stays visible. The no_silent_except hook leaves a note on the canonical pattern.

Handling an exception
  • Catch narrowly: except ValueError, not bare except: or except Exception. A broad catch

hides the error you didn't anticipate, and a bare except also catches KeyboardInterrupt/SystemExit. A broad try around many lines has the same effect: one catch absorbs several different failures.

  • Do something real: recover meaningfully, or log with context and re-raise. Propagating is better

than silencing. Converting a hard failure into a default or None that flows downstream unflagged is silencing.

  • Don't drop data silently: an except: continue that skips bad inputs is a silent selection

effect. Count, log, and report what was skipped (→ adversarial-result-check, lane 5).

  • An intended no-op is explicit and narrow: `except FileNotFoundError: pass # optional cache,

regenerated below`, so the intent is auditable. This is rare.

  • The same applies to NaN/Inf: nan_to_num or a silent isnan-skip is the float-domain version

(→ numerical-precision).

Data I/O lens

Review data I/O code for whether an output file can be read correctly, by someone else, years from now. Report key issues by default; give the full review with format recommendations on request. You can't verify file contents without reading the file, and you aren't assessing I/O performance.

Format choice
Data TypeRecommendedAcceptableAvoid
Large arraysHDF5, ZarrNumPy .npy/.npzpickle
Tabular dataHDF5, Parquet, FITSCSV (with schema)Excel
Images/spectraFITSHDF5PNG/JPEG for data (8/16-bit integer, no float values or WCS; JPEG is also lossy)
Config/paramsYAML, TOMLJSONpickle
CheckpointsHDF5, Zarr.npzpickle

Pickle is version-fragile (tied to the Python and class definitions that wrote it) and unsafe to load from untrusted sources. Recommendations are defaults; a project's established format can win.

Checks
  • Units and metadata travel with the data. Unit system and units (e.g. "cluster",

"M_sun, pc, Myr"), physical parameters (N, softening), code version (git hash), timestamp, and a run id linking to the run record. Seeds live once, in the run record (run-reproducibility); the file links to it rather than copying them. A bare np.save("output.npy", positions) answers none of "what units, what parameters".

  • Precision. float64 is preserved where needed and not silently truncated to float32 on write

(.astype(np.float32) before save); integers have an appropriate dtype; intentional precision loss is documented. Set the dtype explicitly on write.

  • Schema. A complex layout has a schema file or documentation giving each dataset's shape, dtype,

and units, with self-explanatory field names and documented nesting: ``yaml simulation_output.h5: /positions: # (n_particles, 3) float64, units: pc /velocities: # (n_particles, 3) float64, units: pc/Myr /masses: # (n_particles,) float64, units: M_sun /attributes: unit_system: # str, e.g., "cluster" time: # float64, current simulation time in Myr git_hash: # str, code version ``

  • Readable in 2+ years. A widely supported format (HDF5, FITS, not custom binary), no

Python-version-specific features (pickle protocol), minimal and stable read dependencies.

  • Large data. Chunking matched to access (e.g. chunks=(100, n_particles, 6) chunks a trajectory

by time), so one timestep reads without loading everything (f["trajectory"][100]); compression where appropriate (e.g. gzip level 4).

Output (quick mode)
## Data I/O Review: [filename]
**Format:** Using pickle for checkpoints -> recommend HDF5
**Metadata:** No unit system recorded; missing git hash; timestamp not timezone-aware
**Precision:** float64 preserved for positions/velocities
**Portability:** Pickle files won't survive Python version changes

Craft lens: structure and documentation

Review the craft of scientific-computing code (structure, abstraction, documentation) separately from its scientific correctness. Report key issues by default; give the full report with suggested fixes on request. Findings go to the researcher. A refactor that preserves behavior is a mechanical suggestion; one that would change what the code computes, or who owns an equation, is flagged as a proposal (→ researcher-in-the-loop, ownership-and-structure).

Research code is not production code

Scientific code is read by domain experts and rewritten constantly for experiments. Optimize for readable by physicists, easy to modify, and a clear connection to the equations or paper. It does not need enterprise patterns (factories, DI frameworks, deep class hierarchies) and shouldn't be prematurely optimized. Judge every "clean code" suggestion against that bar, and flag both over- and under-engineering.

Architecture

Abstraction, in both directions:

  • Over: class hierarchies for simple scripts, factories/DI for single implementations,

"future-proofing" that will never be used.

  • Under: 500+ line functions, nesting deeper than 3, the same logic copy-pasted with minor variations

(extract a parameterized function).

Prefer simple flat functions; refactor to classes only when backends must be swapped, code is reused across projects, or state genuinely benefits from encapsulation.

Public API surface: minimal, with implementation details not exposed; helpers private (_prefixed) and __all__ defined for public modules; action-oriented names (compute_orbital_period, not orbit); consistent parameter order across related functions (e.g. every *_step(state, dt, force_fn)).

Layout (computational-astrophysics convention, e.g. gravax): physics kernels in dedicated modules; integrators compose kernels rather than duplicate physics; state transitions isolated to step functions; I/O separated from computation; tests beside the package.

Documentation

Docstring–code consistency is the freshness check that matters most:

  • documented parameters, defaults, and returns match the actual signature;
  • documented exceptions are actually raised;
  • no docstring describes an old API that no longer exists (the highest-value catch);
  • public functions and classes have docstrings; complex ones include an example.

NumPy docstring format; flag missing or stale content rather than re-teaching the format.

README, for scientific code beyond purpose/install/quickstart/deps/license: a link to the paper or citation if applicable, the unit system, and example outputs.

Guides (if present): user guide = install, getting-started, common use cases, API reference, troubleshooting. Developer guide = architecture overview, how to add a feature, testing conventions, release process. Check internal links resolve and referenced functions and classes still exist (→ verification-gate for the sweep after a change lands).

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/drannarosen/research-workflow/scientific-code-reviewer/badge)](https://verified-skill.com/skills/drannarosen/research-workflow/scientific-code-reviewer)

Something wrong with this skill or its page? Tell us.