Nim Debugging logo

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.

Overview

Publisherplanetis-m
Repositoryskills
Skill namenim-debugging
Stars
66
Forks
7
Bundled files
3
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by planetis-m on GitHub. Read the source before you install it.

Installation

Install the Nim Debugging AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/planetis-m/skills/tree/master/nim-debugging
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

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
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Nim Debugging in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Nim Debugging on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Nim Debugging is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Nim Debugging AI skill do?

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.

Why use Nim Debugging on TypingMind?

Because you install it once and use it with any model. Nim Debugging is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Nim Debugging in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/planetis-m/skills/tree/master/nim-debugging. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Nim Debugging?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Nim Debugging?

As many as you like. As long as a model supports skills, you can use Nim Debugging with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Nim Debugging AI skill free?

It is published on GitHub by planetis-m. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇