test-economy

Counts full-suite test runs per session and nudges when they exceed the budget.

2|Updated Jul 18, 2026
One-click install
npx skills add https://github.com/Arasz/ai-badger --skill test-economy-arasz
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: test-economy
Source: https://github.com/Arasz/ai-badger/tree/main/features/common/skills/test-economy
Command: npx skills add https://github.com/Arasz/ai-badger --skill test-economy-arasz

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Agents repeatedly run full test suites locally — the agent's run, then a gate's run, then CI's run — all proving the same commit and burning time and tokens. This Skill enforces a test-run economy: run the modified surface and its consumers once, leave the full suite to CI, and only fall back to local gates when CI is dead. ## Core Features & Use Cases - Runner detection and classification: Recognizes pytest, unittest, dotnet test, npm/yarn/pnpm/bun test, jest, vitest, playwright, go test, cargo test, mvn, gradle, mix, phpunit, rake, and swift test, classifying each invocation as full or filtered based on selectors like paths, -k, --filter, and -run. - Per-session budget with escalation: A PostToolUse hook counts full-suite runs per project per session, fires an advisory nudge on the run past the budget (3rd by default), and escalates to a STOP message from the escalation bar (5th by default). - CI-aware guidance and gate detection: The nudge message names detected local gate wiring (lefthook, pre-commit, husky, git pre-push hooks) so the CI-dead branch is actionable, and deliberate flake diagnosis is the one exempted repetition. - Use Case: While fixing a bug, you run the full pytest suite three times in one session; the hook emits an additionalContext message telling you to run only the touched surface locally and read CI's verdict instead. ## Quick Start Ask the agent to fix a failing test and let the PostToolUse hook automatically count your test runs and warn you if full-suite runs repeat past the session budget.

Frequently Asked Questions about test-economy

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I stop an AI agent from re-running the full test suite?▼

Install the test-economy PostToolUse hook, which counts full-suite runs per session and emits an advisory message once the count passes the budget (default: nudge on the 3rd run). It never blocks the tool call; it only adds context telling the agent to run the touched surface and read CI's verdict.

Which test runners does the hook recognize?▼

It recognizes pytest, python -m unittest, dotnet test, npm/yarn/pnpm/bun test, npx jest/vitest/playwright/mocha, go test, cargo test, mvn test, gradle test, mix test, phpunit, php artisan test, rake test, and swift test, classifying each as full or filtered.

Does a filtered test run count against the budget?▼

No. A run carrying a selector — a path, -k, --filter, --tests, -run, or -Dtest= — is classified as filtered and never counts. Note that go test ./... counts as full while go test ./pkg/... counts as filtered.

Can I configure the full-suite run budget?▼

Yes. Set AI_BADGER_TEST_ECONOMY_MAX_FULL to change how many full runs are allowed before the nudge (default 2, nudge on the 3rd), and AI_BADGER_TEST_ECONOMY_ESCALATE_AT to set the count from which every full run emits the STOP form (default 5).

What happens when CI is dead or absent?▼

The economy shifts the gate local: run the project's hooked-up gates (lefthook, pre-commit, husky, or a git pre-push hook) once before push, or one manual full-suite run when nothing is wired. The hook's message names whichever wiring it detects in the project.

Why does the nudge fire during deliberate flake diagnosis?▼

The hook cannot read intent, so it fires on any repeated full run. When repetition is the diagnosis — measuring a flake's distribution — state the diagnosis in your response and continue; naming it is what exempts the run from the economy.