patterns

A collection of verified Sounio code examples that you can copy into your programs. Sounio is a systems and scientific programming language.

In plain words
What is it for?
Use it for common Sounio tasks such as printing text, processing fixed-size arrays, handling errors with tuples, and defining structs with methods.
Why use it?
It gives you working examples without having to infer the language syntax from scratch. Each pattern comes from tests that the Sounio compiler has checked.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/sounio-lang/sounio/patterns
Clone the repo
git clone --depth 1 https://github.com/Sounio-lang/sounio

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,226 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01226
Opus 5 $0.00000 $0.00613
Sonnet 5 $0.00000 $0.00245
Haiku 4.5 $0.00000 $0.00123

Measured 2d ago against content hash 290893fabbf5, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/patterns.mdc · 169 lines

How it starts

The opening of the file, as written. The whole thing — 169 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Sounio Patterns — Verified Copy-Paste Examples

All patterns are sourced from tests/run-pass/ and verified with souc check.

Hello World

fn main() with IO {
    println("Hello, World!")
}

Array Processing (map/fold)

fn square(x: i64) -> i64 { x * x }

fn map4(arr: [i64; 4], f: fn(i64) -> i64) -> [i64; 4] with Mut, Panic {
    var out: [i64; 4] = [0; 4]
    var i: i64 = 0
    while i < 4 {
        out[i as usize] = f(arr[i as usize])
        i = i + 1
    }
    out
}

fn fold4(arr: [i64; 4], init: i64, f: fn(i64, i64) -> i64) -> i64 with Panic {
    var acc = init
    for i in 0..4 {
        acc = f(acc, arr[i as usize])
    }
    acc
}

Error Handling (Tuples)

fn safe_divide(a: f64, b: f64) -> (f64, i32) with Div, Panic {
    if b == 0.0 { (0.0, 1) }    // error code 1
    else { (a / b, 0) }          // success
}

fn main() with IO, Div, Panic {
    let (result, err) = safe_divide(10.0, 3.0)
    if err == 0 { println("OK") }
    else { println("Division by zero") }
}

Struct with Methods

struct Counter { value: i64 }

impl Counter {
    fn new() -> Counter { Counter { value: 0 } }
    fn get(self: &Counter) -> i64 { self.value }
    fn increment(self: &!Counter) with Mut { self.value = self.value + 1 }
}

fn main() with IO, Mut {
    var c = Counter::new()
    c.increment()
    c.increment()
    assert(c.get() == 2)
}

Array Mutation via &! Reference

// Use explicit deref for bare arrays
fn fill(arr: &![i64; 4], val: i64) with Mut, Panic {
    (*arr)[0] = val
    (*arr)[1] = val
    (*arr)[2] = val
    (*arr)[3] = val
}

// Or wrap in struct (more reliable)
struct Buffer { data: [i64; 256] }

fn fill_buffer(buf: &!Buffer, val: i64) with Mut, Panic {
    for i in 0..256 {
        buf.data[i as usize] = val
    }
}

Higher-Order Functions

fn double(x: i64) -> i64 { x + x }
fn negate(x: i64) -> i64 { 0 - x }

fn select_op(which: i64) -> fn(i64) -> i64 {
    if which == 0 { double }
    else { negate }
}

fn main() with IO, Panic {
    let op = select_op(0)
    let result = op(21)
    assert(result == 42)
}

Read the full file on GitHub · 169 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 169 lines · 0 tokens per session scan A 290893fabbf5

Subscribe to this mod's changes

patterns is a cursor rule published in the GitHub repository Sounio-lang/sounio (5 stars, last pushed 2d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 1,226 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.