agentleFS
klntskyklntsky/icare/skills/test-efficiently/SKILL.md

test-efficiently

Skill1 starsChanged 7 days agoUnlicenseView on GitHub

Improves performance of the tests

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 9 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before you apply any of these principles, decide if you should using the understand-intent skill.

    line 9
  2. Distinctive:

    When dealing with test performance problems, figure out which resources are the bottleneck first:

    line 15
  3. Distinctive:

    Test utilities should contain bracket-pattern-style helpers for every layer.

    line 28
  4. Distinctive:

    When to use: if the resources are verifiably isolated enough that we don't care about their interactions.

    line 42
  5. Distinctive:

    Don't be overprotective: excessive resource utilization can be fixed later.

    line 52
  6. Distinctive:

    if CPU-bound: aim to leave 2 cores unused (roughly, 8 cores implies max 6 runners)

    line 54
  7. Distinctive:

    if I/O-bound: keep disk I/O utilization roughly below 50%

    line 55
  8. Distinctive:

    if API ratelimit-bound: parallelization is not helping much, but keep 2 parallel workers so that the tests fail loudly if the app logic …

    line 56
  9. Distinctive:

    If a test runner or framework supports only file-based test parallelisation, then parallelisation is controled by test file structure.

    line 60

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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

Principles for improving test performance

Before you apply any of these principles, decide if you should using the understand-intent skill.

TP0. Diagnosing test performance problems

Tests share different types of system resources.

When dealing with test performance problems, figure out which resources are the bottleneck first:

  • Memory
  • CPU utilization (total percentage and pinned cores)
  • Disk I/O
  • File descriptors
  • Environment resources (third-party API ratelimit allowance, remote resource locks, and such)

TP1. Layered resource management

Resources form layers naturally. Example of a multi-layer test environment: funds allocated on a smart contract running on an EVM testnet forked from mainnet that uses a third-party RPC.

Test utilities should contain bracket-pattern-style helpers for every layer.

To reduce boilerplate, expose a declarative utility that accepts a single record containing a declaration of every needed resource, and prepares the context for a test runner callback.

Consider that:

  • resources can have multiple sources (e.g. a mock EVM chain and a public testnet) - represent that in the interface
  • resources may be optional - make them optional in the interface. Ensure the tests only request the needed ones.

TP2. Optimizing resource sharing

Tests that utilize resources from their environment can be optimized heavily by sharing these resources between tests, as much as isolation requirements permits that. The decision to do so mush be based on concrete time measurements of resource acquisition and release.

When to use: if the resources are verifiably isolated enough that we don't care about their interactions. Requires understanding both the nature of resources and the way they are used in the application logic.

TP3. Test parallelization

How much to parallelize?

  1. Determine if the resources needed for testing are scarce enough for that to be a problem:
  • Measure measureable TP0 resource consumption
  • Third party resources may have documented limits - investigate.
  • Estimate the utilization of the rest of resources using common sense
  1. Don't be overprotective: excessive resource utilization can be fixed later. Assume we're good if unclear.
  2. The system and other apps compete for some of the resources the tests use. Unless instructed otherwise:
  • if CPU-bound: aim to leave 2 cores unused (roughly, 8 cores implies max 6 runners)
  • if I/O-bound: keep disk I/O utilization roughly below 50%
  • if API ratelimit-bound: parallelization is not helping much, but keep 2 parallel workers so that the tests fail loudly if the app logic silently assumes it can have all the resources to itself without proper ratelimit handling.

Sharing resources between parallel test instances

If a test runner or framework supports only file-based test parallelisation, then parallelisation is controled by test file structure.

In this case, consider implementing a test server that manages the test environment and provides an API for test workers to connect to it. It can be made compatible with TP1 layered resource management, but instead of allocating the resources, the helpers should delegate providing them to the test server.

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.