tdd
ما الذي تفعله
ترشد هذه المهارة الوكيل إلى بناء الكود بكتابة اختبار أولاً، ثم أصغر كود يجتازه. وهي موجهة إلى المطورين الذين يريدون إثبات كل تغيير باختبار كُتب قبل الكود.
متى تستخدمها
- ✓عندما تريد بناء سلوك جديد بالاختبار أولاً، خطوة صغيرة كل مرة.
- ✓عندما تريد إصلاح خطأ بكتابة اختبار يعيد إنتاجه أولاً.
- ✓عندما تريد كتابة الاختبارات انطلاقاً من مصدر موثوق، لا من الكود نفسه.
رابط المهارة
https://github.com/Yeachan-Heo/oh-my-claudecode/blob/main/skills/tdd/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“ابنِ قاعدة الخصم باختبار أولاً، خطوة صغيرة كل مرة، مستخدماً الأمثلة الواردة في مواصفات التسعير لدينا.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
يكتب الوكيل الاختبار التالي عند نقطة متفق عليها، ويتأكد من فشله للسبب المتوقع، ثم يكتب أصغر تغيير يجعله يجتاز. ويكرر هذه الحلقة، ويؤجل إعادة الهيكلة إلى مرحلة مراجعة لاحقة.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
TDD
Red-green in small steps, at seams that were agreed in advance. In a launch run the seam list is C2's approved output; outside launch, agree the seams with the user before the first test exists — a seam nobody approved gets no tests.
The loop
One test → one implementation → repeat:
- Write the next test at a seam. Run it. Watch it fail for the reason you expect — a test that cannot fail is not a test.
- Implement the smallest change that turns it green.
- Repeat. Each test is a tracer bullet: a narrow but complete path through the behavior, not a layer finished in isolation.
Rules
- Expected values come from an independent source of truth — a spec line, a worked example, a documented output. Never from the implementation under test: a test that asserts what the code happens to do is a mirror, not a check.
- Substitute at the seam's declared boundary class only — in-process, locally substitutable, owned-remote port, or true-external, the class C2 records for each seam. No substitutes inside the boundary the test is exercising.
- Refactoring is not part of the loop. It belongs to the review stage; the repair worker owns it. Do not refactor mid-red-green.
- A bug fix starts with the failing test that reproduces it — reproduction before theory, the debugger's rule.
- When proposing a seam, say in one line what it catches and what it lets through — a seam choice nobody can price is a guess, not a decision.
When no seam fits
If the behavior cannot be tested at any approved seam, stop and say so: report the missing seam as a finding (it feeds architecture-survey and refit) rather than inventing a seam or testing through internals.
Output
- The seam list used, with boundary classes and each seam's catch/miss line
- Red/green evidence — the failing run and the passing run
- Any seam-absence findings
الأسئلة الشائعة
هل تنسخ الاختبارات ما يفعله الكود؟
لا. القيم المتوقعة تأتي من مصدر مستقل، كالمواصفات أو مثال محلول، لا من الكود الذي يُختبر.
أين توضع الاختبارات؟
فقط عند النقاط المتفق عليها مسبقاً، فلا يُكتب اختبار لنقطة لم يوافق عليها أحد.
متى تتم إعادة الهيكلة؟
ليست داخل حلقة الأحمر والأخضر. تنتمي إلى مرحلة مراجعة لاحقة.
التفاصيل
الوصف الأصلي من المؤلف
Test-first at pre-agreed seams — one test, one implementation, tracer-bullet red/green; independent expected values; substitutions only at the seam's boundary class; launch Phase 4 reference.
الشعبية
- نجوم GitHub
- 41k
- الترتيب
- #7027
- الترخيص
- MIT
- آخر تحديث
- 2/11/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
agent-doc-discipline
41kيعلّم وكيلك كتابة تعليمات يستطيع وكلاء ذكاء اصطناعي آخرون اتباعها وحدهم، بقواعد قابلة للفحص ومع سبب واضح وراء كل قاعدة.
ai-slop-cleaner
41kيساعد وكيلك على تنظيف الكود الذي كتبه الذكاء الاصطناعي، وهو يعمل لكنه منتفخ أو مكرر، فيحذف الكود الزائد دون تغيير ما يفعله.
architecture-survey
41kيساعد وكيلك على مراجعة بنية الكود وسرد الأجزاء التي تصبح أصعب في التغيير، مع الأدلة، دون أن يغيّر أي شيء بنفسه.
ask-navigator
41kيساعد وكيلك على تحويل مشروع غامض إلى خريطة من أسئلة قرار واضحة، ثم العمل عليها واحداً تلو الآخر حتى يتضح الطريق.
مهارات مشابهة
test-driven-development
311kيعلّم وكيلك كتابة اختبار فاشل أولًا، ثم رؤيته يفشل، ثم كتابة أصغر شيفرة تنجحه، قبل بناء أي ميزة أو إصلاح.
verification-before-completion
311kيعلّم وكيلك تشغيل فحوصات حقيقية وقراءة نتائجها قبل أن يقول إن المهمة أو الإصلاح أو البناء مكتمل أو ناجح.
migrate-to-shoehorn
310kيستبدل تأكيدات النوع الخطرة في ملفات الاختبار بمكتبة shoehorn، حتى تتمكن الاختبارات من استخدام بيانات جزئية وتجتاز فحوص الأنواع.