nim-ownership-hooks

Implement minimal Nim ARC/ORC ownership hooks for value types and managed resources.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you design and review Nim ownership hooks so ARC/ORC can safely destroy, move, copy, and transfer resources without leaks, double-frees, or incorrect warnings.

Core Features & Use Cases

  • Ownership model classification: Determine whether a type is compiler-managed, move-only, deep-owning, shared/refcounted, or borrowing/view before writing any hooks.
  • Minimal correct hook sets: Implement only the hook functions required for the real ownership model, keeping behavior consistent with local Nim style.
  • Hook ordering and verification: Avoid phase-order hook declaration errors and verify changes with focused compile/runtime tests.

Quick Start

Ask the AI to review your Nim type under ARC/ORC ownership semantics and produce the minimal correct set of =destroy, =wasMoved, =sink, =copy, =dup, and optional =trace implementations, plus a short checklist of targeted tests to run.

Frequently Asked Questions about nim-ownership-hooks

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

FAQPage Schema
How do I implement correct Nim ARC/ORC move hooks for custom types?

Nim ARC/ORC ownership hooks are custom functions like `=destroy`, `=sink`, and `=copy` that dictate how the compiler manages memory for manually managed resources. They are needed when default memory management cannot safely handle deep resource ownership or move semantics.

When should I write `=trace` hooks in Nim memory management?

To avoid phase-order hook declaration errors in Nim, ensure hook functions are exported and declared in the correct sequence before use. You should verify correctness by running focused compile and runtime tests targeting the specific move and copy semantics.

Why does my Nim code throw ownership warnings under ARC?

Nim throws ownership warnings under ARC when `=wasMoved` or `=sink` hooks are missing or implemented incorrectly for value types. Reviewing the type's ownership model and applying the minimal correct hook set resolves these warnings.

Do I need to implement `=copy` and `=dup` together for Nim move semantics?

You do not always need `=copy` and `=dup` together. The requirement depends entirely on whether your type is deep-owning or shared, and you should select only the minimal hook set that matches your actual ownership model.