Skillpedia
برمجة عامة15k · #10991

principle-type-system-discipline

ما الذي تفعله

تمنح هذه المهارة وكيلك قاعدة لتصميم أنواع تكشف الأخطاء مبكرًا. وهي لمطوّرين يعملون بلغات ذات أنواع ثابتة.

متى تستخدمها

  • ✓عندما تصمم أنواعًا أو تراجع توقيع دالة.
  • ✓عندما تشترك قيمتان في النوع نفسه مع أنهما تعنيان شيئين مختلفين.
  • ✓عندما تدخل بيانات من خارج البرنامج إلى الكود.

رابط المهارة

https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/principle-type-system-discipline/SKILL.md

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

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

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

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

استخدم هذه المهارة لمساعدتي: https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/principle-type-system-discipline/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

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

“معرّفات المستخدمين ومعرّفات الطلبات كلاهما نصوص عادية، وتختلط باستمرار. شدّد الأنواع حتى يوقف المترجم هذا.”

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

كيف تعمل

يعطي وكيلك كل قيمة دلالية نوعها الخاص، ويحلل البيانات الخارجية إلى نماذج مُنمَّطة عند الحد، ويجعل الحالات غير المعالجة تُفشل البناء، ويشتق الأنواع من المخططات الموثوقة بدل نسخها يدويًا.

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

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

Type System Discipline

Make the compiler reject impossible states, mismatched primitives, and unhandled variants. Prefer defining errors and special cases out of existence over proliferating handlers. For TypeScript syntax, see the typescript-best-practices skill.

  • Brand semantic primitives. UserId and OrderId are strings underneath but should not be interchangeable. Give each its own type, such as a branded intersection in TypeScript or a newtype elsewhere. Validate once at creation, trust the type downstream. If two arguments share a primitive type but mean different things, brand them.
  • External data is untyped until parsed. RPC payloads, JSON, IPC messages, CLI args, config files, environment variables, database rows. Have a parse function at every boundary that turns unstructured input into the typed model. The boundary-discipline principle skill says where to put validation.
  • Derive types from authoritative schemas. When a protocol buffer, OpenAPI spec, GraphQL schema, database migration, design-token file, or another file owns a shape, derive from it instead of hand-rolling a parallel type. See the encode-lessons-in-structure principle skill.
الأسئلة الشائعة

ما النوع المُعلَّم (branded type)؟

نوع يبدو نصًا من الداخل لكن لا يمكن خلطه مع معرّفات أخرى، فيلتقط المترجم الخطأ.

أين يحدث التحليل؟

عند كل حد، مثل حمولات الشبكة وملفات الإعداد ومعاملات سطر الأوامر وصفوف قاعدة البيانات.

لماذا نشتق الأنواع من المخططات؟

حتى لا يُكرَّر شكل تملكه بروتوكول أو ترحيل، ثم يتباعد عنه بمرور الوقت.

التفاصيل

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

Apply when designing types, reviewing a function signature, or writing code in any statically-typed language. Make illegal states unrepresentable, brand semantic primitives, parse external data at boundaries, exhaust variants, derive from authoritative schemas.

repo: cursor/plugins

الشعبية

نجوم GitHub
15k
الترتيب
#10991
الترخيص
—
آخر تحديث
31‏/10‏/2026

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

0

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

التعليقات

  • …

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

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