Agent skill · posthog
maintaining-python-tests
Maintains existing pytest and Django test suites without weakening correctness. Use when asked to reduce Python test runtime or CI work, investigate slow pytest families, remove stale migration tests, consolidate repeated setup, improve Python test ownership, or measure whether a test optimization worked after merge. Ranks work by measured cost, applies the writing-tests value gate to existing coverage, preserves distinct behavior cases, validates isolation after shared-fixture changes, and separates testcase work from pytest-suite wall time. For an intermittent failure, use fixing-flaky-tests instead.
What it needs
About 6k tokens when loaded.
What this skill does
Maintaining Python tests Before you propose a change to how the suite runs in CI, check things already tried. It records measured verdicts on test parallelism, sharding, and coverage-based selection, so a rejected approach is not rebuilt. Use this skill for an existing Python test suite. Use /writing-tests before adding or substantially changing coverage. Use /fixing-flaky-tests when intermittent failure is the main problem. The goal is not a smaller test count. The goal is a suite that catches the same realistic regressions with less compute, less waiting, and less maintenance. Principles 1. Measure before changing code. Rank tests by total observed work, not by one slow local run. 2. Preserve behavior coverage. Keep cases that exercise different validation, persistence, integration, or output paths. 3. Remove only expired or redundant coverage. Get explicit approval before deleting a test. 4. Share expensive infrastructure, not mutable test state. Preserve isolation with unique IDs, schemas, tables, topics, or tenants. 5. Measure after merge. Local results prove the mechanism. Fresh master data proves the result in CI. 6. Separate testcase work from suite wall time. A change can reduce summed testcase time and not change the slowest pytest suite. Read measurement.md before you query timing data or report an improvement. Read optimization-patterns.md when you select a fix. Workflow 1. Define the result Write down the user problem before choosing a test: Reduce total test compute. Reduce the slowest pytest suite. Remove expired maintenance burden. Restore test ownership. Reduce repeated external-service setup. These results need different measurements. Do not claim faster CI when only summed test call time decreased. 2. Rank current work Use recent PostHog test spans from master when available. Start with a complete window after the latest relevant merge. Rank at least three views: Individual tests: execution count multiplied by duration. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills posthog/maintaining-python-tests