oh-my-opencode 5.1.83 → 5.1.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/cli-program.d.ts +3 -0
- package/dist/cli/index.js +202 -193
- package/dist/cli-node/index.js +202 -193
- package/dist/index.js +28 -22
- package/dist/skills/browser/SKILL.md +97 -91
- package/dist/skills/browser/references/commands.md +88 -26
- package/dist/skills/browser/references/desktop.md +21 -0
- package/dist/skills/browser/references/install.md +18 -0
- package/dist/skills/browser/references/owned-engine/README.md +5 -2
- package/dist/skills/browser/references/owned-engine/frames-and-humans.md +7 -2
- package/dist/skills/browser/references/owned-engine/network.md +4 -3
- package/dist/skills/browser/references/recipes/1password.md +4 -2
- package/dist/skills/browser/runtime/omowright/index.js +7 -7
- package/dist/skills/browser/runtime/omowright/manifest.json +4 -4
- package/dist/skills/debugging/references/tools/browser-qa.md +1 -1
- package/dist/skills/programming/SKILL.md +51 -320
- package/dist/skills/programming/references/go/README.md +1 -0
- package/dist/skills/programming/references/python/README.md +21 -3
- package/dist/skills/programming/references/python/error-handling.md +14 -0
- package/dist/skills/programming/references/rust/README.md +5 -1
- package/dist/skills/programming/references/typescript/README.md +9 -3
- package/dist/skills/programming/references/typescript/error-handling.md +18 -0
- package/dist/skills/ultimate-browsing/SKILL.md +1 -1
- package/dist/skills/visual-qa/references/browser-setup.md +5 -5
- package/dist/tui.js +16 -16
- package/package.json +14 -14
- package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +2 -2
- package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/package.json +1 -1
- package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/git-bash/package.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +1 -1
- package/packages/omo-codex/plugin/components/lsp/dist/.omo-runtime-manifest.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/package.json +1 -1
- package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
- package/packages/omo-codex/plugin/components/rules/package.json +1 -1
- package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/teammode/package.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/dist/cli.js +8711 -172
- package/packages/omo-codex/plugin/components/telemetry/dist/posthog.js +8660 -121
- package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/src/posthog.ts +5 -0
- package/packages/omo-codex/plugin/components/telemetry/tsconfig.json +2 -2
- package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/package.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-execute-continuation/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-execute-continuation/package.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +5 -5
- package/packages/omo-codex/plugin/components/ulw-loop/package.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-git-bash-mcp-reminder.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-lsp-diagnostics-cache.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-project-rule-cache.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-comments.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-lsp-diagnostics.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-thread-title-hygiene.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-matching-project-rules.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-recording-spawn-admission.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-enforcing-unlimited-goal-budget.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-guarding-ulw-loop-spawns.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-recommending-git-bash-mcp.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-auto-update.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-bootstrap-provisioning.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-loading-project-rules.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-recording-session-telemetry.json +1 -1
- package/packages/omo-codex/plugin/hooks/stop-checking-ulw-execute-continuation.json +1 -1
- package/packages/omo-codex/plugin/hooks/stop-checking-ulw-loop-resume.json +1 -1
- package/packages/omo-codex/plugin/hooks/subagent-stop-verifying-lazycodex-executor-evidence.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ultrawork-trigger.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ulw-loop-steering.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-loading-project-rules.json +1 -1
- package/packages/omo-codex/plugin/package-lock.json +12 -12
- package/packages/omo-codex/plugin/package.json +1 -1
- package/packages/omo-codex/plugin/shared/src/config-loader.ts +15 -1
- package/packages/omo-codex/plugin/skills/browser/SKILL.md +97 -91
- package/packages/omo-codex/plugin/skills/browser/references/commands.md +88 -26
- package/packages/omo-codex/plugin/skills/browser/references/desktop.md +21 -0
- package/packages/omo-codex/plugin/skills/browser/references/install.md +18 -0
- package/packages/omo-codex/plugin/skills/browser/references/owned-engine/README.md +5 -2
- package/packages/omo-codex/plugin/skills/browser/references/owned-engine/frames-and-humans.md +7 -2
- package/packages/omo-codex/plugin/skills/browser/references/owned-engine/network.md +4 -3
- package/packages/omo-codex/plugin/skills/browser/references/recipes/1password.md +4 -2
- package/packages/omo-codex/plugin/skills/browser/runtime/omowright/index.js +7 -7
- package/packages/omo-codex/plugin/skills/browser/runtime/omowright/manifest.json +4 -4
- package/packages/omo-codex/plugin/skills/debugging/references/tools/browser-qa.md +1 -1
- package/packages/omo-codex/plugin/skills/programming/SKILL.md +51 -320
- package/packages/omo-codex/plugin/skills/programming/references/go/README.md +1 -0
- package/packages/omo-codex/plugin/skills/programming/references/python/README.md +21 -3
- package/packages/omo-codex/plugin/skills/programming/references/python/error-handling.md +14 -0
- package/packages/omo-codex/plugin/skills/programming/references/rust/README.md +5 -1
- package/packages/omo-codex/plugin/skills/programming/references/typescript/README.md +9 -3
- package/packages/omo-codex/plugin/skills/programming/references/typescript/error-handling.md +18 -0
- package/packages/omo-codex/plugin/skills/ultimate-browsing/SKILL.md +1 -1
- package/packages/omo-codex/plugin/skills/visual-qa/references/browser-setup.md +5 -5
- package/packages/omo-codex/scripts/install-dist/install-local.mjs +21189 -20653
- package/packages/shared-skills/skills/browser/SKILL.md +97 -91
- package/packages/shared-skills/skills/browser/references/commands.md +88 -26
- package/packages/shared-skills/skills/browser/references/desktop.md +21 -0
- package/packages/shared-skills/skills/browser/references/install.md +18 -0
- package/packages/shared-skills/skills/browser/references/owned-engine/README.md +5 -2
- package/packages/shared-skills/skills/browser/references/owned-engine/frames-and-humans.md +7 -2
- package/packages/shared-skills/skills/browser/references/owned-engine/network.md +4 -3
- package/packages/shared-skills/skills/browser/references/recipes/1password.md +4 -2
- package/packages/shared-skills/skills/browser/runtime/omowright/index.js +7 -7
- package/packages/shared-skills/skills/browser/runtime/omowright/manifest.json +4 -4
- package/packages/shared-skills/skills/debugging/references/tools/browser-qa.md +1 -1
- package/packages/shared-skills/skills/programming/SKILL.md +51 -320
- package/packages/shared-skills/skills/programming/references/go/README.md +1 -0
- package/packages/shared-skills/skills/programming/references/python/README.md +21 -3
- package/packages/shared-skills/skills/programming/references/python/error-handling.md +14 -0
- package/packages/shared-skills/skills/programming/references/rust/README.md +5 -1
- package/packages/shared-skills/skills/programming/references/typescript/README.md +9 -3
- package/packages/shared-skills/skills/programming/references/typescript/error-handling.md +18 -0
- package/packages/shared-skills/skills/ultimate-browsing/SKILL.md +1 -1
- package/packages/shared-skills/skills/visual-qa/references/browser-setup.md +5 -5
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.3.
|
|
3
|
-
"sourceDigest": "
|
|
2
|
+
"version": "0.3.4",
|
|
3
|
+
"sourceDigest": "fe852d313d66bead31fcc5eaff09b2608c6743b49e093cf4a76a01f1831ec84b",
|
|
4
4
|
"files": {
|
|
5
|
-
"index.js": "
|
|
5
|
+
"index.js": "792c4dbf1a9dbceff36888470b29706dd5b9ab22b25ba20d8da875fb57f7ade6",
|
|
6
6
|
"page-bundle.js": "c517fa11a62a1b83dc79f72b288159a420831426418b1d4d9d492fc6c414f78c",
|
|
7
7
|
"LICENSE": "b083425948376611de9b92b0aeb7377e604505756ea427e541a34d9b030d4dc1"
|
|
8
8
|
},
|
|
9
|
-
"stagedAtUtc": "2026-11-
|
|
9
|
+
"stagedAtUtc": "2026-11-26T15:55:33.030Z"
|
|
10
10
|
}
|
|
@@ -22,7 +22,7 @@ downloading a managed browser.
|
|
|
22
22
|
|
|
23
23
|
```js
|
|
24
24
|
const profile = mkdtempSync(join(tmpdir(), "debug-repro-"))
|
|
25
|
-
const browser = await omowright.connectPipe({ browserPath, browserArgs: ["--headless", `--user-data-dir=${profile}`], storageRoot: profile })
|
|
25
|
+
const browser = await omowright.connectPipe({ browserPath: omowright.detectBrowsers().find((b) => b.installed)?.binary, browserArgs: ["--headless", `--user-data-dir=${profile}`], storageRoot: profile })
|
|
26
26
|
const page = await browser.newTab("about:blank")
|
|
27
27
|
const trace = omowright.createTrace(page, { dir: traceDir }) // trace.jsonl + trace.har + before/after screenshots
|
|
28
28
|
try {
|
|
@@ -7,332 +7,63 @@ description: "Applies strict, modern language practice (typed errors, exhaustive
|
|
|
7
7
|
|
|
8
8
|
**You own this code.** What it is for and how it is built are your call, so change it the way its owner would: fit new behavior into the structure that is there and leave no duplicate or dead code behind. **A defect in the code you are changing is yours to fix now, at its root cause; never excuse it as pre-existing, someone else's, or the tool's fault.** One elsewhere goes in your summary as a follow-up.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## 1. LANGUAGE GATE: READ BEFORE THE FIRST LINE OF CODE
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
## PHASE 0 — LANGUAGE GATE (RUN THIS FIRST, EVERY TIME)
|
|
15
|
-
|
|
16
|
-
**DO NOT WRITE OR EDIT A SINGLE LINE OF CODE BEFORE COMPLETING THIS GATE.**
|
|
17
|
-
|
|
18
|
-
1. **Identify the language** from the file extension or the user's request.
|
|
19
|
-
2. **STOP** and read the matching reference set:
|
|
20
|
-
|
|
21
|
-
| File / Language | MANDATORY reading (load `Read` tool on every file below) |
|
|
22
|
-
|---|---|
|
|
23
|
-
| `.py`, `.pyi`, "Python" | `references/python/README.md` + every file under `references/python/` that the README tells you to load on demand |
|
|
24
|
-
| `.rs`, `Cargo.toml`, "Rust" | `references/rust/README.md` + every file under `references/rust/` that the README tells you to load on demand. **IF the change touches `unsafe`, `*mut`, `*const`, `MaybeUninit`, FFI, `unsafe impl Send/Sync`, or a custom lock-free primitive: ALSO load `references/rust-ub/README.md` plus every file under `references/rust-ub/`.** |
|
|
25
|
-
| `.ts`, `.tsx`, `.mts`, `.cts`, `.js`, `.jsx`, `.mjs`, `.cjs`, "TypeScript" / "JavaScript" | `references/typescript/README.md` + every file under `references/typescript/` that the README tells you to load on demand |
|
|
26
|
-
| `.go`, `go.mod`, `go.sum`, `.golangci.yml`, `*.proto` next to a Go module, "Go" / "Golang" | `references/go/README.md` + every file under `references/go/` that the README tells you to load on demand |
|
|
27
|
-
| any test file (`*.test.*`, `*.spec.*`, `*_test.go`, `test_*.py`, `*_test.py`, under `test/`, `tests/` or `__tests__/`), or a change that adds, reshapes, or deletes a test | the language row above PLUS `references/testing/README.md` (the authoring gate) and `references/testing/junk-classes.md` (the table the gate reviewer applies) |
|
|
28
|
-
| a rendered web surface: `.html`, `.css`, `.jsx`, `.tsx`, `.vue`, `.svelte`, `.astro`, or any task that ships a UI | the matching language row above, if any, PLUS the `frontend` skill, before the first line of UI code. With no design direction (no named brand, reference image or site, `DESIGN.md`, or existing styled UI to match), take the look from its references; never improvise one. The UI is done only after the `visual-qa` skill passes on the real rendered surface. |
|
|
29
|
-
|
|
30
|
-
3. Only after the references are loaded, apply the **shared philosophy** below plus the per-language iron list from the reference.
|
|
31
|
-
|
|
32
|
-
**No exceptions for "small" or "one-off" code.** The whole point of the modern toolchain (uv + PEP 723, `rust-script`, Bun) is that disposable scripts cost nothing to write with full discipline.
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
## Shared philosophy (all four languages)
|
|
37
|
-
|
|
38
|
-
These are not style preferences. They are the seven axioms every recipe in `references/` derives from.
|
|
39
|
-
|
|
40
|
-
0. **The best code is the code never written.** Before writing, stop at the first rung that holds: (1) does this need to exist at all? (YAGNI) (2) does this codebase already have it? — reuse the helper or pattern, do not re-implement. (3) does the standard library do it? (4) does a native platform feature cover it? (5) does an installed dependency solve it? (6) can it be one line? (7) only then, write the minimum that works. Climb the ladder *after* you understand the problem and trace the real flow end to end — the smallest diff in the wrong place is a second bug. The ladder is a fast decision, not a written essay: pick the rung and move. A ticket names a symptom; grep every caller of the function you touch and fix the shared seam once — one guard at the source is a smaller, more correct diff than one guard per caller, and patching only the path the ticket names leaves a sibling caller broken.
|
|
41
|
-
|
|
42
|
-
1. **The type system is your proof system.** Make illegal states unrepresentable. The compiler / type checker is the cheapest test you will ever run. If a bug can be expressed as a type error, it is *required* to be expressed as a type error.
|
|
43
|
-
|
|
44
|
-
2. **Parse, don't validate.** Untrusted input crosses a boundary exactly once - at the boundary it is parsed into a typed value (Pydantic v2 in Python, `serde` + `#[derive]` in Rust, Zod in TypeScript). Inside the boundary, code receives typed values and never re-validates. The boundary owns trust; the interior owns logic.
|
|
45
|
-
|
|
46
|
-
3. **One name = one concept.** A `UserId` is not a `string`. A `Seconds` is not a `Milliseconds`. Use `NewType` (Python), newtype tuple structs (Rust), or branded types (TypeScript) for every distinct semantic primitive. The compiler refuses to let two semantic units mix.
|
|
47
|
-
|
|
48
|
-
4. **Exhaustive variant matching, always.** Discriminated unions and enums are matched exhaustively. Python: `match` + `case unreachable: assert_never(unreachable)`. Rust: `match` (the compiler enforces). TypeScript: `switch` + `assertNever`. **`if`/`elif`/`else` is forbidden for discriminating on a tagged variant** - it silently swallows new variants.
|
|
49
|
-
|
|
50
|
-
5. **Trust framework guarantees. Validate only at boundaries.** No null checks for values the type system already proves non-null. No `try/except` around code that cannot raise. No `unwrap`/`!`/`as` to paper over a contract you should have encoded in types. No defensive layer for a scenario you cannot name.
|
|
51
|
-
|
|
52
|
-
6. **Tests are the behavior of record, and only tests that can fail count.** READ the tests covering the area BEFORE you change it: do they encode the intent, cover this path, pass? One wrong before your change is a FINDING — never edit it green. Reproduce a bug before fixing it. The run proves the change; add a test ONLY where the repository keeps tests for this behavior AND a regression would otherwise pass unnoticed — sized like its neighbors, never restating the change. The authoring gate and the junk-class table are in `references/testing/`.
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## TEST DISCIPLINE
|
|
57
|
-
|
|
58
|
-
Tests are code: the language gate above applies to them, plus [`references/testing/README.md`](references/testing/README.md) (the contract every language's recipes assume) and [`references/testing/junk-classes.md`](references/testing/junk-classes.md) (the table the gate reviewer applies to every test in a diff). Read both before adding, reshaping, or deleting a test.
|
|
59
|
-
|
|
60
|
-
**The authoring gate.** Before a test exists, answer all four; a missing answer means do not add it yet.
|
|
61
|
-
|
|
62
|
-
1. What observable behavior, invariant, or independent contract does it protect?
|
|
63
|
-
2. What credible regression makes it fail?
|
|
64
|
-
3. Why does existing coverage not already catch that failure? One primary owner per contract, at the strongest boundary; extend a table row before adding a near-duplicate, a copy in another package, or a replay through a wrapper.
|
|
65
|
-
4. Does it need a production seam (export, flag, getter, wrapper, injection hook) no production caller needs? Then test at the real boundary instead.
|
|
66
|
-
|
|
67
|
-
The README owns the shape (Given / When / Then, the pyramid, the mock ladder, determinism, isolation, the prompt-test rule) and the "test your test" step: break the production owner, watch the test go red for the intended reason, restore byte for byte. A test that fails on the unchanged base is a bug to fix at its owner; one your own change turns red is fixed at the code or at the test; neither is deleted or edited green to unblock a run.
|
|
68
|
-
|
|
69
|
-
---
|
|
70
|
-
|
|
71
|
-
## Cross-language iron list
|
|
72
|
-
|
|
73
|
-
Apply unless the per-language reference overrides with something stricter.
|
|
74
|
-
|
|
75
|
-
| Rule | Python | Rust | TypeScript | Go |
|
|
76
|
-
|---|---|---|---|---|
|
|
77
|
-
| Immutable by default | `@dataclass(frozen=True, slots=True)` / Pydantic `frozen=True` | every binding is `let` (not `let mut`) unless mutation is the documented purpose | every field is `readonly`; arrays are `readonly T[]` | value types, unexported fields, no mutation methods unless mutation is the purpose |
|
|
78
|
-
| Branded primitives | `UserId = NewType("UserId", int)` | `struct UserId(u64);` (newtype tuple) | `type UserId = Brand<string, "UserId">` | `type UserID string` + smart constructor with unexported field |
|
|
79
|
-
| Exhaustive variant matching | `match` + `assert_never` | `match` (compiler-enforced) | `switch` + `assertNever` | sealed interface + type switch + **`exhaustive` linter** (the compiler will not help) |
|
|
80
|
-
| No untyped escape hatches | no `Any` in public sigs, no `cast`, no `# type: ignore` | no `unwrap`/`expect` outside tests (invariant `expect` only behind `#[expect(clippy::expect_used, reason)]`), no numeric `as`, no `#[allow]` (silence with `#[expect(lint, reason)]`) | no `any`, no `as` (except `as const`, `satisfies`), no `!`, no `@ts-ignore`, no `@ts-expect-error` | no `interface{}` / bare `any` in domain sigs; no `_ = err`; no `//nolint` without reason |
|
|
81
|
-
| No bare error strings | typed exception dataclass with `__str__` | `thiserror` enum (lib) or `anyhow` with `.context(...)` (app) | `Error` subclass with typed fields | sentinel `errors.New` + typed `*XError` struct; wrap with `%w`; check via `errors.Is/As` |
|
|
82
|
-
| Boundary catch only | catch the exact exception you expect; broad `except Exception` only at a top-level boundary (`main()`/CLI entry, HTTP handler), with logging + re-raise | `?` everywhere; never `panic!` in library code | `catch` must narrow with `instanceof` and re-throw or convert; no empty catch | every `(T, error)` checked; `panic` only in `main`/tests; one `httperr.Write` funnel in handlers |
|
|
83
|
-
| Resources via RAII | `with` (sync) / `async with` (async) | `Drop` impl or RAII guard | `using`/`await using` (TC39 explicit resource management) | `defer x.Close()` immediately after acquisition; `bodyclose`/`sqlclosecheck` linters enforce |
|
|
84
|
-
| Async runtime is mandatory | `anyio` (NEVER bare `asyncio`) | `tokio` (`async-std` is unmaintained) | platform-native async (Bun/Node) with structured cancellation via `AbortSignal` | `context.Context` as first param + `errgroup` for structured concurrency; `-race` on every test |
|
|
85
|
-
| Modern HTTP client | [`httpx2`](https://github.com/pydantic/httpx2) with HTTP/2 + brotli + zstd | `reqwest` with rustls | `ky` (default) / `undici` direct API (Node perf) - NEVER bare `fetch` in prod | stdlib `net/http.Client` with tuned `Transport` + `go-retryablehttp` for retry/backoff |
|
|
86
|
-
| No parameter mutation | params are inputs; produce a new value | `&mut` only when mutation is the documented purpose | parameters never reassigned (`noParameterAssign`) | value receivers when not mutating; pointer receivers only for genuine mutation; `copylocks` vet enforces |
|
|
87
|
-
| No helpers for one-off | inline a 3-line operation; do not abstract until the second caller | same | same | same |
|
|
88
|
-
|
|
89
|
-
---
|
|
90
|
-
|
|
91
|
-
## Modern ecosystem - canonical libraries (2026)
|
|
92
|
-
|
|
93
|
-
Use these unless the project's manifest explicitly picks something else.
|
|
94
|
-
|
|
95
|
-
| Domain | Python | Rust | TypeScript | Go |
|
|
96
|
-
|---|---|---|---|---|
|
|
97
|
-
| Data validation / boundary parse | **Pydantic v2** | **serde** + `#[derive(Deserialize)]` + `validator` | **Zod v4** (Standard Schema) | `validator/v10` (HTTP) + `protovalidate` (proto) + smart constructors (domain) |
|
|
98
|
-
| Internal value object | `@dataclass(frozen=True, slots=True)` | newtype tuple struct or plain `struct` | `type` alias with `readonly` | struct with unexported fields + `NewX(...)` constructor |
|
|
99
|
-
| Error types | typed exception dataclass | `thiserror` (lib) + `anyhow` (app) | `Error` subclass + Result pattern | sentinel `errors.New` + typed `*XError` struct + `%w` wrap |
|
|
100
|
-
| HTTP client | [`httpx2`](https://github.com/pydantic/httpx2) | `reqwest` | `ky` / `undici` | stdlib `net/http` + `go-retryablehttp` |
|
|
101
|
-
| Web framework | **FastAPI** | **axum** | **Hono** + `hono-openapi` | **gin** (de facto, ~48%) / `chi` (minimalist) / `connect-go` (RPC) |
|
|
102
|
-
| ORM / DB | SQLAlchemy 2.x async + `asyncpg` | `sqlx` (compile-time checked) | **Drizzle** | **sqlc** (codegen from `.sql`) + `pgx/v5` + `goose` migrations |
|
|
103
|
-
| CLI | **typer** + `rich` | **clap** (derive) + `color-eyre` + `indicatif` | `@clack/prompts` + `commander` | **cobra** + `huh` (prompts) + `slog` |
|
|
104
|
-
| Logging / observability | `structlog` (prod) or `rich.logging` (dev) | **tracing** + `tracing-subscriber` | `pino` (structured JSON) | stdlib **`log/slog`** (NEVER logrus/zap/zerolog for new code) |
|
|
105
|
-
| Testing | `pytest` | `cargo nextest` + `proptest` + `insta` | `bun test` / `vitest` | stdlib `testing` + `testify/require` + `goleak` + `autogold` + `rapid` + `testcontainers` |
|
|
106
|
-
| Data / analytics | **polars** + **duckdb** + `numpy` (NEVER pandas) | `polars-rs` or `arrow` | (defer to backend service) | `arrow-go` + DuckDB-Go bindings + `gonum` |
|
|
107
|
-
| LLM / agent | **pydantic-ai** | (call out to Python via subprocess) | **Vercel AI SDK** | direct `net/http` + Connect (langchaingo not recommended) |
|
|
108
|
-
| TUI | **textual** | `ratatui` | `@clack/prompts` or ink | **bubbletea v2 RC** + `bubbles/v2` + `lipgloss/v2` (v2 mandatory for CJK IME) |
|
|
109
|
-
| Config from env | **pydantic-settings** | `figment` or `config` | `zod` + `process.env` | `caarlos0/env/v11` (struct-tag env) |
|
|
110
|
-
|
|
111
|
-
A bare default constructor for any of these (no timeouts, no pool tuning, no schema) is a bug. See the per-language reference for the canonical production defaults.
|
|
112
|
-
|
|
113
|
-
---
|
|
114
|
-
|
|
115
|
-
## Modern toolchain - the only acceptable setup
|
|
116
|
-
|
|
117
|
-
| Tool category | Python | Rust | TypeScript | Go |
|
|
118
|
-
|---|---|---|---|---|
|
|
119
|
-
| Package / project manager | **uv** (NEVER pip/poetry/conda) | **cargo** + `cargo-nextest` + `cargo-machete` + `cargo-deny` | **Bun** (runtime + package manager); pnpm if Node is forced | **`go modules`** + `go work` for monorepos |
|
|
120
|
-
| Type checker | **basedpyright** with `typeCheckingMode = "all"` | the Rust compiler with `-D warnings` + clippy `pedantic` + `nursery` + `cargo` groups | `tsc --noEmit` (or `tsgo` when available) with `strict` + `noUncheckedIndexedAccess` + `exactOptionalPropertyTypes` + `verbatimModuleSyntax` | the Go compiler + **`golangci-lint v2`** with the strict bundle + **`nilaway`** (nil-deref static analysis) |
|
|
121
|
-
| Linter + formatter | **ruff** with `select = ["ALL"]` | `clippy` + `rustfmt` | **oxlint + oxfmt**, with the local copy and suppression-reason rules | **`gofumpt`** (stricter gofmt) + `goimports -local` + `golangci-lint v2` |
|
|
122
|
-
| Test runner | **pytest** | **cargo-nextest** | `bun test` / `vitest` | stdlib `go test -race -shuffle=on -count=1` + `goleak` |
|
|
123
|
-
| UB / soundness gate | (n/a) | **nightly miri** with strict provenance + Tree Borrows pass | (n/a) | **`nilaway`** + `-race` detector + `goleak` are the equivalent gate |
|
|
124
|
-
| Disposable scripts | **PEP 723** inline metadata + `uv run script.py` | **rust-script** with inline `Cargo.toml` block | `bun run script.ts` | `//go:build ignore` + `go run script.go` |
|
|
125
|
-
| Bootstrap a new project | `bun run scripts/python/new-project.ts` | `bun run scripts/rust/new-project.ts` | `bun run scripts/typescript/new-project.ts` | `bun run scripts/go/new-project.ts` |
|
|
126
|
-
| Pre-commit / CI gate | `ruff check . && basedpyright && pytest` | `cargo clippy --all-targets -- -D warnings && cargo nextest run && cargo test --doc && cargo +nightly miri nextest run` | `bunx oxlint --type-aware --deny-warnings && bunx oxfmt --check && bunx tsc --noEmit && bun test` | `gofumpt -l . && golangci-lint run ./... && nilaway ./... && go test -race -shuffle=on -count=1 ./...` |
|
|
127
|
-
|
|
128
|
-
For TS/JS, **use oxlint + oxfmt with these two rules by default**: `no-em-dash-copy` and `require-suppression-reason`. Strongly prefer this OXC toolchain for new projects; retain ESLint, Prettier, or Biome only when the repository already uses them. Load [`references/typescript/oxc-lint.md`](references/typescript/oxc-lint.md) for the complete configs, plugin, and type-aware support requirements. Rewrite paired em dashes as asides using parentheses or commas, not colon chains.
|
|
129
|
-
|
|
130
|
-
A `tsconfig.json` with `"strict": true` alone is **not** strict. The reference enumerates the additional flags. Same for `pyproject.toml` and `Cargo.toml` - the references contain the canonical full configuration.
|
|
131
|
-
|
|
132
|
-
---
|
|
133
|
-
|
|
134
|
-
## CODE SMELLS — AUTOMATIC REVIEW TRIGGERS
|
|
135
|
-
|
|
136
|
-
Most smells below are design review triggers: STOP, re-examine the code, and either fix the smell or justify carrying it with a SPECIFIC reason. **The 250 pure LOC ceiling is stricter: >250 is a DEFECT. Refactor before adding lines except for rare SIZE_OK or pure-data-table exceptions.**
|
|
137
|
-
|
|
138
|
-
Full rationale, measurement methods, workaround detection, and split examples: **[`references/code-smells.md`](references/code-smells.md)**.
|
|
139
|
-
|
|
140
|
-
### Smell 1 — File exceeds 250 pure LOC
|
|
141
|
-
|
|
142
|
-
A source file past 250 non-blank, non-comment lines has outgrown a single reviewer's working memory. The module is almost certainly doing more than one thing. Measure: `awk '!/^[[:space:]]*$/ && !/^[[:space:]]*(\/\/|#|--)/' <file> | wc -l`.
|
|
143
|
-
|
|
144
|
-
**When detected:** Name what the file owns in one short noun phrase. If the answer needs "and", the file needs splitting. Load `/refactor` and split by responsibility. If the file genuinely cannot be split (generated parser, indivisible state machine), mark it in the first 10 lines with `# noqa: SIZE_OK — <reason>` in Python (the form `scripts/python/check-no-excuse-rules.py` reads) or `// allow: SIZE_OK — <reason>` in `//`-comment languages.
|
|
145
|
-
|
|
146
|
-
### Smell 2 — Function with more than 3 parameters
|
|
147
|
-
|
|
148
|
-
More than 3 arguments signals the function is doing too much, or that related parameters belong in a typed struct. **Workarounds count as the same smell** — passing `dict`/`Record<string, unknown>`/`map[string]any`/`**kwargs`/`...args` to smuggle parameters through one argument, or a throwaway "config" object with 6+ fields that exists solely to wrap what would otherwise be positional args (genuine reusable domain types like `HttpClientConfig` are fine).
|
|
149
|
-
|
|
150
|
-
**When detected:** Group related parameters into a typed value object with a domain name. If 4+ independent inputs are genuinely required, the justification must be SPECIFIC. See [`references/code-smells.md` Smell 2](references/code-smells.md#smell-2--function-with-more-than-3-parameters) for Python, TypeScript, and Go examples.
|
|
151
|
-
|
|
152
|
-
### Smell 3 — Redundant verification after a destructive action
|
|
153
|
-
|
|
154
|
-
Performing a delete/remove/clear/drop and then immediately querying to "confirm" the thing is gone. **The operation's contract IS the verification.** Re-checking is AI-generated defensive bloat that wastes cycles and teaches the reader the operation is unreliable — which it is not. Same smell: calling a setter then getting to "confirm", writing a file then reading it back, inserting a row then SELECT-ing it, pushing to an array then checking `.length`.
|
|
12
|
+
This file holds what every language shares. Each README holds that language's hard rules, canonical libraries, toolchain, CI gate, scaffolder, and the table of references to load per task. Read the README, then the files its table names for the work. Manifests and tool configs follow their language's row. One-off scripts get the same discipline: `uv run` + PEP 723, `rust-script`, `bun run`, and `go run` make it free.
|
|
155
13
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
### Smell 4 — Negative-form names and conditions
|
|
159
|
-
|
|
160
|
-
Naming variables, functions, or flags by the **absence** of a quality (`isNotValid`, `noErrors`, `cannotProceed`, `DisableLogging`) instead of its **presence** (`isValid`, `isClean`, `canProceed`, `LoggingEnabled`). Every negation forces the reader to invert mentally; two negations (`if !isNotReady`) become a logic puzzle nobody reviews confidently.
|
|
161
|
-
|
|
162
|
-
**When detected:** Rename to the positive form and invert the branch logic. Negation IS appropriate in guard clauses (`if !authorized { return }`) and filters (`items.filter(|x| !x.is_expired())`) — the negative form is the intent there. See [`references/code-smells.md` Smell 4](references/code-smells.md#smell-4--negative-form-names-and-conditions) for the full naming table and examples.
|
|
163
|
-
|
|
164
|
-
---
|
|
165
|
-
|
|
166
|
-
## LOGGING — CROSS-CUTTING RULES
|
|
167
|
-
|
|
168
|
-
Logging is part of the code you ship, and it has iron rules of its own: levels chosen by naming the consumer (never by severity vibes), placement at decision points (never inside helpers), stable messages with structured fields — and, above everything else, **the project's existing practice wins: a project with a designated logger gets that logger and nothing else, and a project that does not log does not get logging uninvited.**
|
|
169
|
-
|
|
170
|
-
**Read [`references/logging.md`](references/logging.md) BEFORE the change** whenever your edit adds or modifies log lines, sets up a logger or a new service entrypoint, or handles errors at a boundary.
|
|
171
|
-
|
|
172
|
-
---
|
|
173
|
-
|
|
174
|
-
## DEPENDENCY UPGRADES — CROSS-CUTTING RULES
|
|
175
|
-
|
|
176
|
-
- **`0.x` minor = major.** Semver promises nothing below 1.0: treat `0.N → 0.N+1` as a breaking upgrade — read the changelog, build, and run the full suite before trusting it. A required field appearing in a public options type is a routine `0.x` "minor".
|
|
177
|
-
- **Version literals live outside the manifest.** Before committing a bump, grep the repo for the old version string: Dockerfiles pinning a global CLI, CI workflows, and docs all carry copies. A bump that updates only the package manifest ships a split-brain deploy.
|
|
178
|
-
- **Never hand-merge a lockfile.** On conflict, take either side whole and regenerate with the package manager — the resolver owns that file, not you.
|
|
179
|
-
|
|
180
|
-
---
|
|
181
|
-
|
|
182
|
-
## MANDATORY POST-WRITE REVIEW LOOP
|
|
183
|
-
|
|
184
|
-
**This runs EVERY time you finish writing or substantively editing code, before you claim the task is done.** No exceptions.
|
|
185
|
-
|
|
186
|
-
### Step 1 — measure
|
|
187
|
-
|
|
188
|
-
For every file you created or modified:
|
|
189
|
-
|
|
190
|
-
```bash
|
|
191
|
-
awk '!/^[[:space:]]*$/ && !/^[[:space:]]*(\/\/|#|--)/' <file> | wc -l
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
Or run the per-language checker the skill ships:
|
|
195
|
-
|
|
196
|
-
```bash
|
|
197
|
-
# Python
|
|
198
|
-
uv run scripts/python/check-no-excuse-rules.py <changed paths>
|
|
199
|
-
# Rust
|
|
200
|
-
bash scripts/rust/check-no-excuse-rules.sh <changed paths>
|
|
201
|
-
# TypeScript
|
|
202
|
-
bun run scripts/typescript/check-no-excuse-rules.ts <changed paths>
|
|
203
|
-
# Any language, test files you touched: the junk classes a regex can see (candidates for "test your test")
|
|
204
|
-
bun run scripts/typescript/check-test-junk.ts <changed test paths>
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
### Step 2 — interpret
|
|
208
|
-
|
|
209
|
-
| Pure LOC | Verdict | Required action |
|
|
210
|
-
|---|---|---|
|
|
211
|
-
| ≤ 200 | Healthy | continue |
|
|
212
|
-
| 200 - 250 | **Warning band** | State that fact and propose a split if the next edit will add lines. |
|
|
213
|
-
| > 250 | **DEFECT** | Do NOT commit new lines to this file. Refactor now: split the touched unit before adding lines, except for rare SIZE_OK or pure-data-table exceptions. |
|
|
214
|
-
|
|
215
|
-
### Step 3 — architectural self-review (always, even at 80 LOC)
|
|
216
|
-
|
|
217
|
-
After every code-writing session, answer these out loud (in your reply) before declaring done:
|
|
218
|
-
|
|
219
|
-
1. **Single responsibility?** Can I name what this file owns in one short noun phrase? If the answer needs the word "and", split.
|
|
220
|
-
2. **Boundary purity?** Did I parse untrusted input into a typed value at the boundary, or did I pass `dict[str, Any]` / `serde_json::Value` / `unknown` past the boundary? If the latter, fix it.
|
|
221
|
-
3. **Variant discrimination?** Did I use `if`/`elif`/`else` (or `switch` without `assertNever`, or `match` without `assert_never`) anywhere to discriminate on a tagged type or enum? If yes, rewrite as exhaustive match.
|
|
222
|
-
4. **Escape hatches?** Any `Any`, `# type: ignore`, `unwrap`, `expect` outside tests, `as` numeric cast, `!`, `@ts-ignore`, `@ts-expect-error`, a Rust `#[allow]` instead of `#[expect(lint, reason)]`? If yes, fix the type or document why with a comment.
|
|
223
|
-
5. **Defensive layer?** Any null check, try/except, or `isinstance` guarding a value the type system already proves? If yes, delete.
|
|
224
|
-
6. **Helpers for one-off?** Any function, class, or trait introduced for a single caller that will never get a second caller? If yes, inline — axiom 0 should have caught it pre-write; this is the backstop.
|
|
225
|
-
7. **Tests?** Does every test I added or reshaped answer the four-question authoring gate (`references/testing/README.md`), go red when I break its production owner, and match no row of `references/testing/junk-classes.md`? Where the repository keeps tests for a behavior I introduced and a regression would otherwise pass unnoticed, is it covered at its owner, not by a copy or a change certificate?
|
|
226
|
-
8. **Parameter bloat?** Any function I wrote or modified that takes more than 3 parameters — or smuggles them through a dict/kwargs/`...args`/throwaway options object? If yes, group related params into a typed value object. See [Smell 2](references/code-smells.md#smell-2--function-with-more-than-3-parameters).
|
|
227
|
-
9. **Redundant verification?** Did I perform a destructive action (delete, remove, clear) and then immediately re-query to "confirm" it worked? Did I call a setter then a getter to "verify"? If yes, delete the verification — the operation's contract IS the proof. See [Smell 3](references/code-smells.md#smell-3--redundant-verification-after-a-destructive-action).
|
|
228
|
-
10. **Negative naming?** Any variable, function, or flag named by the absence of a quality (`isNotValid`, `noErrors`, `DisableX`) when a positive name (`isValid`, `isClean`, `EnableX`) would work? If yes, rename to positive form and invert the branch. See [Smell 4](references/code-smells.md#smell-4--negative-form-names-and-conditions).
|
|
229
|
-
11. **Logging?** If I touched log lines, logger setup, or error boundaries: did I follow the project's existing practice (including its absence)? Is every new line leveled by its consumer, placed at a decision point, and message-stable with data in fields? See [`references/logging.md`](references/logging.md).
|
|
230
|
-
|
|
231
|
-
**If any answer fails, fix it before declaring done.** This loop is the difference between "the code compiles" and "the code is correct."
|
|
232
|
-
|
|
233
|
-
### Step 4 — if you need to refactor right now, invoke the right skill
|
|
234
|
-
|
|
235
|
-
- Any code smell from the [CODE SMELLS section](#code-smells--automatic-review-triggers) fired (250+ LOC, >3 params, redundant verification, negative naming), or step 3 surfaced more than two issues: **load the `refactor` skill** and execute its safe-refactor protocol (codemap, plan, LSP-driven edits, test after each step). Do not improvise a refactor under time pressure — the refactor skill exists precisely so you do not corrupt behavior while reshaping structure.
|
|
236
|
-
- You inherited a branch with AI-generated patterns (broad `except`, redundant null checks, vague TODOs, oversized modules, dead helpers, redundant post-action verification): **load the `remove-ai-slops` skill** to do a categorized branch-scope cleanup with regression tests pinned first.
|
|
237
|
-
|
|
238
|
-
These two skills are not optional cosmetics. They are the recovery path for the smells this loop is designed to catch.
|
|
239
|
-
|
|
240
|
-
---
|
|
241
|
-
|
|
242
|
-
## Companion skills - explicit invocation triggers
|
|
243
|
-
|
|
244
|
-
| Trigger | Skill to load | Why |
|
|
245
|
-
|---|---|---|
|
|
246
|
-
| Any [code smell](#code-smells--automatic-review-triggers) fires (250+ LOC, >3 params, redundant verification, negative naming), OR the post-write loop surfaces more than two issues, OR the user says "reshape this", "extract this", "clean this up" | `refactor` | Safe codemap-driven multi-step refactor with LSP + tests after each step. Never improvise a structural change. |
|
|
247
|
-
| Recent branch contains AI-authored patterns (broad except, dead helpers, vague comments, oversized files, redundant post-action verification, junk tests), OR the user says "remove slop", "clean AI code", "deslop" | `remove-ai-slops` | Behavior locked by gate-passing tests FIRST, then categorized parallel cleanup (junk tests included, each cut proven by a mutation), then quality gates. Behavior-preserving. |
|
|
248
|
-
| Rust code touches `unsafe`, `*mut`, `*const`, `MaybeUninit`, FFI, `unsafe impl Send/Sync`, or a custom lock-free primitive | `references/rust-ub/` | Full UB taxonomy + Miri strictness escalation. Every `unsafe` block must survive Miri Level 3 (strict provenance + symbolic alignment + preemption) and the Level 4 Tree Borrows pass before it ships. |
|
|
249
|
-
|
|
250
|
-
---
|
|
251
|
-
|
|
252
|
-
## Per-language jump table
|
|
253
|
-
|
|
254
|
-
**Stop. Read the matching reference fully before writing code.**
|
|
255
|
-
|
|
256
|
-
### Python (`.py`, `.pyi`)
|
|
257
|
-
|
|
258
|
-
**READ `references/python/README.md` FIRST.** Then load on demand:
|
|
259
|
-
|
|
260
|
-
| Need | Load |
|
|
14
|
+
| Touching | Read |
|
|
261
15
|
|---|---|
|
|
262
|
-
|
|
|
263
|
-
|
|
|
264
|
-
|
|
|
265
|
-
|
|
|
266
|
-
|
|
|
267
|
-
|
|
|
268
|
-
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
**
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
|
290
|
-
|
|
291
|
-
|
|
|
292
|
-
|
|
|
293
|
-
|
|
|
294
|
-
|
|
|
295
|
-
| **ANY `unsafe` / FFI / `MaybeUninit` / lock-free work** | **`references/rust-ub/` (full directory)** |
|
|
296
|
-
|
|
297
|
-
### TypeScript / JavaScript (`.ts`, `.tsx`, `.mts`, `.cts`, `.js`, `.jsx`, `.mjs`, `.cjs`)
|
|
298
|
-
|
|
299
|
-
**READ `references/typescript/README.md` FIRST.** Then load on demand:
|
|
300
|
-
|
|
301
|
-
| Need | Load |
|
|
302
|
-
|---|---|
|
|
303
|
-
| Strict tsconfig | `references/typescript/tsconfig-strict.md` |
|
|
304
|
-
| Default oxlint + oxfmt configs and copy rules | `references/typescript/oxc-lint.md` |
|
|
305
|
-
| Type patterns (branded types, `as const`, `satisfies`, narrowing, `assertNever`) | `references/typescript/type-patterns.md` |
|
|
306
|
-
| Data modeling (type vs interface vs Zod, readonly, parse-don't-validate) | `references/typescript/data-modeling.md` |
|
|
307
|
-
| Error handling (Result, typed errors, union vs throw, AbortSignal timeouts) | `references/typescript/error-handling.md` |
|
|
308
|
-
| Bootstrapping a new project (Bun, pnpm, Hono, Vite) | `references/typescript/bootstrap.md` |
|
|
309
|
-
| Hono backend stack (hono-openapi, Scalar, Swagger, Zod v4) | `references/typescript/backend-hono.md` |
|
|
310
|
-
|
|
311
|
-
### Go (`.go`, `go.mod`, `go.sum`, `.golangci.yml`, `*.proto`)
|
|
16
|
+
| `.py`, `.pyi` | `references/python/README.md` |
|
|
17
|
+
| `.rs`, `Cargo.toml` | `references/rust/README.md`. **`unsafe`, `*mut`, `*const`, `MaybeUninit`, FFI, `unsafe impl Send/Sync`, or a custom lock-free primitive: ALSO every file under `references/rust-ub/`.** |
|
|
18
|
+
| `.ts`, `.tsx`, `.mts`, `.cts`, `.js`, `.jsx`, `.mjs`, `.cjs` | `references/typescript/README.md` |
|
|
19
|
+
| `.go`, `go.mod`, `.golangci.yml`, `*.proto` next to a Go module | `references/go/README.md` |
|
|
20
|
+
| a test file, or a change that adds, reshapes, or deletes a test | the language row PLUS `references/testing/README.md` (the authoring gate) and `references/testing/junk-classes.md` (the table the gate reviewer applies) |
|
|
21
|
+
| log lines, logger setup, a service entrypoint, an error boundary | `references/logging.md`. The project's existing practice wins: its designated logger and nothing else, and no logging in a project that does not log. |
|
|
22
|
+
| a rendered web surface: `.html`, `.css`, `.jsx`, `.tsx`, `.vue`, `.svelte`, `.astro`, or any task that ships a UI | the language row, if any, PLUS the `frontend` skill, before the first line of UI code. With no design direction (no named brand, reference image or site, `DESIGN.md`, or existing styled UI to match), take the look from its references; never improvise one. The UI is done only after the `visual-qa` skill passes on the real rendered surface. |
|
|
23
|
+
|
|
24
|
+
## 2. AXIOMS
|
|
25
|
+
|
|
26
|
+
Every recipe under `references/` derives from these.
|
|
27
|
+
|
|
28
|
+
0. **The best code is the code never written.** Stop at the first rung that holds: does this need to exist (YAGNI)? Does this codebase already have it? The standard library? A platform feature? An installed dependency? One line? Only then write the minimum that works, with no helper, class, or trait for a single caller. Climb the ladder after tracing the real flow end to end: the smallest diff in the wrong place is a second bug. A ticket names a symptom; grep every caller of the function you touch and fix the shared seam once, because a guard per caller leaves a sibling caller broken.
|
|
29
|
+
1. **Deep modules: every decision has ONE owner.** A module earns its boundary by hiding a decision (a format, a protocol, a storage layout, a policy) behind an interface smaller than what it hides. Knowledge two modules both hold is a leak: changing it must touch one place. Remove pass-through layers and wrappers that only rename. Split along the decision each piece hides, never by size or by execution order.
|
|
30
|
+
2. **Decisions in the core, effects at the edge.** Domain logic takes values and returns values. I/O, the clock, randomness, and the environment are read at the edge and passed in. Dependencies point from the edge toward the domain, never back, so the core is testable without mocks.
|
|
31
|
+
3. **The type system is your proof system.** Make illegal states unrepresentable. A bug that can be a type error is REQUIRED to be one.
|
|
32
|
+
4. **Parse, don't validate.** Untrusted input is parsed into a typed value once, at the boundary. Inside, code receives typed values and never re-validates.
|
|
33
|
+
5. **One name = one concept.** A `UserId` is not a `string`; `Seconds` is not `Milliseconds`. Every distinct semantic primitive gets a newtype or branded type, so the compiler refuses to mix them.
|
|
34
|
+
6. **Exhaustive variant matching, always.** A tagged variant is matched exhaustively with an unreachable check the compiler or linter enforces. **`if`/`else` chains on a variant are FORBIDDEN**: they silently swallow new variants.
|
|
35
|
+
7. **Trust guarantees; validate only at boundaries.** No null check for a value the types prove non-null. No `try` around code that cannot raise. No escape hatch (`Any`, `as`, `!`, `unwrap`, a suppression comment) to paper over a contract the types should carry. No defensive layer for a scenario you cannot name.
|
|
36
|
+
8. **State and failure are explicit.** Immutable by default; parameters are inputs, so produce a new value. Errors are typed values, never bare strings, caught only where they are handled or at the top-level boundary, never swallowed. Resources are released by scope. Concurrency is structured and cancellable. A client left on bare defaults (no timeout, no pool limit, no schema) is a bug.
|
|
37
|
+
9. **Tests are the behavior of record, and only tests that can fail count.** READ the tests covering the area BEFORE you change it: do they encode the intent, cover this path, pass? One wrong before your change is a FINDING; never edit it green, never delete it to unblock a run. Reproduce a bug before fixing it. Add a test ONLY where the repository keeps tests for this behavior AND a regression would otherwise pass unnoticed, sized like its neighbors, after answering the four-question gate in `references/testing/README.md`.
|
|
38
|
+
|
|
39
|
+
## 3. SMELLS: STOP AND FIX
|
|
40
|
+
|
|
41
|
+
Fix each, or carry it with a SPECIFIC stated reason. Rationale, workaround detection, and split examples: `references/code-smells.md`.
|
|
42
|
+
|
|
43
|
+
| Smell | Fires when | Fix |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| 1. Oversized file | **>250 pure LOC (non-blank, non-comment) is a DEFECT.** 200-250: say so and propose a split if the next edit adds lines. | Name what the file owns in one noun phrase; if it needs "and", split it (axiom 1) before adding lines. Indivisible (generated parser, state machine, pure data table): mark the first 10 lines `# noqa: SIZE_OK — <reason>` in Python or `// allow: SIZE_OK — <reason>` elsewhere. |
|
|
46
|
+
| 2. Parameter bloat | A function takes >3 parameters, or smuggles them through a dict, `**kwargs`, `...args`, or a throwaway options object. | Group related parameters into a typed value object with a domain name. |
|
|
47
|
+
| 3. Redundant verification | Code deletes, writes, inserts, or sets, then re-reads to "confirm". | Delete the check: the operation's contract IS the verification. If it can fail silently, fix the operation. |
|
|
48
|
+
| 4. Negative names | `isNotValid`, `noErrors`, `DisableLogging`. | Rename to the positive form and invert the branch. Guard clauses and filters keep their negation. |
|
|
312
49
|
|
|
313
|
-
|
|
50
|
+
## 4. DEPENDENCY UPGRADES
|
|
314
51
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
| Canonical strict `.golangci.yml` (v2) with per-linter rationale | `references/go/golangci-strict.md` |
|
|
319
|
-
| Project layout, Taskfile, CI, `go.mod` template | `references/go/bootstrap.md` |
|
|
320
|
-
| Type patterns (named types, smart constructors, sealed interfaces, generics) | `references/go/type-patterns.md` |
|
|
321
|
-
| Data modeling — the three layers of validation (validator/v10 → smart ctor → sqlc) | `references/go/data-modeling.md` |
|
|
322
|
-
| Error handling (`errors.Is/As`, typed errors, `%w` wrapping, no panic) | `references/go/error-handling.md` |
|
|
323
|
-
| Concurrency (`context.Context`, `errgroup`, channels, locks, `-race`, `goleak`) | `references/go/concurrency.md` |
|
|
324
|
-
| HTTP backend stack (gin + slog + validator + pgx, middleware ordering, SSE, WS) | `references/go/backend-stack.md` |
|
|
325
|
-
| RPC stack (Connect-Go default, grpc-go fallback, protovalidate, Buf) | `references/go/grpc-connect.md` |
|
|
326
|
-
| CLI stack (cobra + slog + huh) | `references/go/cobra-stack.md` |
|
|
327
|
-
| Database stack (sqlc + pgx + goose + testcontainers) | `references/go/sqlc-pgx.md` |
|
|
328
|
-
| TUI stack (bubbletea v2 + bubbles v2 + lipgloss v2; **CJK / IME support**) | `references/go/bubbletea-v2.md` |
|
|
329
|
-
| Testing (Given/When/Then, table-driven, fakes-over-mocks, autogold, rapid) | `references/go/testing.md` |
|
|
330
|
-
| Disposable `go run` scripts | `references/go/one-liners.md` |
|
|
52
|
+
- **`0.x` minor = major.** Treat `0.N → 0.N+1` as breaking: read the changelog, build, and run the full suite before trusting it.
|
|
53
|
+
- **Version literals live outside the manifest.** Before committing a bump, grep the repo for the old version string: Dockerfiles, CI workflows, and docs carry copies, and a manifest-only bump ships a split-brain deploy.
|
|
54
|
+
- **Never hand-merge a lockfile.** On conflict, take either side whole and regenerate with the package manager.
|
|
331
55
|
|
|
332
|
-
|
|
56
|
+
## 5. AFTER WRITING: REVIEW BEFORE YOU CLAIM DONE
|
|
333
57
|
|
|
334
|
-
|
|
58
|
+
1. **Measure every file you created or changed.** `awk '!/^[[:space:]]*$/ && !/^[[:space:]]*(\/\/|#|--)/' <file> | wc -l`, or the shipped checker for the language:
|
|
335
59
|
|
|
336
|
-
|
|
60
|
+
```bash
|
|
61
|
+
uv run scripts/python/check-no-excuse-rules.py <paths>
|
|
62
|
+
bash scripts/rust/check-no-excuse-rules.sh <paths>
|
|
63
|
+
bun run scripts/typescript/check-no-excuse-rules.ts <paths>
|
|
64
|
+
bash scripts/go/check-no-excuse-rules.sh <paths>
|
|
65
|
+
bun run scripts/typescript/check-test-junk.ts <test paths> # any language
|
|
66
|
+
```
|
|
337
67
|
|
|
338
|
-
|
|
68
|
+
2. **Re-read your diff against every axiom and smell above**, and state in your reply which you carried and why. A test you added or reshaped must go red when its production owner breaks and match no row of `references/testing/junk-classes.md`.
|
|
69
|
+
3. **Fix every failure before declaring done.** When a smell fired or the review found more than two issues, load the `refactor` skill and run its protocol; never improvise a structural change. When the branch carries AI-authored patterns (broad catch, dead helpers, junk tests, vague comments), load the `remove-ai-slops` skill.
|
|
@@ -60,6 +60,7 @@ If any of these fails, the change is not done. Period. The bundle is set up so a
|
|
|
60
60
|
|
|
61
61
|
Read these per-file references for the canonical patterns:
|
|
62
62
|
|
|
63
|
+
- **Library choice** → `libraries.md` — the 2026 stack with the reasoning for each pick (gin vs chi, sqlc, slog) and the data, analytics, and LLM defaults.
|
|
63
64
|
- **Types & data** → `type-patterns.md`, `data-modeling.md` — branded named types, smart constructors with unexported fields, sealed interfaces as sum types.
|
|
64
65
|
- **Errors** → `error-handling.md` — sentinel vs typed struct, `errors.Is/As`, `%w` wrapping, no panic in libraries, the `errorlint` ruleset.
|
|
65
66
|
- **Concurrency** → `concurrency.md` — `context.Context` discipline, `errgroup`, `sync.OnceValue`, `goleak`, `-race`, channel selection rules.
|
|
@@ -26,13 +26,15 @@ These are deliberate project choices. Violations are always wrong, not "style pr
|
|
|
26
26
|
| Testing | `pytest` | unittest |
|
|
27
27
|
| CLI | `typer` + `rich` | argparse, click, fire |
|
|
28
28
|
|
|
29
|
+
The CI gate is one command: `ruff format --check . && ruff check . && basedpyright && pytest`. A project with no lint or type-check config gets the block from `pyproject-strict.md` before the first new module; a project that already runs its own (mypy, flake8) keeps them, and the code you add is still fully annotated.
|
|
30
|
+
|
|
29
31
|
### The iron list
|
|
30
32
|
|
|
31
33
|
1. **Frozen by default** — `@dataclass(frozen=True, slots=True)`. Pydantic: `model_config = ConfigDict(frozen=True)`. Mutable only when mutation is the documented purpose.
|
|
32
|
-
2. **
|
|
34
|
+
2. **No naive primitive for a domain value** — a bare `str`, `int`, `float`, `dict`, `list`, or `tuple` in a signature must be what the value really is. IDs are `NewType` (`UserId = NewType("UserId", int)`); a closed set is `StrEnum` or `Literal[...]`; money is `Decimal`; an instant is a timezone-aware `datetime`, a span is `timedelta`; a filesystem location is `Path`.
|
|
33
35
|
3. **`match` only for variants, `if` only for booleans** — **NEVER** use `if/elif/else` to discriminate on type (`isinstance`), enum value, or literal variant. `match/case` is mandatory for these — non-negotiable. **ALWAYS** end with `case unreachable: assert_never(unreachable)` — bare `case _: pass` and `case _: raise ValueError` are banned (they silently swallow new variants). `if/else` is fine only for boolean expressions, range checks, and predicate calls that aren't variant discrimination. See "Why `if/elif` on variants is banned" below for examples.
|
|
34
36
|
4. **Protocol over ABC** — `typing.Protocol` for interfaces. ABC only when you need shared method implementation.
|
|
35
|
-
5. **No raw dicts in signatures** — params and returns use `TypedDict`, `dataclass`, or Pydantic model. Internal scratch dicts are fine.
|
|
37
|
+
5. **No raw dicts in signatures** — params and returns use `TypedDict`, `dataclass`, or Pydantic model. Internal scratch dicts are fine. Generics are always parameterized (`list[Order]`, `Callable[[Order], Money]`, never bare `list` or `Callable`); parameters accept the widest read-only shape (`Sequence`, `Mapping`, `Iterable` from `collections.abc`).
|
|
36
38
|
6. **Parse, don't validate** — constructors produce typed objects or raise. Never pass unvalidated data deeper into the call stack.
|
|
37
39
|
7. **Typed errors** — error types are dataclasses or exceptions with typed fields. Never `raise ValueError("something")` with a bare string. Use union returns when the caller is within 1-2 call levels and must handle the outcome (repository → service). Use exceptions when the error should propagate up many layers to a boundary handler (service → HTTP handler).
|
|
38
40
|
8. **Final for constants** — module-level constants use `Final`. Mutable module globals are a code smell.
|
|
@@ -45,7 +47,7 @@ These are deliberate project choices. Violations are always wrong, not "style pr
|
|
|
45
47
|
|
|
46
48
|
### Typing and safety
|
|
47
49
|
|
|
48
|
-
- `basedpyright` in `typeCheckingMode = "all"`. Every public
|
|
50
|
+
- `basedpyright` in `typeCheckingMode = "all"`. Every function, public or private, annotates every parameter and its return type; the config sets `reportMissingParameterType` and `reportMissingReturnType` to error.
|
|
49
51
|
- `ruff` with `select = ["ALL"]`. Override specific rules per project in `pyproject.toml`, never globally disable the strict baseline.
|
|
50
52
|
- Every new function must have a `docstring` unless its name + signature makes it completely obvious (e.g. `def full_name(first: str, last: str) -> str:`).
|
|
51
53
|
- Use `X | Y` union syntax (PEP 604), never `Union[X, Y]` or `Optional[X]`.
|
|
@@ -169,6 +171,22 @@ def main() -> int:
|
|
|
169
171
|
- For concurrency gates, use `anyio.CapacityLimiter` (not `asyncio.Semaphore`).
|
|
170
172
|
- Load `async-anyio.md` when writing async code for the full pattern library.
|
|
171
173
|
|
|
174
|
+
### Thread and process pools
|
|
175
|
+
|
|
176
|
+
- I/O-bound blocking calls go to `ThreadPoolExecutor`, CPU-bound work to `ProcessPoolExecutor`. Open both with `with`, so workers are joined on exit, and always pass `max_workers`.
|
|
177
|
+
- In async code, never block the loop: `await anyio.to_thread.run_sync(fn, *args, limiter=limiter)` for I/O, `anyio.to_process.run_sync` for CPU, fanned out through a task group.
|
|
178
|
+
- Bound every wait: `future.result(timeout=...)` or `anyio.fail_after(...)`. A timed-out thread keeps running; only a process can be killed, so anything that must be cancellable runs in a process.
|
|
179
|
+
- Process pools pickle their work: pass module-level functions and plain data, guard the entry point with `if __name__ == "__main__":`, and create the pool with `mp_context=multiprocessing.get_context("spawn")`. Forking a threaded process deadlocks, and macOS already defaults to `spawn`.
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
from concurrent.futures import ProcessPoolExecutor, as_completed
|
|
183
|
+
import multiprocessing
|
|
184
|
+
|
|
185
|
+
with ProcessPoolExecutor(max_workers=4, mp_context=multiprocessing.get_context("spawn")) as pool:
|
|
186
|
+
futures = {pool.submit(render, page): page for page in pages}
|
|
187
|
+
results = {futures[done]: done.result(timeout=60) for done in as_completed(futures)}
|
|
188
|
+
```
|
|
189
|
+
|
|
172
190
|
### Data modeling — which container, when
|
|
173
191
|
|
|
174
192
|
All model fields carry type annotations. No `Any`, no untyped dicts in public APIs.
|
|
@@ -179,6 +179,20 @@ async with managed_connection("postgres://...") as conn:
|
|
|
179
179
|
# conn is closed here, guaranteed
|
|
180
180
|
```
|
|
181
181
|
|
|
182
|
+
### A variable number of resources
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
from contextlib import AsyncExitStack
|
|
186
|
+
|
|
187
|
+
async with AsyncExitStack() as stack:
|
|
188
|
+
conns = [await stack.enter_async_context(managed_connection(url)) for url in urls]
|
|
189
|
+
stack.callback(cleanup_tmp, workdir) # a plain function runs at exit too
|
|
190
|
+
await sync_all(conns)
|
|
191
|
+
# every conn is closed here, in reverse order
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
`ExitStack` is the sync form; `stack.pop_all()` hands the open resources to a longer-lived owner.
|
|
195
|
+
|
|
182
196
|
---
|
|
183
197
|
|
|
184
198
|
## Exception hierarchy — when you do raise
|
|
@@ -221,6 +221,10 @@ Full decision tree with rationale and code snippets → [libraries.md](libraries
|
|
|
221
221
|
| HTTP server | `axum` + `tower` | Type-safe extractors, tower middleware. Stack → [axum-stack.md](axum-stack.md) |
|
|
222
222
|
| CLI | `clap` derive + `color-eyre` | Typed args, beautiful errors. Stack → [clap-stack.md](clap-stack.md) |
|
|
223
223
|
| Serialization | `serde` + `serde_json` | Non-negotiable for any boundary type |
|
|
224
|
+
| HTTP client | `reqwest` with rustls | Tuned timeouts and pool, never a bare default client |
|
|
225
|
+
| Logging | `tracing` + `tracing-subscriber` | Structured spans and fields |
|
|
226
|
+
| Config from env | `figment` or `config` | Parsed once into a typed struct |
|
|
227
|
+
| Data / analytics | `polars` or `arrow` | Columnar, no row-at-a-time loops |
|
|
224
228
|
| Error (library) | `thiserror` | Derive `Error` with zero boilerplate |
|
|
225
229
|
| Error (binary) | `anyhow` / `color-eyre` | Context-rich ad-hoc errors |
|
|
226
230
|
| Database | `sqlx` (compile-time checked) | No runtime SQL surprises |
|
|
@@ -236,7 +240,7 @@ Full decision tree with rationale and code snippets → [libraries.md](libraries
|
|
|
236
240
|
|
|
237
241
|
## Cargo Strict Configuration
|
|
238
242
|
|
|
239
|
-
Every new project gets the strict lint config from [cargo-strict.md](cargo-strict.md). The non-negotiable CI gate:
|
|
243
|
+
Scaffold a new project with `bun run ../../scripts/rust/new-project.ts <name>`. Every new project gets the strict lint config from [cargo-strict.md](cargo-strict.md). The non-negotiable CI gate:
|
|
240
244
|
|
|
241
245
|
```bash
|
|
242
246
|
cargo fmt --all -- --check && \
|
|
@@ -24,6 +24,8 @@ These are deliberate project choices. Violations are always wrong, not "style pr
|
|
|
24
24
|
| Testing | `bun test` or vitest | jest |
|
|
25
25
|
| ORM | Drizzle | TypeORM, Prisma (unless already in project) |
|
|
26
26
|
|
|
27
|
+
The CI gate is one command: `bunx oxlint --type-aware --deny-warnings && bunx oxfmt --check && bunx tsc --noEmit && bun test`.
|
|
28
|
+
|
|
27
29
|
### The iron list
|
|
28
30
|
|
|
29
31
|
1. **Readonly by default** — all `type`/`interface` properties are `readonly`. Arrays are `readonly T[]`. Mutable only when mutation is the documented purpose.
|
|
@@ -40,6 +42,8 @@ These are deliberate project choices. Violations are always wrong, not "style pr
|
|
|
40
42
|
12. **import type** — type-only imports use `import type`. Enforced by `verbatimModuleSyntax`.
|
|
41
43
|
13. **Named exports only** — no `export default`. Exception: framework requirement (Next.js pages, etc.).
|
|
42
44
|
14. **No empty catch, no catch-and-swallow** — every `catch` block must either (a) narrow the error with `instanceof` and handle each case, or (b) re-throw. Empty catch blocks and `catch (e) { console.error(e) }` without narrowing or re-throw are banned — they hide bugs. At top-level boundaries (CLI entry, HTTP handler), opt out with `// no-excuse-ok: catch` on the `catch` line.
|
|
45
|
+
15. **`using` for resources** — files, connections, and locks are released by `using` / `await using`. Cancellation and timeouts travel as an `AbortSignal`.
|
|
46
|
+
16. **Parameters are never reassigned** — produce a new value.
|
|
43
47
|
|
|
44
48
|
### Data modeling — which construct, when
|
|
45
49
|
|
|
@@ -110,11 +114,13 @@ async function main(): Promise<void> {
|
|
|
110
114
|
| ORM | Drizzle | Type-safe SQL, no codegen |
|
|
111
115
|
| HTTP client | `ky` | Thin fetch wrapper (5KB); auto-throw on non-2xx, retry, timeout, hooks, prefixUrl. Browser + Node + Bun + Deno |
|
|
112
116
|
| HTTP client (perf) | `undici` (direct API) | When a Node backend needs connection pooling, HTTP/2, or pipelining |
|
|
113
|
-
|
|
114
|
-
> **HTTP client rule** - production code must not use bare `fetch()`. It has no retry, timeout, or error-handling policy and causes silent failures during incidents. Install **`ky`** by default, and use the **`undici`** direct API when a Node backend needs high-volume requests, connection pooling, HTTP/2, or pipelining. ~~`axios`~~ is forbidden after the supply-chain compromise (2026-03). `node-fetch` is unnecessary because Node 18+ includes built-in fetch.
|
|
115
117
|
| Testing | `bun test` / vitest | Fast, ESM-native |
|
|
116
118
|
| Logging | `pino` | Structured JSON, fast |
|
|
117
|
-
| CLI | `@clack/prompts` + `commander
|
|
119
|
+
| CLI / TUI | `@clack/prompts` + `commander`; ink for a full TUI | Interactive + parsing |
|
|
120
|
+
| LLM / agent | Vercel AI SDK | Typed tools, streaming, provider-neutral |
|
|
121
|
+
| Config from env | Zod schema over `process.env` | Parsed once at startup |
|
|
122
|
+
|
|
123
|
+
> **HTTP client rule** - production code must not use bare `fetch()`. It has no retry, timeout, or error-handling policy and causes silent failures during incidents. Install **`ky`** by default, and use the **`undici`** direct API when a Node backend needs high-volume requests, connection pooling, HTTP/2, or pipelining. ~~`axios`~~ is forbidden after the supply-chain compromise (2026-03). `node-fetch` is unnecessary because Node 18+ includes built-in fetch.
|
|
118
124
|
|
|
119
125
|
## tsconfig — the one true config
|
|
120
126
|
|
|
@@ -163,6 +163,24 @@ async function fetchWithTimeout(url: string, ms: number): Promise<Response> {
|
|
|
163
163
|
|
|
164
164
|
---
|
|
165
165
|
|
|
166
|
+
## Resource release — `using`
|
|
167
|
+
|
|
168
|
+
A `using` / `await using` binding is disposed when its block exits, on a throw too, in reverse order. Collect resources without a dispose method on a stack; `try/finally` stays for one-off values.
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
await using stack = new AsyncDisposableStack()
|
|
172
|
+
const dir = stack.use(await fs.promises.mkdtempDisposable(join(tmpdir(), "job-")))
|
|
173
|
+
const server = Bun.serve({ port: 0, fetch: handle })
|
|
174
|
+
stack.defer(() => server.stop(true))
|
|
175
|
+
const child = stack.use(Bun.spawn(["worker", dir.path]))
|
|
176
|
+
await run(server.port, child)
|
|
177
|
+
// child, server, dir are closed here, in that order
|
|
178
|
+
|
|
179
|
+
const kept = stack.move() // hand the open resources to a longer-lived owner instead
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
166
184
|
## Sources
|
|
167
185
|
|
|
168
186
|
- MDN: [Error cause](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause)
|