test-pyramid
Choose the cheapest test level that proves a behavior once, avoid duplicate coverage, and keep local and CI feedback fast when adding, changing, reviewing, or…
от agentty-xyz★ 46 звёзд на GitHub
Установить test-pyramid в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Test Pyramid
Use this skill whenever a change adds, edits, reviews, or removes tests. It decides
where a behavior is proven; root AGENTS.md still defines which gates must pass, and
crates/AGENTS.md defines how test files are written.
Principle
Prove each behavior once, at the lowest level that can observe it. A higher level may assert only what lower levels cannot see. Line and function coverage is satisfied by the lowest test that reaches the code, never by adding a slower test.
Levels
Pick the first level that can observe the behavior. Costs are approximate per-test magnitudes from local macOS runs; Linux CI is cheaper, so slow fixtures hurt local iteration most.
- Pure unit (default, ≈15 ms, the nextest per-process floor). Domain rules,
parsers, formatting, prompt rendering, reducers, and key-to-intent mapping over mode
state. No database, Git, temporary directory, subprocess,
Appstartup, or real time. Build state directly, asnew_test_prompt_modedoes incrates/agentty/src/runtime/mode/prompt_test/, not as itsnew_test_prompt_appcases do (a fullApp, ≈100–200 ms each). When code takes&mut Appbut the behavior is a state transformation, extract a pure step (mode and input to new mode and intents) and test that. - Boundary unit. Workflow orchestration through injected traits with
mockallmocks or scripted worker facilities. Add an in-memory database only when persisted state is the subject, and a real Git repository only when Git behavior is the subject. - Crate contract (
crates/*/tests/). One test per public contract rule, using the crate's public API in process. Leave argument permutations and error branches to levels 1–2. - CLI subprocess (crate
tests/that spawn the built binary, such ascrates/ag-harness-cli/tests/cli/main.rs; ≈0.5–1 s). One test per command-line contract: arguments, exit status, and output streams. Keep parsing and branch logic below. - PTY scenario (
crates/agentty/tests/e2e/,FeatureTest; ≈1–12 s). One scenario per user-visible journey, asserting rendering and wiring. Do not re-check ordering, validation, or error permutations already pinned below.
Execution Policy
Test levels describe what a test proves. Local versus CI execution is a separate
decision: follow root AGENTS.md and the required procedure in
skills/validate-changes/SKILL.md. A manual gate is not another test level.
Gated suites hold only tests that need their environment; place everything else at one
of the levels. The native sandbox suite (crates/ag-harness/tests/sandbox.rs) runs in
its own serialized test group, crates/agentty/tests/prompt_evaluation.rs calls live
providers as an ignored manual check, and protocol_compliance_e2e runs with the PTY
suite. Their hooks are defined in .pre-commit-config.yaml. Asset generators are not
tests: the marketing GIFs come from the showcase binary, which only the
e2e-container hook runs.
Compile Cost
Test code compiles with its crate. Most of crates/agentty/src/ (≈150k of ≈230k lines)
is test code in one lib-test unit that dominates the CI coverage build, and any test
edit there rebuilds it. Put logic and its tests in the smallest owning crate. Each
top-level tests/*.rs file or tests/<name>/main.rs is a separate binary, and a
library edit rebuilds every binary linking that library; merging ten ag-store binaries
into one more than halved the CPU of rebuilding its tests. Add a module to the crate's
existing binary, such as crates/ag-store/tests/contract/main.rs, instead of a new
top-level file.
Before Adding a Test
- Name the behavior in one sentence and find its owner level from the list above.
- Search for existing coverage with
rgover test names and asserted values. If a test at that level already proves the behavior, extend it with a case instead of adding a function. - If a higher-level test already covers the behavior, add the lower-level test and narrow the higher one to what only it can observe.
- Express variations as a case table in one test rather than near-identical functions.
- Reuse the lightest existing fixture. When none fits, add a light builder to the
suite's support module instead of reaching for
new_test_appor a Git repository.
Fixture and Time Rules
- Never start an
App, create a session, or initialize Git to test a transformation of in-memory state; onenew_test_app, with or without the Git template, costs as much as about ten pure tests. - Use the cached fixtures:
Database::in_memoryandAppRepositories::in_memoryload a migrated-schema snapshot at little cost, andsetup_test_git_repoincrates/agentty/src/copies a committed template repository. KeepDatabase::open_in_memory, which replays every migration (several times slower under coverage), for tests of migrations or production construction, and run Git commands directly only when Git behav
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл test-pyramid?
Choose the cheapest test level that proves a behavior once, avoid duplicate coverage, and keep local and CI feedback fast when adding, changing, reviewing, or consolidating tests.
Как установить скилл test-pyramid?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл test-pyramid запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…