test-pyramid

test-pyramid is a skill for Claude Code from sawrus/agent-guides. It costs 26 tokens per session (992 once invoked), scanned A, original, MIT.

A guide to choosing the right level of test for each kind of code and keeping a test suite healthy. It distinguishes unit tests for isolated logic, integration tests for connected systems, E2E tests for user workflows, and contract tests for service agreements.

In plain words
What is it for?
Use it to plan test coverage, decide whether a change needs a unit, integration, E2E, or contract test, diagnose slow or flaky suites, and choose suitable mocks or fakes.
Why use it?
Teams can end up with slow, flaky suites or high coverage that still misses real behavior. This approach helps balance speed, confidence, and appropriate use of test doubles such as mocks.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/sawrus/agent-guides/test-pyramid
Any agent
npx skills add sawrus/agent-guides --skill test-pyramid
Clone the repo
git clone --depth 1 https://github.com/sawrus/agent-guides

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for test-pyramid

README.md
[![agentmods](https://agentmods.dev/badge/skills/sawrus/agent-guides/test-pyramid.svg)](https://agentmods.dev/skills/sawrus/agent-guides/test-pyramid)
Your own site
<a href="https://agentmods.dev/skills/sawrus/agent-guides/test-pyramid"><img src="https://agentmods.dev/badge/skills/sawrus/agent-guides/test-pyramid.svg" alt="Measured on agentmods" height="20"></a>
Per session 26 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 992 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00026 $0.00992
Opus 5 $0.00013 $0.00496
Sonnet 5 $0.00005 $0.00198
Haiku 4.5 $0.00003 $0.00099

Measured 2d ago against content hash 0dde31ddc368, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

test-pyramid scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

with patch("requests.get") as mock:
areas/software/qa/skills/test-pyramid/SKILL.md · 128 lines

How it starts

The opening of the file, as written. The whole thing — 128 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Test Pyramid Strategy Skill

Expertise: Test type selection, suite health, test doubles, coverage strategy, CI integration.

Test Type Decision Tree

Is this a user-visible multi-step workflow (login → action → confirmation)?
  → E2E test (Playwright/Cypress/Detox)

Does the code call external systems (DB, API, queue, file system)?
  → Integration test (real or containerized dependency)

Is this pure business logic, calculation, data transformation, conditional?
  → Unit test (fast, isolated, no I/O)

Is this a contract between two services?
  → Contract test (Pact or schema validation)

Healthy Suite Ratios

Layer Target % When runs Max duration
Unit 70% Every commit < 2 min
Integration 20% Every PR < 5 min
E2E 10% Pre-release < 20 min

Suite health signals to act on:

  • Tests take > 10 min → too many E2E, not enough unit
  • Flake rate > 1% → isolation problems
  • Coverage high but bugs still escape → testing implementation, not behavior

Test Doubles Reference

Situation                                      → Double
──────────────────────────────────────────────────────────
Verify a function WAS called                   → Mock
Control what a dependency returns              → Stub
Need working but simplified implementation     → Fake (in-memory DB)
Observe calls without replacing behavior       → Spy

Golden rule: Never mock what you don't own. Wrap third-party libraries in your own adapter → mock the adapter.

# ❌ Mocking requests directly
with patch("requests.get") as mock:
    mock.return_value.json.return_value = {"status": "ok"}

# ✅ Mock your own wrapper
class HttpClient:
    async def get(self, url: str) -> dict: ...

class FakeHttpClient:
    async def get(self, url: str) -> dict:
        return {"status": "ok"}

service = MyService(http_client=FakeHttpClient())

Coverage Strategy (Risk-Based Priority)

Coverage is a floor, not a ceiling. Priority:

  1. Data mutations — anything that writes to DB
  2. Business rules — validation, state machines, calculations
  3. Error paths — what happens when things fail
  4. Integration boundaries — DB queries, API calls, queue messages
  5. Happy path UI flows — last, most expensive

Read the full file on GitHub · 128 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 128 lines · 26 tokens per session scan A 0dde31ddc368

Subscribe to this mod's changes

test-pyramid is a skill published in the GitHub repository sawrus/agent-guides (17 stars, last pushed 5d ago), licensed MIT. It adds 26 tokens to every session and 992 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

appium-skill

Generates production-grade Appium mobile automation scripts for Android and iOS in Java, Python, or JavaScript. Supports real device and emulator testing locally and on TestMu AI cloud with 100+ real devices. Use when the user asks to automate mobile apps, test on Android/iOS, write...

sickn33/agentic-awesome-skills · 66 tokens

android-ui-journey-testing

XML-specified Android UI journey testing, interactive step execution, assertion verification, and JSON outcome reporting.

sickn33/agentic-awesome-skills · 27 tokens

quinn

Proves the system works by writing and executing comprehensive test suites.

sickn33/agentic-awesome-skills · 16 tokens

android_ui_verification

Automated end-to-end UI testing and verification on an Android Emulator using ADB.

sickn33/agentic-awesome-skills · 22 tokens

browser-testing-with-devtools

Tests in real browsers via Chrome DevTools MCP. Use when building or debugging anything that runs in a browser. Use when you need to inspect the DOM, capture console errors, analyze network requests, profile performance, or verify visual output with real runtime data. Requires the chrome-devtools MCP server to be…

addyosmani/agent-skills · 68 tokens

awt-e2e-testing

AI-powered E2E web testing — eyes and hands for AI coding tools. Declarative YAML scenarios, Playwright execution, visual matching (OpenCV + OCR), platform auto-detection (Flutter/React/Vue), learning DB. Install: npx skills add ksgisang/awt-skill --skill awt -g.

sickn33/agentic-awesome-skills · 74 tokens