شعار Nim Debugging

Nim Debugging

المجتمع
planetis-m
nim-debugging

Debug Nim compile failures, crashes, wrong results, macro expansion, ownership behavior, and unsafe-memory defects using focused reproduction, stack traces, inspection, compiler expansion, and sanitizers. Use when diagnosing runtime failures, release-only behavior, generic or macro issues, unexpected copies, pointer bugs, or memory leaks.

Add to TypingMind

نظرة عامة

الناشرplanetis-m
المستودعskills
اسم المهارةnim-debugging
النجوم
66
التفريعات
7
الملفات المرفقة
3
الروابط
  • تعليمات بصيغة Markdown

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

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

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

  • الملفات المرفقة: 3

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

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

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

التثبيت

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

1

التثبيت في TypingMind

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

  1. افتح التطبيق وانتقل إلى «الإضافات» ثم «المهارات».
  2. اختر «تثبيت من GitHub».
  3. الصق رابط مجلد المهارة الموضّح أدناه وأكّد التثبيت.
    https://github.com/planetis-m/skills/tree/master/nim-debugging
  4. فعّل المهارة في كل محادثة تريد إتاحتها فيها.
الإضافات ← المهارات ← إضافة مهارة ← من رابط GitHub، ثم الصق رابط المجلد واضغط على «متابعة».
2

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

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

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

استخدمها في TypingMind

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

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

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

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

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

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

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

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

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

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

Nim Debugging

Debug by reducing uncertainty: preserve the failure, state one hypothesis, and collect the smallest piece of evidence that can reject it. Find the first violated invariant rather than stopping at the final crash.

Rules

Preserve the failure

  • Record the exact input, command, working directory, backend, memory manager, thread setting, build mode, and relevant environment.
  • Make the failure deterministic before changing code. If it is intermittent, preserve a seed, event order, or failing fixture.
  • Change one diagnostic dimension at a time. A debug build that no longer fails is a comparison point, not a reproduction.
  • Turn each confirmed defect into a regression test before removing instrumentation.

Choose evidence by failure class

FailureFirst evidence
Compile-time type or generic questionNormal compiler diagnostic; use compiles only for a yes/no probe
Unhandled exception or defectDefault stack trace, or --lineTrace:on in the failing optimized mode
Wrong runtime valueecho, debugEcho, or repr at invariant boundaries
Buffered output lost at a crashstdout.write followed by stdout.flushFile()
Macro-generated code--expandMacro:<name>
Unexpected copy, move, or destruction--expandArc:<proc> under the project memory manager
Pointer, manual allocation, or FFI memory errorAddressSanitizer with the complete required recipe
Independent leak or invalid-access checkValgrind

Stack traces and build modes

Default build behavior:

ModeUnhandled exception tracewriteStackTrace()
default or -d:debugfull paths and line numbersfull trace
-d:releaseraising frame onlyno traceback available
-d:dangerraising frame onlyno traceback available
  • Add --lineTrace:on to the failing release or danger command to restore the call chain and line numbers. It implies --stackTrace:on.
  • Use --excessiveStackTrace:off when filenames are sufficient; the default on form includes full paths.
  • Call writeStackTrace() when the current path matters before an exception exists.
  • Read the trace from the failure backward, then inspect values along that path until the first invalid state is found.

Runtime inspection

  • Use echo for ordinary values and repr when a type lacks useful $ formatting.
  • Use debugEcho inside {.noSideEffect.} code; ordinary echo is rejected there.
  • echo flushes automatically. Flush stdout.write explicitly when a crash could occur before the buffer drains.
  • Label diagnostic values with the phase and invariant being checked. Avoid dumping large structures when one length, index, tag, or identity answers the hypothesis.
  • compiles(expr) is a compile-time boolean probe. If it returns false, compile the candidate normally to obtain the actual diagnostic.
  • fields and fieldPairs use the expression's static type, not its runtime subtype. Use when, not if, for code that depends on a field's name or type.

Compiler-generated code

  • Run nim c --expandMacro:<name> file.nim to inspect a macro's expanded AST. The compiler emits an [ExpandMacro] hint.
  • Run nim c --expandArc:<proc> file.nim to inspect injected copy, sink, move, and destroy operations.
  • Keep an --expandArc target reachable from the entry point and use the target project's --mm: mode.
  • Measure copy behavior inside a named proc; last-use analysis does not fire at module top level.
  • Treat expansion output as evidence about generated operations, not as a reason to optimize by itself. move is destructive and requires deliberate last use plus behavior tests.
  • Nim defaults to ORC. Read the compiler build hint because project configuration may select ARC or atomic ARC.

AddressSanitizer

Use ASan for ptr, addr, cstring, cstringArray, manual allocation, and C-FFI memory faults. The required Linux/GCC recipe is:

bash
nim c \
  --passC:"-fsanitize=address -fno-omit-frame-pointer" \
  --passL:"-fsanitize=address -fno-omit-frame-pointer" \
  -g \
  -d:useMalloc \
  -d:noSignalHandler \
  file.nim
  • Pass sanitizer flags to both compilation and linking.
  • -d:useMalloc is required so ASan observes memory obtained through Nim's allocator.
  • -d:noSignalHandler is required so ASan, rather than Nim's signal handler, reports signal faults.
  • -g gives symbolized Nim locations with GCC. Add --cc:clang for Clang and ensure llvm-symbolizer is in PATH.
  • Preserve the project's memory manager and failing input.
  • Read both the invalid-access stack and the allocation/free stack before editing code.

See references/memory_sanitizers.md for a complete runnable example. Platform recipes not verified in this repository are intentionally omitted.

Valgrind

Use Valgrind as an independent native-memory check:

bash
nim c -g -o:program file.nim
valgrind --leak-check=full --error-exitcode=1 ./program

It requires no sanitizer instrumentation and is slower than ASan. A non-zero exit distinguishes detected errors in automated checks.

Debug symbols and native debuggers

  • -g and --debugger:native enable native debug information and line directives.
  • This project does not use GDB: Nim name mangling and generated C make variable inspection slower and less reliable than stack traces, focused inspection, ASan, Valgrind, and compiler expansion.

Workflow

  1. Reproduce the failure with an exact command and fixed input.
  2. Minimize unrelated setup while keeping the same failure and configuration.
  3. State one falsifiable hypothesis and the invariant it predicts.
  4. Select the narrowest evidence source from the failure-class table.
  5. Follow the failing path backward and locate the first invalid state.
  6. Fix the invariant at its owner instead of suppressing the final symptom.
  7. Re-run the original reproduction and relevant sanitizer or expansion check.
  8. Add a regression test, then remove temporary prints and scratch artifacts.

Common Mistakes

MistakeWhy it is wrong
Changing input, build mode, and code togetherThe result cannot identify which change affected the failure
Reading only the final crashing lineCorruption or invalid state commonly begins earlier
Expecting full traces from release or danger defaultsAdd --lineTrace:on to the failing optimized command
Using compiles as a replacement for compiler diagnosticsIt answers only yes or no and suppresses the candidate diagnostic
Printing with stdout.write immediately before a crash without flushingBuffered evidence can be lost
Running ASan without -d:useMallocNim allocator overflows can remain invisible to ASan
Running ASan without -d:noSignalHandlerNim can intercept signal faults before ASan reports them
Passing ASan flags only to C compilationThe sanitizer runtime must also be linked
Using Clang ASan without llvm-symbolizerReports can contain raw addresses instead of Nim locations
Adding move merely because --expandArc shows a copymove changes ownership semantics and must be safe at last use
Using GDB for routine Nim debuggingThe project uses faster Nim-aware evidence sources instead

References

  • references/stack_trace_diagnosis.md — Boundary instrumentation for finding the first bad value behind a crash.
  • references/memory_sanitizers.md — ASan and Valgrind commands for unsafe access and leaks.
  • references/arc_optimization.md — expandArc comparison for unexpected ownership copies.

الملفات المرفقة

يقرأ النموذج هذه الملفات عند الحاجة ما دامت المهارة محمّلة. وهي متاحة للقراءة ولا تُنفّذ أبدًا.

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

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

Debug Nim compile failures, crashes, wrong results, macro expansion, ownership behavior, and unsafe-memory defects using focused reproduction, stack traces, inspection, compiler expansion, and sanitizers. Use when diagnosing runtime failures, release-only behavior, generic or macro issues, unexpected copies, pointer bugs, or memory leaks.

لماذا تستخدم Nim Debugging على TypingMind؟

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

كيف أثبّت Nim Debugging في TypingMind؟

في TypingMind، افتح «الإضافات»، ثم «المهارات»، ثم اختر «التثبيت من GitHub» والصق https://github.com/planetis-m/skills/tree/master/nim-debugging. يقرأ TypingMind ملف SKILL.md الخاص بالمهارة، ويجمع ملفاتها ويثبّتها كمهارة يمكنك تفعيلها لكل محادثة على حدة.

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

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

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

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

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

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

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

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

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

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

عرض الكل

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

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