principle-test-behavior-not-implementation

principle-test-behavior-not-implementation is a skill for Claude Code, Cursor from backnotprop/pstack. It costs 50 tokens per session (548 once invoked), scanned A, a copy of principle-test-behavior-not-implementation, MIT.

A testing rule that checks what users observe rather than checking internal function calls or copied constants. It requires a literal expected result that would fail when the code has a real defect.

In plain words
What is it for?
It helps write or assess tests for user-visible behavior and identify weak assertions, mock-only checks, and tests that merely repeat implementation details.
Why use it?
It removes tests that pass even when the code returns no useful value, saving review and continuous-integration time while catching little.

Skill for Claude CodeCursor

Written for Claude Code and Cursor: disable-model-invocation in frontmatter, but also shipped in a Cursor plugin.

Part of the pstack plugin — 61 skills, 2 agents shipped together

Good fit It helps write or assess tests for user-visible behavior and identify weak assertions, mock-only checks, and tests that merely repeat implementation details.

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

pstack is a collection of plain Agent Skills and engineering principles that guide AI-assisted software development across coding agents such as Claude Code, Codex, Pi, Cursor, and OpenCode. It is for developers who want reusable practices for tasks including testing, technical writing, debugging, review, and coordinating agent work. The catalogue entries are the project's skills, agents, and plugin.

backnotprop/pstack · 2,707 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 backnotprop/pstack --skill principle-test-behavior-not-implementation
Clone the repo
git clone --depth 1 https://github.com/backnotprop/pstack

Made for: Claude Code, Cursor.

Or install pstack, the plugin that ships this one along with the rest of its 61 skills, 2 agents.

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/backnotprop/pstack/principle-test-behavior-not-implementation/github.svg)](https://agentmods.dev/skills/backnotprop/pstack/principle-test-behavior-not-implementation)
Your own site
<a href="https://agentmods.dev/skills/backnotprop/pstack/principle-test-behavior-not-implementation"><img src="https://agentmods.dev/badge/skills/backnotprop/pstack/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/backnotprop/pstack/principle-test-behavior-not-implementation"><img src="https://agentmods.dev/badge/skills/backnotprop/pstack/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 548 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 16 Oct 2026
  • Snyk pass 16 Oct 2026
How audits are shown
Origin 97% copy Near-identical to another mod 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.00548
Opus 5.5 $0.00020 $0.00219
Sonnet 5.5 $0.00010 $0.00110
Haiku 4.5 $0.00005 $0.00055

Measured 9d ago against content hash f7223698623b, 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

This is a copy

97% identical to principle-test-behavior-not-implementation — 4 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

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.

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 f7223698623b
  2. 12d ago Changed · -4 lines · -11 tokens per session b2b73ba42920
  3. 1mo ago First seen · 26 lines · 63 tokens per session scan A 87e40efe4e48

Subscribe to this mod's changes

principle-test-behavior-not-implementation is a skill published in the GitHub repository backnotprop/pstack (2,707 stars, last pushed yesterday), licensed MIT. It adds 50 tokens to every session and 548 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 97% identical to principle-test-behavior-not-implementation, differing in 4 lines, and is treated as a copy.

Related

Other skills, from other repositories

verification-contract

Internal contract: the acceptance artifact per delivery unit — legacy (pre- feature 61) units may carry a frozen ACCEPTANCE.md (binding if present); post-feature 61 units use the unit doc's ## Acceptance criteria section as the canonical acceptance source; the unit doc's ## Evidence table serves as the execution…

gtrabanco/agentic-workflow · 86 tokens

api-test-suite-builder

Use when the user asks to generate API tests, create integration test suites, test REST endpoints, or build contract tests.

bestagentkits/agency-skills · 29 tokens

browserstack

Run tests on BrowserStack. Use when user mentions "browserstack", "cross-browser", "cloud testing", "browser matrix", "test on safari", "test on firefox", or "browser compatibility".

bestagentkits/agency-skills · 44 tokens

coverage

Analyze test coverage gaps. Use when user says "test coverage", "what's not tested", "coverage gaps", "missing tests", "coverage report", or "what needs testing".

bestagentkits/agency-skills · 39 tokens

secops-detection-engineering

Author, validate, test, and deploy YARA-L 2.0 detection rules and evaluate end-to-end detection coverage gaps in Google SecOps. Use when writing new detection rules, tuning existing rules, validating syntax, testing logic against historical telemetry, or evaluating detection coverage against threat intelligence blogs…

google/skills · 129 tokens

story-origin-check

Recover the first public timestamp and canonical major coverage for a newsjacking signal, then decide whether newer coverage is the same story, a different story, or a materially new development.

elvisun/newsjack · 40 tokens