diff --git a/write-discoverable-code/SKILL.md b/write-discoverable-code/SKILL.md index a5255e8..966c720 100644 --- a/write-discoverable-code/SKILL.md +++ b/write-discoverable-code/SKILL.md @@ -34,7 +34,8 @@ rules make code resolvable in one search instead of five. disambiguates `users/diff.ts` from `orders/diff.ts` sits at the top of the file; the search hit is at line 300. Put the context in the symbol (`formatDurationMs`), not the folder. Exception: rigid, absolute conventions where the path carries the meaning - (e.g. every contract file exporting `Input`/`Output`). + (e.g. every contract file exporting `Input`/`Output`). Folders still group related + files (section 2); they just don't carry the name's context. - **One concept, one spelling.** Pick `organizationId` or `orgId` and use it everywhere; every synonym splits every future search in half. Reuse existing vocabulary in the codebase you are editing rather than introducing near-synonyms. @@ -47,7 +48,16 @@ rules make code resolvable in one search instead of five. `billing-plan-config.ts`, not `config.ts`. (`index.ts` is acceptable only as a thin re-export entry point.) -## 2. Types are the documentation agents can't skip +## 2. Folders are the map + +A directory listing is the first search in an unfamiliar codebase, and it should read +as a map of the system. Group related files into folders — by feature, domain, or +layer, whichever organizing principle the codebase already follows — so each listing +shows a handful of named areas rather than every file at once. Folders carry the +grouping; context still lives in the symbol (section 1), so a name should make sense +even when quoted without its path. + +## 3. Types are the documentation agents can't skip - **Brand your primitive IDs.** `z.string().brand<'UserId'>()` (TS) or newtypes (Rust). A `transferOwnership(userId: string, orgId: string)` signature makes argument @@ -61,7 +71,7 @@ rules make code resolvable in one search instead of five. uses to self-correct. `OrgScopedDb` explains itself; `Ctx2` does not. Avoid `any`: every `any` is a spot where the compiler goes silent and the agent is back to guessing. -## 3. Say it where the search lands +## 4. Say it where the search lands - **One-line doc comment on every export**, stating the sharpest constraint the code itself can't show (units, timezone, "source time, not insert time", ownership). @@ -105,3 +115,5 @@ rules make code resolvable in one search instead of five. 4. Do all log/error strings exist verbatim in the source? 5. Did anything change behavior without changing its name? 6. When code moved, is it gone from where it came from? +7. Does each new file sit in a folder alongside related code, and does the listing + still read as a map of the system?