شعار D2 Diagram

D2 Diagram

المجتمع
diegomarino
d2-diagram

Generate a D2 diagram from a text description

نظرة عامة

الناشرdiegomarino
المستودعclaude-toolshed
اسم المهارةd2-diagram
النجوم
58
التفريعات
5
الملفات المرفقة
تعليمات فقط
الروابط
  • تعليمات بصيغة Markdown

    ملف SKILL.md يُحمّله النموذج عند الحاجة، فلا يستهلك توكنات إلا عندما يَرِد طلب ذو صلة فعلًا.

  • تعمل مع أي نموذج لغوي كبير

    مهارات الذكاء الاصطناعي مكتوبة بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا تعمل مع GPT أو Claude أو Gemini أو Grok أو نموذج محلي.

  • مكتفية بذاتها

    كل ما يحتاجه النموذج موجود في التعليمات — لا ملفات إضافية لمزامنتها.

  • مفتوحة المصدر

    نشرها diegomarino على GitHub. اطّلع على المصدر قبل تثبيتها.

التثبيت

ثبّت مهارة الذكاء الاصطناعي D2 Diagram في TypingMind لاستخدامها مع أي نموذج لغوي كبير، أو أضفها إلى وكيل ذكاء اصطناعي آخر يقرأ SKILL.md.

1

التثبيت في TypingMind

يُثبّت TypingMind المهارة مباشرةً من مجلدها على GitHub — فيقرأ SKILL.md، ويجمع ملفات الموارد في حزمة، ويحفظ النتيجة محليًا.

  1. افتح التطبيق وانتقل إلى «الإضافات» ثم «المهارات».
  2. اختر «تثبيت من GitHub».
  3. الصق رابط مجلد المهارة الموضّح أدناه وأكّد التثبيت.
    https://github.com/diegomarino/claude-toolshed/tree/main/plugins/d2/skills/d2-diagram
  4. فعّل المهارة في كل محادثة تريد إتاحتها فيها.
الإضافات ← المهارات ← إضافة مهارة ← من رابط GitHub، ثم الصق رابط المجلد واضغط على «متابعة».
2

التثبيت في وكيل ذكاء اصطناعي آخر

يمكن لأي وكيل ذكاء اصطناعي يقرأ تنسيق Agent Skills استخدام هذه المهارة — انسخ المجلد إلى مجلد المهارات الخاص بذلك الوكيل.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/diegomarino/claude-toolshed.git /tmp/claude-toolshed
mkdir -p .claude/skills
cp -r /tmp/claude-toolshed/plugins/d2/skills/d2-diagram .claude/skills/d2-diagram
أعد تشغيل Claude Code بعد النسخ ليتعرّف على المهارة الجديدة.

استخدمها في TypingMind

فعّل D2 Diagram في أي محادثة على TypingMind وسيتولى النموذج الباقي. تتضمن مطالبة النظام اسمها ووصفها، وبمجرد ورود طلب ذي صلة، يُحمّل النموذج التعليمات الكاملة تلقائيًا — فلا تحتاج إلى استدعائها يدويًا، ولا تستهلك أي توكنات حتى تُستخدم فعليًا.

يُحمّل النموذج مهارة D2 Diagram تلقائيًا بمجرد ورود طلب ذي صلة بها.

تعمل مع أي نموذج ذكاء اصطناعي

مهارات الذكاء الاصطناعي هي تعليمات بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا لا ترتبط D2 Diagram بالنموذج الذي كُتبت له. ثبّتها مرة واحدة في TypingMind واستخدمها مع GPT-5 أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو نموذج محلي تشغّله بنفسك — كل ذلك باستخدام مفاتيح API الخاصة بك.

  • تُحمَّل عند الحاجة فقط

    تتضمن مطالبة النظام الاسم والوصف فقط. وتُجلب التعليمات عند أول طلب ذي صلة، لذا لا تستهلك تعليمات المهارة أي توكنات ما دامت المهارة غير مستخدمة.

  • بدّل النماذج أثناء المحادثة

    لأن المهارة تعليمات وليست شيفرة، فإن تغيير النموذج لا يعطّلها — فالنموذج التالي يقرأ ملف SKILL.md نفسه.

تعليمات المهارة

هذا هو محتوى SKILL.md الذي يُحمّله النموذج. اقرأه قبل التثبيت — فالمهارة عبارة عن تعليمات سيتبعها نموذجك.

/d2-diagram

User request: "$ARGUMENTS"

Task

Generate a well-composed D2 diagram from the user's description.

Step 1: Setup

Resolve plugin path and read config:

bash
PLUGIN_DIR=$(find "$HOME/.claude/plugins/cache" -type d -name "d2" -path "*/skills/d2" 2>/dev/null | head -1)
[ -z "$PLUGIN_DIR" ] && PLUGIN_DIR=$(find "$HOME" -maxdepth 8 -type d -name "d2" -path "*/skills/d2" 2>/dev/null | head -1)
bash "$PLUGIN_DIR/scripts/ensure-deps.sh"

Read .claude/d2.json if it exists (theme_id, layout, sketch, output_directory, auto_validate, auto_render). If it does not exist, display a one-time nudge:

First time using the d2 plugin? Run /d2-config to pick a theme. Using defaults for now.

Step 2: Classify

Determine diagram type from the description:

IntentType
API calls, request/response, message passingSequence
System components, microservices, infrastructure, pipelines, workflowsArchitecture
Database tables, schema, foreign keys, entitiesER
Class hierarchy, OOP, interfaces, data modelsClass

If ambiguous between 2 types, ask one clarifying question. If clear, proceed.

Step 3: Structural Plan

Before writing any D2, build this plan internally. Apply the policies from $PLUGIN_DIR/SKILL.md.

Determine:

  • diagram_type — from Step 2
  • abstraction_level — infer from prompt: context, container, component, or deployment
  • grouping_criterion — infer or default: layer, domain, ownership, or environment
  • direction — from orientation heuristics (right for flows, down for hierarchies)
  • layout_engine — from engine selection table (<8 nodes: dagre, >=8: elk)
  • nodes — inventory with id (snake_case), label, kind (actor/service/database/queue/cache/gateway/external)
  • groups — with label and children node IDs
  • edges — with from, to, and optional label
  • budget_check — count total nodes, max group size, nesting depth, max fanout against visual budget limits
  • split_decision — pass or split_required

Visibility rule: If the budget check passes and there is no ambiguity in level or grouping, proceed directly to Step 4. If split is required OR the abstraction level or grouping is ambiguous, present a summary to the user:

text
I'm planning to generate:
- Type: {type} at {abstraction_level} level
- Grouping: by {criterion}
- Direction: {direction}
- {N} nodes in {M} groups
- Split: {overview + N detail diagrams | single diagram}

Proceed, or want to adjust?

Step 4: Load Specialist

Read the specialist for the classified type:

  • Sequence: $PLUGIN_DIR/specialists/d2-sequence.md
  • Architecture: $PLUGIN_DIR/specialists/d2-architecture.md
  • ER: $PLUGIN_DIR/specialists/d2-er.md
  • Class: $PLUGIN_DIR/specialists/d2-class.md

Use the specialist's compositional patterns and D2 syntax conventions. The structural plan from Step 3 governs the structure — the specialist provides type-specific syntax.

Step 5: Generate D2

Write the diagram following:

  1. Structural plan — governs structure (what nodes, what groups, what edges)
  2. Specialist patterns — governs D2 syntax (shapes, conventions, type-specific features)
  3. Global policies — governs conventions (IDs, labels, direction, engine)

Order in the .d2 file:

  1. vars block (theme, engine, sketch from config)
  2. direction declaration
  3. classes block (if >4 nodes of same type)
  4. Node and group declarations
  5. Connections

Non-negotiable conventions:

  • IDs: snake_case, no emojis, no spaces — api_gw, user_svc, orders_db
  • Labels: api_gw: "API Gateway" — emojis allowed in labels only
  • Direction: MUST appear right after vars block — direction: right for flows, direction: down for hierarchies. If unsure, use direction: right. Never omit.
  • Quote labels containing spaces or special characters.

Step 6: Repair Pass

Before delivering, run the 10-point repair checklist from $PLUGIN_DIR/SKILL.md:

  1. No level mixing
  2. Consistent grouping criterion
  3. Budget compliance (12 top-level, 7 per group, 3 nesting, 4 fanout)
  4. Labels <= 24 chars
  5. No orphan nodes
  6. No single-child groups
  7. No excessive fanout (>4 edges out)
  8. Self-loops converted to notes (sequences)
  9. Direction explicitly set
  10. Layout engine appropriate for complexity

Fix any violations silently. Do not ask the user — just fix them.

Step 7: Validate Syntax

bash
d2 validate {output_file}

Fix syntax errors using $PLUGIN_DIR/references/guides/troubleshooting.md.

Step 8: Save and Deliver

bash
mkdir -p {output_directory}

Filename: {type}-{short-description}-{YYYYMMDD}.d2

Render if auto_render=true or user asks:

bash
d2 {output_file} {output_directory}/{basename}.svg

Output:

text
{d2 code block}

**What this shows:** {1-2 sentences describing the diagram}
**Saved to:** {filename}
**Elements:** {N} nodes, {M} connections
**Layout:** {engine}, direction {direction}

Want to adjust? I can change the detail level, scope, grouping, or type.

If split was required, list all generated files.

Code/Script Flow Requests

If the user asks to "diagram the flow" of a file or script:

  1. Read the file and derive the flow from actual control paths
  2. Build the structural plan from the code structure
  3. Execute as the appropriate specialist

الأسئلة الشائعة

ماذا تفعل مهارة الذكاء الاصطناعي D2 Diagram؟

Generate a D2 diagram from a text description

لماذا تستخدم D2 Diagram على TypingMind؟

لأنك تثبّتها مرة واحدة وتستخدمها مع أي نموذج. مهارة D2 Diagram عبارة عن نص Markdown وليست شيفرة خاصة بمزود بعينه، لذا تعمل المهارة نفسها مع GPT-5 أو Claude أو Gemini أو Grok أو نموذج محلي، ويمكنك تبديل النموذج أثناء المحادثة دون تعطّل المهارة. يعمل TypingMind بمفاتيح API الخاصة بك، فتدفع للمزودين مباشرةً بدلًا من اشتراك لكل مقعد، وتبقى مهاراتك ومحادثاتك في مساحة التخزين الخاصة بك.

كيف أثبّت D2 Diagram في TypingMind؟

في TypingMind، افتح «الإضافات»، ثم «المهارات»، ثم اختر «التثبيت من GitHub» والصق https://github.com/diegomarino/claude-toolshed/tree/main/plugins/d2/skills/d2-diagram. يقرأ TypingMind ملف SKILL.md الخاص بالمهارة ويثبّتها كمهارة يمكنك تفعيلها لكل محادثة على حدة.

ما نماذج الذكاء الاصطناعي التي يمكنها استخدام D2 Diagram؟

أي نموذج تربطه في TypingMind. مهارات الذكاء الاصطناعي عبارة عن تعليمات Markdown وليست شيفرة خاصة بمزود بعينه، لذا يمكن لكل من GPT وClaude وGemini وGrok والنماذج المحلية تحميل هذه المهارة عندما يتوافق الطلب معها.

كم نموذج ذكاء اصطناعي يمكنني استخدامه مع D2 Diagram؟

أي عدد تريده. ما دام النموذج يدعم المهارات، يمكنك استخدام D2 Diagram معه، سواء كان GPT أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو غيرها، وكل ذلك على TypingMind باستخدام مفاتيح API الخاصة بك.

هل مهارة الذكاء الاصطناعي D2 Diagram مجانية؟

نشرها diegomarino على GitHub. راجع المستودع للاطلاع على شروط الترخيص. لا تدفع إلا لمزود الذكاء الاصطناعي الخاص بك مقابل التوكنات التي تستخدمها.

ما هي مهارات الذكاء الاصطناعي؟

مهارة الذكاء الاصطناعي حزمة تعليمات قابلة لإعادة الاستخدام تعلّم نموذج الذكاء الاصطناعي كيفية تنفيذ مهمة محددة. وتتبع تنسيق Agent Skills المفتوح: ملف SKILL.md يتضمن اسمًا ووصفًا، إلى جانب أي نصوص برمجية أو قوالب أو ملفات مرجعية قد يحتاج إليها النموذج. لا يقرأ النموذج التعليمات إلا عندما يتوافق طلبك مع المهارة، لذا لا تترتب على المهارة المثبتة أي تكلفة حتى تُستخدم.

كيف تختلف مهارات الذكاء الاصطناعي عن الإضافات أو موصلات MCP؟

تمنح الإضافة أو موصل MCP النموذج أدوات جديدة يمكنه استدعاؤها، وهي شيفرة تُنفَّذ في مكان ما وتُرجع نتيجة. أما مهارة الذكاء الاصطناعي فتزوّد النموذج بالمعرفة ومنهجية العمل: كيفية التعامل مع مهمة، والخطوات التي ينبغي اتباعها، وما ينبغي أن تكون عليه المخرجات الجيدة. المهارات عبارة عن نصوص Markdown، لذا لا تحتاج إلى خادم أو مفتاح API أو بيئة تشغيل، وتعمل مع أي نموذج.

عرض الكل

أنشئ مساحة عملك للذكاء الاصطناعي الآن

اشترك في نشرتنا الإخبارية لتصلك أخبار الميزات الجديدة والهدايا القادمة 👇