Skip to content

Commit 5f60230

Browse files
committed
chore(claude): add '1 path, 1 reference' mantra section
1 parent 19d715d commit 5f60230

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

β€ŽCLAUDE.mdβ€Ž

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,27 @@ Emojis allowed sparingly: πŸ“¦ πŸ’‘ πŸš€ πŸŽ‰. Prefer text-based symbols for ter
7373

7474
---
7575

76+
### 1 path, 1 reference
77+
78+
**A path is *constructed* exactly once. Everywhere else *references* the constructed value.**
79+
80+
Referencing a single computed path many times is fine β€” that's the whole point of computing it once. What's banned is *re-constructing* the same path in multiple places, because that's where drift is born.
81+
82+
- **Within a package**: every script imports its own `scripts/paths.mts` (or `lib/paths.mts`). No `path.join('build', mode, ...)` outside that module.
83+
- **Across packages**: when package B consumes package A's output, B imports A's `paths.mts` via the workspace `exports` field. Never `path.join(PKG, '..', '<sibling>', 'build', ...)`.
84+
- **Workflows, Dockerfiles, shell scripts**: they can't `import` TS, so they construct the string once and reference it everywhere downstream. Workflows: a "Compute paths" step exposes `steps.paths.outputs.final_dir`; later steps read `${{ steps.paths.outputs.final_dir }}`. Dockerfiles/shell: assign once to a variable / `ENV`, reference by name thereafter. Each canonical construction carries a comment naming the source-of-truth `paths.mts`. **Re-building** the same path in a second step is the violation, not referring to the constructed value many times.
85+
- **Comments**: may describe path *structure* with placeholders ("`<mode>/<arch>`") but should not encode a complete literal path string. The import statement IS the comment.
86+
87+
Code execution takes priority over docs: violations in `.mts`/`.cts`, Makefiles, Dockerfiles, workflow YAML, and shell scripts are blocking. README and doc-comment violations are advisory unless they contain a fully-qualified path with no parametric placeholders.
88+
89+
**Three-level enforcement:**
90+
91+
- **Hook** β€” `.claude/hooks/path-guard/` blocks `Edit`/`Write` calls that would introduce a violation in a `.mts`/`.cts` file at edit time.
92+
- **Gate** β€” `scripts/check-paths.mts` runs in `pnpm check`. Fails the build on any violation that isn't allowlisted in `.github/paths-allowlist.yml`.
93+
- **Skill** β€” `/path-guard` audits the repo and fixes findings; `/path-guard check` reports only; `/path-guard install` drops the gate + hook + rule into a fresh repo.
94+
95+
The mantra is intentionally short so it sticks: **1 path, 1 reference**. When in doubt, find the canonical owner and import from it.
96+
7697
## πŸ—οΈ SDK-SPECIFIC
7798

7899
### Architecture

0 commit comments

Comments
Β (0)