nim-code-organization
Organize Nim modules and multi-step workflows with explicit state ownership, cohesive boundaries, narrow exports, and structured orchestration.
Skill by Vyrnexis
Chalk Labs
Need help deploying nim-code-organization?
Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/vyrnexis-nim-code-organization
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/nim-code-organization
What's inside
- Skill name
nim-code-organization- Description
- Organize Nim modules and multi-step workflows with explicit state ownership, cohesive boundaries, narrow exports, and structured orchestration. Use when refactoring a large Nim file, splitting logic across modules, designing parser-style stateful code, or simplifying nested helpers and hidden mutable state.
- License
- MIT
- Instructions
- 101 lines in SKILL.md · view on GitHub
Files (3)
- SKILL.md
- orchestration_pattern.md · references/
- parser_state_pattern.md · references/
SKILL.md (first lines)
# Nim Code Organization
Choose the smallest structure that exposes the real workflow.
# Rules
## State ownership
- Use ordinary locals when a workflow fits clearly in one proc.
- When independently meaningful operations must preserve one invariant, collect that state in
a named object and pass it explicitly.
- Start with a plain `object` passed by `var`.
- Choose `ref object` when identity, aliasing, or shared lifetime is part of the design.
- Make shared mutation visible in proc parameters and field updates.
## Helper placement
- Extract a helper when it names a meaningful step, is reused, isolates a contract, or makes
an invariant easier to state.
- To share an implementation across compile-time variants, parameterize one helper with
`static[bool]` or a static enum and branch with `when`.
- Keep a short, one-use sequence in its driver when extraction would only move lines elsewhere.
- Put helpers at module scope when several phases use them or they stand on their own.
- Use a nested proc for logic local to one caller or for an intentional closure.
- A nested proc captures outer locals by default. Mark it `{.nimcall.}` when its non-capturing
calling convention is required.
## Module boundaries
- Give each module one cohesive responsibility and public contract. A module may own several
related types or pieces of state.
- Split a module when a part has an independent responsibility, dependency set, lifecycle,
or reuse boundary.
- Export only the types and entry points callers need.
- Keep orchestration state and helpers private unless another module is meant to use them.
- Do not use `{.define.}`/`{.undef.}` to scope behavior across modules; use a runtime parameter.
## Control flow
- Keep the normal path structured so its invariants remain visible.
- For a closed set of behaviors, represent the kind as data and branch with `case`.
- Use `method` when runtime subtype dispatch is part of the design, rather than as the default
way to divide orchestration steps.
## Incremental APIs
- When the caller drives consumption piecewise, keep the cursor and lifecycle state in
the object's fields so it survives between calls.
- Expose one proc per transition, with `open`/`close`-style lifecycle procs only when a
resource or ordering constraint spans calls; keep a one-shot operation a single proc.
- Enforce that ordering with an assert on the lifecycle field (for example
`assert s.opened`) at the start of each `next`-style proc.
# Workflow
1. Trace the data flow.
Identify which values evolve, which steps share them, and which invariants must hold
between steps.
2. Choose the smallest state scope.
Use locals for one clear proc, a plain object for operations preserving one invariant,
and a reference only for intentional identity or shared lifetime.
3. Shape the helpers.
Extract meaningful operations. Keep local incidental logic near its caller.
4. Choose module boundaries.
Group code by responsibility and contract, then split only at a real dependency,
lifecycle, or reuse boundary.
5. Define the public surface.
Export the minimum caller-facing types and operations.
6. Choose dispatch.
Use direct calls and `case` for closed behavior. Introduce runtime dispatch for an open
subtype-based design.
## State Scope
| Situation | Default shape |
| --- | --- |
| One linear operation | Local values in one proc |
| Several operations share an invariant | Plain state object passed by `var` |
| One caller owns a short captured operation | Nested proc |
| Several phases share a named operation | Module-level proc |
| Identity or shared lifetime is required | `ref object` |
# Common Mistakes
| Mistake | Why it is wrong |
| --- | --- |
| Hiding state shared by several phases in nested captures | The mutation and cross-phase invariants disappear from proc signatures |
| Creating a state type for a short linear calculation | The extra type adds ceremony without clarifying ownership or invariants |
| Extracting every small block into a top-level helper | The reader must jump between names that do not represent meaningful operations |
| Splitting modules by file size alone | File length does not identify a responsibility, dependency, lifecycle, or reuse boundary |
| Using a `method` hierarchy for a closed set of kinds | Static data plus `case` keeps the possible behaviors visible to the compiler and reader |
| Exporting orchestration helpers or state by default | It turns implementation details into a public compatibility obligation |
| Starting with `ref object` for locally owned state | It introduces aliasing and identity that the workflow does not require |
## References
- `references/orchestration_pattern.md` — Inventory reservations across independent operations
that share a stock invariant, contrasted with a local calculation.
- `references/parser_state_pattern.md` — A scanner object for incremental cursor and lifecycle state.From Vyrnexis/nim-agent-template, MIT.
More from Vyrnexis/nim-agent-template
- 0.574score
nim-testing
Vyrnexis
Write and run deterministic Nim tests, including isolated test files, expected-exception checks, multi-configuration builds, and sanitizer integration.
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
atlas-package-cloner
Vyrnexis
Use Atlas to initialize Nim projects, install or update Atlas-managed dependencies, configure dependency directories, inspect Atlas-generated nim.cfg paths…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-doc-comments
Vyrnexis
Document exported Nim modules and APIs with doc comments that `nim doc` actually picks up, including module docs, proc and type docs, field docs, and runnable…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-error-handling
Vyrnexis
Design clear Nim error-handling flows; when to raise exceptions vs return `Option`/`bool`, how to enforce non-raising contracts, and where to translate or…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-fuzzing
Vyrnexis
Set up and run libFuzzer-based fuzz targets for Nim code, including harness wiring, compilation flags, corpus management, structure-aware mutators, and crash…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-ownership-hooks
Vyrnexis
Implement and review Nim ARC/ORC ownership hooks for types that manually manage resources, including move-only, deep-copy, refcounted, and copy-on-write…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-style-guide
Vyrnexis
Write clear, consistent Nim code in a simple stdlib-aligned style, covering imports, naming, proc vs func vs template choices, local variables, constructors…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nimonyplugins
Vyrnexis
Build and debug Nimony compile-time plugins for code generation and DSL rewrites.
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-api-design
Vyrnexis
Design clear public Nim APIs for libraries and modules, including exported types, constructors, parameter ownership, lookup functions, error contracts, and…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-c-bindings
Vyrnexis
Bind C libraries to Nim and make them build reliably across Linux, macOS, and Windows, including headers, types, linking, shared-library loading, and…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-c-wrappers
Vyrnexis
Turn low-level C FFI bindings into an idiomatic Nim API, with safer types, cleaner module boundaries, resource management, callbacks, enums, bitflags, and…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-debugging
Vyrnexis
Debug Nim compile failures, crashes, wrong results, macro expansion, ownership behavior, and unsafe-memory defects using focused reproduction, stack traces…
SkillBFreshness: B★ 4Claude Code +9
Signals
- Stars
- 4
- Forks
- 2
- Open issues
- 0
- Last commit (this folder)
- Aug 20, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/Vyrnexis/nim-agent-template
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from Vyrnexis
- 0.574score
nim-c-wrappers
Vyrnexis
Turn low-level C FFI bindings into an idiomatic Nim API, with safer types, cleaner module boundaries, resource management, callbacks, enums, bitflags, and…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-testing
Vyrnexis
Write and run deterministic Nim tests, including isolated test files, expected-exception checks, multi-configuration builds, and sanitizer integration.
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
atlas-package-cloner
Vyrnexis
Use Atlas to initialize Nim projects, install or update Atlas-managed dependencies, configure dependency directories, inspect Atlas-generated nim.cfg paths…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-api-design
Vyrnexis
Design clear public Nim APIs for libraries and modules, including exported types, constructors, parameter ownership, lookup functions, error contracts, and…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-c-bindings
Vyrnexis
Bind C libraries to Nim and make them build reliably across Linux, macOS, and Windows, including headers, types, linking, shared-library loading, and…
SkillBFreshness: B★ 4Claude Code +9 - 0.574score
nim-debugging
Vyrnexis
Debug Nim compile failures, crashes, wrong results, macro expansion, ownership behavior, and unsafe-memory defects using focused reproduction, stack traces…
SkillBFreshness: B★ 4Claude Code +9
Done for you
Rather not set it up yourself?
Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.
See how we build AI agents →Read the case studies
Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.
- launches shipped
- 50+
- launches shipped
- media placements
- 500+
- media placements
- founders on every account
- 2
- founders on every account
Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block
Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.
Get nim-code-organization running in your business
Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.
Cite this page
nim-code-organization skill. Agent Mart. https://agentmart.dev/skills/vyrnexis-nim-code-organization (last updated 2026-10-24)