agentleFS
hidenobunagaihidenobunagai/astack/skills/principle-test-behavior-not-implementation/SKILL.md

principle-test-behavior-not-implementation

Skill1 starsChanged 11 days agoMITView on GitHub

Apply when you write, change, or keep a data test, pipeline check, or unit test for analysis code. Assert what the users of the output can observe, such as values, row sets, schema, and written tables, so the test fails when the result breaks and survives internal refactors.

37 other projects use a version of this, 15 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use poteto-help, ketchup-video and 4 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.
  • ianclearySkill

    poteto-help

    Guides users through pstack setup, /poteto-mode, and picking the skill, playbook, or principle for a task. Type /poteto-help with a question.

    Also in 14 projects that use this

  • tristanphvnSkill

    ketchup-video

    Catch the user up like /keel:ketchup, with a short silent video of slides for what happened and the waiting calls as text under it. Use for /keel:ketchup-video.

    Also in 11 projects that use this

  • eryzerzSkill

    make-bot-ui

    Use when building a custom UI (page, dashboard, buttons) that should wake a Grok Bot over a webhook, when the user must provide a webhook sender key, or when exposing that UI on Tailscale.

    Also in 16 projects that use this

  • bnemaSkill

    setup-pstack

    Configure which Pi models pstack uses per role. Detects available provider/model specs and writes pstack's user configuration. Use for /setup-pstack, "configure pstack models", or changing pstack model choices.

    Also in 19 projects that use this

  • JoshueOsunaSkill

    Poteto Mode

    poteto's agent style for concise, detailed responses, deliberate subagents, unslopped prose, simple code, and verified work. Use for poteto, /poteto-mode, or requests to work in this style.

    Also in 3 projects that use this

  • instructureSkill

    ketchup

    Rebuild context after /clear by analyzing uncommitted changes across Canvas LMS and all plugin repositories

    Also in 18 projects that use this

The file

Files
SKILL.md

Test Behavior, Not Implementation

A test is a claim about what the code does for its users: a notebook reader, a downstream table, a dashboard, or another service. Behavior is what those users can observe through the interface they use. That includes returned values, the row set, the schema, errors, and effects outside the code, such as a table written or a file emitted. Implementation is what they cannot observe: private helpers, the order of internal calls, intermediate frames, and which internal expression did the work.

Judge each test against two imagined edits.

  • Break the behavior. Make the code return a wrong value, drop a row, or double count. 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, and assertions on data the test built itself.
  • Change the internals. Keep every observable result the same and restructure the code underneath, for example by moving from eager to lazy frames. If the test now fails, it is pinned to the implementation.

Keep a test that catches the first edit and survives the second. Rewrite or delete the rest. To build such a test, feed the code a small hand-made frame through its public function. Derive the expected value from the definition, 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. If the promise is "refunds are excluded from revenue", assert the revenue value on a frame with a refund, and pair it with a frame without one, so the test shows it can see the effect. A call to an internal helper is implementation. A value that a mocked external service receives is behavior, because that service observes it. An exact warning string pins wording no caller reads. An error type that callers branch on is the contract.

An invariant can be the test. "Every order_id in the fact table exists in the customer dimension" is a behavior of the output, so assert it on the output.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.