pytest-optimizer

pytest-optimizer is a skill for Claude Code, Codex from tony/skills. It costs 27 tokens per session (2,427 once invoked), scanned A, original, MIT.

A measured process for making a slow pytest test suite faster. Pytest is a Python testing tool; this process profiles the suite, tests possible changes, and keeps only speedups that exceed normal timing variation.

In plain words
What is it for?
Use it to optimize slow pytest tests or fixtures, compare timing baselines, apply safe changes one at a time, and resume unfinished optimization work.
Why use it?
A change that looks faster may simply be within measurement noise or may weaken test safety. Measuring before and after each change helps distinguish real improvements from misleading results.

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/tony/skills/pytest-optimizer
Any agent
npx skills add tony/skills --skill pytest-optimizer
Clone the repo
git clone --depth 1 https://github.com/tony/skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pytest-optimizer

README.md
[![agentmods](https://agentmods.dev/badge/skills/tony/skills/pytest-optimizer.svg)](https://agentmods.dev/skills/tony/skills/pytest-optimizer)
Your own site
<a href="https://agentmods.dev/skills/tony/skills/pytest-optimizer"><img src="https://agentmods.dev/badge/skills/tony/skills/pytest-optimizer.svg" alt="Measured on agentmods" height="20"></a>
Per session 27 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,427 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.00027 $0.02427
Opus 5 $0.00014 $0.01213
Sonnet 5 $0.00005 $0.00485
Haiku 4.5 $0.00003 $0.00243

Measured 4d ago against content hash 99e2e280f64b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

pytest-optimizer 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 4d ago.

The scan reads SKILL.md. This mod also ships 2 executable files (templates/conftest_cache_snippet.py, templates/pytest_optimizer_plugin.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

.agents/skills/pytest-optimizer/SKILL.md · 194 lines

How it starts

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

pytest-optimizer

Profile a pytest suite, find safe speedups, and apply each one as its own verified commit — through a resumable, idempotent four-phase loop.

The core discipline: measure before you mutate, and prove a speedup against the project's own timing noise before you trust it. A theoretically great change whose measured delta falls inside the noise band is worth nothing and is never committed.

$ARGUMENTS may name a test path or marker to scope the run, a --phase to jump to, --force to ignore idempotency tokens and re-run, and --memory-dir to override where durable state is written.

The loop

00-scan  ->  01-benchmark  ->  02-plan  ->  03-execute  ->  (re-scan)

Each phase is a separate command that reads and writes durable JSON under the resolved memory directory. Re-running the whole skill resumes at the first incomplete phase. After 03-execute, re-scanning measures the new baseline and the loop can continue until no candidate clears the rubric.

Phase Command Reads Writes
1 the pytest-optimizer-00-scan skill AGENTS.md/CLAUDE.md, prior state.json baseline.json, capabilities.json, hypotheses.json
2 the pytest-optimizer-01-benchmark skill baseline.json, hypotheses.json benchmarks.json
3 the pytest-optimizer-02-plan skill benchmarks.json, baseline.json plan.json
4 the pytest-optimizer-03-execute skill plan.json, baseline.json execution-log.json + commits

Step 1: Detect preferred tools and the project test command

Check for the user's preferred search tools, then read the project's own test and quality-check commands. Never hardcode the runnerpytest, uv run, tox, nox, and hatch are all valid and the project declares which it uses.

for tool in rg ag fd jq uv uvx; do command -v "$tool" >/dev/null 2>&1 && echo "$tool:available" || echo "$tool:missing"; done

Read AGENTS.md, CLAUDE.md, justfile, tox.ini, and pyproject.toml to discover the canonical commands for running the suite, the formatter, the linter, and the type checker. Record the test command verbatim; every phase reuses it.

Read the full file on GitHub · 194 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. 4d ago First seen · 194 lines · 27 tokens per session scan A 99e2e280f64b

Subscribe to this mod's changes

pytest-optimizer is a skill published in the GitHub repository tony/skills (2 stars, last pushed 6d ago), licensed MIT. It adds 27 tokens to every session and 2,427 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-31.

Related

Other skills, from other repositories

specify-factory

Decompose a multi-feature or multi-component specification into factory-consumable artifacts. Use this for high-complexity work — multiple features, three or more components, or parallel-eligible workstreams.

rsmdt/the-startup · 45 tokens

debug

Systematically diagnose and resolve bugs through conversational investigation and root cause analysis.

rsmdt/the-startup · 15 tokens

specify-incremental

Decompose a single-feature specification into a linear, phase-by-phase implementation plan. Use this for medium-complexity work — single feature, one or two components — where transparent human-in-the-loop phase review is preferred over factory automation.

rsmdt/the-startup · 53 tokens

validate

Validate in any of six modes — spec quality, single-file review, spec-to-implementation drift, constitution rule enforcement, comparison between two artifacts, or sanity-checking your understanding. Use when checking a spec by ID, validating a file by path, detecting drift, enforcing constitution rules, comparing two…

rsmdt/the-startup · 77 tokens

pattern-detection

Identify existing codebase patterns (naming conventions, architectural patterns, testing patterns) to maintain consistency. Use when generating code, reviewing changes, or understanding established practices.

rsmdt/the-startup · 37 tokens

requirements-elicitation

Requirement gathering techniques, stakeholder analysis, user story patterns, and specification validation. Use when clarifying vague requirements, resolving conflicting needs, documenting specifications, or validating requirements with stakeholders.

rsmdt/the-startup · 40 tokens