skills/tdd/SKILL.md
Use when implementing features, fixing bugs, or adding deliberate test coverage. Enforces test-first (red-green-refactor) cycle, handles mock bootstrap for projects with mockReset:true, prevents code-before-tests violations. NOT for reviewing existing code or running test suites.
npx skillsauth add acedergren/agentic-tools tddInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
4 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Enforce a strict test-driven development cycle: Red → Green → Refactor → Commit.
If mockReset: true in test runner config, most internet mock examples silently fail — return values clear between tests.
grep -rn 'mockReset\|mockClear\|restoreMocks' vitest.config.* jest.config.*
If mockReset: true, you MUST reconfigure return values in beforeEach, not at module scope. Write ONE bootstrap test first to validate your mock wiring:
import { describe, it, expect, vi, beforeEach } from "vitest";
const mocks = vi.hoisted(() => ({
myDep: vi.fn(),
}));
vi.mock("../path/to/dependency", () => ({
myDep: (...args: unknown[]) => mocks.myDep(...args),
}));
describe("bootstrap", () => {
beforeEach(() => {
mocks.myDep.mockResolvedValue({ ok: true });
});
it("mock resolves correctly", async () => {
const { myDep } = await import("../path/to/dependency");
expect(await myDep()).toEqual({ ok: true });
});
});
Run it, confirm it passes, then delete it and write the real tests using that same pattern.
Write tests covering: happy path, edge cases (empty/boundary inputs), error cases (invalid input, unauthorized, missing resource).
npx vitest run <test-file> --reporter=verbose
Checkpoint: All new tests MUST fail. If any pass → the behavior already exists or the test is wrong.
Write the minimum code to make tests pass. No untested features, no premature optimization, no untested error handling.
npx vitest run <test-file> --reporter=verbose
Checkpoint: All tests (new and existing) pass.
npx vitest run --reporter=verbose
If outside tests fail: determine if your change caused the regression. If yes → fix before proceeding. If pre-existing → note it and continue.
Only when tests are green. Extract helpers, improve naming, simplify conditionals. Re-run full suite after.
npx eslint <changed-files>
npx tsc --noEmit
Fix before committing.
const mockFn = vi.fn();
vi.mock("./dep", () => ({
dep: (...args: unknown[]) => mockFn(...args),
}));
beforeEach(() => {
mockFn.mockResolvedValue(defaultResult);
});
let callCount = 0;
mockExecute.mockImplementation(async () => {
callCount++;
if (callCount === 1) return insertResult;
if (callCount === 2) return selectResult;
});
vi.mock("./dep", () => {
if (!(globalThis as any).__mocks) (globalThis as any).__mocks = {};
const m = { dep: vi.fn() };
(globalThis as any).__mocks.dep = m;
return { dep: (...a: unknown[]) => m.dep(...a) };
});
// In tests: const mocks = (globalThis as any).__mocks;
$ARGUMENTS: Optional description of what to implement via TDD
/tdd add rate limiting to the search endpointdevelopment
--- name: api-audit description: "Use when auditing API routes for schema drift, missing auth, or validation gaps. Scans routes against shared TypeScript types to find mismatches, missing middleware, and undocumented endpoints. Read-only — produces a severity-grouped report. Keywords: audit routes, schema drift, auth gaps, missing validation, type mismatch, orphaned schemas. Triggers on "audit API routes" or "find schema drift"." --- # API Route & Type Audit Skill ## When to Use Load this skil
development
Use when drafting, translating, polishing, or reviewing Swedish text so it sounds natural, fluent, contemporary, and appropriate for its audience. Triggers include "write better Swedish", "make this sound natural in Swedish", "translate into Swedish", "polish this Swedish", "tech company Swedish", "contemporary Swedish words", "Swedish developer docs", and "avoid Anglicisms".
development
Use when working with shadcn-svelte components, TanStack Table in Svelte 5, or Tailwind v4.1. Covers non-obvious reactivity bugs, library selection trade-offs, and migration pitfalls not in the official docs. Keywords: shadcn-svelte, TanStack Table, Tailwind v4.1, Svelte 5 runes, bits-ui, superforms, data table, svelte-check.
data-ai
Use when mapping IDCS claims to org membership after OAuth login succeeds. Covers mapProfileToUser, session.create.before, session.create.after hooks, MERGE INTO upserts, tenant-org mapping, and first-admin bootstrap. Keywords: IDCS groups, org_members, provisioning, session hooks, tenant map, MERGE INTO.