From grimoire
Audits existing test coverage and maps behaviors to a test pyramid (unit, integration, E2E) to guide testing investment.
How this skill is triggered — by the user, by Claude, or both
Slash command
/grimoire:design-test-strategyThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Map the codebase to a test pyramid — assign each behavior to the correct layer so the suite is fast, trustworthy, and cheap to maintain.
Map the codebase to a test pyramid — assign each behavior to the correct layer so the suite is fast, trustworthy, and cheap to maintain.
Adopted by: Google, Spotify, Netflix, and Thoughtworks cite the test pyramid explicitly in their engineering blogs and internal standards. Google's "Software Engineering at Google" (O'Reilly 2020) dedicates three chapters to the pyramid and reports that Google targets 70% unit / 20% integration / 10% E2E across most services. Spotify's "Testing at Spotify" post (2018) describes the same ratio as the outcome of hard-won experience abandoning an inverted pyramid. Impact: An inverted pyramid (many E2E, few unit tests) is the most common cause of slow CI. At Google, test suites that violated the pyramid took 10–30× longer to run and had 3–5× higher flakiness rates compared to pyramid-conformant suites (reported in "Software Engineering at Google", Ch. 11). The cost of a flaky E2E test is 20–40 minutes of engineer time to triage per failure (PagerDuty Engineering, 2020). Why best: Unit tests are ~1000× faster than E2E tests (milliseconds vs. seconds) and have zero flakiness from infrastructure. Tests should fail only because the code is wrong, not because a network partition occurred. The pyramid shapes investment toward tests that give fast, deterministic signal while using E2E only to verify the integration seams that cannot be validated in isolation.
Sources: Mike Cohn, "Succeeding with Agile" (2009); Martin Fowler, "TestPyramid" (martinfowler.com); "Software Engineering at Google" (O'Reilly 2020, Ch. 11–14); Google Testing Blog (testing.googleblog.com)
Categorize every existing test as unit, integration, or E2E:
# Count test files by layer (adapt to project conventions)
find . -path '*/unit/*' -name '*test*' | wc -l
find . -path '*/integration/*' -name '*test*' | wc -l
find . -path '*/e2e/*' -name '*test*' | wc -l
Plot the current shape. Is it a pyramid, a rectangle, or an inverted pyramid?
For each system concern, assign the correct layer:
| Concern | Correct layer | Reason |
|---|---|---|
| Business logic, pure functions | Unit | No I/O, instant feedback |
| Single service + one real dependency (DB, queue) | Integration | Validates contract with real infra |
| Authentication, authorization rules | Integration | Security requires real tokens/sessions |
| Critical user flows (checkout, login, signup) | E2E | Cross-service contract |
| All UI permutations, edge case inputs | Unit (not E2E) | Too slow and fragile at E2E layer |
| Infrastructure config, networking | Infrastructure test (separate) | Not a code test |
Use these as starting targets, adjusted for risk profile:
Write a one-paragraph definition for your project:
Unit: Tests in /unit. No network, no filesystem, no clock. Must run in < 5s total.
Mock all I/O at the boundary. Use real objects for domain logic.
Integration: Tests in /integration. Run against a local Docker compose stack.
One real external dep per test. Allowed to be slow (< 5 min total).
Tagged @integration, excluded from default CI fast-path.
E2E: Tests in /e2e. Run against a deployed staging environment.
Covers checkout, login, and account flows only.
Run nightly and on release branches. Tagged @e2e.
Add missing tests starting at the lowest applicable layer. Ask for each gap: "Can this be tested with a unit test?" If yes, write a unit test. Only go higher if the behavior requires real infrastructure.
Configure CI to run layers in order, fail fast:
# Example: GitHub Actions
jobs:
unit: # runs on every push, < 3 min
integration: # runs on PR merge, < 10 min, needs docker
e2e: # runs on release branch, < 30 min, needs staging
npx claudepluginhub jeffreytse/grimoire --plugin grimoireDesigns a test pyramid strategy (unit/integration/e2e) when test suites are slow, flaky, or imbalanced. Audits ratios, defines test categories, and builds layers with target distributions (e.g., 80/15/5).
Create testing pyramid with unit/integration/E2E strategy. Define coverage targets and high-risk testing. Use when planning tests for features.
Guides test pyramid structure, coverage targets, and patterns for unit, integration, and E2E tests. Includes AAA pattern, naming conventions, and API test checklist.