Skillpedia
برمجة عامة12k · #11523

pit-of-success

ما الذي تفعله

توجّه المهارة الذكاء الاصطناعي إلى إيجاد واجهات البرمجة ودوال التعديل (setters) والخصائص التي قد يُساء استخدامها، ثم نقل السلوك المطلوب إلى الكود المشترك. وهي مخصصة للمطورين الذين يراجعون الكود أو يعيدون هيكلته.

متى تستخدمها

  • ✓عندما تحتوي واجهة برمجية أو دالة تعديل أو خاصية مكوّن على فخ يقع فيه الاستدعاء الطبيعي.
  • ✓عندما تعيد هيكلة الكود بحيث يصبح المسار الآمن هو المسار الافتراضي.
  • ✓عندما تريد استبدال الدوال المساعدة أو الأغلفة المكررة بتنفيذ مشترك واحد.

رابط المهارة

https://github.com/trycompai/crm/blob/release/.agents/skills/pit-of-success/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/trycompai/crm/blob/release/.agents/skills/pit-of-success/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“هذه الدالة المعدِّلة تنكسر إذا مرّر أحدهم القيمة null. هل يمكنك تغيير الكود حتى يعمل الاستدعاء العادي دائمًا؟”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

يجد الذكاء الاصطناعي كل مستدعٍ لنقطة الدخول العامة، ويتحقق مما إذا كان الاستدعاء الواضح يُفسد السلوك، ثم ينقل القاعدة إلى الكود المشترك.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

Pit of Success

Make misuse hard and the obvious call correct.

Steps

  1. Find the public seam being used: exported function, hook return value, setter, component prop, route body, schema, or command. Then search every caller of that seam. Done when you know the natural call a future maintainer would write.
  2. Run the footgun test: “If someone does the obvious thing without knowing the hidden helper or convention, does behavior break?” Examples: setSelection(null) should mean the product’s normal clear behavior; a schema should reject states the UI never wants; a prop should not require sibling props in the right combo.
  3. Move the invariant into the seam. Prefer, in order:
    • make the existing API do the safe thing,
    • narrow the type/schema so bad states cannot be represented,
    • rename/split the API so the dangerous path is explicit,
    • only then add a helper, and only if all natural callers use it.
  4. Delete bypasses and duplicate meanings. Replace local wrappers, parallel helper names, and comments that explain the trap with one shared implementation at the seam.
  5. Prove the pit with one check: a focused test or type/schema assertion showing the obvious call now preserves behavior, plus a grep confirming no caller still uses the old footgun.

Rules

  • Do not fix only the named callsite. If the seam is wrong, fix the seam.
  • Do not rely on “remember to call this helper first” when callers can still call the raw API.
  • Do not add comments as a substitute for making misuse impossible or obvious.
  • Keep the diff boring: one invariant, one owner, no speculative abstraction.
  • If compatibility prevents changing the seam, name the dangerous API accordingly and expose a safe default API beside it.
الأسئلة الشائعة

هل يصلح موضعًا واحدًا فقط؟

لا. إذا كانت الواجهة نفسها خاطئة، تقول المهارة إن الإصلاح يكون في نقطة الربط المشتركة لا في مستدعٍ واحد.

ما ترتيب الإصلاحات الذي تفضله؟

تفضّل جعل الواجهة الموجودة آمنة أولًا، ثم تضييق الأنواع، ثم تقسيم الواجهات، وتضيف الدوال المساعدة في الأخير.

كيف تثبت الإصلاح؟

تستخدم اختبارًا مركّزًا أو فحص أنواع يُظهر أن الاستدعاء الواضح يعمل الآن، مع بحث يتأكد من عدم بقاء مستدعين قدامى.

التفاصيل

الوصف الأصلي من المؤلف

Review or refactor code so the correct behavior is the default path; use when APIs, setters, hooks, helpers, or component props have footguns where a natural call bypasses required semantics.

repo: trycompai/crm

الشعبية

نجوم GitHub
12k
الترتيب
#11523
الترخيص
MIT
آخر تحديث
1‏/11‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة