principle-test-behavior-not-implementation
Skill58 starsChanged 3 months agoMITView on GitHub
Apply when writing or reviewing tests. Test what the system does from the outside (inputs, outputs, observable behavior, invariants), not how it is structured internally (private methods, call counts, internal state).
10 other projects use a version of this.
Adopted by
Most recently taken up by
- PickleBoxer/pstacktheir own version, first seen Oct 6, 2026
- uzairansaruzi/p3-stacktheir own version, first seen Oct 5, 2026
- backnotprop/pstacktheir own version, first seen Oct 4, 2026
- creedants/pstack-t3their own version, first seen Oct 3, 2026
- adjohn/pstacktheir own version, first seen Oct 2, 2026
- dhanji4U/skillstheir own version, first seen Oct 2, 2026
Used with
Projects with it also use benchmark-checklist, principle-explain-the-number and 1 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
creedantsSkillbenchmark-checklist
Vet a perf measurement (limiter, tuning, limits, errors, repeatability, relevance, and whether the work happened) before you report or act on it. Use when you run a benchmark or report a speedup or regression you measured.
Also in 4 projects that use this
creedantsSkillprinciple-explain-the-number
Apply before you trust, report, or act on a number you measured: a speedup, a regression, a throughput, a latency, or an eval result. Find what limits it, and rule out that it measured something other than the work you think.
Also in 4 projects that use this
lobomfzSkillcorrect
Correct-option selection. Use when the user says /correct or asks what is most correct.
Also in 4 projects that use this
Other versions10 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 10
- backnotprop/pstack★ 991same name
- uzairansaruzi/p3-stack★ 129same name
- TheOnlyFusionCube/potetos-for-everyone★ 6same name
- adjohn/pstack★ 4same name
- creedants/pstack-t3★ 3same name
- dhanji4U/skills★ 2same name
- JoshueOsuna/pstack★ 2same name
- PickleBoxer/pstack★ 1same name
- ahmedbenaw/pstack★ 0same name
- lucasvidela94/opencode-pstack★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository49 other files it gives its agents.
- rules/AGENTS.mdAGENTS.md
- agystackSkill
- architectSkill
- arenaSkill
- automate-meSkill
- blast-radiusSkill
- broSkill
- create-verification-skillSkill
- deslopSkill
- figure-it-outSkill
- howSkill
- interrogateSkill
- loopSkill
- maintain-verification-skillSkill
- no-commentsSkill
- Poteto ModeSkill
- principle-attack-the-premiseSkill
- principle-boundary-disciplineSkill
- principle-build-the-leverSkill
- principle-encode-lessons-in-structureSkill
- principle-exhaust-the-design-spaceSkill
- principle-experience-firstSkill
- principle-fix-root-causesSkill
- principle-foundational-thinkingSkill
- principle-guard-the-context-windowSkill
- principle-laziness-protocolSkill
- principle-make-operations-idempotentSkill
- principle-migrate-callers-then-delete-legacy-apisSkill
- principle-minimize-reader-loadSkill
- principle-model-the-domainSkill
- principle-never-block-on-the-humanSkill
- principle-outcome-oriented-executionSkill
- principle-prove-it-worksSkill
- principle-redesign-from-first-principlesSkill
- principle-separate-before-serializing-shared-stateSkill
- principle-sequence-verifiable-unitsSkill
- principle-subtract-before-you-addSkill
- principle-type-system-disciplineSkill
- recallSkill
- reflectSkill
- setup-agystackSkill
- show-me-your-workSkill
- swarmSkill
- tddSkill
- teachSkill
- technical-writingSkill
- typescript-best-practicesSkill
- unslopSkill
- whySkill
The file
We split this skill into the rules it gives an agent
7 rules. 0 are common, 7 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 10 edited versions we read keep these.
7
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
Write tests against observable behavior and contracts, not internal implementation details.
- Distinctive: line 13
Pattern: Ask: "If I rewrote the internals completely, would this test still pass?"
- Distinctive: line 16
Treat the unit or subsystem as a black box with defined inputs and outputs.
- Distinctive: line 17
Test contracts, invariants, and edge cases.
- Distinctive: line 18
Use public APIs and observable side effects.
- Distinctive: line 19
Verify state through public query methods or final output artifacts.
- Distinctive: line 28
If changing internal implementation breaks tests while the feature still works, the tests were testing implementation, not behavior.
“Common” is measured: kept by at least 6 in 10 of the 10 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Test Behavior, Not Implementation
Write tests against observable behavior and contracts, not internal implementation details. Tests should survive refactoring without changes.
Why: Tests coupled to internal details (mocking internal methods, asserting specific call counts, inspecting private state) break when code is refactored, even when behavior is unchanged. This creates test maintenance burden and discourages refactoring.
Pattern: Ask: "If I rewrote the internals completely, would this test still pass?"
Good tests:
- Treat the unit or subsystem as a black box with defined inputs and outputs.
- Test contracts, invariants, and edge cases.
- Use public APIs and observable side effects.
- Verify state through public query methods or final output artifacts.
Avoid:
- Mocking functions you own (prefer real instances or lightweight fakes).
- Asserting on internal call counts or execution order when order is not part of the contract.
- Asserting on exact internal data structures rather than the public result.
- Writing tests that duplicate the implementation logic.
Refactoring test:
- If changing internal implementation breaks tests while the feature still works, the tests were testing implementation, not behavior.
- Rewrite the brittle tests to assert on public outcomes before proceeding with the refactor.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

