For Claude Code, Codex, Cursor and other agents
What should your coding agent write in?
When an agent writes most of the code, the best language is the one it can get right without you: mistakes caught before anything runs, errors that say what to write, and a result that’s cheap to deploy. That’s what Tern is built for.
curl -fsSL https://ternlang.dev/install.sh | sh
tern new myapp --template web # AGENTS.md and CLAUDE.md includedWhat makes a language good for agents
A human picks a language for its ecosystem and what the team knows. An agent has different weak spots: it writes fast, guesses names it half remembers, and only finds out it was wrong when something checks. So the language should:
- Catch mistakes before the code runs. Every type checked at compile time, so a wrong guess is an error message, not a bug found in production.
- Say what to write instead. An error the agent can act on in one step saves a turn of guessing. Tern’s errors name the fix, and habits from other languages get a hint.
- Fit in context. The whole language is one reference page an agent can read before it starts, and
tern guide NAMEprints any library’s API so it doesn’t invent functions. - Look like what models already know. Tern reads like Python, so first drafts are close.
- Keep the loop fast. An optimized rebuild after an edit takes well under a second, so check, fix and test cycles stay short.
- Be cheap to run. Agents write more code than people review closely. Native code with no runtime keeps whatever they write small and fast by default.
Here’s what an agent sees when it writes Python habits into Tern. tern check --json gives the same thing as data:
main.tn:3: error: unknown function `range` main.tn:3: hint: there is no range(): write `for i in 0..n:` (or `for i in a..b:`; the end is exclusive) main.tn:4: error: unknown function `append` main.tn:4: hint: arrays grow with `xs.push(value)`
Same spec, same agent, three languages
We gave a coding agent a spec for a link shortener (a database, click counts, a JSON API) and an empty directory, once each in Tern, Go and TypeScript. All three apps pass the same 32 black-box acceptance checks.
| Agent-built app | Tern | Go | TypeScript |
|---|---|---|---|
| Lines of code excluding tests | 273 | 805 | 502 |
| Redirects per second | 146k | 154k | 47k |
| CPU per redirect | 23 µs | 32 µs | 21 µs one thread |
| Deployed size | 408 KB | 13.6 MB | 25.8 MB |
| Memory at idle | 4.4 MB | 18.6 MB | 89.6 MB |
Less code means less for you to review. A 408 KB binary that idles in 4 MB means the cheapest server you can rent will run it. Go served slightly more redirects per second, and we show that too. More numbers, losses included, are on the benchmarks.
How it compares with what agents usually write
- Python. Models know it best, but type mistakes surface only when that line runs, and it’s slow and heavy to deploy. Tern keeps the syntax and checks everything before it runs.
- TypeScript. Types help, but it runs on Node: in our test, 25.8 MB on disk and 89.6 MB at idle against Tern’s 408 KB and 4.4 MB.
- Go. Simple and fast, and a strong choice for agents. The same app took 805 lines against Tern’s 273.
- Rust. As fast as anything, but agents spend turns on lifetimes and the borrow checker. Tern has no references (every value is a copy), so there’s no borrow checker to satisfy, and data races are compile errors.
Set up your agent
Every project from tern new includes AGENTS.md, the file Codex, Cursor and most other agents read, and CLAUDE.md for Claude Code. They tell the agent to read tern guide before writing, to run tern check --json after every change, and to finish with tern test.
The honest caveats
- Models have seen very little Tern. The first time, agents look things up more than they would in Python. That’s why the errors, hints and guides are built the way they are. We watch where agents trip and fix it in the compiler, docs and templates.
- It’s an early release. The language will still change, and the package index is small.
- macOS and Linux only for now (arm64 and x86_64). Tern also builds WebAssembly, iOS and Android apps from those machines.
Claude Code is a product of Anthropic, Codex of OpenAI, Cursor of Anysphere. Tern isn’t affiliated with any of them. Benchmark: macOS on Apple silicon, 128 keep-alive connections for 5 s, medians of three alternating rounds.