بنقرة واحدة
test-driven-development
TDD: enforce RED-GREEN-REFACTOR cycle. Tests before code, always.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
TDD: enforce RED-GREEN-REFACTOR cycle. Tests before code, always.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Karpathy-inspired guidelines: Think before coding, Simplicity first, Surgical changes, Goal-driven execution
Use when you have a written implementation plan to execute in a separate session with review checkpoints
Write an actionable markdown plan before implementation. Bite-sized tasks, exact paths, complete code.
Write clear Conventional Commits. Imperative subject, explain why not what, one logical change per commit.
Optimize based on measurement, never guesswork. Profile first, fix the real bottleneck, verify the win.
Refactor code without changing behavior. Small steps, green tests after every change, no mixing with feature work.
| name | test-driven-development |
| description | TDD: enforce RED-GREEN-REFACTOR cycle. Tests before code, always. |
Core principle: If you didn't watch the test fail, you don't know if it tests the right thing.
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
Write code before the test? Delete it. Start over. No exceptions.
Write one minimal test showing what should happen:
func TestRetriesFailedOperations(t *testing.T) {
attempts := 0
operation := func() error {
attempts++
if attempts < 3 {
return errors.New("fail")
}
return nil
}
err := retryOperation(operation)
if err != nil {
t.Fatalf("expected success, got %v", err)
}
if attempts != 3 {
t.Fatalf("expected 3 attempts, got %d", attempts)
}
}
Use bash to run it:
go test -run TestRetriesFailedOperations ./path/
Expected: FAIL — function not defined.
Write the absolute minimum code to make the test pass:
func retryOperation(op func() error) error {
var err error
for i := 0; i < 3; i++ {
err = op()
if err == nil {
return nil
}
}
return err
}
Run again: go test -run TestRetriesFailedOperations ./path/
Expected: PASS
Now that tests pass, improve the code:
Run tests after each refactor step.
If you find yourself thinking: