agentleFS
markneoninmarkneonin/paneline/.claude/skills/write-test/SKILL.md

write-test

Skill9 starsChanged 18 days agoMITView on GitHub

Use when writing or changing a test for paneline hooks or draw functions.

  • Reads credentials

8 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Import from claude-code/testing: describe, expect, test, mock.

    line 13
  2. Very specific:

    Test body: async ($, on) => { ...

    line 15
  3. Distinctive:

    No comments in tests.

    line 44

“Common” is measured: kept by at least 6 in 10 of the 7 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Write a test

Tests run only with claude plugin test . (also part of npm run check). They run in a sandbox like the plugin's own: no file system, no network, no process.

Layout and names

  • One file per area: tests/<area>.test.ts, or .test.tsx when it mounts UI. Shared helpers for draw trees are in tests/draw-tree.ts.
  • Import from claude-code/testing: describe, expect, test, mock. Types Engine, Mounted come from the same module.
  • describe("<area>"), then tests named <ID> <what the user sees>, for example M3 clicking a server selects it and shows its actions. IDs are one letter and a number per file.
  • Test body: async ($, on) => { ... }. $ is the engine, on registers fake engine hooks.

Build the fake world

Copy the worldOf(on) helper from the nearest test file, for example tests/mcp-pane.test.tsx. It:

  • calls mock.clock(on, { now }) and mock.env(on, { HOME: "/h/u" });
  • answers the engine events the code under test calls, such as session.usage and ui.open, with fixed data;
  • returns a world object that records calls (commands run, usage fetches) for assertions.

Mount and act

const pane = await $.ui.mount({ plugin: "paneline", surface: "terminal", component: "Pane",
  requestId: "session", props: { title: "Session", isFocused: false, bodyColumns: 60,
  placement: "dock", scroll: { offset: 0, bodyRows: 40 }, view: {} },
  viewport: { columns: 60, rows: 40 } })
  • Find: pane.findAll({ type: "Button" }), pane.find({ type: "Text", text }).
  • Act: pane.press({ key }). Read the tree: pane.drawn().
  • Chat parts mount the same way with their own component name, see tests/reply.test.tsx.

Assert

  • Assert drawn text, theme keys from palette, and the keys written to state. Not private variables.
  • Name numbers as constants at the top of the file.
  • Pure helpers, such as fitTabs, are tested by calling them directly (tests/tab-bar.test.ts).
  • A new behaviour needs a test that fails without it. Check by breaking the code once.
  • No comments in tests.

claude plugin test . runs every test file. To run one file, copy the folder with only that file under tests/, or accept the full run: it is fast.

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.