# Principle test behavior not implementation

> Principle test behavior not implementation is an open-source agent skill for developer tools. Guides agents to write tests that check observable behavior, not internal details. It is available on Claude Code.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code
- **Website:** https://github.com/michael-denyer/pstack-claude/tree/main/plugins/pstack/skills/principle-test-behavior-not-implementation
- **Repository:** https://github.com/michael-denyer/pstack-claude
- **GitHub stars:** 5,057
- **License:** MIT
- **Skill name:** principle-test-behavior-not-implementation
- **Collection:** https://github.com/michael-denyer/pstack-claude
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-01

## About

This skill teaches an agent to judge tests by what callers of the code can observe: return values, raised errors, readable state and effects on external systems. Private helpers, call order and intermediate data are treated as implementation that tests should not pin.

It gives the agent a two-part check to apply to any test it writes, changes or keeps. The first asks whether the test would fail if the behavior broke, flagging loose assertions, expected values computed by the code under test, and assertions on data the test created itself. The second asks whether the test would survive a refactor that keeps every observable result. Tests that fail the second check are to be rewritten or removed.

The guidance covers practical habits such as driving code through its public interface with concrete inputs, deriving expected values from the requirement, asserting error types rather than messages, and pairing a "this never happens" test with a case where it does. It is written as instructions only, with no scripts, and works with whatever test framework the project already uses.

## When your agent uses it

> 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.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/michael-denyer/pstack-claude/tree/HEAD/plugins/pstack/skills/principle-test-behavior-not-implementation)
- [License: MIT](https://github.com/michael-denyer/pstack-claude/tree/HEAD/plugins/pstack/skills/principle-test-behavior-not-implementation)

## Features

- **Observable behavior focus:** Defines what counts as the public interface: return values, errors, readable state and outside effects.
- **Break-and-refactor check:** Two imagined edits test whether a test catches real bugs without breaking on internal changes.
- **Concrete expected values:** Expected results come from the requirement rather than from the code under test.
- **Error type assertions:** Asserts the error type callers branch on instead of brittle message text.
- **Paired negative cases:** Pairs a claim that something never happens with a case where it does happen.
- **Constant pin guidance:** Treats documented defaults and promised values as behavior worth asserting, with the promise named.

## Good for

- Review a new test suite so it fails when user-visible behavior breaks
- Rewrite brittle tests that break whenever internal helpers are renamed
- Check that a test asserts a real outcome rather than a value it computed itself
- Assert that an external service receives the right request without testing internal call order
- Replace message-text assertions with checks on the error type callers handle

## Install

### Claude Code

This skill ships in the `pstack` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add michael-denyer/pstack-claude
/plugin install pstack@pstack-claude
```

Or copy only this skill to `~/.claude/skills/principle-test-behavior-not-implementation`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/principle-test-behavior-not-implementation &&
cp -R "$tmp/plugins/pstack/skills/principle-test-behavior-not-implementation" ~/.claude/skills/principle-test-behavior-not-implementation &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/principle-test-behavior-not-implementation` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/principle-test-behavior-not-implementation` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/principle-test-behavior-not-implementation &&
cp -R "$tmp/plugins/pstack/skills/principle-test-behavior-not-implementation" ~/.agents/skills/principle-test-behavior-not-implementation &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/principle-test-behavior-not-implementation` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/principle-test-behavior-not-implementation` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/principle-test-behavior-not-implementation &&
cp -R "$tmp/plugins/pstack/skills/principle-test-behavior-not-implementation" ~/.cursor/skills/principle-test-behavior-not-implementation &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/principle-test-behavior-not-implementation` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/michael-denyer/pstack-claude.git --path plugins/pstack/skills/principle-test-behavior-not-implementation
```

Or copy the folder to `~/.gemini/skills/principle-test-behavior-not-implementation` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/principle-test-behavior-not-implementation`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/principle-test-behavior-not-implementation &&
cp -R "$tmp/plugins/pstack/skills/principle-test-behavior-not-implementation" ~/.copilot/skills/principle-test-behavior-not-implementation &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/principle-test-behavior-not-implementation` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git
```

Then copy `pstack-claude/plugins/pstack/skills/principle-test-behavior-not-implementation` into your agent's skills folder as `principle-test-behavior-not-implementation`. Agents that support SKILL.md read one folder per skill.

## FAQ

### When does Principle test behavior not implementation trigger?

It applies when the agent writes, changes or keeps a test, according to its description.

### Does Principle test behavior not implementation need any scripts or tools?

No. It has no scripts and no allowed tools are set; it is a set of written instructions.

### Which clients can use Principle test behavior not implementation?

It is a Claude Code plugin skill from the pstack-claude marketplace, so it is listed for Claude Code.

### How do I install Principle test behavior not implementation in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/principle-test-behavior-not-implementation to use it in all your projects, or to .claude/skills/principle-test-behavior-not-implementation in one project. Or install the pstack plugin, which includes it: /plugin marketplace add michael-denyer/pstack-claude, then /plugin install pstack@pstack-claude.

### Does Principle test behavior not implementation run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Principle test behavior not implementation?

Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.

### What are the best alternatives to Principle test behavior not implementation?

The closest alternatives to Principle test behavior not implementation are Property based testing, Characterization tests, TDD, Refactor and Testing strategy.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Property based testing](https://ai-powered.com/skills/property-based-testing): Property based testing is an open-source agent skill for developer tools.
- [Characterization tests](https://ai-powered.com/skills/characterization-tests): Characterization tests is an open-source agent skill for developer tools.
- [TDD](https://ai-powered.com/skills/tdd): TDD is an open-source agent skill for developer tools.
- [Refactor](https://ai-powered.com/skills/refactor): Refactor is an open-source agent skill for developer tools.
- [Testing strategy](https://ai-powered.com/skills/testing-strategy): Testing strategy is an open-source agent skill for developer tools.
- [Principle fix root causes](https://ai-powered.com/skills/principle-fix-root-causes): Principle fix root causes is an open-source agent skill for developer tools.
- [Principle prove it works](https://ai-powered.com/skills/principle-prove-it-works): Principle prove it works is an open-source agent skill for developer tools.
- [Principle type system discipline](https://ai-powered.com/skills/principle-type-system-discipline): Principle type system discipline is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/principle-test-behavior-not-implementation
