agentleFS
lgtm-hqlgtm-hq/ai-skills/skills/stand-odin/SKILL.md

stand-odin

Skill1 starsChanged 12 days agoMITView on GitHub

Odin coding standards. Use when writing Odin code. Covers idiomatic error handling with or_else and or_return, memory/allocator patterns, attributes, naming and API conventions, and testing with core:testing.

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 2 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Prefer or_else when every failure path returns the same default:

    line 17
  2. Very specific:

    Use or_return to propagate errors instead of check-and-return blocks:

    line 46
  3. Very specific:

    Use explicit (value, ok) checks only when failure modes differ (log, branch, or propagate differently per case).

    line 57
  4. Very specific:

    Do not expand (value, ok) into multi-branch control flow when every branch returns the same value — use or_else

    line 72
  5. Very specific:

    Do not hardcode a 0 fallback when a default parameter is appropriate

    line 74
  6. Very specific:

    Do not pre-check v == "" before trimming when a failed parse of the empty string already yields the fallback — only distinguish missing vs …

    line 75
  7. Very specific:

    Do not write Go-style if err != nil { return err } ladders — use or_return

    line 78
  8. Distinctive:

    Prefer default-parameter fallbacks for config/env parsing helpers

    line 114
  9. Distinctive:

    Use default parameter values for fallbacks instead of sentinel checks

    line 120
  10. Very specific:

    Prefer plain procs and struct composition — Odin has no classes or inheritance.

    line 123
  11. Very specific:

    Use core:testing with the @(test) attribute.

    line 128
  12. Very specific:

    Follow the lint skill where a project has lintro configured.

    line 151

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Odin Standards

Standards for Odin code. Odin is underrepresented in training data — do not transplant Go/Rust/C error-handling patterns verbatim; reach for Odin constructs first.

Idioms

Prefer or_else when every failure path returns the same default:

// Don't — all branches return the same fallback
parse_env_int :: proc(key: string, default: int = 0) -> int {
    v, ok := os.lookup_env(key, context.temp_allocator)
    if !ok || v == "" { return default }
    x, ok2 := strconv.parse_int(strings.trim_space(v), 10)
    if !ok2 { return default }
    return x
}

// Do
parse_env_int :: proc(key: string, default: int = 0) -> int {
    v := os.lookup_env(key, context.temp_allocator) or_else ""
    return strconv.parse_int(strings.trim_space(v), 10) or_else default
}

Domain validation after parse is one line, not a rewrite:

parse_env_f64_nonneg :: proc(key: string, default: f64 = 0) -> f64 {
    v := os.lookup_env(key, context.temp_allocator) or_else ""
    x := strconv.parse_f64(strings.trim_space(v)) or_else default
    return max(0, x)
}

Use or_return to propagate errors instead of check-and-return blocks:

// Don't
data, err := os.read_entire_file_or_err(path)
if err != nil { return nil, err }

// Do
data := os.read_entire_file_or_err(path) or_return

Use explicit (value, ok) checks only when failure modes differ (log, branch, or propagate differently per case).

Mark file-local helpers and must-use results with attributes:

@(private = "file")
trimmed :: proc(s: string) -> string { return strings.trim_space(s) }

@(require_results)
checksum :: proc(data: []byte) -> u32 { ... }

Anti-Patterns

  • Do not expand (value, ok) into multi-branch control flow when every branch returns the same value — use or_else
  • Do not hardcode a 0 fallback when a default parameter is appropriate
  • Do not pre-check v == "" before trimming when a failed parse of the empty string already yields the fallback — only distinguish missing vs empty vs invalid when the caller needs the distinction
  • Do not write Go-style if err != nil { return err } ladders — use or_return

Memory & Allocators

  • context.temp_allocator for short-lived scratch data (env lookups, parse buffers, per-frame strings); free in bulk with free_all(context.temp_allocator) at a natural boundary (frame/request)
  • context.allocator for general heap allocation; pair make/new with delete/free, typically via defer
  • In library code, take an explicit allocator := context.allocator parameter instead of allocating from implicit globals:
// Don't — caller cannot control allocation
clone_name :: proc(s: string) -> string { return strings.clone(s) }

// Do — caller controls allocation; allocator errors propagate
clone_name :: proc(s: string, allocator := context.allocator) -> (string, mem.Allocator_Error) {
    return strings.clone(s, allocator)
}
  • Copy strings that must outlive their source; temp-allocate strings that do not escape the current scope

Error Handling

  • or_else — same default for every failure
  • or_return — early exit from a procedure whose final return value is an error or ok boolean
  • Explicit (value, ok) — failure modes need different handling
  • Model recoverable failures as error enums or unions returned as the last value; reserve panic for unrecoverable programmer error, never library control flow
  • assert / #assert only for invariants, not input validation
  • Prefer default-parameter fallbacks for config/env parsing helpers

Types & API Design

  • snake_case for procedures and variables; Ada_Case for types (Entity_Kind, Parse_Error); SCREAMING_SNAKE_CASE for constants
  • Use default parameter values for fallbacks instead of sentinel checks
  • Encode domain constraints in the name (parse_env_f64_nonneg) or via post-parse validation (max(0, x))
  • Prefer plain procs and struct composition — Odin has no classes or inheritance; do not simulate them

Testing

  • Use core:testing with the @(test) attribute; run via odin test
  • Table-driven cases over one-proc-per-case:
import "core:testing"

@(test)
parse_env_int_defaults :: proc(t: ^testing.T) {
    cases := [][2]int{{-3, -3}, {0, 0}, {42, 42}}
    for c in cases {
        testing.expect_value(t, parse_env_int("MISSING_KEY", c[0]), c[1])
    }
}
  • For parsing helpers, cover: missing, empty, whitespace-only, invalid, valid, and domain edges (e.g. negative clamp)
  • Defer global coverage/commit rules to stand-general

Toolchain

  • odin check is the primary validation gate; odin build -vet -strict-style catches unused values and style drift
  • Follow the lint skill where a project has lintro configured; no lintro Odin plugin exists yet, so the compiler vet flags are the linter

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.