Command Palette

Search for a command to run...

Назад к скиллам
скилл № 75092

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от 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.

  1. 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, App startup, or real time. Build state directly, as new_test_prompt_mode does in crates/agentty/src/runtime/mode/prompt_test/, not as its new_test_prompt_app cases do (a full App, ≈100–200 ms each). When code takes &mut App but the behavior is a state transformation, extract a pure step (mode and input to new mode and intents) and test that.
  2. Boundary unit. Workflow orchestration through injected traits with mockall mocks 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.
  3. 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.
  4. CLI subprocess (crate tests/ that spawn the built binary, such as crates/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.
  5. 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

  1. Name the behavior in one sentence and find its owner level from the list above.
  2. Search for existing coverage with rg over 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.
  3. 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.
  4. Express variations as a case table in one test rather than near-identical functions.
  5. Reuse the lightest existing fixture. When none fits, add a light builder to the suite's support module instead of reaching for new_test_app or 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; one new_test_app, with or without the Git template, costs as much as about ten pure tests.
  • Use the cached fixtures: Database::in_memory and AppRepositories::in_memory load a migrated-schema snapshot at little cost, and setup_test_git_repo in crates/agentty/src/ copies a committed template repository. Keep Database::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
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

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), без исполняемых скриптов.

Похожие скиллы

Сравнить test-pyramid с