Harn language

From burin-labs/harn · View interactive version

Harn language is an AI agent skill from the GitHub repository burin-labs/harn. Use for Harn language syntax, typechecking, modules, imports, and idiomatic script authoring.

How to use this skill

Skill file

Harn language

Use this skill when writing, reviewing, or explaining .harn source code.

Pair it with [[harn-testing]] for fixtures and [[harn-diagnostics]] for user-facing errors.

Start here

HARN_BIN_NO_BUILD=1 ./scripts/harn_bin.sh -- <command> for narrow CLI

checks. This resolves the lane-local binary without starting a hidden Cargo

build. Outside the repository, use the installed, pinned harn executable.

route side effects through harness.*.

visible under sandbox policy; avoid composing .harn/tmp paths by hand.

that must not overwrite a newer observation; branch on the closed receipt.

SchemaContract<T> when consumers need typed records and named rules.

provider/access-token through harness.secrets from a package script; the

runner scopes the default provider from the nearest harn.toml.

never hand-edit the generated spec/HARN_SPEC.md or

docs/src/language-spec.md projections.

typed data-only module. Import that value into the evaluator and mechanically

project it downstream instead of duplicating lists or host branches.

Syntax checklist

windows, chunks, map_keys, merge). Mutating methods (push, pop,

insert, extend, sort, reverse, set add/remove, dict remove)

change a let binding in place; sorted(), reversed(), and xs + [v]

return new values.

branches poll or wait, so one branch's doomed verdict can stop the rest.

Decode at the boundary

Untyped data (JSON text, a GraphQL response, a dict from another API) gets

decoded once where it enters. After that, read typed fields with ..

type WorkflowRun = {headBranch: string, conclusion: string?, url: string}
type WorkflowRuns = list<WorkflowRun>

const runs = json_decode(child.stdout, schema_of(WorkflowRuns))?   // text
const pr = schema_parse(payload, schema_of(Snapshot))?             // a value

issues}>. match or postfix ? keeps T; unwrap` returns a dynamic

value. Use schema_expect to throw instead.

payload.data with it.

requests already return typed, never-nil records: write result.stdout,

not result?.stdout ?? "". Keep the type when you wrap them; a wrapper

that returns dict erases it.

on a field means a decode is missing.

Types and boundaries

validation. Capture typed context in the rule closure; do not replace it with

an open dictionary.

artifact. Bind its relative name and SchemaContract<T> once, then reuse the

descriptor for reads and writes.

Typed decisions

boolean, choice, or score questions over one shared, closed serializable

state. Import the builders from std/predicate; declare question ids and

choice labels as literals so the checker can type every answer and record

the site in the predicate manifest.

entry point returns a bare boolean: match the closed outcome and handle

uncertainty, refusal, and budget limits explicitly. An answered batch

contains every declared question, or the evaluator refuses it.

policy. Keep deterministic authorization rules outside the model decision,

and do not treat a reported confidence as measured accuracy.

contract. Pair with [[harn-testing]] for hermetic fixtures and quality reads.

Portable execution

language. Source must use the canonical parser, typechecker, and compiler.

support. Compile the intended entry through the portable interface so

unsupported opcodes, builtins, and capability methods fail explicitly.

integers, finite or tagged floats, strings, bytes, lists, and named records.

boundaries. The portable kernel enforces declared call contracts rather than

treating browser JSON as any.

target-specific browser builtins or read ambient file, network, process,

clock, random, or model authority.

portable behavior in a Web Worker and exchange typed values.

list to an adapter. Generate projections or test parity against the owning

language/runtime registry.

measurements. Use std/timing only for hostful application spans.

Modules and imports

member names under a collision-safe alias; do not invent receiver-method

APIs for that case.

module name in ui_event; the call site already reads ui.event.

not the target's flattened members (contrast pub import "module").

and API docs follow re-exports to the original declaration.

Prompt templates

Simpler first

Verify

HARN_BIN_NO_BUILD=1 ./scripts/harn_bin.sh -- check <path>.

HARN_BIN_NO_BUILD=1 ./scripts/harn_bin.sh -- lint <path>.

HARN_BIN_NO_BUILD=1 ./scripts/harn_bin.sh -- fmt --check <path> (fmt,

never format).

HARN_BIN_NO_BUILD=1 ./scripts/harn_bin.sh -- test conformance --filter <name>.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.