Langsung ke konten
Skillpedia
Testing48k Β· #5933

tdd-workflow

Fungsinya

Skill ini membantu Anda menulis kode dengan cara yang terorganisir dan andal. Skill ini memandu Anda melalui siklus: pertama tulis test yang gagal, lalu tulis kode minimal agar test itu lolos, dan terakhir tingkatkan kualitas kode.

Kapan dipakai

  • βœ“Saat memulai fitur baru.
  • βœ“Saat memperbaiki bug.
  • βœ“Saat bekerja dengan logika yang rumit.

Link skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/tdd-workflow/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/tdd-workflow/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œBantu saya menerapkan siklus TDD untuk membuat fungsi yang menjumlahkan dua angka.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

AI mengikuti sebuah siklus: pertama, Anda menjelaskan apa yang seharusnya dilakukan kode, lalu AI menulis test yang gagal. Setelah itu, AI menulis kode paling sederhana agar test tersebut lolos. Terakhir, AI meninjau dan memperbaiki kode tanpa merusak test yang ada.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

TDD Workflow

Write tests first, code second.


1. The TDD Cycle

πŸ”΄ RED β†’ Write failing test
    ↓
🟒 GREEN β†’ Write minimal code to pass
    ↓
πŸ”΅ REFACTOR β†’ Improve code quality
    ↓
   Repeat...

2. The Three Laws of TDD

  1. Write production code only to make a failing test pass
  2. Write only enough test to demonstrate failure
  3. Write only enough code to make the test pass

3. RED Phase Principles

What to Write

Focus Example
Behavior "should add two numbers"
Edge cases "should handle empty input"
Error states "should throw for invalid data"

RED Phase Rules

  • Test must fail first
  • Test name describes expected behavior
  • One assertion per test (ideally)

4. GREEN Phase Principles

Minimum Code

Principle Meaning
YAGNI You Aren't Gonna Need It
Simplest thing Write the minimum to pass
No optimization Just make it work

GREEN Phase Rules

  • Don't write unneeded code
  • Don't optimize yet
  • Pass the test, nothing more

5. REFACTOR Phase Principles

What to Improve

Area Action
Duplication Extract common code
Naming Make intent clear
Structure Improve organization
Complexity Simplify logic

REFACTOR Rules

  • All tests must stay green
  • Small incremental changes
  • Commit after each refactor

6. AAA Pattern

Every test follows:

Step Purpose
Arrange Set up test data
Act Execute code under test
Assert Verify expected outcome

7. When to Use TDD

Scenario TDD Value
New feature High
Bug fix High (write test first)
Complex logic High
Exploratory Low (spike, then TDD)
UI layout Low

8. Test Prioritization

Priority Test Type
1 Happy path
2 Error cases
3 Edge cases
4 Performance

9. Anti-Patterns

❌ Don't βœ… Do
Skip the RED phase Watch test fail first
Write tests after Write tests before
Over-engineer initial Keep it simple
Multiple asserts One behavior per test
Test implementation Test behavior

10. AI-Augmented TDD

Multi-Agent Pattern

Agent Role
Agent A Write failing tests (RED)
Agent B Implement to pass (GREEN)
Agent C Optimize (REFACTOR)

Remember: The test is the specification. If you can't write a test, you don't understand the requirement.

When to Use

This skill is applicable to execute the workflow or actions described in the overview.

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Pertanyaan umum

Apa arti 'RED', 'GREEN', 'REFACTOR'?

'RED' adalah kondisi ketika test gagal. 'GREEN' adalah kondisi ketika kode membuat test lolos. 'REFACTOR' adalah saat Anda memperbaiki kode sambil memastikan semuanya tetap berjalan.

Mengapa test ditulis sebelum kode?

Menulis test lebih dulu memastikan Anda tahu persis apa yang harus dilakukan kode dan membantu menghindari kode yang tidak perlu.

Apa itu 'YAGNI'?

YAGNI adalah singkatan dari 'You Aren't Gonna Need It'. Ini adalah prinsip untuk hanya menulis kode yang benar-benar dibutuhkan saat ini.

Detail

Deskripsi asli dari pembuat

Test-Driven Development workflow principles. RED-GREEN-REFACTOR cycle.

repo: sickn33/agentic-awesome-skills

Popularitas

Bintang GitHub
48k
Peringkat
#5933
Lisensi
MIT
Diperbarui
15/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa