Write, edit or review Maxon code in this repository — a .maxon or .maxtest file, a spec case, stdlib/, runtime/, or the compiler's own source under maxon-bin/. Loads the language rules, the extra rules for where the code lives, and the loop that compiles every edit before it is handed back. Invoke it before writing any Maxon, and tell every agent you dispatch to write Maxon to invoke it too.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Maxon Coder?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/maxon-lang-maxon-coder)
---
name: maxon-coder
description: Write, edit or review Maxon code in this repository — a .maxon or .maxtest file, a spec case, stdlib/, runtime/, or the compiler's own source under maxon-bin/. Loads the language rules, the extra rules for where the code lives, and the loop that compiles every edit before it is handed back. Invoke it before writing any Maxon, and tell every agent you dispatch to write Maxon to invoke it too.
---
# Writing Maxon
## 1. Read the rulebook first
**Read `docs/WRITING_MAXON_CODE.md` before writing any Maxon, every session.** It is the one source of the
language's rules — the syntax that does not exist, the mandatory rules, the idioms, tests — and this skill
does not repeat it. Then, as needed:
- `docs/LANGUAGE_REFERENCE.md` — the full semantics.
- `docs/STDLIB_REFERENCE.md` — the standard library's API. Read a stdlib signature there (or in `stdlib/`)
before calling it; do not guess a method name.
- `lookup_error_code` — what a diagnostic means, by number (`"E3014"`) or case name.
⚠ If the compiler and the doc disagree, the compiler is right about what compiles today and the doc is a
defect: fix the doc in the same change (the `documenter` skill owns that step).
## 2. Where the code lives decides the extra rules
| Where | Extra rules |
|---|---|
| `maxon-bin/` — the compiler | Read `maxon-bin/AGENTS.md` and this skill's `compiler.md` first. A diagnostic names `ErrorCode.<case>`, never `"E3010"`; `maxon-bin/Compiler/ErrorCodeRegistry.maxon` is hand-authored — add a case there. A change to emitted runtime (`Compiler/Runtime/` or `Compiler/Targets/*/*Runtime*.maxon`) needs two self-compiles; `maxon run build` does both by itself. Run `maxon fmt` on every file you change: nothing gates `maxon-bin/`'s formatting. |
| `runtime/` | Read `runtime/README.md` and the tier rules in this skill's `compiler.md`: no managed values (E3153), a restated geometry figure owes its pin. |
| `stdlib/` | A symbol callers outside the stdlib use is `public`, not `export`. No instrumentation (no `Log` calls) in stdlib algorithms. |
| `specs/`, `ir-specs/` | The language's canonical definition. Under `/land` it is read-only except to the agent briefed to write the cases. A case is a program in a spec `.md` file, pinned by `exitcode` / `stdout` / `maxoncstderr` blocks; `docs/SPECS.md` is the format, and this skill's `specs.md` the traps in writing and re-pinning cases. |
| `tests/` | Read `tests/README.md` first. A fixture `.maxon` is stored as `<name>.fixture`; one test per `.maxtest` file; expectations are generated, never hand-written. |
| anywhere else | A standalone program or example: `main` returns `ExitCode`. |
## 3. No comments
⛔ **Write no comments** — not a `//`, not a `///`, not the doc block above a registry case. Code changes
shape while it is being written, so a comment written now is rewritten and mostly thrown away. **The
`documenter` skill writes every comment, once, on the finished diff before the commit** — it is the one
exception to this rule. Leave the *why* of an unobvious shape in your report instead; the documenter decides
whether it earns a comment. A block holding only a comment is still empty (E3082).
## 4. Compile every edit before you hand it back
**Code you hand back compiles.** A syntax or type error left for review to find is a round trip wasted.
After each edit:
1. **Format the file** — `mcp__maxon__fmt` with `path:` naming **the file**. With no path it formats the
whole current directory.
2. **Compile it** with the check that fits where it lives:
| You edited | Check |
|---|---|
| a standalone program or example | `mcp__maxon__check`, then `mcp__maxon__execute` if it should run — `path:` the file for a one-file program, **the directory** for one spread over several files |
| a `.maxtest` or its project | `mcp__maxon__test` (`path:` the project directory, `filter:` the test), then `./maxon-bin/.maxon/maxon lint --tests <project directory>` |
| a spec case | `mcp__maxon__run_spec_test` (`filter:` a case-sensitive substring of `<spec>/<test>`, or an array of them selecting their union in one run; the failures come back in `failures`, and `cases: true` adds every case's verdict) |
| `maxon-bin/` | build the slot — `./maxon-bin/.maxon/maxon run build` — then `./maxon-bin/.maxon/maxon lint maxon-bin` and the spec filter that owns the behaviour |
| `stdlib/` or `runtime/` | the spec filter that owns the behaviour — the suite compiles both from source. Build the slot too when a driver command (`fmt`, `test`, the LSP) must see the change |
The `maxon-tools` skill holds the MCP tool table, `spec-test`'s filters and flags, and how to run a suite by
hand without losing its failures.
⚠ **Traps in the instruments:**
- `check` and `dump_ir` compile inside the MCP server, so they answer with the **server's** compiler, and a
running server keeps serving the compiler it started as after a rebuild. Read the `executable` field, and
restart the server when a rebuild must be what answers.
- `build`, `execute`, `test` and `maxon run build` compile past the lint rules — E3064 and E3065 (a dropped
result), E3092 (an unused `export`), E3219 (an unused unexported declaration). `check`, `dump_ir`,
`run_spec_test` and `maxon lint` report them, so a green build or test run is no evidence of a clean lint.
- A directory path compiles every `.maxon` under it as one program, so two probe programs in one
directory are one program — give each its own. A file path compiles that file ALONE: a `main.maxon`
that uses another file's types fails there, and can report a misleading error (an undefined type behind
a later `try` reads as E2015 "the expression after `try` is not a call").
- `execute` runs the program with the host's working directory — the repository root. A probe that writes
a file writes it there; delete it.
- A diagnostic run reports every independent error the analysis finds, and nothing that is only the
consequence of another (a call to a function whose declaration was refused, a use of a refused binding).
A parse error abandons only the body, initializer or declaration it is in (one in a generic body fails
its file). Unused bindings and exports,
target refusals and the checks made during lowering are reported only once no other error remains, so
fixing one error can still reveal the next. Re-run until clean.
- **Exit 101 is a leak.** Read exit codes; never grep output for a success string.
- The compiler binary is gitignored and nothing rebuilds it, so a stale one lies in both directions —
build after editing `maxon-bin/`. `spec-test` and `scale-test` refuse a stale binary by themselves.
- In a worktree, pass `repoRoot` (the worktree's absolute path) to the tools that act in a tree — `build`,
`run_spec_test`, `run_scale_test`, `execute`, `test`, `fmt`. `check`, `dump_ir`,
`lookup_error_code` and `info` take none.
## 5. Traps the compiler will not explain well
- **A name is declared once (E3006): there is no overloading.** A short form is a default parameter on the
one declaration, or a second function with its own name (`sort` / `sortBy`). Add a new parameter LAST — a
second function-typed parameter at argument 0 withholds closure parameter inference from every caller.
- **A parameter is a `let` (E2013 on reassignment).** Mark it `mutable` to write through to the caller's
`var`, or copy it into a local `var`.
- **A method is not a function value.** `apply(Ops.twice, …)` is E2078, for a static or an instance
method; pass `function(n) gives Ops.twice(n)`.
- **An unmarked declaration — top-level, method, static, nested typealias or field — is visible to its
directory and that directory's subdirectories** (E3008, E3014 from anywhere else). An `export` nothing
outside its directory uses is E3092, the root included, and an exported signature naming an unexported
typealias is E3167 — so files sharing one directory mark nothing `export`, and `export` is for a reader in
another directory.
- **An unused parameter is E3012**, like an unused variable.
- **Never add `.clone()` "just in case": it allocates and copies.** Reassigning a `var` to a freshly
produced value needs none. Add one only where the compiler refuses a write without it (E3197, E3207) or the
code must diverge from a shared reference.
⛔ **In `maxon-bin/`, `stdlib/` and `runtime/`, a `.clone()` added to satisfy a read-only diagnostic is a
HALT:** report the site, do not add the copy. First make the checker precise, then move, make the source
`let`, or declare the receiving field `let` or `var`. A builder handing a field to its product threads that
field as a local `var` through the methods that use it and moves it at the end.
- **When a natural spelling does not compile and a rewrite does, that is a compiler bug report, not a style
choice.** Nothing distinguishes "I wrote it this way" from "I had to". Bisect it to the smallest shape, fix
the compiler, and put the natural spelling back so it pins the fix. Narrow a repro before believing its
description.