principle-test-behavior-not-implementation

principle-test-behavior-not-implementation is a skill for Claude Code from michael-denyer/pstack-claude. It costs 50 tokens per session (572 once invoked), scanned A, original, MIT.

A testing rule that requires tests to call code as a user would and check the literal result the user should see. It rejects tests that only check internal calls, constants, or weak conditions.

In plain words
What is it for?
Use it when writing, changing, or reviewing tests to replace implementation-focused assertions with checks of observable behaviour.
Why use it?
It prevents tests that pass even when the code is broken, saving review and test-run effort while preserving checks that can detect real defects.

Skill for Claude Code

Written for Claude Code: user-invocable in frontmatter.

Part of the pstack plugin — 69 skills, 4 agents, 1 hook shipped together

Good fit Use it when writing, changing, or reviewing tests to replace implementation-focused assertions with checks of observable behaviour.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/michael-denyer/pstack-claude/principle-test-behavior-not-implementation
About the project

pstack-claude is a set of opinionated coding-agent skills and workflows ported from Cursor to Claude Code, Codex, Pi, and other agent harnesses. It guides agents toward concise, simple, and verified code by routing goals to suitable workflows and supporting subagent tools. The catalogue entries are the project's skills, agents, hook, and plugin implementations for these agent environments.

michael-denyer/pstack-claude · 3,377 stars · on GitHub

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.

Any agent
npx skills add michael-denyer/pstack-claude --skill principle-test-behavior-not-implementation
Clone the repo
git clone --depth 1 https://github.com/michael-denyer/pstack-claude

Made for: Claude Code.

Or install pstack, the plugin that ships this one along with the rest of its 69 skills, 4 agents, 1 hook.

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 principle-test-behavior-not-implementation

README.md
[![agentmods](https://agentmods.dev/badge/skills/michael-denyer/pstack-claude/principle-test-behavior-not-implementation/github.svg)](https://agentmods.dev/skills/michael-denyer/pstack-claude/principle-test-behavior-not-implementation)
Your own site
<a href="https://agentmods.dev/skills/michael-denyer/pstack-claude/principle-test-behavior-not-implementation"><img src="https://agentmods.dev/badge/skills/michael-denyer/pstack-claude/principle-test-behavior-not-implementation/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for principle-test-behavior-not-implementation

Your own site · 80×15
<a href="https://agentmods.dev/skills/michael-denyer/pstack-claude/principle-test-behavior-not-implementation"><img src="https://agentmods.dev/badge/skills/michael-denyer/pstack-claude/principle-test-behavior-not-implementation.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 50 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 572 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • Socket pass 13 Oct 2026
  • Snyk pass 13 Oct 2026
How audits are shown
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.00050 $0.00572
Opus 5.5 $0.00020 $0.00229
Sonnet 5.5 $0.00010 $0.00114
Haiku 4.5 $0.00005 $0.00057

Measured 9d ago against content hash 8fa32ef41283, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

principle-test-behavior-not-implementation scanned grade A with 0 findings 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 9d 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

plugins/pstack/skills/principle-test-behavior-not-implementation/SKILL.md · 21 lines

What it actually says

Test Behavior, Not Implementation

A test is a claim about what the code does for its users: a caller, an end user, or another service. Behavior is what those users can observe through the interface they use. That includes return values, errors, state they can read back, and effects on systems outside the code, such as a request sent, a row written, or a message emitted. Implementation is what they cannot observe: private helpers, internal call order, intermediate data, and which internal collaborator did the work.

Judge each test against two imagined edits:

  • Break the behavior. Make the code return a wrong value, skip an effect, or do the effect twice. If the test still passes, it proves nothing. The usual causes are an assertion looser than the contract, an expected value computed by the code under test, a restated constant or prompt string that never runs the code that reads it, and an assertion on data that the test built itself.
  • Change the internals. Keep every observable result the same and restructure the code underneath. If the test now fails, it is pinned to the implementation. It will need a rewrite on every refactor and still catches no bug.

Keep a test that catches the first edit and survives the second. Rewrite or delete the rest. To write a test that does both, drive the code through its users' interface with a concrete input. Derive the expected value from the requirement, not from a run of the code. Assert what the contract promises, no less and no more.

The contract decides, not the shape of the assertion. When "an empty cart never charges" is the promise, an assertion that the payment client got no call is behavior. Pair it with a case where the charge happens, so that the test shows it can see a call. The payload that a mocked external service receives is behavior, because that service observes it. A call to an internal helper is implementation, because no user can see it. An empty list is the exact answer when no record matches, and a hollow check when the test only needs some result. An exact error message pins wording that no caller reads. The error type that callers branch on is the contract.

A test can pin an invariant instead of a call, such as a key that must exist in two tables or a compile-time type check. The invariant is the behavior. A constant pin is behavior when the value is a promise to users, such as a documented default, so name that promise.

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. 9d ago Changed · -1 lines · -2 tokens per session 8fa32ef41283
  2. 12d ago Changed · -4 lines · -11 tokens per session c1da1aa8a555
  3. 13d ago Changed · +8 lines · +13 tokens per session 63839805ba61
  4. 1mo ago Changed · -8 lines · -13 tokens per session 9f6a2e492337
  5. 1mo ago First seen · 26 lines · 63 tokens per session scan A 08f6e5f38643

Subscribe to this mod's changes

principle-test-behavior-not-implementation is a skill published in the GitHub repository michael-denyer/pstack-claude (3,377 stars, last pushed 2d ago), licensed MIT. It adds 50 tokens to every session and 572 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-08.

Related

Other skills, from other repositories