Help us improve
Share bugs, ideas, or general feedback.
From tdd-guardian
Global TDD governance policy. Enforces plan-first development, behavior-driven test quality, and strict completion gates.
npx claudepluginhub xiaolai/claude-plugin-marketplace --plugin tdd-guardianHow this skill is triggered — by the user, by Claude, or both
Slash command
/tdd-guardian:policy-coreThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
1. Plan-first: map all work to explicit work items and acceptance criteria before edits.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Provides behavioral guidelines to reduce common LLM coding mistakes, focusing on simplicity, surgical changes, assumption surfacing, and verifiable success criteria.
Provides UI/UX resources: 50+ styles, color palettes, font pairings, guidelines, charts for web/mobile across React, Next.js, Vue, Svelte, Tailwind, React Native, Flutter. Aids planning, building, reviewing interfaces.
Share bugs, ideas, or general feedback.
A test must verify what the code does (its observable output, side effects, or state changes), not how it does it (which internal functions it calls). If you can refactor the internals and the test still passes despite broken behavior, the test is worthless.
| Level | Assertion type | Example | Quality |
|---|---|---|---|
| 1 | Output verification | expect(result).toEqual({ id: "mx-foo-abc123", port: 7700 }) | Best |
| 2 | Side-effect verification | expect(await db.query("SELECT ...")).toHaveLength(1) | Best |
| 3 | Real integration | const res = await app.inject({ method: "GET", url: "/healthz" }) | Best |
| 4 | State verification | expect(container.State.Running).toBe(true) | Good |
| 5 | Mock return + output | Mock returns data, assert caller produces correct output from it | Good |
| 6 | Mock call args | expect(mockFn).toHaveBeenCalledWith(...) | Weak |
| 7 | Mock was called | expect(mockFn).toHaveBeenCalled() | Unacceptable alone |
expect(mockCreate).toHaveBeenCalledWith(opts) but ONLY if you also verify the observable result (return value, formatted output, error thrown).app.inject() (not mocked HTTP)tmpdir() (not mocked fs)Date.now(), crypto.randomBytes(). Unacceptable: mocking your own modules, mocking types/schemas, mocking pure functions.expect(callArgs.HostConfig.CapDrop).toEqual(["ALL"]). Instead, inspect the actual created resource or use integration tests.// BAD: Wiring-only test — would pass even if createContainer was gutted
it("creates container", async () => {
await mechaUp(client, opts);
expect(mockCreateContainer).toHaveBeenCalledWith(client, {
containerName: "mecha-mx-foo-abc123",
image: "mecha-runtime:latest",
// ... 10 lines of expected args
});
});
// GOOD: Behavior test — verifies the observable result
it("creates and starts a mecha, returning its ID and port", async () => {
const result = await mechaUp(client, { projectPath: "/tmp/test" });
expect(result.id).toMatch(/^mx-/);
expect(result.port).toBeGreaterThanOrEqual(1024);
expect(result.authToken).toHaveLength(64);
expect(result.name).toBe(`mecha-${result.id}`);
});
// BAD: Security check via mock args — would miss if defaults were silently dropped
it("applies security defaults", async () => {
await createContainer(client, opts);
const callArgs = mockCreate.mock.calls[0][0];
expect(callArgs.HostConfig.ReadonlyRootfs).toBe(true);
});
// GOOD: Security check via integration — verifies Docker actually received the config
it("applies security defaults", async () => {
await createContainer(client, opts);
const info = await inspectContainer(client, name);
expect(info.HostConfig.ReadonlyRootfs).toBe(true);
expect(info.HostConfig.CapDrop).toContain("ALL");
});
// BAD: Mock-was-called as sole assertion
it("stops the container", async () => {
await mechaStop(client, "test-id");
expect(mockStopContainer).toHaveBeenCalled();
});
// GOOD: Verify state change
it("stops a running container", async () => {
await mechaStop(client, "test-id");
const info = await inspectContainer(client, containerName("test-id"));
expect(info.State.Running).toBe(false);
});
When excluding lines from coverage, always use range comments, never the line-count form:
// BAD: /* v8 ignore next N */ silently fails on ??, ternaries, catch bodies, and short-circuit operators
/* v8 ignore next 3 */
const value = input ?? defaultValue;
// GOOD: range comments work reliably on all constructs
/* v8 ignore start */
const value = input ?? defaultValue;
/* v8 ignore stop */
/* v8 ignore next N */ silently miscounts on these constructs — coverage appears covered but the ignore is not applied, or worse, it skips the wrong lines. The start/stop form is explicit and immune to this class of bugs.
Mandatory rule: flag any /* v8 ignore next */ or /* v8 ignore next N */ in review as a potential silent failure. Replace with /* v8 ignore start */ / /* v8 ignore stop */.