@@ -24,6 +24,19 @@ Plain text readme file: https://raw.githubusercontent.com/badlogic/pi-mono/refs/
2424 - Typescript files should be modules with exports over classes.
2525 - Hoist variables, define helpers before using them, ensure code reads well for humans.
2626
27+## Coding style
28+
29+- Prefer small named functions and plain exported objects over classes or heavy abstractions.
30+- Keep imports grouped as node built-ins, external packages, then local modules. Use `type` imports for types.
31+- Use 2-space indentation, semicolons, double quotes, and trailing commas in multiline literals/calls.
32+- Name values with `camelCase`, types/schemas/TUI components with `PascalCase`, and fixed defaults with `SCREAMING_SNAKE_CASE`.
33+- Model state and events with explicit TypeScript types, discriminated unions, and TypeBox schemas for persisted or parsed data.
34+- Use early returns and guard clauses for validation, missing files, aborts, and fallback cases.
35+- Prefer Bun APIs (`Bun.file`, `Bun.write`, `Bun.spawn`, `Bun.Glob`) for runtime, file, and process work.
36+- Keep async flows readable with `async` functions/generators, `for await`, and explicit `AbortSignal` handling before writes or long work.
37+- In tool runners, report recoverable failures as tool result text instead of throwing; reserve thrown `Error`s for caller-facing validation failures.
38+- Comments should explain why something exists or document non-obvious behavior; use `TODO:` for known follow-up work.
39+
2740 ## Benchmarks
2841
2942 - Please see `BENCHMARK.md` for Terminal Bench benchmark info, and how to run it.