Write, check, fix, and debug Narra code using the narrac compiler. Provides a workflow for querying definitions/references, running checks, applying fixes, and formatting.
Ships in narra. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Narra is a compiled language. narrac is its compiler and its tools. Do not guess a rule from another language: run narrac check and read the error.
narrac query def NAME, narrac query callers NAME, narrac query refs NAME, narrac query interface PACKAGE/MODULE (such as task/calc), narrac query type-of FILE:LINE:COL (the position must sit on an expression). Queries need a package (a folder with narra.toml). Options such as --json go before the question. refs and callers skip import lines and calls through function values, so also search the text for the name.narrac check --json PATH. It prints one JSON object per error with code, message, range (start and end, each [line, column], from 1) and often fixes. Exit code 0 means no errors.narrac explain CODE.narrac apply-fix PATH. It prints the whole file with the first fix applied and writes nothing. Read it, then save it through a new file (narrac apply-fix a.nra > b.nra && mv b.nra a.nra), never straight to a.nra.narrac fmt PATH (it rewrites files in place), then narrac test PATH.Fix the first error first. Later errors often come from it.
Each pair shows the error code the compiler gives. The second block of a pair compiles.
A name is declared once per function. Shadowing is an error.
export function total(prices: Array<int>): int {
let sum = 0
for (const price of prices) {
const sum = price
}
return sum
}
Pick another name: const current = price.
There are no function declarations inside a function. Use an arrow function in a const, or a private function at module level.
export function run(args: Array<string>): int {
function double(value: int): int {
return value * 2
}
return double(2)
}
export function run(args: Array<string>): int {
const double = (value: int): int => value * 2
return double(2)
}
A name that is never read is an error, a parameter too (except the entry function's, when narra.toml has a [[binary]]). Remove it, or start its name with _ to keep it on purpose.
export function run(args: Array<string>): int {
const unused = 5
return 0
}
Code after a return, break, continue or panic is dead code, also an error.
export function run(args: Array<string>): int {
return 0
print("done")
}
Use const unless the name is assigned again. A const array or struct can still change through name[0] = ..., name.field = ... or mutable name. A let that is never assigned is an error. Passing mutable name counts as an assignment.
export function run(args: Array<string>): int {
let count = 3
return count
}
An exported function lists its effects after the result type: uses alloc when it builds strings, arrays or maps, uses io when it reads or prints. Private functions need no list. A package's binary entry (entry in narra.toml), usually run, needs none.
import * as Int from "std/int"
export function label(count: int): string {
return Int.toString(count)
}
import * as Int from "std/int"
export function label(count: int): string uses alloc {
return Int.toString(count)
}
A function that changes its argument takes mutable in the parameter and in every call.
import * as Arrays from "std/array"
export function addOne(items: Array<int>) uses alloc {
Arrays.push(mutable items, 1)
}
import * as Arrays from "std/array"
export function addOne(mutable items: Array<int>) uses alloc {
Arrays.push(mutable items, 1)
}
There are no exceptions. A function that can fail returns Result<T, E>; the caller checks it with is Err or match. Use panic("message") only for bugs.
export function check(value: int): int {
if (value < 0) {
throw "negative"
}
return value
}
export function check(value: int): Result<int, string> {
if (value < 0) {
return Err("negative")
}
return Ok(value)
}
Only print, assert, panic and copy are global functions. Everything else is imported from std/..., as import * as Arrays from "std/array". Statements end at a line break, with no semicolons. There are no classes, new or this; use struct, enum and functions of the module.
Each std function has one form. Files (std/fs), processes and standard input are plain, also in async code. Time.sleep (std/time) and the sockets of std/net are async: call them with await inside an async function.
Tests sit in the same file, in test "name" { ... } blocks, with checks from std/test. Test functions work only inside a test block.
import * as Test from "std/test"
export function double(value: int): int {
return value * 2
}
test "double doubles" {
Test.eq(double(4), 8)
}
narrac test PATH prints one line per test and exits 1 when one fails. -filter TEXT runs the tests whose name contains the text.
The guide is in docs/guide/ of the Narra repository. Read the chapter for the topic before writing code you are unsure about: values and types (2), functions (3), structs and enums (4), match (5), Option and Result (6), traits and JSON (7), modules and packages (8), mutable and Cell (9), effects and tests (10), files and the system (11), generators (12), the standard library (13), async (14), threads (15), unsafe code and C (16), proofs and @const (17), the tools (18), and targets (19).
evals/check-examples.py (opens in a new tab)evals/grade.sh (opens in a new tab)evals/prepare-eval.sh (opens in a new tab)evals/results.md (opens in a new tab)evals/tasks/c1-rename/case.yaml (opens in a new tab)evals/tasks/c1-rename/checks.nra (opens in a new tab)evals/tasks/c1-rename/prompt.md (opens in a new tab)evals/tasks/c1-rename/scaffold.sh (opens in a new tab)evals/tasks/c1-rename/solution/src/main.nra (opens in a new tab)evals/tasks/c1-rename/solution/src/shapes.nra (opens in a new tab)evals/tasks/c1-rename/starter/narra.toml (opens in a new tab)evals/tasks/c1-rename/starter/src/main.nra (opens in a new tab)evals/tasks/c1-rename/starter/src/shapes.nra (opens in a new tab)evals/tasks/c2-divide/case.yaml (opens in a new tab)evals/tasks/c2-divide/checks.nra (opens in a new tab)evals/tasks/c2-divide/prompt.md (opens in a new tab)evals/tasks/c2-divide/scaffold.sh (opens in a new tab)evals/tasks/c2-divide/solution/src/calc.nra (opens in a new tab)evals/tasks/c2-divide/starter/narra.toml (opens in a new tab)evals/tasks/c2-divide/starter/src/calc.nra (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
/narra:narrafrom narra
npx claudepluginhub lxsmnsyc/narra --plugin narraOther plugins' skills for the same job