agentleFS
gjbexgjbex/scientific-computing-skills/skills/scientific-testing/SKILL.md

scientific-testing

Skill1 starsChanged 6 months agoApache-2.0View on GitHub

Design and implement tests for scientific-computing and HPC

The file

Show its rules and text

We split this skill into the rules it gives an agent

30 rules. About 0 are common, 27 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈27

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when adding or reviewing tests for scientific, numerical, or parallel software where correctness must be established with …

    line 11
  2. Distinctive:

    Use this skill when:

    line 29
  3. Distinctive:

    Do not use this skill to replace formal verification, large-scale scientific validation campaigns, or performance benchmarking.

    line 37
  4. Distinctive:

    When this skill applies:

    line 42
  5. Distinctive:

    Read the repository AGENTS.md first, if present.

    line 44
  6. Distinctive:

    Prefer fast tests that isolate one numerical property at a time.

    line 46
  7. Distinctive:

    Use exact equality only for inherently discrete outputs.

    line 47
  8. Distinctive:

    Prefer repository-native test runners and layout.

    line 52
  9. Distinctive:

    Prefer a mix of:

    line 57
  10. Distinctive:

    Keep expensive end-to-end cases sparse.

    line 67
  11. Very specific:

    Prefer abs(a - b) <= atol + rtol * abs(b) or the testing framework's equivalent.

    line 72
  12. Very specific:

    Use atol for quantities expected near zero.

    line 74
  13. Very specific:

    Use rtol when magnitude scales with the input or reference solution.

    line 75
  14. Distinctive:

    Avoid reusing one global tolerance for every variable.

    line 76
  15. Distinctive:

    When choosing a tolerance, consider:

    line 81
  16. Distinctive:

    Prefer analytically solvable cases when available.

    line 91
  17. Distinctive:

    Keep reference inputs and outputs small enough for routine test runs.

    line 94
  18. Distinctive:

    Do not treat a previous buggy implementation as ground truth simply because it is older.

    line 98
  19. Distinctive:

    When randomness is intrinsic, assert distribution-level or range-based properties instead of single exact values.

    line 104
  20. Distinctive:

    If a solver may converge in different iteration counts across platforms, test the achieved quality of the solution rather than the exact …

    line 108
  21. Distinctive:

    Test more than one thread or rank count when practical.

    line 114
  22. Distinctive:

    Check for invariants that should hold regardless of scheduling.

    line 116
  23. Distinctive:

    Add at least one test designed to catch partitioning or halo-exchange errors when the code is domain-decomposed.

    line 117
  24. Distinctive:

    If bitwise reproducibility is a user requirement, treat it as a separate goal and document the runtime and compiler constraints needed to …

    line 120
  25. Distinctive:

    Run the smallest relevant test slice first before broader suites.

    line 134
  26. Distinctive:

    Prefer framework-native assertions over hand-rolled comparison code.

    line 135
  27. Distinctive:

    When a tolerance is non-obvious, explain it in the test or commit message.

    line 136
  28. Distinctive:

    If a test is flaky, identify whether the cause is randomness, concurrency, I/O, or an invalid assertion before widening the tolerance.

    line 137
  29. Distinctive:

    Prefer CI-friendly tests that finish quickly and avoid machine-specific assumptions unless the repository explicitly supports heavier …

    line 139
  30. Distinctive:

    When using this skill, briefly note:

    line 160

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “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

Scientific Testing

Use this skill when adding or reviewing tests for scientific, numerical, or parallel software where correctness must be established with domain-appropriate checks rather than naive exact equality.

Repository AGENTS.md instructions take precedence over this skill.

Purpose

Apply a pragmatic default for:

  • numerical assertions and tolerance choices;
  • regression tests for scientific outputs;
  • deterministic and stochastic test design;
  • parallel correctness checks;
  • lightweight test reporting that explains what was and was not validated.

When To Use

Use this skill when:

  • outputs are floating-point, iterative, or otherwise numerically sensitive;
  • the user asks for tests, validation, or regression protection;
  • a benchmark or optimization task still needs a correctness backstop;
  • serial and parallel implementations should agree within a justified margin;
  • exact output equality is unstable or misleading.

Do not use this skill to replace formal verification, large-scale scientific validation campaigns, or performance benchmarking.

Working Approach

When this skill applies:

  1. Read the repository AGENTS.md first, if present.
  2. Identify the smallest stable signal that demonstrates correctness.
  3. Prefer fast tests that isolate one numerical property at a time.
  4. Use exact equality only for inherently discrete outputs.
  5. Choose tolerances that reflect the algorithm, scale, and conditioning of the problem.
  6. State what the test proves and what it does not prove.

Prefer repository-native test runners and layout. Add new test helpers only when they reduce duplication or clarify numerical intent.

Test Selection

Prefer a mix of:

  • smoke tests for basic execution and output shape;
  • regression tests against trusted reference outputs;
  • property tests for invariants such as conservation, monotonicity, symmetry, or bounded residuals;
  • edge-case tests for small inputs, degenerate geometry, empty data, and boundary conditions;
  • parallel-consistency tests comparing thread counts, schedules, or ranks.

Keep expensive end-to-end cases sparse. Cover most behavior with small, interpretable inputs.

Numerical Assertions

  • Prefer abs(a - b) <= atol + rtol * abs(b) or the testing framework's equivalent.
  • Use atol for quantities expected near zero.
  • Use rtol when magnitude scales with the input or reference solution.
  • Avoid reusing one global tolerance for every variable.
  • Tighten tolerances only when the algorithm and platform justify them.
  • Loosen tolerances only with a concrete reason such as conditioning, non-associative reductions, or vendor-library variation.

When choosing a tolerance, consider:

  • floating-point precision;
  • accumulation order and reduction structure;
  • iterative solver stopping criteria;
  • mesh size, discretization error, or sampling noise;
  • cross-platform differences from BLAS, MPI, OpenMP, or math libraries.

Reference Data

  • Prefer analytically solvable cases when available.
  • Otherwise use trusted baseline outputs generated from a known-good version.
  • Record how the reference data was produced.
  • Keep reference inputs and outputs small enough for routine test runs.
  • Store derived summaries when full outputs are too large, such as norms, residuals, checksums, or key observables.

Do not treat a previous buggy implementation as ground truth simply because it is older.

Stochastic and Iterative Workloads

  • Fix random seeds when the goal is deterministic regression protection.
  • When randomness is intrinsic, assert distribution-level or range-based properties instead of single exact values.
  • For iterative methods, assert convergence behavior, residual thresholds, or invariant preservation rather than internal iteration-by-iteration identity.
  • If a solver may converge in different iteration counts across platforms, test the achieved quality of the solution rather than the exact count alone.

Parallel Correctness

  • Compare serial and parallel outputs on the same input.
  • Test more than one thread or rank count when practical.
  • Expect small floating-point differences from non-associative reductions.
  • Check for invariants that should hold regardless of scheduling.
  • Add at least one test designed to catch partitioning or halo-exchange errors when the code is domain-decomposed.

If bitwise reproducibility is a user requirement, treat it as a separate goal and document the runtime and compiler constraints needed to maintain it.

Anti-Patterns

  • exact equality for generic floating-point arrays without justification;
  • tolerances so loose that major regressions still pass;
  • tests that only check that a file exists;
  • benchmarking without a correctness guardrail;
  • asserting implementation details instead of scientific properties;
  • large golden files with no provenance.

Validation Defaults

  • Run the smallest relevant test slice first before broader suites.
  • Prefer framework-native assertions over hand-rolled comparison code.
  • When a tolerance is non-obvious, explain it in the test or commit message.
  • If a test is flaky, identify whether the cause is randomness, concurrency, I/O, or an invalid assertion before widening the tolerance.
  • Prefer CI-friendly tests that finish quickly and avoid machine-specific assumptions unless the repository explicitly supports heavier validation tiers.
  • State explicitly which test commands were run and which could not be run.

Framework Patterns

For Python, prefer pytest with pytest.approx or numpy.testing helpers.

For C++, prefer the repository's existing framework. When options are open, Google Test with helper functions for vector, norm, or residual checks is a practical default.

For CMake-based projects, prefer registering tests with ctest when that is the existing project pattern.

For array-style comparisons, prefer norms or elementwise comparisons with clear absolute and relative tolerances instead of custom loops unless the framework is unavailable.

Output Expectations

When using this skill, briefly note:

  • what numerical property or invariant each added test checks;
  • how tolerances or acceptance criteria were chosen;
  • whether reference data, seeds, or parallel comparisons were used;
  • which validation commands were run;
  • which correctness risks remain untested.

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.