Harn quick reference (LLM-friendly)
Canonical URL: https://harnlang.com/docs/llm/harn-quickref.html
This file is a one-pass reference optimized for LLM consumption and
grep. It covers the syntax, stdlib highlights, concurrency, and the
LLM / agent_loop surface an agent typically needs to write scripts.
You can fetch the hosted quick reference in any agent context that supports
HTTP fetches (Claude with WebFetch, Cursor's @web, Aider, etc.)
using the canonical URL above.
The human-facing companion lives at docs/src/scripting-cheatsheet.md.
Keep the two in lockstep when syntax changes.
For trigger manifests, connector contract v1, and the provider catalog, also
load docs/llm/harn-triggers-quickref.md.
--json cheatsheet (agent-driven Harn)
Every machine-readable mode returns a versioned envelope:
{ "schemaVersion": N, "ok": bool, "data": ..., "error": ..., "warnings": [] }.
Stdout is one parseable JSON document (or one NDJSON event per line);
logs and progress always go to stderr.
- Discover supported commands and their current schema versions:
harn --json-schemas(filter with--command <name>). - Per-command shape reference:
docs/src/cli-json-contract.md. - Common pairs an agent will use:
harn version --json— build metadata (name,version,description).harn upgrade --check --json— resolve target release without downloading.harn lint --json <path>— structured lint diagnostics + summary; pair withharn lint --fix <path>(no--json) to apply the recommended edits.harn replay --json <run.json>— per-stage replay summary + fixture verdict.harn check --json <path>/harn fmt --json <path>— type-check and format reports with the sameCheckDiagnosticshape.harn run --json script.harn— NDJSON event stream (one envelope per line).harn doctor --json— capability matrix for host / targets / providers.
Files and execution
- File extension:
.harn. - Entry points:
- Preferred capability-aware script entrypoint:
fn main(harness: Harness) { ... }. - Workflow entrypoint:
pipeline default() { ... }(pipeline mode —compile_top_level_declarationsruns first, then the pipeline body). - Bare script with top-level statements for tiny one-off files.
- Preferred capability-aware script entrypoint:
- Run:
harn run script.harn. - Inline:
harn run -e 'log("hi")'. The snippet is wrapped inpipeline main(task) { ... }; leadingimport "..."/import { x } from "..."/pub import { x } from "..."lines are hoisted out of the wrapper. The temp file lives in the current directory so relative imports (import "./lib") andharn.tomldiscovery resolve against your project, e.g.harn run -e