Nim Coding Practices
Application skill for NEP-1 style learning (from the archived awesome-guidelines style capsules). For legacy codebases with non-NEP spellings, prefer --styleCheck:usages over full NEP-1 enforcement until migrated.
Core Principle
Nim library quality is guessable names + mechanical layout, PascalCase types, camelCase API, result assignments, compiler styleCheck in CI.
When to Use / NOT
- Nim packages, stdlib-shaped libraries, CLI/tools targeting NEP-1 conventions.
- Setting up
--styleCheck, testament/nim test, nimble CI.
NOT when:
- Generated Nim from c2nim/other translators, validate generators.
- One-off scripts with local conventions, apply layout/naming lightly.
Workflow
- Layout, 2-space, 80 cols, multiline breaks (
nim-style-formatting-layout.md).
- Naming/types, PascalCase, enums, init/new (
nim-style-naming-types.md).
- Procedures, result, let, API verbs (
nim-style-procedures-api.md).
- Modules/verify, std imports, styleCheck (
nim-style-modules-verify.md).
- Verify,
nim c --styleCheck:error, tests on changed modules.
Red Flags
- Tab indentation
- Lines > 80 without wrap
- Manual column-aligned type blocks
- Shouting acronyms (
parseURL)
existsFile verbSubject order
- Unprefixed non-pure enum members
Exception without CatchableError/Defect lineage
var when value never reassigned
- Macro/template where proc suffices
- Terminal
return instead of result =
getLen / append instead of len / add
- Missing
m prefix on mutating views
import os without std/ for stdlib
- Inconsistent identifier spelling across file
- Triple-quote content glued to opener line
- Unnecessary spaces in
a .. b
- Undocumented exported procs
Verification
nim c --styleCheck:error [--styleCheck:usages] <files>
- Project test command (
nim test, testament, nimble task)
- 80-column and 2-space spot check on changed hunks
- Capsule checklist on public API naming (
fileExists, initFoo, newFoo)
References
awesome-guidelines/references/nim-style-learning-note.md
awesome-guidelines/references/nim-style-formatting-layout.md
awesome-guidelines/references/nim-style-naming-types.md
awesome-guidelines/references/nim-style-procedures-api.md
awesome-guidelines/references/nim-style-modules-verify.md
1---2name: nim-coding-practices3description: Use when authoring or reviewing Nim, NEP-1 2-space/80-col layout, PascalCase/camelCase naming, init/new and abbrev API vocabulary, result-first procs, std/ imports, and --styleCheck plus tests in CI.4---56# Nim Coding Practices78Application skill for NEP-1 style learning (from the archived `awesome-guidelines` style capsules). For legacy codebases with non-NEP spellings, prefer `--styleCheck:usages` over full NEP-1 enforcement until migrated.910## Core Principle1112Nim library quality is **guessable names + mechanical layout**, PascalCase types, camelCase API, `result` assignments, compiler styleCheck in CI.1314## When to Use / NOT1516- Nim packages, stdlib-shaped libraries, CLI/tools targeting NEP-1 conventions.17- Setting up `--styleCheck`, testament/`nim test`, nimble CI.1819**NOT when:**2021- Generated Nim from c2nim/other translators, validate generators.22- One-off scripts with local conventions, apply layout/naming lightly.2324## Workflow25261. **Layout**, 2-space, 80 cols, multiline breaks (`nim-style-formatting-layout.md`).272. **Naming/types**, PascalCase, enums, init/new (`nim-style-naming-types.md`).283. **Procedures**, result, let, API verbs (`nim-style-procedures-api.md`).294. **Modules/verify**, std imports, styleCheck (`nim-style-modules-verify.md`).305. **Verify**, `nim c --styleCheck:error`, tests on changed modules.3132## Red Flags3334- Tab indentation35- Lines > 80 without wrap36- Manual column-aligned type blocks37- Shouting acronyms (`parseURL`)38- `existsFile` verbSubject order39- Unprefixed non-pure enum members40- `Exception` without CatchableError/Defect lineage41- `var` when value never reassigned42- Macro/template where proc suffices43- Terminal `return` instead of `result =`44- `getLen` / `append` instead of `len` / `add`45- Missing `m` prefix on mutating views46- `import os` without `std/` for stdlib47- Inconsistent identifier spelling across file48- Triple-quote content glued to opener line49- Unnecessary spaces in `a .. b`50- Undocumented exported procs5152## Verification5354- `nim c --styleCheck:error [--styleCheck:usages] <files>`55- Project test command (`nim test`, testament, nimble task)56- 80-column and 2-space spot check on changed hunks57- Capsule checklist on public API naming (`fileExists`, `initFoo`, `newFoo`)585960## References6162- `awesome-guidelines/references/nim-style-learning-note.md`63- `awesome-guidelines/references/nim-style-formatting-layout.md`64- `awesome-guidelines/references/nim-style-naming-types.md`65- `awesome-guidelines/references/nim-style-procedures-api.md`66- `awesome-guidelines/references/nim-style-modules-verify.md`