For agents · Codex
Write Tern with Codex.
Codex reads AGENTS.md, and every Tern project starts with one. It tells Codex how to look up the language, how to check its work, and when it’s done.
1. Install Tern
curl -fsSL https://ternlang.dev/install.sh | shmacOS or Linux, arm64 or x86_64, plus clang (xcode-select --install on a Mac, sudo apt install clang on Debian or Ubuntu). If Codex runs in a sandbox or a cloud container, install Tern and clang in its setup script the same way.
2. Start from a template
tern new myapp --template web # or cli, or lib
cd myapp && codexThe project’s AGENTS.md tells Codex what Tern is and how to work in it:
- Before writing:
tern guide short, the rules that differ from Python, andtern guide NAMEfor any library’s API, so it doesn’t guess function names. - After every change:
tern check --json main.tn, which reports every error at once with a hint for each. - Before it’s done:
tern test, which must pass. - The layout: where logic and tests go, how errors are returned, and how to add packages.
3. Let the compiler steer
An agent new to Tern will sometimes write Python habits. That’s fine, because the compiler answers in a form it can act on:
{"file": "main.tn", "line": 4, "message": "unknown function `append`",
"hint": "arrays grow with `xs.push(value)`", "source": "xs.append(i)"}Every check reports all errors in one pass, and an optimized rebuild after an edit takes well under a second, so each fix-and-check round stays short.
An existing repository
No tern new? Copy the AGENTS.md from a fresh template into your repository and edit its “This project” section. For any other model, ternlang.dev/llms.txt indexes the docs, and llms-full.txt has the whole reference and standard library in one file.