agentleFS
UfukCetinkaya57UfukCetinkaya57/backend-governance/.claude/skills/tdd/SKILL.md

tdd

Skill0 starsChanged 5 months agoMITView on GitHub

Feature veya bugfix implementasyonunda, uygulama kodu yazmadan ONCE kullan

194 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use capture-learning-tools, design-frontend-dev and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 7 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 187 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Test'ten once kod yazdiysan → sil, bastan basla.

    line 14
  2. Distinctive:

    Test FAIL ediyor mu? (error degil, FAIL)

    line 63
  3. Distinctive:

    Test PASS ediyorsa → mevcut davranisi test ediyorsun, test'i duzelt.

    line 67
  4. Distinctive:

    Test'i gecirmek icin EN BASIT kodu yaz.

    line 71
  5. Distinctive:

    Test PASS ediyor mu?

    line 98
  6. Distinctive:

    Test'ten once kod yazdin

    line 155
  7. Distinctive:

    Test hemen PASS etti (mevcut davranisi test ediyorsun)

    line 156

“Common” is measured: kept by at least 6 in 10 of the 187 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Test-Driven Development (TDD)

Temel Kural

FAILING TEST OLMADAN UYGULAMA KODU YAZILMAZ. ISTISNASI YOK.

Test'ten once kod yazdiysan → sil, bastan basla.

Ne Zaman Kullanilir

Her zaman:

  • Yeni feature
  • Bug fix
  • Refactoring
  • Davranis degisikligi

Istisnalar (kullaniciya sor):

  • Bir kerelik prototip
  • Generate edilen kod
  • Config dosyalari

Red-Green-Refactor Dongusu

RED — Failing Test Yaz

Tek bir davranisi gosteren minimal test yaz.

// IYI: Net isim, gercek davranisi test eder
test('should return 404 when user does not exist', async () => {
  const res = await request(app).get('/api/v1/users/999');
  expect(res.status).toBe(404);
  expect(res.body.error.code).toBe('NOT_FOUND');
});
// KOTU: Belirsiz isim, mock test eder
test('user test', async () => {
  const mock = jest.fn().mockResolvedValue(null);
  expect(mock).toHaveBeenCalled();
});

Kurallar:

  • Tek davranis
  • Acik isim (ne test ettigini soyle)
  • Gercek kod test et (mock sadece kacinilmazsa)

RED DOGRULA — Hata Verdigini Gor

npm test path/to/test.test.ts
  • Test FAIL ediyor mu? (error degil, FAIL)
  • Hata mesaji beklenen mi?
  • Feature eksik oldugu icin mi fail ediyor (typo degil)?

Test PASS ediyorsa → mevcut davranisi test ediyorsun, test'i duzelt.

GREEN — Minimal Kod Yaz

Test'i gecirmek icin EN BASIT kodu yaz.

// IYI: Yeterli kadar
async function getUserById(id: string) {
  const user = await db('users').where('id', id).first();
  if (!user) throw new NotFoundError('User not found');
  return user;
}
// KOTU: Over-engineered
async function getUserById(
  id: string,
  options?: { cache?: boolean; include?: string[]; transform?: (u: User) => any }
) { /* YAGNI */ }

Feature ekleme, baska kodu refactor etme, test'in otesinde "iyilestirme" yapma.

GREEN DOGRULA — Gectigini Gor

npm test path/to/test.test.ts
  • Test PASS ediyor mu?
  • Diger testler hala geciyor mu?
  • Ciktida hata/uyari yok mu?

REFACTOR — Temizle

Sadece GREEN'den sonra:

  • Tekrari kaldir
  • Isimleri iyilestir
  • Helper'lar cikar

Testler yesil kalsin. Yeni davranis EKLEME.

Tekrarla

Siradaki davranis icin yeni failing test yaz.

Bug Fix Ornegi

Bug: Bos email kabul ediliyor

RED:

test('should reject empty email with validation error', async () => {
  const res = await request(app)
    .post('/api/v1/auth/register')
    .send({ email: '', password: 'Test1234!' });
  expect(res.status).toBe(422);
  expect(res.body.error.code).toBe('VALIDATION_ERROR');
});

RED DOGRULA: FAIL — expected 422, got 201 ✓

GREEN:

if (!data.email?.trim()) {
  throw new ValidationError('Email zorunludur');
}

GREEN DOGRULA: PASS ✓

REFACTOR: Baska alanlar icin de validation gerekiyorsa cikar.

Yaygin Bahaneler

BahaneGercek
"Test yazacak kadar basit degil"Basit kod da kirilir. Test 30 saniye surer.
"Sonra test yazarim"Hemen gecen test hicbir sey kanitlamaz.
"Once elle test ettim"Elle test sistematik degil, tekrar calistirilamaz.
"X saatlik isi silmek israf"Batik maliyet yanilgisi. Test edilmemis kod teknik borc.
"TDD beni yavaslatir"TDD debugging'den hizli.

Kirmizi Bayraklar — DUR ve Bastan Basla

  • Test'ten once kod yazdin
  • Test hemen PASS etti (mevcut davranisi test ediyorsun)
  • Neden FAIL ettigini aciklayamiyorsun
  • "Bir kerelik istisna" bahanesi
  • "Referans olarak tutayim" (= test'ten sonra yazma)

Tumu = Kodu sil. TDD ile bastan basla.

Dogrulama Listesi

Isi tamamlandi olarak isaretlemeden once:

  • Her yeni fonksiyon/metod icin test var
  • Her test'in fail ettigini gordun
  • Her test beklenen sebeple fail etti (feature eksik, typo degil)
  • Her test icin minimal kod yazdin
  • Tum testler geciyor
  • Testler gercek kod kullaniyor (mock sadece kacinilmazsa)
  • Edge case'ler ve hata senaryolari kapsanmis

test-scaffold ile Farki

  • test-scaffold: Test DOSYASI olusturma pattern'leri — naming, yapi, AAA, edge case uretimi
  • tdd: Gelistirme SURECI — once test yaz, fail gordukten sonra implement et

Birlikte kullanilirlar: TDD sureci icinde test-scaffold pattern'leri uygulanir.


Kaynak: obra/superpowers (uyarlanmis versiyon)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.