agent-instructions
Use when writing project instructions for a coding agent (CLAUDE.md, AGENTS.md, or equivalent). Covers what belongs in them, what does not, structure, and…
Use when deciding what to test and at which level. Covers the test pyramid, what belongs in unit versus integration versus end-to-end tests, coverage as a signal rather than a target, and eliminating flakiness.
$ npx -y skills add nimadorostkar/Claude-Skills-collection --skill test-strategy --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/test-strategyContext preview
The summary Claude sees to decide when to auto-load this skill.
Use when deciding what to test and at which level. Covers the test pyramid, what belongs in unit versus integration versus end-to-end tests, coverage as a signal rather than a target, and eliminating flakiness.
name: test-strategy description: Use when deciding what to test and at which level. Covers the test pyramid, what belongs in unit versus integration versus end-to-end tests, coverage as a signal rather than a target, and eliminating flakiness. metadata: category: testing version: 1.0.0 tags: [testing, strategy, pyramid, coverage, flakiness]
Build a test suite that catches real defects, runs fast enough to be run, and does not need to be rewritten every time the code is refactored.
1. **Test behavior, not implementation** — A test that breaks when you rename a private method is a test that prevents refactoring rather than enabling it. 2. **Choose the level by what you are verifying** — Business logic: unit tests, fast and many. Integration with a real database or queue: integration tests, fewer. A complete user journey: end-to-end, a handful. 3. **Use real dependencies where practical** — A test against a real Postgres in a container catches the SQL error that a mocked repository never will. Mocks verify that you called a thing; they do not verify that it works. 4. **Write the test that would have caught the bug** — After every production defect. This is where the highest-value tests come from — a real bug is empirical evidence of an untested path. 5. **Treat a flake as a defect** — Quarantine it immediately, then fix it. A suite with a 2% flake rate teaches the team to re-run and eventually to ignore. 6. **Keep the fast loop fast** — Under five minutes for what runs on every change, or people will stop running it.
**A test that verifies behavior, and one that verifies implementation:**
# Bad: verifies the implementation. Breaks on any refactor; catches no bugs.
def test_refund_calls_gateway():
gateway = Mock()
RefundService(gateway).refund(order, 1000)
gateway.refund.assert_called_once_with(order.charge_id, 1000)
# This passes even if the refund is never recorded, the amount is wrong
# in the database, and the customer is charged again.
# Good: verifies the behavior that the user and the business care about.
def test_refund_reduces_balance_and_is_idempotent(db, fake_gateway):
order = place_order(db, total_cents=5_000)
service = RefundService(fake_gateway, db)
result = service.refund(order.id, amount_cents=2_000)
assert result.ok
assert db.orders.get(order.id).refunded_cents == 2_000
assert fake_gateway.total_refunded(order.charge_id) == 2_000
# The same request again must not refund twice.
service.refund(order.id, amount_cents=2_000, idempotency_key=result.key)
assert db.orders.get(order.id).refunded_cents == 2_000**The distribution that actually works:**
Unit ~70% milliseconds each business logic, edge cases, error paths Integration ~25% seconds each real DB, real queue, real HTTP layer End-to-end ~5% tens of seconds the three journeys that must never break The proportions matter less than the principle: put the volume where the tests are fast and the coverage is cheap, and reserve the slow, brittle level for the handful of paths whose failure would be catastrophic.
A curated library of 137 production-grade skills for Claude and other AI coding agents. Every skill follows one structure, speaks with one voice, and earns its place by changing what the agent does.
Repo: nimadorostkar/Claude-Skills-collection
Use when writing project instructions for a coding agent (CLAUDE.md, AGENTS.md, or equivalent). Covers what belongs in them, what does not, structure, and…
Use when an agent needs state that survives a session or a context compaction. Covers what to persist, file-based memory, structuring notes for retrieval, and…
Use when automating agent behavior with lifecycle hooks. Covers hook events, deterministic enforcement of rules the model should not be trusted to remember,…
Use when packaging skills, commands, hooks, and MCP servers into a distributable plugin. Covers manifest structure, bundling, versioning, testing, and…
Use when writing a new skill for an AI agent. Covers scoping, description writing for reliable triggering, progressive disclosure, and the difference between a…
Use when reviewing or improving an existing agent skill. Covers triggering accuracy, content quality, redundancy with the base model, and measuring whether the…