Skip to content
Back to skills

Principle Test Behavior Not Implementation

ASecurity

Apply when you write, change, or keep a test. Assert what the code's users can observe, so that the test fails when that behavior breaks and keeps passing when only the internals change.

  • 17 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added October 1, 2026
ai-agents

Security analysis

A100/100

Scanned December 3, 2026

npx -y skills add arjitj2/open-pstack --skill principle-test-behavior-not-implementation --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Principle Test Behavior Not Implementation?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Principle Test Behavior Not Implementation
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/arjitj2-principle-test-behavior-not-implementation/badge)](https://www.skillsdirectory.com/skills/arjitj2-principle-test-behavior-not-implementation)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: principle-test-behavior-not-implementation
description: "Apply when you write, change, or keep a test. Assert what the code's users can observe, so that the test fails when that behavior breaks and keeps passing when only the internals change."
user-invocable: false
---

# Test Behavior, Not Implementation

A test is a claim about what users of the code can observe through its interface: return values, errors, state they can read back, and effects on outside systems. Private helpers, internal call order, and intermediate data are implementation.

Judge each test against two imagined edits:

- **Break the behavior** (a wrong value, a skipped or doubled effect). If the test still passes, it proves nothing. The usual causes are a loose assertion, 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 the test built itself.
- **Change the internals** and keep every observable result. If the test fails, it is pinned to the implementation.

Keep a test that catches the first edit and survives the second. Rewrite or delete the rest. Drive the code through its public interface with a concrete input, and derive the expected value from the requirement. What an external service receives is behavior. A call to an internal helper is not. Pair "this never happens" with a case where it does happen. Assert the error type that callers branch on, not the message, unless the exact diagnostic is itself a public contract that a caller or user relies on. Then keep its text check.

A test can pin an invariant instead of a call, such as a key that must exist in two tables, agreement between two implementations of one contract, or a compile-time type check. The invariant is the behavior.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.