Skip to content
Back to skills

Common Tdd

ASecurity

Implements a strict Red-Green-Refactor loop to ensure zero production code is written without a prior failing test. Use when: creating new features, fixing bugs, or expanding test coverage.

  • 549 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added June 6, 2026
developmentgojavatestingapi

Works with

  • api

Security analysis

A100/100

Pro scans all 8 files and shows the line behind each finding

Scanned June 6, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill common-tdd --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Common Tdd?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Common Tdd
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-common-tdd/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-common-tdd)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: common-tdd
description: 'Implements a strict Red-Green-Refactor loop to ensure zero production code is written without a prior failing test. Use when: creating new features, fixing bugs, or expanding test coverage.'
metadata:
  triggers:
    files:
    - '**/*.test.ts'
    - '**/*.spec.ts'
    - '**/*_test.go'
    - '**/*Test.java'
    - '**/*_test.dart'
    - '**/*_spec.rb'
    keywords:
    - tdd
    - unit test
    - write test
    - red green refactor
    - failing test
    - test coverage
---
# Test-Driven Development (TDD) Standard

## **Priority: P0 — Iron Law**

> **NO PRODUCTION CODE WITHOUT FAILING TEST FIRST.**
> Code written before test MUST deleted. Start over.

## **Step 1: RGR Loop (Red-Green-Refactor)**

1. **RED**: Write minimal failing test. **Verify failure** (Expected error, not typo).
2. **GREEN**: Write simplest code to pass. **Verify pass**.
3. **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 single unit under test.
- **Assert**: Verify output and side effects. One logical assertion per test.
 **(See [AAA Example](references/aaa_example.md) for code structure)**.

## **Step 3: Verification & Thresholds**

- **Minimum Coverage**: 80% (Stat/Func/Line), 75% (Branch).
- **Mocks**:
 - Always mock: HTTP, Time/Date, Filesystem.
 - Never mock: Fast internal services (<200ms), pure domain logic.
- See [Test Runner Reference](references/test_runners.md) for environment-specific commands.

## **Step 4: Principles & Mocks**

- **Watch it Fail**: Prove test works before writing code.
- **Minimalism**: Don't add features/options beyond current test (YAGNI).
- **Isolation**: Mock external APIs (HTTP) and Time.
- **Realism**: Prefer real DBs (test containers) and fast internal services (<200ms).

## **Verification Checklist**

- [ ] Every new function/method failing test first?
- [ ] Failure message expected?
- [ ] Minimal code implemented passed?
- [ ] AAA structure followed?
- [ ] Coverage thresholds met?

## **Expert References**

- [AAA Example](references/aaa_example.md)
- [AAA Methodology](references/aaa_methodology.md)
- [Test Runners](references/test_runners.md)
- [TDD Patterns](references/tdd_patterns.md)
- [Testing Anti-Patterns](references/testing_anti_patterns.md)

## Anti-Patterns

- **No test-after**: Writing tests post-implementation defeats TDD. Delete and restart.
- **No assertion-free tests**: test without assert not test.
- **No testing implementation**: Test behavior and contracts, not internal calls.

Files in this skill

  • SKILL.md2.6 KB
  • references/aaa_example.md387 B
  • references/aaa_methodology.md1.2 KB
  • references/anti-patterns.md1.2 KB
  • references/best-practices.md1.9 KB
  • references/tdd_patterns.md1.2 KB
  • references/test_runners.md1014 B
  • references/testing_anti_patterns.md1.6 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.