Nim Style Guide logo

Nim Style Guide

Community
planetis-m
nim-style-guide

Write clear, consistent Nim code in a simple stdlib-aligned style, covering imports, naming, proc vs func vs template choices, local variables, constructors, formatting, and control flow. Use when writing new Nim code or reviewing a Nim module for readability, consistency, and low-noise style decisions.

Overview

Publisherplanetis-m
Repositoryskills
Skill namenim-style-guide
Stars
66
Forks
7
Bundled files
2
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.

  • 2 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 Style Guide 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-style-guide
  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-style-guide .claude/skills/nim-style-guide
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Nim Style Guide 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 Style Guide 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 Style Guide 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 Style Guide

Rules

Formatting

  • Indent blocks with 2 spaces and use spaces instead of tab characters.
  • Keep lines at or below 100 characters.
  • Use ordinary spacing instead of aligning columns by hand.
  • Write range operators compactly: a..b, a..<b, and a..^b. Add spaces when an operand contains an operator, as in a .. -3.
  • In range type constructors, use ..: range[0..n-1] is valid; range[0..<n] is invalid.
  • Indent wrapped declarations, calls, and conditions one extra level.

Imports

  • Use std/... imports for stdlib modules.
  • Group imports from the same directory: import std/[a, b, c], import lib/[x, y, z].
  • Use from foo import bar, baz when you only need a small API slice.
  • import brings symbols into scope without qualification.
  • export takes only the module name: export baz, not export foo/bar/baz.
  • Use qualified module.symbol access only to resolve genuine name conflicts between imported modules.

Naming

  • Types use PascalCase.
  • Procs, funcs, iterators, templates, vars, and fields use camelCase.
  • Constants default to PascalCase; camelCase is also allowed.
  • Use ALL_UPPERCASE only when preserving names from a C or C++ wrapper.
  • Use normal word casing such as parseUrl and httpStatus.
  • Do not stutter the type name into its fields; Product.name, not Product.productName.
  • Use short names for parameters and locals that echo the type, as in inv: Inventory or s: Session.
  • Give the most-used representation the base type name. Suffix the others with Obj, Ref, or Ptr.
  • Suffix catchable exception types with Error and programming-bug defect types with Defect.
  • For non-pure enums, prefix values such as pcFile. For pure enums, use PascalCase.
  • Prefix mutable views with m, as in mitems and mpairs.
  • Pair in-place and copied transforms as reverse and reversed. If the copy name already exists, suffix the in-place form with In, as in replaceIn.
  • Name domain predicates subject-first, as in fileExists, not existsFile.
  • Use established stdlib names when behavior matches: initX, newX, find, contains, add, cmp, len, cap, items, pairs, incl, and excl.
  • Name a cheap, side-effect-free field getter foo. Use getFoo when the operation has side effects or is not O(1).
  • Pair foo with foo= and getFoo with setFoo.
  • Accessors may share the field's name, no collision.

Proc, Func, Template, Macro

  • Default to proc.
  • Use func for pure helpers and pure accessors when checked purity helps.
  • Use template when call-site substitution, lazy evaluation, or a control-flow abstraction is required.
  • Prefer proc and func over method. Use method only when you need runtime dispatch.
  • Prefer top-level helpers for reusable logic.
  • Use a nested proc when the logic is truly local or when you want a closure.
  • A nested proc may capture outer locals. If a nested proc must stay non-capturing, mark it {.nimcall.}.
  • Use macro only when syntax transformation is required.
  • Mark one-expression forwarders and field accessors {.inline.}.

Calls, Locals, And Types

  • Prefer compact wrapped calls over one-argument-per-line call blocks.
  • Use UFCS when it reads like an accessor.
  • Write typeof(x), not the historical type(x).
  • Write addr x, not the deprecated unsafeAddr x.
  • Write enum values unqualified (north, not Direction.north); qualify only on ambiguity.
  • Use let by default.
  • Use var only for values that mutate.
  • Keep local declarations close to first use.
  • Keep public and reusable types at module scope.
  • Group related fields with the same type when it improves readability.
  • Initialize result explicitly; prefer object constructors (TypeName(field: value)) over field-by-field assignment.
  • Omit fields that should keep their declared defaults.
  • T() works only for objects; arrays use arrayWith, tuples use literals, strings/seqs use ""/@[], default(T) as fallback.

Parsing-Sensitive Whitespace

These whitespace choices change how Nim parses code:

  • Attach [ to a type name.

    • array[N, T] compiles. array [N, T] does not.
    • The same applies to seq[T], Table[K, V], etc.
  • Attach ( to a callable name for a parenthesized call.

    • foo(1, 2) passes two int arguments.
    • foo (1, 2) passes a single (int, int) tuple. Nim treats the parenthesized comma-list as a tuple constructor.
  • Do not use command-call syntax with comparisons or nested calls.

    • foo 1 == 1 parses like foo(1 == 1), not foo(1) == 1.
    • outer(inner 1, 1) parses as outer(inner(1), 1), not outer(inner(1, 1)).
  • Use [:T] for explicit generic parameters in UFCS calls.

    • x.p[:T]() rewrites to p[T](x).
    • x.p[T]() parses as (x.p)[T](), not a generic instantiation.
  • Group negated compound expressions.

    • Parenthesize compound operands of not: not a or b parses as (not a) or b, so write not (a or b) and not (x < y).
    • Write x notin items, not not x in items.

Line Continuation

Nim has no line-continuation character. Break expressions after an operator or comma, or within open delimiters such as (), [], and {}. Indent the continued line further than the statement that started it.

For constructs with a body, double indentation can distinguish continuation lines from the body.

Multiline Strings

  • Use """...""" triple-quoted literals instead of "a\n" & "b\n" concatenation for multiline values.
  • Start with a newline right after """. That newline is stripped, so the value is identical; the content aligns with the next line.

See references/multiline_strings.md.

Control Flow

  • Use structured control flow.
  • If the body is exactly one expression, end with that expression, as in func len(b: Bag): int = b.items.len
  • Otherwise assign the return value to result explicitly: as a default at the start, at the end, or once per branch.
  • A default result may be overridden by the branch that produces the value.
  • When a loop finds the return value, return it directly instead of using a flag.
  • Do not use continue. Put the remaining loop body inside a condition.

Workflow

  1. Pick the callable kind. Start with proc. Switch to func for a useful purity contract, template for call-site substitution, and macro for syntax transformation. Choose method for runtime dispatch.
  2. Write imports and names. Use std/... imports, narrow imports when practical, and keep names in normal Nim casing.
  3. Shape the control flow. Use structured control flow. Return directly when a loop finds its result.
  4. Clean up locals and constructors. Use let by default, keep locals near first use, and keep reusable helpers at module scope.
  5. Remove noise. Remove unused imports, dead helpers, column alignment, and stretched call formatting.

Common Mistakes

MistakeWhy it is wrong
Using method as the default callable kindIt adds runtime dispatch where a plain proc or func would usually be clearer.
Hiding reusable helpers inside another procIt makes the helper harder to reuse and easier to turn into an accidental closure.
Writing one argument per line by defaultIt adds vertical noise without adding structure.
Using var for values that never mutateIt hides which locals actually change.
Assuming {.pure.} requires Type.valuePure enum values may be unqualified.
Turning every branch into an early return in a multi-step procIt makes the normal path harder to scan.
Using continueA structured branch keeps the loop invariant visible.

References

  • references/core_patterns.md — General style patterns for imports, callable kinds, wrapping, locals, and constructors.
  • references/multiline_strings.md — Whitespace-preserving triple-quoted strings, joins, and dedenting.

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 Style Guide AI skill do?

Write clear, consistent Nim code in a simple stdlib-aligned style, covering imports, naming, proc vs func vs template choices, local variables, constructors, formatting, and control flow. Use when writing new Nim code or reviewing a Nim module for readability, consistency, and low-noise style decisions.

Why use Nim Style Guide on TypingMind?

Because you install it once and use it with any model. Nim Style Guide 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 Style Guide in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/planetis-m/skills/tree/master/nim-style-guide. 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 Style Guide?

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 Style Guide?

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

Is the Nim Style Guide 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 👇