agentleFS
TheAstroByteTheAstroByte/astrobyte-agent-skills/skills/hermetic-test-suites/SKILL.md

hermetic-test-suites

Skill1 starsChanged 15 days agoMITView on GitHub

Make test suites deterministic across local, CI, clean checkout, repeated, and randomized runs. Use when tests depend on environment variables, repository files, external services, background work, process-global caches, execution order, or leftover state.

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:

    Run the failing tests in the developer checkout and a clean checkout from the same commit.

    line 10
  2. Distinctive:

    default config paths and repository-local data

    line 19
  3. Distinctive:

    Treat a passing dirty checkout as suspect until the same test passes without its leftover state.

    line 26
  4. Distinctive:

    use framework-native dependency overrides and restore the previous mapping

    line 34
  5. Distinctive:

    run workers inline for behavior tests.

    line 36
  6. Distinctive:

    Keep production defaults at the composition root.

    line 39
  7. Distinctive:

    Update stale assertions only after isolation is in place.

    line 45
  8. Distinctive:

    Verify in this order:

    line 49
  9. Distinctive:

    no unhandled-thread, unraisable, or delayed background exception

    line 57

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

Hermetic test suites

Establish the mismatch

Run the failing tests in the developer checkout and a clean checkout from the same commit. Record exact node IDs, environment differences, generated files, warnings, and background failures. Keep stale assertions separate from isolation failures.

The baseline is complete when every observed difference has evidence rather than an assumed CI explanation.

Inventory ambient inputs

Trace each test through the real runtime boundary and account for:

  • environment variables and credential discovery
  • default config paths and repository-local data
  • network clients, cloud SDKs, clocks, randomness, and host services
  • process-global caches, singletons, mutable factories, and dependency maps
  • background threads, tasks, subprocesses, and delayed exceptions
  • writes outside per-test temporary storage
  • state left by earlier tests

Treat a passing dirty checkout as suspect until the same test passes without its leftover state.

Build explicit seams

Move nondeterminism to injectable boundaries:

  • pass config values or explicit fixture paths
  • construct services with injected clients, formatters, clocks, launchers, and storage
  • use framework-native dependency overrides and restore the previous mapping
  • clear every relevant cache before and after tests
  • run workers inline for behavior tests; use a recording launcher when only scheduling matters
  • store reusable payloads under the test data tree and load them through fakes

Keep production defaults at the composition root. Core behavior should run without credentials, network access, repository config, or mutable class state.

Patch third-party constructors only at their import boundary when constructor wiring is the behavior under test. Prefer dependency injection for application code.

Repair expectations

Update stale assertions only after isolation is in place. Assert domain results, persisted status transitions, constructor contracts, and scheduled work at their owning seams. Give each API test unique identifiers and use clients as context managers so lifespan cleanup runs.

Prove hermeticity

Verify in this order:

  1. previously failing node IDs in isolation
  2. the full suite from a clean checkout with generated directories absent
  3. the full suite with provider, credential, tracing, and app-config variables removed
  4. two consecutive full runs
  5. at least three deterministic shuffled orders
  6. unchanged repository status and no repository-local writes
  7. no unhandled-thread, unraisable, or delayed background exception

Make thread and unraisable warnings test errors. A network-blocking plugin is optional evidence, not a substitute for injected dependencies.

The suite is trustworthy when every verification mode agrees and no run depends on state that another run created.

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.