nim-debugging

Debug Nim programs using compiler flags and sanitizer diagnostics.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/planetis-m/skills_experiment --skill nim-debugging
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nim-debugging
Source: https://github.com/planetis-m/skills_experiment/tree/main/skills/nim-debugging
Command: npx skills add https://github.com/planetis-m/skills_experiment --skill nim-debugging

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It helps you quickly pinpoint why a Nim program crashes, behaves unexpectedly, or corrupts memory by guiding you through the most effective debugging signals available.

Core Features & Use Cases

  • Stack traces that match your build mode: Explain how -d:debug, -d:release, and -d:danger affect stack trace fidelity and how to restore line-traced stack output with --lineTrace:on.
  • Fast runtime inspection: Use echo, debugEcho, and repr to inspect values even when $ is unavailable or side effects are restricted.
  • Compiler and runtime diagnostics: Expand macro output (--expandMacro), inspect ARC/ownership operations (--expandArc), and find unsafe-memory issues with AddressSanitizer (or Valgrind as a fallback).

Quick Start

Ask the AI to help you debug a failing Nim program by reproducing the error, extracting the most informative stack trace, and then narrowing the root cause using either --expandMacro, --expandArc, or AddressSanitizer based on the suspected failure type.

Frequently Asked Questions about nim-debugging

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I get a stack trace with line numbers when my Nim program crashes?

To get a stack trace with line numbers when your Nim program crashes, compile with `--lineTrace:on` and use `-d:debug` or `-d:release` build modes, as `-d:danger` strips stack trace fidelity.

Why does my Nim code have unexpected behavior or memory corruption?

Unexpected behavior or memory corruption in Nim code can be diagnosed by running the program with AddressSanitizer or Valgrind to detect unsafe-memory issues, or by using `--expandArc` to inspect ARC ownership operations.

What is the best way to inspect Nim macro expansion during compilation?

The best way to inspect Nim macro expansion during compilation is to pass the `--expandMacro:<macro_name>` flag to the compiler, allowing you to review the generated code and narrow down compilation issues.

How do I print variable values in Nim when side effects are restricted?

To print variable values in Nim when side effects are restricted or the `$` operator is unavailable, use `debugEcho` or `repr` to safely inspect runtime values without triggering side effect constraints.

Does Valgrind work with Nim to find memory leaks and unsafe memory access?

Valgrind works with Nim to find memory leaks and unsafe memory access by executing the compiled binary with appropriate compilation and linking options, serving as a fallback to AddressSanitizer for runtime diagnostics.

How do I debug Nim ARC ownership issues and memory management?

To debug Nim ARC ownership issues and memory management, compile with the `--expandArc:<proc_name>` flag to inspect automatic reference counting operations and verify memory ownership behavior within specific procedures.