tdd
ما الذي تفعله
توجّه هذه المهارة إصلاح خلل يبدأ باختبار انحدار مركّز. وهي لمطوّرين يريدون دليلًا على أن الخلل أُصلح ولن يعود.
متى تستخدمها
- ✓عندما تطلب التطوير المدفوع بالاختبارات أو اختبار انحدار.
- ✓عندما يملك الخلل اختبارًا بسيطًا رخيصًا يُظهر السلوك المعطوب.
- ✓عندما تريد إصلاحًا يثبت اختبار أنه لن يعود.
رابط المهارة
https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/tdd/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“أصلح خلل تسجيل الدخول، لكن اكتب اختبارًا فاشلًا أولًا حتى نعرف أنه أُصلح فعلًا.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
يصف وكيلك الخلل، ويكتب اختبارًا صغيرًا يجب أن يفشل، ويشغّله ليتأكد من الفشل، ثم يُجري أصغر تغيير في الكود يجعله ينجح. وإذا لم يكن اختبار رخيص عمليًا، يستخدم فحصًا آخر.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
TDD Bug Fix
When fixing a bug with a clear, cheap test path, make the broken behavior executable before changing production code. The goal is a focused regression test that fails before the fix and passes after it.
Do not force a test when it would be impractical. If the available test would require broad harness setup, brittle mocks, slow end-to-end infrastructure, production-only state, vague reproduction steps, or large unrelated fixture churn, skip adding a new test and use the closest useful verification instead.
Workflow
- Understand the bug. Identify the intended behavior, current behavior, affected path, and smallest observable reproduction.
- Choose the narrowest executable check. Prefer the closest unit, component, integration, or regression test already used for that codepath. If no practical test path is obvious, do not create one from scratch just to satisfy the workflow.
- Write the failing test first. Add the smallest focused test that would have caught the bug. The test should encode intended behavior, not mirror the current implementation.
- Run the new test before fixing. Confirm it fails for the intended reason. If it passes or fails for an unrelated reason, correct the test or reproduction before editing the implementation.
- Fix the bug. Make the smallest production change that satisfies the intended behavior while preserving nearby contracts.
- Rerun the regression test. Confirm the test now passes.
If a Failing Test Is Impractical
Use the closest executable regression check instead: a targeted script, manual reproduction command, browser automation, snapshot comparison, log assertion, or focused integration check.
Prefer no new test over a bad test. A bad test is one that mostly tests mocks, encodes current implementation details, depends on timing or unrelated global state, needs expensive infrastructure for a small fix, or would be deleted immediately after proving the fix.
Guardrails
- Do not change tests merely to match a wrong implementation.
- Do not weaken existing assertions unless the expected behavior has genuinely changed and the reason is clear.
- Keep the regression test focused on the bug. Avoid broad fixture churn or unrelated coverage expansion.
- If the bug is flaky, make the test deterministic where possible and document the signal being locked down.
- If the bug exposes a broader class of failures, first land the focused regression path, then consider additional sibling coverage.
Final Response
Report the evidence, not just the outcome:
- Name the failing-before test or executable check and the failure it produced.
- Name the passing-after test run and any nearby validation performed.
- If failing-before evidence could not be demonstrated, state why and describe the closest regression check used instead.
الأسئلة الشائعة
ماذا لو لم يكن الاختبار عمليًا؟
المهارة لا تفرضه. تستخدم أقرب فحص مفيد بدلًا منه.
هل يجب أن يفشل الاختبار أولًا؟
نعم. يُشغَّل الاختبار الجديد قبل الإصلاح ليتأكد أنه يفشل للسبب الصحيح.
لماذا نكتب الاختبار قبل الإصلاح؟
ليثبت وجود الخلل أولًا، ثم يثبت لاحقًا متى أُصلح.
التفاصيل
الوصف الأصلي من المؤلف
Use only when the user explicitly asks for TDD, a failing test, or a regression test, OR when the bug has an obvious cheap local test target. Skip when the test path is unclear, expensive, integration-heavy, or not requested.
repo: cursor/plugins
الشعبية
- نجوم GitHub
- 15k
- الترتيب
- #10999
- الترخيص
- —
- آخر تحديث
- 31/10/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
advisor
15kيتيح لوكيلك استشارة نموذج ثانٍ أقوى عند نقاط مفصلية، مثل قبل قرار كبير أو عند تعثره في خطأ، إذا فعّلت ذلك.
check-agent-compatibility
15kيُجري فحصاً شاملاً لمدى قدرة وكلاء البرمجة بالذكاء الاصطناعي على تشغيل المستودع والتحقق منه وتوثيقه، ويعيد درجة توافق واحدة مع أهم المشكلات.
cli-for-agents
15kيعلّم وكيلك تصميم أدوات سطر الأوامر أو مراجعتها، حتى يستطيع وكلاء الذكاء الاصطناعي تشغيلها دون مطالبات، مع نصوص مساعدة واضحة وأمثلة.
continual-learning
15kيحافظ على ملاحظاتك في AGENTS.md محدّثة، بتسليم مهمة مراجعة المحادثات السابقة إلى مُحدِّث ذاكرة مخصص.
مهارات مشابهة
test-driven-development
311kيعلّم وكيلك كتابة اختبار فاشل أولًا، ثم رؤيته يفشل، ثم كتابة أصغر شيفرة تنجحه، قبل بناء أي ميزة أو إصلاح.
verification-before-completion
311kيعلّم وكيلك تشغيل فحوصات حقيقية وقراءة نتائجها قبل أن يقول إن المهمة أو الإصلاح أو البناء مكتمل أو ناجح.
migrate-to-shoehorn
310kيستبدل تأكيدات النوع الخطرة في ملفات الاختبار بمكتبة shoehorn، حتى تتمكن الاختبارات من استخدام بيانات جزئية وتجتاز فحوص الأنواع.