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 | sh

macOS 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 && codex

The project’s AGENTS.md tells Codex what Tern is and how to work in it:

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:

tern check --json main.tn
{"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.