pytest-dev
pytest-dev
Produce high-signal, low-flake, fast pytest suites and CI configs, with an explicit focus on measurable wins (runtime, flake rate, coverage quality).
Default workflow
- Classify the tests
- Unit: pure functions, no I/O (preferred)
- Integration: DB/filesystem/multiprocess, slower but valuable
- System/E2E: external services or UI, keep minimal and well-gated
- Identify boundaries
- Time/clock, randomness, network, filesystem, DB, env vars, global state
- Pick the lightest seam
- Prefer fakes/stubs over deep mocks; prefer dependency injection over patching internals
- Make it deterministic
- Control time, seeds, tmp dirs; avoid order dependencies
- Measure before optimizing
- Collection time vs runtime; quantify with
--durations+ a single baseline
- Collection time vs runtime; quantify with
- Harden for CI
- Enforce marker discipline, strict config, timeouts, isolation for parallel
Quick commands
Use python3 by default. If the project uses uv, prefer uv run python.
- Smallest repro:
python3 -m pytest path/to/test_file.py -q - First failure only:
python3 -m pytest -x --maxfail=1 - Find slow tests:
python3 -m pytest --durations=20 --durations-min=0.5 - Emit JUnit for CI:
python3 -m pytest --junitxml=reports/junit.xml - Parallelize on one machine (xdist):
python3 -m pytest -n auto --dist load
Optimization playbook (high ROI)
- Reduce collection scope (
testpaths,norecursedirs, avoid importing heavy modules at import time). - Fix fixture scoping (move expensive setup up-scope; ensure isolation).
- Eliminate sleeps and retries (poll with timeouts; mock time).
- Parallelize safely (xdist; isolate worker resources: tmp/db ports).
- Shard in CI (split test files by historical timings; keep shards balanced).
Use the bundled references
Read these when needed (keep SKILL.md lean):
references/pytest_core.md: fixtures, markers, parametrization, strict mode, TOML config, subtests (pytest 9.x).references/plugins.md: plugin selection + usage patterns.references/performance.md: collection/runtime profiling and speedups.references/ci_github_actions.md: sharding, artifacts, caching, concurrency.
Use the bundled scripts
scripts/junit_slowest.py: report slowest tests/files from JUnit XML.scripts/junit_split.py: split test files into N shards using JUnit timings.scripts/run_pytest_filelist.py: run pytest for a list of test files.
Quality gates
- Tests pass in a clean environment (no hidden dependency on local state).
- No network/time dependency without explicit control.
- Parallel-safe or explicitly marked/serialized.
- CI emits machine-readable artifacts when relevant (JUnit, coverage).
More from bjornmelin/dev-skills
streamdown
|
13docker-architect
SOTA Docker/Compose architecture, implementation, refactor, and security hardening. Use when working on containerization tasks such as creating or rewriting Dockerfiles, docker-compose files, buildx/bake configs, .dockerignore, and CI pipelines for build/test/scan/publish; auditing existing container setups for security, correctness, size/perf, and best practices (least privilege, non-root, minimal images, pinned base images, BuildKit secrets, healthchecks); debugging Docker build/run issues; or designing dev vs prod compose workflows across services (DB/cache/queues) with correct networking, volumes, secrets, and resource limits.
6ai-sdk-core
|
5supabase-ts
Production-ready Supabase integration patterns for Next.js/React/TypeScript applications. Use when working with Supabase for (1) SSR authentication with @supabase/ssr, (2) Database operations and migrations, (3) Row Level Security (RLS) policies, (4) Storage buckets and file uploads, (5) Realtime channels and presence, (6) Edge Functions with Deno, (7) pgvector embeddings and semantic search, (8) Vercel deployment and connection pooling, (9) CLI operations (type generation, migrations). Triggers on Supabase client setup, auth patterns, RLS policies, storage uploads, realtime subscriptions, Edge Functions, vector search, or Vercel+Supabase deployment.
2bun-dev
Definitive, rule-first Bun development/build/runtime guidance + automation. Use when adopting Bun, migrating a repo from Node.js, auditing/fixing Bun package management (bun.lockb, bun install), optimizing scripts/monorepos (bun run --parallel/--sequential, --workspaces/--filter), configuring Bun + TypeScript, using bun test/build, tuning performance, or deploying Bun workloads/Vercel Functions with the Bun runtime (bunVersion, limitations, Next.js ISR scripts).
1gh-pr-review-fix
Fetch unresolved GitHub PR review threads, normalize them, fix them end-to-end, verify the results, and re-check until the PR is clean or blocked. Use when the user wants GitHub PR comments resolved with minimal verified fixes. Do not use for local review files, Codex reviews, or Zen reviews; review-remediation owns those.
1