> tdd
Enforces Test-Driven Development (Red-Green-Refactor). Use when writing unit tests, implementing TDD, or improving test coverage for any feature.
curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/tdd?format=md"Test-Driven Development (TDD)
Priority: P1 (OPERATIONAL)
The Iron Law
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST. Code written before the test must be deleted. Start over.
The TDD Cycle
- RED: Write a minimal failing test. Verify failure (Expected error, not typo).
- GREEN: Write simplest code to pass. Verify pass.
- REFACTOR: Clean up code while staying green.
AAA Structure (Mandatory)
Every test must follow Arrange-Act-Assert:
- Arrange: Set up inputs, stubs, mocks, and expected values.
- Act: Call the single unit under test.
- Assert: Verify output and side effects. One logical assertion per test. (See AAA Example for code structure).
Coverage Thresholds
- Minimum: 80% (Statements, Functions, Lines), 75% (Branches).
- Target: 90% (Statements, Functions, Lines), 85% (Branches).
- Configure in test runner config (e.g.
jest.config.ts,vitest.config.ts). Coverage below minimum is a build-gate failure.
Test Runner Commands
| Language | Runner | Watch Mode | Coverage |
|---|---|---|---|
| TypeScript/JS | jest / vitest | vitest --watch | vitest run --coverage |
| Go | go test | go test -v ./... -count=1 | go test -cover ./... |
| Java | JUnit 5 + Maven | mvn test | mvn verify -P coverage |
| Kotlin | JUnit 5 + Kotest | ./gradlew test | ./gradlew jacocoTestReport |
| Dart/Flutter | flutter test | flutter test --watch | flutter test --coverage |
Core Principles
- Watch it Fail: Prove the test works.
- Minimalism: Don't add features/options beyond current test (YAGNI).
- Real Over Mock: Prefer real dependencies unless slow/flaky.
- One Reason to Fail: Test one behavior per test.
- Descriptive Names: e.g.
should_returnError_when_emailIsInvalid.
When to Use Mocks vs Real Dependencies
- Database: Real DB (test container) or in-memory; mock as last resort.
- HTTP/External APIs: Always mock.
- Filesystem: Use temp dir; mock for unit isolation.
- Time/Dates: Always mock/control.
- Internal services: Real if fast (<200ms); mock if cross-network.
Verification Checklist
- Every new function/method has a failing test first?
- Failure message was expected?
- Minimal code implemented passed?
- AAA structure followed?
- Coverage thresholds met?
Expert References
> related_skills --same-repo
> common-store-changelog
Generate user-facing release notes for the Apple App Store and Google Play Store by collecting git history, triaging user-impacting changes, and drafting store-compliant changelogs. Enforces character limits (App Store ≤4000, Google Play ≤500), tone, and bullet format. Use when generating release notes, app store changelog, play store release, what's new, or version release notes for any mobile app. (triggers: generate changelog, app store notes, play store release, what's new, release notes, ve
> golang-tooling
Go developer toolchain — gopls LSP diagnostics, linting, formatting, and vet. Use when setting up Go tooling, running linters, or integrating gopls with Claude Code. (triggers: gopls, golangci-lint, golangci.yml, go vet, goimports, staticcheck, go tooling, go lint)
> common-ui-design
Design distinctive, production-grade frontend UI with bold aesthetic choices. Use when building web components, pages, interfaces, dashboards, or applications in any framework (React, Next.js, Angular, Vue, HTML/CSS). (triggers: build a page, create a component, design a dashboard, landing page, UI for, build a layout, make it look good, improve the design, build UI, create interface, design screen)
> common-owasp
OWASP Top 10 audit checklist for Web Applications (2021) and APIs (2023). Load during any security review, PR review, or codebase audit touching web, mobile backend, or API code. (triggers: security review, OWASP, broken access control, IDOR, BOLA, injection, broken auth, API review, authorization, access control)