plugins/smedjen/skills/tdd-workflow/SKILL.md
Red-green-refactor cycle enforcement for test-driven development. Guides writing failing tests first, making them pass with minimal code, then refactoring.
npx skillsauth add hjemmesidekongen/ai tdd-workflowInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
TDD is not universal. Know when to exit:
React (Testing Library): Test user behavior, not component internals. getByRole over getByTestId. Fire real events (userEvent.click) not synthetic ones. Never assert on component state — assert on what the user sees. For hooks: renderHook + act(), test the contract not the implementation.
Next.js: Server components can't use Testing Library — test the data layer directly. For API routes, call the handler function with mocked NextRequest. For server actions, test the function, mock redirect/revalidatePath. Client components test normally.
NestJS: Use Test.createTestingModule to bootstrap isolated modules. Override providers with .overrideProvider(Service).useValue(mock). Test guards and interceptors in isolation from controllers.
Prisma: Never mock Prisma Client method-by-method — use a test database or @prisma/client/runtime for unit tests. For integration tests, use a seeded test DB with transaction rollback ($transaction + throw to rollback).
Pick the lightest double that serves the test:
| Need | Use | Not | |------|-----|-----| | Provide canned data to the subject | Stub | Mock — you don't need call verification | | Verify the subject called a dependency | Spy | Mock — spy preserves real behavior | | Replace a slow/flaky dependency entirely | Fake (in-memory DB, local server) | Mock — fakes catch more integration bugs | | Enforce exact call sequence and arguments | Mock | Use sparingly — brittle to refactoring |
Rule of thumb: if your test breaks when you refactor internals but behavior is unchanged, you over-mocked.
When a function has a contract expressible as invariants (sorting, encoding/decoding, serialization roundtrips), add property tests alongside example tests. Use fast-check for JS/TS. Write the property first (red), implement until it holds (green), refactor.
Properties that always pay off: roundtrip (decode(encode(x)) === x), idempotency (f(f(x)) === f(x)), commutativity where expected, "no crash" on arbitrary input.
See references/process.md for the step-by-step TDD cycle with cycle gates and anti-patterns.
development
Creates a brand from scratch through market research and interactive sparring. Runs competitive research via Perplexity, then guides the user through positioning, audience, voice, values, and content pillars. Produces the full brand guideline set at .ai/brand/{name}/. Use when building a new brand, defining brand strategy for a product, or when /våbenskjold:create is invoked.
testing
Loads brand guidelines from .ai/brand/{name}/ and makes them available to the current context. Progressive disclosure: L1 confirms brand exists, L2 loads summary, L3 loads specific files on demand. Use when a downstream skill or user needs brand context, or when /våbenskjold:apply is invoked.
documentation
Guided reinvention of an existing brand guideline. Loads current brand from .ai/brand/{name}/, identifies what to keep vs change, and walks the user through targeted evolution. Preserves brand equity while updating positioning, voice, or values. Use when refreshing a brand or when /våbenskjold:evolve is invoked.
development
Codifies an existing brand from materials, samples, and references. Analyzes provided content to extract voice patterns, values, and positioning. Produces the same guideline format as brand-strategy. Use when a brand already exists but isn't documented, or when /våbenskjold:audit is invoked.