Agent skill

Hermetic Python Unit Tests

by dimensionalOS in dimensionalOS/dimos

Rules for writing, fixing and reviewing pytest unit tests that are hermetic: behavior-focused, deterministic, isolated and cheap to run.

Custom licenceAuto-check passedTesting & QA

Install Hermetic Python Unit Tests

skills CLI
$ npx skills add dimensionalOS/dimos --skill python-unit-tests -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install dimensionalOS/dimos python-unit-tests --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/dimensionalOS/dimos.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/python-unit-tests .claude/skills/python-unit-tests && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
python-unit-tests
GitHub stars
4.6k
Token cost
~1.4k tokens
SKILL.md length
760 words
Files
1
Skills in repo
1
Repo updated
First seen
Licence
Custom licence

At a glance

Rules for writing, fixing and reviewing pytest unit tests that are hermetic: behavior-focused, deterministic, isolated and cheap to run.

  • Works in 5 steps: Scope the behavior. Identify the code… → Build a hermetic setup. Use module-level… → Assert the contract. Use small examples… → …
  • Writing pytest unit tests for new or changed Python code
  • SKILL.md covers Steps, Test shape, Fixtures and cleanup and Assertions, plus 4 more sections
  • Calls uv

What it does

This skill sets out how to write Python pytest unit tests that are hermetic. It is meant to be used before adding, changing or reviewing tests. A five-step flow starts by scoping the behavior and placing the test file beside the code (`dimos/core/foo.py` gets `dimos/core/test_foo.py`), then builds a setup that owns its cleanup and has no fixed sleeps, asserts exact outcomes a caller depends on, mocks only slow, nondeterministic or external boundaries, and validates with the smallest command that could fail.

Test-shape rules favor descriptive names, Arrange-Act-Assert order, module-level imports and `assert result == expected` over shape-only checks, and rule out no-value tests such as ones proving a dataclass stores its constructor arguments. Mocking goes through `mocker.patch`, `mocker.patch.object` or `monkeypatch`, never direct method assignment. Fixtures keep setup and teardown together so cleanup runs even when assertions fail. A few repo docs on testing and code quality are consulted only when more context is needed.

When your agent uses it

  • Writing pytest unit tests for new or changed Python code
  • Fixing flaky tests that use sleeps or leak global state
  • Reviewing feedback on a PR's tests
  • Replacing hand-rolled mocks with mocker or monkeypatch

Example prompts

  • “Write unit tests for dimos/core/foo.py covering the retry behavior.”
  • “This test uses time.sleep to wait for a thread. Make it deterministic.”
  • “Review the tests in my PR and remove any that only prove a constructor stored its arguments.”

Requirements

  • Python with pytest

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Scope the behavior. Identify the code under test, the caller-visible outcome, and the smallest test file next to it: dimos/core/foo.py…
  2. Build a hermetic setup. Use module-level imports, Arrange-Act-Assert structure, fixtures for shared or resource-owning setup, and context…
  3. Assert the contract. Use small examples and exact expected values. Completion: every test has an unconditional assertion that proves…
  4. Mock the boundary. Mock only slow, nondeterministic, or external boundaries. Completion: patches use mocker.patch, mocker.patch.object, or…
  5. Validate tightly. Run the smallest command that can fail for the change, then broaden only when the edit justifies it. Completion: the…

What it can do on your machine

Read from SKILL.md and the folder at commit faf1bed. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • uv

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use uv, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Hermetic Python Unit Tests loads about 1.4k tokens when it runs. Until then it costs about 30 tokens; SKILL.md has 760 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~30
When it runs · the whole SKILL.md, loaded when a task matches
~1.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

Its licence (Custom licence) doesn't allow us to republish the file, so here is its outline and opening line. It has 760 words (~1,438 tokens).

“Use this skill before adding, changing, or reviewing Python unit tests. The goal is hermetic tests: behavior-focused, deterministic, isolated, and cheap to run.”

— opening of SKILL.md by dimensionalOS, Custom licence
name
python-unit-tests

Read the full SKILL.md on GitHub

Files

Just SKILL.md in .agents/skills/python-unit-tests of dimensionalOS/dimos.

Open the folder on GitHubat commit faf1bed

Compare with similar skills

Hermetic Python Unit Tests next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Hermetic Python Unit Tests compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Hermetic Python Unit Tests this skilldimensionalOS/dimos4.6k—~1.4kAutomated safety check: PassCustom licence
Adk Verify Snippetsgoogle/adk-python22k—~1.4kAutomated safety check: PassApache-2.0
Test Coverage Reviewareed1192/finance-news-aggregator149—~2.6kAutomated safety check: PassMIT
Py Package Checkipea/geobr959—~1.4kAutomated safety check: NotesNone
Testing Livekit Agentslivekit-examples/agent-starter-python2641 repos~1.9kAutomated safety check: PassMIT
Mutation Test Strength Auditbuildfastwithai/gen-ai-experiments785—~641Automated safety check: PassMIT

Similar skills

  • Adk Verify Snippets

    google/adk-python

    Official

    Checks that every Python code block in a Markdown file actually compiles and runs, by extracting each block to a temporary file, executing it in an isolated subprocess, and writing a pass/fail…

    22k GitHub stars~1.4k tokensUpdated today
    Testing & QAAuto-check passed
  • Test Coverage Review

    areed1192/finance-news-aggregator

    Audit, plan, write, and verify unit tests for Python projects using pytest.

    149 GitHub stars~2.6k tokensUpdated 5 mo ago
    Testing & QAAuto-check passed
  • Run the Python package release gate for geobr — sync the locked environment, run the offline and network test suites, build the distribution, and review the source against the Python conventions.

    959 GitHub stars~1.4k tokensUpdated 9 days ago
    Testing & QAAuto-check: notes
  • Testing Livekit Agents

    livekit-examples/agent-starter-python

    Writes turn-level tests for a LiveKit agent in the user's normal test suite: pytest (Python) or Vitest (Node.js).

    264 GitHub starsUsed in 1 repo~1.9k tokens
    Testing & QAAuto-check passed
  • Mutation Test Strength Audit

    buildfastwithai/gen-ai-experiments

    Measures how well a Python pytest suite catches behavior changes through diff-scoped mutation testing, then proposes and verifies tests for surviving mutants.

    785 GitHub stars~641 tokensUpdated 15 days ago
    Testing & QAAuto-check passed
  • TDD Guide

    alirezarezvani/claude-skills

    Test-driven development skill for writing unit tests, generating test fixtures and mocks, analyzing coverage gaps, and guiding red-green-refactor workflows across Jest, Pytest, JUnit, Vitest, and…

    28k GitHub stars~3.4k tokensUpdated 1 mo ago
    Testing & QAAuto-check passed

Works with

Categories

Questions about Hermetic Python Unit Tests

What does Hermetic Python Unit Tests do?

Rules for writing, fixing and reviewing pytest unit tests that are hermetic: behavior-focused, deterministic, isolated and cheap to run. This skill sets out how to write Python pytest unit tests that are hermetic. It is meant to be used before adding, changing or reviewing tests.

When should I use Hermetic Python Unit Tests?

Hermetic Python Unit Tests fits situations like: writing pytest unit tests for new or changed Python code; fixing flaky tests that use sleeps or leak global state; reviewing feedback on a PR's tests; replacing hand-rolled mocks with mocker or monkeypatch.

How do I install Hermetic Python Unit Tests in Claude Code?

Run `npx skills add dimensionalOS/dimos --skill python-unit-tests -a claude-code`. Or copy the skill folder (.agents/skills/python-unit-tests in dimensionalOS/dimos) into .claude/skills/python-unit-tests in your project. Claude Code loads it when a task matches its description.

How do I install Hermetic Python Unit Tests in Codex?

Run `npx skills add dimensionalOS/dimos --skill python-unit-tests -a codex`. Or copy the skill folder (.agents/skills/python-unit-tests in dimensionalOS/dimos) into .agents/skills/python-unit-tests in your project. Codex loads it when a task matches its description.

Can I use Hermetic Python Unit Tests in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add dimensionalOS/dimos --skill python-unit-tests -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/python-unit-tests, .gemini/skills/python-unit-tests, .github/skills/python-unit-tests and .opencode/skills/python-unit-tests in your project.

What does Hermetic Python Unit Tests need to run?

Going by SKILL.md and its folder, Hermetic Python Unit Tests needs the command-line tools its instructions call (uv). Our summary lists: Python with pytest.

Does Hermetic Python Unit Tests access the network?

SKILL.md contains no URLs. Its commands use uv, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Hermetic Python Unit Tests safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Hermetic Python Unit Tests use?

Hermetic Python Unit Tests has a licence file (the repository's licence) that doesn't match a standard licence. Read it on GitHub before reusing the skill.

How many tokens does Hermetic Python Unit Tests use?

About 1.4k tokens (SKILL.md is roughly 5.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Hermetic Python Unit Tests?

Skills that share tags, products or a category with Hermetic Python Unit Tests: Adk Verify Snippets (google/adk-python, 22k stars), Test Coverage Review (areed1192/finance-news-aggregator, 149 stars), Py Package Check (ipea/geobr, 959 stars) and Testing Livekit Agents (livekit-examples/agent-starter-python, 264 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Hermetic Python Unit Tests?

dimensionalOS (a GitHub organization) maintains it in dimensionalOS/dimos, which has 4,626 GitHub stars. The repository was last updated on October 7, 2026.

Source: dimensionalOS/dimos on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.