test

A testing guide for writing tests that follow Selectools project patterns. It covers unit, integration, regression, provider, retrieval, and tool-system tests, including fakes and mocks.

In plain words
What is it for?
Use it when adding tests for source modules, agent behavior, providers, retrieval pipelines, integrations, or tools. It explains how to use the shared fake provider and record regression tests.
Why use it?
It helps keep new tests consistent with the existing test layout and shared fixtures. It also encourages checking edge cases and error paths, not only successful cases.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/johnnichev/selectools/test
Any agent
npx skills add johnnichev/selectools --skill test
Clone the repo
git clone --depth 1 https://github.com/johnnichev/selectools

Made for: Claude Code, Codex.

Per session 16 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,290 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00016 $0.01290
Opus 5 $0.00008 $0.00645
Sonnet 5 $0.00003 $0.00258
Haiku 4.5 $0.00002 $0.00129

Measured yesterday against content hash b42f380b2f32, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

test scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/test/SKILL.md · 171 lines

How it starts

The opening of the file, as written. The whole thing — 171 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Test Writing

Write tests for: $ARGUMENTS

Live Project State

  • Current tests: !pytest tests/ --collect-only -q 2>/dev/null | tail -1

Test Organization

tests/
    conftest.py               # SharedFakeProvider, fixtures, helpers
    test_<module>.py           # Unit tests per source module
    agent/                     # Agent core, observer, batch, regression
        test_regression.py     # ALL regression tests go here
    providers/                 # Provider-specific tests
    rag/                       # RAG pipeline, chunking, stores
    integration/               # Cross-module integration tests
    tools/                     # Tool system tests

SharedFakeProvider (from conftest.py)

Use the fake_provider fixture — it returns a factory. Responses can be:

  • str — auto-wrapped as Message(role=ASSISTANT, content=...)
  • Message — used as-is (for tool_calls, etc.)
  • (Message, UsageStats) tuple — controls token/cost tracking
def test_example(self, fake_provider):
    # Simple text response
    provider = fake_provider(responses=["Hello"])

    # Tool call response
    provider = fake_provider(responses=[
        Message(role=Role.ASSISTANT, content="", tool_calls=[
            ToolCall(tool_name="search", parameters={"q": "test"})
        ]),
        "Final answer",
    ])

    # Response with specific usage stats (for budget/cost tests)
    provider = fake_provider(responses=[
        (Message(role=Role.ASSISTANT, content="answer"),
         UsageStats(prompt_tokens=100, completion_tokens=50,
                    total_tokens=150, cost_usd=0.01,
                    model="test", provider="test")),
    ])

Important: Agent requires at least one tool. Use a dummy:

_DUMMY = Tool(name="noop", description="noop", parameters=[], function=lambda: "ok")

Recording Provider Pattern

Use to verify exact args passed to provider methods:

class RecordingProvider:
    name = "recording"
    supports_streaming = False
    supports_async = False

    def __init__(self):
        self.last_messages = []
        self.last_system_prompt = ""
        self.last_tools = None

    def complete(self, *, model, system_prompt, messages, tools=None, **kw):
        self.last_messages = list(messages)
        self.last_system_prompt = system_prompt
        self.last_tools = tools
        return Message(role=Role.ASSISTANT, content="ok"), UsageStats(
            prompt_tokens=10, completion_tokens=5, total_tokens=15,
            cost_usd=0.0001, model=model, provider="recording",
        )

Read the full file on GitHub · 171 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 171 lines · 16 tokens per session scan A b42f380b2f32

Subscribe to this mod's changes

test is a skill published in the GitHub repository johnnichev/selectools (11 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 16 tokens to every session and 1,290 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.