Logo van Nim Debugging

Nim Debugging

Community
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

Overzicht

Uitgeverplanetis-m
Repositoryskills
Skillnaamnim-debugging
Sterren
66
Forks
7
Meegeleverde bestanden
3
Links
  • Instructies in Markdown

    Het model laadt het bestand SKILL.md alleen als dat nodig is. Dat kost dus alleen tokens als een verzoek daadwerkelijk bij de skill past.

  • Werkt met elk LLM

    AI-skills bestaan uit instructies in gewone Markdown, niet uit aanbiederspecifieke code. Daardoor werken ze met GPT, Claude, Gemini, Grok of een lokaal model.

  • Meegeleverde bestanden: 3

    Scripts, sjablonen en referentiemateriaal die het model tijdens het werken kan lezen. De bestanden kunnen alleen worden gelezen en worden nooit uitgevoerd.

  • Open source

    Gepubliceerd door planetis-m op GitHub. Bekijk de bronbestanden voordat je de skill installeert.

Installatie

Installeer de AI-skill Nim Debugging in TypingMind om deze met elk LLM te gebruiken, of voeg de skill toe aan een andere agent die SKILL.md kan lezen.

1

Installeren in TypingMind

TypingMind installeert een skill rechtstreeks vanuit de GitHub-map. De app leest SKILL.md, bundelt de bijbehorende bestanden en slaat het resultaat lokaal op.

  1. Open de app en ga naar Plug-ins → Skills.
  2. Kies "Installeren via GitHub".
  3. Plak de onderstaande URL van de skillmap en bevestig.
    https://github.com/planetis-m/skills/tree/master/nim-debugging
  4. Schakel de skill in voor elke chat waarin je de skill wilt kunnen gebruiken.
Plug-ins → Skills → Skill toevoegen → Via GitHub-URL. Plak vervolgens de map-URL en druk op Doorgaan.
2

Installeren in een andere agent

Elke agent die het Agent Skills-formaat kan lezen, kan deze skill gebruiken — kopieer de map naar de skillmap van die agent.

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
Start Claude Code na het kopiëren opnieuw op, zodat de nieuwe skill wordt herkend.

Gebruik deze skill in TypingMind

Schakel Nim Debugging in voor een chat naar keuze in TypingMind en het model doet de rest. De naam en beschrijving staan in de systeemprompt. Zodra een verzoek bij de skill past, laadt het model zelf de volledige instructies. Je hoeft de skill nooit handmatig aan te roepen. Pas als het model de skill daadwerkelijk gebruikt, kost dat tokens.

Het model laadt Nim Debugging automatisch zodra een verzoek erbij past.

Werkt met elk AI-model

AI-skills zijn gewone Markdown-instructies in plaats van aanbiederspecifieke code. Daardoor is Nim Debugging niet gebonden aan het model waarvoor de skill is geschreven. Installeer de skill één keer in TypingMind en gebruik deze met GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama of een lokaal model dat je zelf draait — allemaal met je eigen API-sleutels.

  • Alleen geladen wanneer nodig

    De systeemprompt bevat alleen de naam en beschrijving. De instructies worden bij het eerste bijpassende verzoek opgehaald, dus een ongebruikte skill kost niets.

  • Wissel van model tijdens een chat

    Omdat de skill uit instructies bestaat en niet uit code, blijft deze werken als je van model wisselt — het volgende model leest hetzelfde SKILL.md-bestand.

Skillinstructies

Dit is de inhoud van SKILL.md die het model laadt. Lees deze vóór de installatie — een skill bestaat uit instructies die je model zal volgen.

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.

Meegeleverde bestanden

Zolang de skill geladen is, leest het model deze bestanden als dat nodig is. Het model kan ze alleen lezen; ze worden nooit uitgevoerd.

Veelgestelde vragen

Wat doet de AI-skill 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.

Waarom Nim Debugging gebruiken in TypingMind?

Omdat je deze skill één keer installeert en met elk model kunt gebruiken. Nim Debugging bestaat uit gewone Markdown in plaats van aanbiederspecifieke code. Dezelfde skill werkt dus met GPT-5, Claude, Gemini, Grok of een lokaal model. Ook als je midden in een chat van model wisselt, blijft de skill werken. TypingMind werkt met je eigen API-sleutels, dus je betaalt aanbieders rechtstreeks in plaats van een abonnement per gebruikersplek af te sluiten. Je skills en chats blijven in je eigen opslag.

Hoe installeer ik Nim Debugging in TypingMind?

Open Plug-ins → Skills → Installeren vanaf GitHub in TypingMind en plak https://github.com/planetis-m/skills/tree/master/nim-debugging. TypingMind leest het bestand SKILL.md, bundelt de bijbehorende bestanden en installeert het geheel als een skill die je per chat kunt inschakelen.

Welke AI-modellen kunnen Nim Debugging gebruiken?

Elk model dat je in TypingMind koppelt. AI-skills bestaan uit gewone Markdown-instructies in plaats van aanbiederspecifieke code. GPT, Claude, Gemini, Grok en lokale modellen kunnen deze skill dus allemaal laden wanneer een verzoek erbij past.

Hoeveel AI-modellen kan ik met Nim Debugging gebruiken?

Zoveel als je wilt. Je kunt Nim Debugging gebruiken met elk model dat skills ondersteunt, zoals GPT, Claude, Gemini, Grok, DeepSeek, Mistral of Llama. Allemaal in TypingMind met je eigen API-sleutels.

Is de AI-skill Nim Debugging gratis?

Deze skill is door planetis-m op GitHub gepubliceerd. Bekijk de repository voor de licentievoorwaarden. Je betaalt alleen je eigen AI-aanbieder voor de tokens die je gebruikt.

Wat zijn AI-skills?

Een AI-skill is een herbruikbare bundel instructies die een AI-model leert hoe het één specifieke taak moet uitvoeren. De skill volgt het open Agent Skills-formaat: het bestand SKILL.md bevat de naam en beschrijving van de skill. Daarnaast kan de skill scripts, sjablonen of referentiebestanden bevatten die het model nodig heeft. Het model leest de instructies alleen als je verzoek bij de skill past. Een geïnstalleerde skill kost dus niets zolang deze niet wordt gebruikt.

Waarin verschillen AI-skills van plug-ins of MCP-servers?

Een plug-in of MCP-server geeft een model nieuwe tools om aan te roepen: code die ergens wordt uitgevoerd en een resultaat teruggeeft. Een AI-skill geeft het model juist kennis en een werkwijze: hoe het een taak moet aanpakken, welke stappen het moet volgen en hoe goede uitvoer eruitziet. Skills bestaan uit gewone Markdown en hebben dus geen server, API-sleutel of runtime nodig. Ze werken met elk model.

Bekijk alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇