tdd-typescript
TDD TypeScript Skill
TypeScript/JavaScript TDD using strict red-green-refactor with Vitest — sharpened by DDD at Red (model the domain with branded types) and DRY at Refactor (deduplicate same-concept repetition only).
Description
Implement features by writing failing tests first, minimal code to pass, then refactoring. Types are the first test; branded types extend that to catch domain errors the compiler wouldn't otherwise see.
Discipline Layering
- Before Red — Model the Domain: Name the entity, value object, or aggregate in the business's language. Use branded types for primitives that carry rules (
type EmailAddress = string & { readonly __brand: 'EmailAddress' }). Preferreadonlyclasses or frozen records for multi-field value objects. Zod/Valibot schemas inferred into branded types give runtime + compile-time safety. - Red: Write a failing test. Name it in domain terms (
it('rejects refund when amount exceeds daily limit')) — not mechanical (it('returns false')). - Green: Minimal code to pass.
- Refactor — DRY with discipline: Deduplicate only when the same domain concept appears ≥3 times with the same meaning. Distinguish true DRY from accidental similarity (same shape, different meaning). Promote recurring primitives to branded types. Keep domain logic out of components, routes, and stores.
What's Included
- Examples: TDD cycles, React component TDD, branded-type value objects, utility function TDD
- Reference: Red-green-refactor patterns, Vitest best practices, branded-type idioms
- Templates: Test templates, implementation workflows
Use When
- Implementing TypeScript features with TDD
- Modeling domain concepts (entities, value objects, aggregates) with branded types
- React component development (keeping domain logic out of components)
- Refactoring duplication after a green test
- Ensuring high test coverage
Related Agents
tdd-typescript-implementer
Skill Version: 1.1
More from greyhaven-ai/claude-code-config
grey-haven-creative-writing
Professional writing assistance for blogs, research articles, fiction, essays, and marketing copy. Use when users want to write, edit, or improve any form of written content. Triggers: 'write a blog', 'write an article', 'help me write', 'write a story', 'write a chapter', 'draft an essay', 'creative writing', 'improve my writing', 'edit my writing', 'write copy', 'content writing'.
139creative-writing
Professional writing assistance for blogs, research articles, fiction, essays, and marketing copy. Use when users want to write, edit, or improve any form of written content. Triggers: 'write a blog', 'write an article', 'help me write', 'write a story', 'write a chapter', 'draft an essay', 'creative writing', 'improve my writing', 'edit my writing', 'write copy', 'content writing'.
35grey-haven-prompt-engineering
Master 26 documented prompt engineering principles for crafting effective LLM prompts with 400%+ quality improvement. Includes templates, anti-patterns, and quality checklists for technical, learning, creative, and research tasks. Use when writing prompts for LLMs, improving AI response quality, training on prompting, designing agent instructions, or when user mentions 'prompt engineering', 'better prompts', 'LLM quality', 'prompt templates', 'AI prompts', 'prompt principles', or 'prompt optimization'.
12grey-haven-ontological-documentation
Create comprehensive ontological documentation for Grey Haven systems - extract domain concepts from TanStack Start and FastAPI codebases, model semantic relationships, generate visual representations of system architecture, and document business domains. Use when onboarding, documenting architecture, or analyzing legacy systems.
12grey-haven-api-design
Design RESTful APIs following Grey Haven standards - FastAPI routes, Pydantic schemas, HTTP status codes, pagination, filtering, error responses, OpenAPI docs, and multi-tenant patterns. Use when creating API endpoints, designing REST resources, implementing server functions, configuring FastAPI, writing Pydantic schemas, setting up error handling, implementing pagination, or when user mentions 'API', 'endpoint', 'REST', 'FastAPI', 'Pydantic', 'server function', 'OpenAPI', 'pagination', 'validation', 'error handling', 'rate limiting', 'CORS', or 'authentication'.
12grey-haven-code-style
Apply Grey Haven Studio's TypeScript/React and Python/FastAPI coding standards from production templates. Use when writing code, reviewing PRs, fixing linting errors, formatting files, or when the user mentions 'code standards', 'Grey Haven style', 'linting', 'Prettier', 'ESLint', 'Ruff', 'formatting rules', or 'coding conventions'. Includes exact Prettier/ESLint/Ruff configs, naming conventions, project structure, and multi-tenant database patterns.
10