sharp-testing
БесплатноБез исполняемых скриптовНе проверенRules for unit and integration tests. Read before implementing a feature, fixing a bug, refactoring, or writing and changing these tests. E2E test design is…
от paleo★ 91 звезда на GitHubОб этом скилле
Sharp Testing
A test earns its place by detecting a plausible mistake that no other check detects. The default for a change is no new test.
When a test is justified
A permanent test answers: which plausible mistake would it catch, which existing check would miss it, and why would the mistake matter. Name the incorrect behavior and its consequence; that the code could change is no answer. Inspect the relevant tests first, and extend one when it can cover the missing case.
New functions, branches, files, and uncovered lines call for no test by themselves. Coverage locates gaps; it never justifies a test. Getters, pass-through code, constructors, type-level guarantees, and framework behavior need no test. A change with no new test is valid when existing protection suffices.
Expected values
Expected values come from the requirement: the domain rule, the specification, the compatibility obligation. The implementation shows what the code does, never what it should do.
An expectation generated with the code under test, or copied from its output into a snapshot, fails only when the code changes. That is a change detector, not a guard. Validate a captured output against the requirement before adopting it as a fixture or a snapshot.
What to assert
Assert behavior: computed results, selected data, state changes, emitted events, access controls. Leave incidental fields, helper calls and internal ordering unconstrained. A behavior-preserving refactor leaves assertions intact.
Exact representations require an executable or machine-readable contract. Name its consumer or compatibility obligation. Public visibility alone establishes neither.
An interaction is asserted only when the interaction is the contract, such as sending a notification exactly once.
A rejection test exercises the intended guard. Failing earlier for an unrelated reason proves nothing.
One behavior per test, named after the behavior.
Presentation belongs to the product
Code and templates own wording and presentation. Never assert authored copy: labels, help, diagnostics, documentation.
UI components, rendering and event wiring need no unit tests. Test algorithms and domain rules directly, including frontend logic. Critical user interactions belong to E2E tests.
Assert output data without fixing the surrounding prose. Test text processing through extraction, preservation, escaping or redaction of supplied input.
Real code, substituted boundaries
The production logic responsible for the claimed behavior runs for real. Substitute only what lies outside it: network, external services, clock, randomness, queues.
A mock shows that a call was requested, never its effect: a mocked write proves nothing about persistence. A mock that implements the asserted behavior proves the mock.
An export, flag, wrapper, or hook whose only caller is a test is a design smell. Test through a real boundary instead.
Choosing the boundary
- Pure logic (calculations, algorithms, state transitions, edge cases): a focused unit test.
- Wiring, persistence, lifecycle: one test exercising real collaboration at the boundary, with hermetic dependencies, instead of a mocked unit test per layer.
Each contract has one owner. A second layer must exercise a risk the owner cannot reach: transport, persistence, concurrency, lifecycle, authorization. Business-rule cases are proved once, at their owner.
Choosing cases
Pick representative cases, meaningful boundaries, and relevant failure paths: one case per distinct defect, not per input variation. When a general invariant expresses the requirement, one property test replaces many examples. Near-duplicates become one table-driven test, unless they protect different boundaries. Setup stays readable; helper chains hide the evidence.
Bug fixes
One regression test, at the owning boundary. It fails on the defective code for the bug's reason and passes after the fix. When the baseline cannot be run, say so.
Hygiene
Small fixtures, isolated state, controlled time and randomness, completion signals instead of sleeps.
Установить sharp-testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл sharp-testing?
Rules for unit and integration tests. Read before implementing a feature, fixing a bug, refactoring, or writing and changing these tests. E2E test design is outside this skill's scope.
Как установить скилл sharp-testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл sharp-testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic