Agent dialects
Agent tools read files: Claude Code reads CLAUDE.md and AGENTS.md, Codex reads
AGENTS.md and .agents/skills/, Cursor reads .cursorrules. Structure writes
those files for you from the company's canon. One canon, one file per thing a
tool reads, all of them generated — each dialect is the same canon said in
the shape one tool expects.
structure compile --write # write every default dialect
structure compile --check # exit nonzero if compiling would change anything
structure compile --targets agents,claude --write # only the ones you name
Every generated file starts with a marker that says it is generated, which build
wrote it, and a checksum of its body. Don't edit these files. Put your own
preferences in the one file the marker names as yours, or change the canon, and
compile again.
structure check reports a generated file that no longer says what the canon
says (drift) and one somebody typed into (a hand-edit).
The targets
| Target | Writes | Read by | Default |
|---|---|---|---|
agents | AGENTS.md — the one full instruction file | Codex, Claude Code, Cursor and most other agents | on |
claude | CLAUDE.md — three lines: @AGENTS.md, a blank, the marker | Claude Code (older sessions and hooks that look for this file) | on |
cursor | .cursorrules — the same three-line pointer | Cursor | on |
githooks | .githooks/pre-commit — names what a commit adds to the check's findings; never blocks | git, once a clone runs git config core.hooksPath .githooks | on |
codex | departments/<name>/AGENTS.md, .agents/skills/<slug>/SKILL.md, and the ## Code Review Rules section of AGENTS.md | Codex | on |
commit-gate | .githooks/commit-msg — refuses a direct commit of a gated document on main | git, in a clone with hooks switched on | on when structure.yml names the founder rung |
pre-push | .githooks/pre-push — a push to a work branch must carry its work record | git, in a clone with hooks switched on | --targets pre-push |
maintainer | a maintainer workflow under .github/workflows/ | GitHub Actions | on when structure.yml says maintainer: gh-actions |
--targets compiles exactly the list you give. CLAUDE.md and .cursorrules
bring AGENTS.md with them, since they only point at it. A partial compile
leaves every target you left out as it was, and stale until the next full
structure compile --write: structure check reports the drift, and
structure compile --check always asks about every default target, whatever
--targets says. AGENTS.md itself compiles the same way whichever targets
you name, ## Code Review Rules included; leaving codex out only leaves the
department files and skill pointers as they were.
What Codex reads
Codex starts at the repository root and walks down to the folder it is working
in, reading the AGENTS.md in each folder on the way and joining them, root
first. So the codex target writes:
departments/<name>/AGENTS.mdfor each department that has something of its own to say: the opening of its mission, each steering document at the department's root (path, title, first paragraph), the code review rules whose jurisdiction is that department, and where its work goes. Roles stay out — they are listed in the root file. A department with no steering documents and no rules gets no file at all, rather than an empty one.## Code Review Rulesin the rootAGENTS.md, after## Approvals. It is compiled only from the typed rulesstructure checkenforces:rules:blocks (banned-words,required-sections) in canon documents, grouped by where they apply — everywhere, then each department (pointing at its file), then each voice — followed by the two rules every company has: every relative link and named path must exist, and a generated file is never edited by hand. A company with norules:blocks still gets those two. This section takes the place of## Content rules, which listed the same rules..agents/skills/<slug>/SKILL.mdfor every skill inskills/: aname, thedescriptionfield of the skill's own document word for word (its title when it has none), and one line pointing atskills/<slug>/SKILL.md. The skill itself is never copied; Codex opens the path. Write the description once, in the skill's own document, as what a person would ask for. A built-in skill compiled intoskills/is described by its name and path instead.
These paths are shared with your own Codex files, so a file already there that
Structure did not write — your own skill, or a symlink — is left alone, even with
--force; move it away if you want the compiled one. When a skill or a
department's last steering document is deleted, its compiled file is no longer
compiled: structure check reports it and structure compile --write removes it
(unless you typed into it, in which case it stays and compile says so).
A rule written in the canon reaches both gates from the same bytes. Give a department's coding standards a block like
rules:
banned-words: ["CSV", "XLSX", "coming soon"]
and structure check flags those words in that department's documents (a
warning in a draft, an error once published), while Codex reads the same words
under that department in ## Code Review Rules.
The budget
Codex stops adding instruction files once the joined text reaches
project_doc_max_bytes — 32 KiB unless you configured it otherwise. What it
reads for work in a department is the root AGENTS.md plus that department's
file, so compile measures the root plus the largest department file against a
budget:
# structure.yml
compile:
agents-budget: 32768 # bytes; the default is Codex's own default
When the two together run over, compile moves detail out of the root, a whole
line at a time and never mid-sentence: first each department's code review rules
become one line pointing at that department's file, then the Work and Memory
groups of the Types list become one line each. It prints the bytes, the budget
and what moved. If the root is still over, structure check reports it as a
budget warning with the fix. Department files have no budget of their own:
each one is read only for work in its own folder, alongside the root.