agentleFS
gjbexgjbex/scientific-computing-skills/skills/scientific-code-style/SKILL.md

scientific-code-style

Skill1 starsChanged 6 months agoApache-2.0View on GitHub

Apply reusable coding, validation, documentation, and compiler

The file

Show its rules and text

We split this skill into the rules it gives an agent

51 rules. About 0 are common, 35 are distinctive, and 16 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈35

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 16

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when editing scientific-computing or HPC code and the repository does not already define stricter conventions in AGENTS.md.

    line 10
  2. Distinctive:

    Use this skill when:

    line 27
  3. Distinctive:

    Do not use this skill to override explicit repository conventions.

    line 33
  4. Distinctive:

    When this skill applies:

    line 37
  5. Distinctive:

    Read the repository AGENTS.md first, if present.

    line 39
  6. Distinctive:

    Follow repository-specific rules where they exist.

    line 40
  7. Distinctive:

    Use this skill only for gaps that are still unspecified.

    line 41
  8. Distinctive:

    Keep changes pragmatic and aligned with the existing codebase.

    line 42
  9. Distinctive:

    Prefer modern coding styles, idioms, and best practices.

    line 46
  10. Distinctive:

    Keep source lines to 79 characters when practical.

    line 47
  11. Distinctive:

    Avoid unnecessary dependencies, imports, and includes.

    line 49
  12. Distinctive:

    Prefer straightforward code that is easy to benchmark, validate, and review.

    line 50
  13. Distinctive:

    Use type hints and docstrings for functions and classes.

    line 54
  14. Very specific:

    Prefer f-strings over % formatting and str.format().

    line 56
  15. Distinctive:

    Prefer list comprehensions and generator expressions when they improve clarity.

    line 57
  16. Distinctive:

    Prefer context managers for resource management.

    line 59
  17. Very specific:

    Prefer pathlib over os.path.

    line 60
  18. Distinctive:

    Use descriptive snake case for variables and functions.

    line 61
  19. Distinctive:

    Prefer single quotes for string literals unless the string contains a single quote.

    line 63
  20. Distinctive:

    Prefer C++20 or later when practical.

    line 70
  21. Distinctive:

    Prefer smart pointers over raw owning pointers.

    line 71
  22. Very specific:

    Prefer range-based for loops when they improve clarity.

    line 72
  23. Very specific:

    Prefer auto when it removes redundant type noise.

    line 73
  24. Very specific:

    Use nullptr instead of NULL or 0.

    line 74
  25. Very specific:

    Prefer constexpr for compile-time constants.

    line 75
  26. Very specific:

    Prefer std::string over C-style strings.

    line 76
  27. Distinctive:

    Use descriptive snake case names.

    line 77
  28. Very specific:

    Prefer -Wall -Wextra -Wpedantic as a practical default when supported.

    line 86
  29. Distinctive:

    Treat new warnings as defects to fix, not noise to ignore.

    line 87
  30. Very specific:

    Use -Werror only when the repository already relies on it or the toolchain is stable enough that it will not create avoidable churn.

    line 88
  31. Distinctive:

    If a warning must be suppressed, prefer the narrowest possible suppression and document why it is necessary.

    line 90
  32. Distinctive:

    Avoid disabling broad warning groups just to silence one issue.

    line 92
  33. Very specific:

    Start with -Wall -Wextra -Wpedantic for GCC and Clang.

    line 96
  34. Very specific:

    Consider adding -Wshadow when variable shadowing is likely to hide defects.

    line 97
  35. Very specific:

    Consider adding -Wconversion and -Wsign-conversion for numerically sensitive code, but expect some cleanup effort before enabling them …

    line 98
  36. Very specific:

    Consider adding -Wdouble-promotion for floating-point-heavy code when the toolchain supports it.

    line 100
  37. Very specific:

    Consider adding -Wformat=2 for stricter format-string checking in C code.

    line 102
  38. Distinctive:

    Prefer enabling additional warnings incrementally and fixing the resulting issues rather than turning on a large set all at once.

    line 103
  39. Distinctive:

    Do not weaken warnings in release builds merely to keep optimized builds quiet.

    line 112
  40. Very specific:

    If -Werror is used, prefer enabling it in CI or in well-controlled toolchains rather than assuming it is safe everywhere.

    line 114
  41. Distinctive:

    Use a target-scoped warning helper rather than global flags when the repository uses CMake:

    line 119
  42. Distinctive:

    Run static analysis tools appropriate to the language when available.

    line 155
  43. Distinctive:

    If tools are unavailable, state that explicitly rather than assuming compliance.

    line 160
  44. Very specific:

    Use developer-tool-installation-policy when deciding whether formatters, linters, or static-analysis tools should be project-pinned through …

    line 163
  45. Distinctive:

    Add automated tests for major functionality when feasible.

    line 169
  46. Distinctive:

    Keep tests independent of execution order.

    line 170
  47. Distinctive:

    Document nontrivial functions, classes, and modules.

    line 177
  48. Distinctive:

    Add usage examples when they materially help understanding.

    line 178
  49. Distinctive:

    Prefer single quotes for Python docstrings.

    line 180
  50. Distinctive:

    Use doctest format for Python examples when examples are useful.

    line 181
  51. Distinctive:

    When using this skill, briefly note:

    line 186

≈ “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 Code Style

Use this skill when editing scientific-computing or HPC code and the repository does not already define stricter conventions in AGENTS.md.

Repository AGENTS.md instructions take precedence over this skill.

Purpose

Apply a consistent reusable default for:

  • coding style
  • language features to prefer or avoid
  • validation habits
  • testing expectations
  • documentation quality

When To Use

Use this skill when:

  • the task is in a scientific, numerical, or HPC codebase
  • the user wants reusable scientific-computing conventions applied
  • repository instructions are absent, minimal, or intentionally high-level

Do not use this skill to override explicit repository conventions.

Working Approach

When this skill applies:

  1. Read the repository AGENTS.md first, if present.
  2. Follow repository-specific rules where they exist.
  3. Use this skill only for gaps that are still unspecified.
  4. Keep changes pragmatic and aligned with the existing codebase.

General Conventions

  • Prefer modern coding styles, idioms, and best practices.
  • Keep source lines to 79 characters when practical.
  • Use descriptive names.
  • Avoid unnecessary dependencies, imports, and includes.
  • Prefer straightforward code that is easy to benchmark, validate, and review.

Python Conventions

  • Use type hints and docstrings for functions and classes.
  • Follow PEP 8.
  • Prefer f-strings over % formatting and str.format().
  • Prefer list comprehensions and generator expressions when they improve clarity.
  • Prefer context managers for resource management.
  • Prefer pathlib over os.path.
  • Use descriptive snake case for variables and functions.
  • Define constants at module scope with uppercase names.
  • Prefer single quotes for string literals unless the string contains a single quote.
  • Group imports as standard library, third-party, and local imports.
  • Separate import groups with a blank line and alphabetize within each group.

C++ Conventions

  • Prefer C++20 or later when practical.
  • Prefer smart pointers over raw owning pointers.
  • Prefer range-based for loops when they improve clarity.
  • Prefer auto when it removes redundant type noise.
  • Use nullptr instead of NULL or 0.
  • Prefer constexpr for compile-time constants.
  • Prefer std::string over C-style strings.
  • Use descriptive snake case names.
  • Define constants with constexpr or const using uppercase names.
  • Group headers as corresponding header, standard library, third-party, and project headers.
  • Separate header groups with a blank line and alphabetize within each group.

Compiler Warnings

  • Enable a useful baseline of compiler warnings for C and C++ builds.
  • Prefer -Wall -Wextra -Wpedantic as a practical default when supported.
  • Treat new warnings as defects to fix, not noise to ignore.
  • Use -Werror only when the repository already relies on it or the toolchain is stable enough that it will not create avoidable churn.
  • If a warning must be suppressed, prefer the narrowest possible suppression and document why it is necessary.
  • Avoid disabling broad warning groups just to silence one issue.

Recommended Warning Flags

  • Start with -Wall -Wextra -Wpedantic for GCC and Clang.
  • Consider adding -Wshadow when variable shadowing is likely to hide defects.
  • Consider adding -Wconversion and -Wsign-conversion for numerically sensitive code, but expect some cleanup effort before enabling them broadly.
  • Consider adding -Wdouble-promotion for floating-point-heavy code when the toolchain supports it.
  • Consider adding -Wformat=2 for stricter format-string checking in C code.
  • Prefer enabling additional warnings incrementally and fixing the resulting issues rather than turning on a large set all at once.

Build-Type Guidance

  • In debug builds, prefer strong warnings and debug symbols so problems are easy to diagnose.
  • In release builds, keep the same warning baseline unless there is a repository-specific reason to differ.
  • Do not weaken warnings in release builds merely to keep optimized builds quiet.
  • If -Werror is used, prefer enabling it in CI or in well-controlled toolchains rather than assuming it is safe everywhere.

CMake Pattern

Use a target-scoped warning helper rather than global flags when the repository uses CMake:

function(enable_project_warnings target_name)
    target_compile_options(${target_name} PRIVATE
        $<$<AND:$<COMPILE_LANGUAGE:C>,$<C_COMPILER_ID:GNU,Clang>>:
            -Wall
            -Wextra
            -Wpedantic
            -Wshadow
            -Wformat=2
        >
        $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:GNU,Clang>>:
            -Wall
            -Wextra
            -Wpedantic
            -Wshadow
        >
    )
endfunction()

Then apply it per target:

add_executable(example example.cpp)
enable_project_warnings(example)

For numerically sensitive targets, consider a second stricter helper that adds flags such as -Wconversion, but only after the repository is ready to address the extra findings.

Validation Defaults

  • Run static analysis tools appropriate to the language when available.
  • For Python, prefer pylint, flake8, and mypy.
  • For C++, prefer clang-tidy and cppcheck.
  • For compiled languages, check whether warning flags are enabled and add them when the build system does not already define a reasonable baseline.
  • If tools are unavailable, state that explicitly rather than assuming compliance.

Use developer-tool-installation-policy when deciding whether formatters, linters, or static-analysis tools should be project-pinned through repository configuration or installed globally for ad hoc inspection.

Testing Defaults

  • Add automated tests for major functionality when feasible.
  • Keep tests independent of execution order.
  • Cover normal behavior and meaningful edge cases.
  • For Python, prefer pytest.
  • For C++, prefer Google Test.

Documentation Defaults

  • Document nontrivial functions, classes, and modules.
  • Add usage examples when they materially help understanding.
  • For Python docstrings, prefer numpy or scipy style.
  • Prefer single quotes for Python docstrings.
  • Use doctest format for Python examples when examples are useful.
  • For C++, prefer Doxygen-style comments.

Output Expectations

When using this skill, briefly note:

  • whether repository rules overrode any part of this skill
  • which validation or test steps were run
  • which checks could not be run

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.