@vwala/tooling-config 1.2.0 → 1.3.0

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/README.md CHANGED
@@ -6,6 +6,10 @@ Each tool gets a folder under `src/`:
6
6
 
7
7
  ```text
8
8
  src/
9
+ ├── _scripts/ Convention-check runner + git helpers
10
+ │ └── check-conventions.mjs
11
+ ├── agent-files/ Agent skill + brief layout policy (consumed via npm)
12
+ │ └── _scripts/
9
13
  ├── biome/ Biome config + custom GritQL rules (consumed via npm)
10
14
  │ ├── biome.config.json
11
15
  │ └── plugins/
@@ -13,6 +17,11 @@ src/
13
17
  │ ├── action.yml
14
18
  │ ├── commitlint.config.js
15
19
  │ └── hooks/
20
+ ├── context/ Module domain-language policy (consumed via npm)
21
+ │ └── _scripts/
22
+ ├── monorepo/ Package-manifest conventions (consumed via npm)
23
+ │ └── _scripts/
24
+ │ └── check-exports.mjs
16
25
  ├── syncpack/ pnpm catalog policy (consumed via npm)
17
26
  │ └── syncpack.config.json
18
27
  ├── typescript/ tsconfig presets (consumed via npm)
@@ -54,13 +63,15 @@ Anything you add alongside `extends` overrides the shared config for that key.
54
63
 
55
64
  ### Rules
56
65
 
57
- On top of Biome's `recommended` preset, four GritQL plugins enforce Vwala conventions:
66
+ Biome's own rules carry the [naming](#naming) and [export](#exports) conventions. On top of its `recommended` preset, six GritQL plugins cover what no built-in rule expresses:
58
67
 
59
68
  | Plugin | Enforces |
60
69
  | --- | --- |
61
70
  | `no-uuid-type-assertion` | No `as Uuid` / `as unknown as Uuid` — parse with `uuid()`, `newUuid()` or `zUuid` instead of manufacturing the brand. Production code only. |
62
71
  | `no-vwala-class-prefix` | No `vwala:` Tailwind prefix in apps — it only resolves inside the design system's precompiled stylesheet. Apps only. |
72
+ | `use-alias-imports` | No relative import crossing two or more parent directories (`../../`) — reach it through the project's configured alias. A single `../` to a sibling folder stays fine. Warns only. |
63
73
  | `use-given-when-then-test-names` | Every `test(...)` title reads GIVEN … WHEN … THEN … |
74
+ | `use-pnpm-scripts` | No `npm run` / `npx` / `yarn` in a script — use `pnpm run`, `pnpm dlx`. `package.json` only. |
64
75
  | `use-tests-folder-location` | Test files live in a `__tests__/` folder, never colocated with the implementation. |
65
76
 
66
77
  Each plugin file carries a header comment explaining the rule and linking to the governing reference in the [`vwala-conventions`](https://github.com/vwala-be/skills) skill. The plugins have tests in `src/biome/plugins/__tests__/` that drive the real Biome binary over fixture workspaces, so a rule that silently stops matching fails CI.
@@ -80,13 +91,33 @@ They are warnings because the convention applies to new code and asks that exist
80
91
 
81
92
  `__tests__`, `__mocks__`, `_scripts`, hidden folders, and the `[slug]` / `(group)` / `@slot` segments Next.js and Expo give meaning to are exempt from the folder check.
82
93
 
94
+ ### Exports
95
+
96
+ Entry points are declared in a package's `package.json` `exports`, not assembled by a barrel that re-exports the world. A feature's own `index.ts` is a different thing — an internal boundary, and one [`vwala-engineering-principles`](https://github.com/vwala-be/skills) requires — so nothing here touches it. Three of Biome's own rules carry the syntax half:
97
+
98
+ | Rule | Level | Enforces |
99
+ | --- | --- | --- |
100
+ | `noReExportAll` | error | No `export * from` — it hides name collisions, defeats tree-shaking, and re-exports whatever the target adds next. Name what you re-export. |
101
+ | `useExportType` | error | Type-only exports use `export type`, so a compiler can drop them without resolving them. |
102
+ | `noPrivateImports` | error | The `@package` and `@private` JSDoc tags are boundaries, not documentation. |
103
+
104
+ All three are errors, which is a departure from the [naming](#naming) rules and deliberate. `useExportType` has a safe autofix, so `biome check --write` clears every existing occurrence and there is no migration to protect against. `noPrivateImports` cannot flag pre-existing code at all: visibility defaults to public, so a diagnostic only exists once someone writes a tag — and a tag you are allowed to ignore is a comment. `noReExportAll` is the one with real remediation cost, but the fix is local to the barrel and changes no importer, which is what separates it from a rename.
105
+
106
+ **`noBarrelFile` is deliberately not enabled.** It flags *named* re-exports too, not just `export *`, which would put it in direct conflict with the feature-first rule that every feature exposes an `index.ts` as its public boundary. The turborepo advice it comes from is about the *package* level — don't make consumers import one giant barrel — and that is enforced by [package exports](#package-exports) instead, where it belongs.
107
+
108
+ **`test-support.ts` may re-export everything.** A package that publishes a `"./test-support"` subpath needs one file to point at, so that filename is exempt from `noReExportAll` — the same exception `check-test-layout` makes when it lets that file import test code.
109
+
110
+ **`noPrivateImports` turns on Biome's project scanner**, which indexes your project *and* its dependencies, including paths `files.includes` excludes. If lint time grows, force-ignore your build output the way this config already force-ignores `.agents`: `"!!**/dist"`, `"!!**/.next"`. Note there is no exemption for test files: `@package` visibility already reaches a `__tests__/` subfolder, and a test reaching for a `@private` symbol is the thing the rule is meant to catch.
111
+
83
112
  ### Test layout boundaries
84
113
 
85
114
  `use-tests-folder-location` can only check syntax — a GritQL plugin cannot see its own file path. The path-level halves of that convention — no `tests/` folder, no non-test files in `__tests__/`, no production code importing test code — are the second of the [convention checks](#convention-checks).
86
115
 
87
- ### Convention checks
116
+ ---
117
+
118
+ ## Convention checks
88
119
 
89
- Some conventions are about paths rather than syntax, and Biome reasons about syntax. Those live in scripts, behind one entry point:
120
+ Some conventions are about paths and manifests rather than syntax, and Biome reasons about syntax. Those live in scripts, behind one entry point:
90
121
 
91
122
  ```jsonc
92
123
  {
@@ -100,11 +131,84 @@ Some conventions are about paths rather than syntax, and Biome reasons about syn
100
131
  | --- | --- |
101
132
  | `naming` | Folders are kebab-case, and a file added since the base ref is named kebab-case — the error half of the [naming](#naming) rules. |
102
133
  | `test layout` | The path-level halves of [test layout boundaries](#test-layout-boundaries). |
134
+ | `pnpm` | The halves of the [package manager](#package-manager) convention Biome cannot see — lockfiles, `packageManager`, and the invocations in hooks, workflows and Dockerfiles. |
135
+ | `package exports` | Every `packages/**` manifest declares an `exports` map of explicit subpaths, with no legacy `main`/`module`/`types` and no dangling targets — see [package exports](#package-exports). |
136
+ | `agent skills` | [`.agents/skills/` is the only copy](#agent-skills); other agent directories mirror it with symlinks. |
137
+ | `agent docs` | [`CLAUDE.md` is a symlink to `AGENTS.md`](#agent-briefs), never a second copy. |
138
+ | `module context` | [Every module under `packages/modules/` declares its domain language](#module-glossaries) in `CONTEXT.md`. |
103
139
 
104
140
  Wire that single script into your own preflight and new checks arrive with an upgrade, rather than as another `&&` you have to add by hand. It runs every check even after one fails — a bad filename and a misplaced test are independent problems, and seeing both in one run beats fixing one to discover the other. Each check is still a standalone script under `src/**/_scripts/` if you want to run one on its own.
105
141
 
106
142
  Every check reads the repository through `git`, so run this from the repository root — and in CI, from a checkout deep enough for `git merge-base` to reach the default branch. With `actions/checkout` that means `fetch-depth: 0`; on a shallow clone the naming check cannot tell a new file from an old one and silently reports everything as a warning.
107
143
 
144
+ The three checks below read the index rather than the working tree — `git ls-files --stage` reports mode `120000` for a symlink on every platform, while `fs.lstat` reports a regular file for every symlink in a repository cloned on Windows without developer mode.
145
+
146
+ > Upgrading into `agent skills` or `agent docs` will fail a repository that currently keeps a copied `.claude/skills/` tree or a second `CLAUDE.md`. That failure is the point, but it arrives with the upgrade rather than with an edit — fix it by replacing the copies with symlinks before wiring the new version in.
147
+
148
+ ### Package exports
149
+
150
+ A shared package's entry points are its `exports` map — one explicit subpath per entry point, so an importer reaches `@vwala/platform-ui/button` and pulls in one file rather than a barrel that drags the whole package along.
151
+
152
+ Scope is two rules, because "must have an exports map" and "the map must be well formed" are different questions:
153
+
154
+ - Only `packages/**` has to **have** an `exports` map and a scoped `@org/name`. An app under `apps/` is bundled by Next or Expo and imported by nobody, so an entry-point map would be ceremony; the workspace root is not a package at all. Neither is ever reported for a missing one.
155
+ - **Any** manifest that declares `exports` has its shape checked, wherever it lives — no `main`/`module`/`types` beside it (Node and TypeScript both resolve through `exports` and ignore them, so they can only go stale), keys that are real subpaths rather than conditions, no `./*` wildcard, and every target resolving to a file. That is also what makes this package check its own root manifest.
156
+
157
+ Detection is by path rather than by `private`, because `private` does not separate the two — an app and an internal package are both routinely private. It is a prefix rather than `packages/*/`, because the layout [`vwala-conventions`](https://github.com/vwala-be/skills) mandates nests a category: `packages/<tooling|modules|platform>/<name>/`.
158
+
159
+ A target is skipped when git ignores it, which is how `"./dist/button.js"` in a compiled package passes before `turbo build` has ever run. The flip side: a build output that nothing in `.gitignore` covers reads as a broken path.
160
+
161
+ Severity follows age, like [naming](#naming): an `exports` map is a published contract, and migrating one means updating every importer, so it cannot be a drive-by. A manifest **added or modified** since the base ref is an error, everything else a warning. The "or modified" is the difference from the naming check — a filename can only be wrong the day it is created, while a manifest field can be wrong at any edit, and the commonest real breakage is a typo in a subpath added to a manifest that already existed. Set `EXPORTS_BASE_REF` when the default branch is not `origin/main`.
162
+
163
+ Three things it deliberately leaves alone. A `"."` root export is fine — a feature's `index.ts` is its documented public boundary, so a package exporting only `"."` is following a convention rather than breaking one, and whether a given package should have one entry point or five is a review judgement, not a pattern. `"./package.json"` and `"./test-support"` are ordinary subpaths; the latter is the export [test layout boundaries](#test-layout-boundaries) explicitly sanctions. And the `@vwala/platform-*` / `module-*` / `tooling-*` prefix is a separate convention — only the `@org/` scope is checked here.
164
+
165
+ ### Agent skills
166
+
167
+ `.agents/skills/` is the only place a skill is stored. Every other agent directory — `.claude/skills/`, `.cursor/skills/`, and the rest — holds symlinks into it.
168
+
169
+ The failure this prevents is silent. `npx skills update` rewrites `.agents/skills/`; a materialised copy under `.claude/skills/` is untouched and stays the version the agent actually loads. Nothing errors, no diff looks wrong, and the agent quietly follows guidance that was replaced months ago. A symlink cannot drift, which is why the convention is a symlink rather than a sync step.
170
+
171
+ ```bash
172
+ ln -s ../../.agents/skills/vwala-conventions .claude/skills/vwala-conventions
173
+ ```
174
+
175
+ A symlink must resolve to exactly `.agents/skills/<its own name>`. Requiring the exact path rather than a prefix rejects a link into another mirror, a link reaching inside a skill, and a link whose name disagrees with the skill it points at. Symlinks are also banned *inside* `.agents/skills/` — if the source of truth is itself a link, every mirror points at nothing.
176
+
177
+ Scope is only the `skills/` subtree of each agent directory. `.claude/settings.json`, `.claude/commands/` and `.claude/agents/` are genuinely Claude's own and have no `.agents/` counterpart, so they are never flagged. Dot-prefixed entries such as `.gitkeep` are skipped too.
178
+
179
+ Mirror completeness is deliberately **not** checked. Agent directories are opt-in per tool, and a repository that only uses Claude should not be made to create a `.cursor/` it will never read.
180
+
181
+ ### Agent briefs
182
+
183
+ `AGENTS.md` is the brief; `CLAUDE.md` is a symlink to it.
184
+
185
+ Two real files means two briefs. They start identical, one gets edited, and from then on the instructions a reader reviews are not the instructions the agent loaded — with no error and no diff to notice, because both files are individually valid.
186
+
187
+ Both files are optional. A repository with neither passes, and so does one with only `AGENTS.md`; the rule only has something to say once a `CLAUDE.md` exists, and then it says the two must be the same file. The pairing is checked per directory, because a monorepo puts a brief next to each app or package. Vendored briefs under `.agents/` and `.claude/` are out of scope — they belong to the upstream skill.
188
+
189
+ ### Module glossaries
190
+
191
+ Every package under `packages/modules/` owns a bounded area of the business, so every one of them declares its domain language in `CONTEXT.md`.
192
+
193
+ Without it each module invents its own words for the same thing — one calls it an order, the next a purchase, the third a transaction — and the cost only shows up later, when the three have to talk to each other and nobody can say whether they mean the same thing. `packages/platform/` and `packages/tooling/` are excluded on purpose: they hold code with no domain knowledge, so they have no domain language to declare.
194
+
195
+ A module is identified by its `package.json`, at any depth. Modules nest (`packages/modules/act/enrich/`) and may be scoped (`packages/modules/@acme/invoicing/`), so every manifest counts — including one at a grouping level that has modules beneath it, because a directory carrying a manifest is a package and a package here is a module. Manifests below `node_modules/`, `src/`, `dist/`, `build/`, `__tests__/`, `test-support/` or `fixtures/` are skipped; a workspace package never has one of those as an ancestor, so excluding by folder rather than by depth is what keeps a fixture's manifest from registering as a module of its own.
196
+
197
+ Existence and non-emptiness are all that is checked. The convention asks for a glossary written as terms crystallise, and a checker that demanded headings and a minimum term count would only teach people to satisfy it with a heading and a fake term.
198
+
199
+ ---
200
+
201
+ ## Package manager
202
+
203
+ Vwala repositories install with pnpm. `use-pnpm-scripts` covers the `package.json` scripts and the `pnpm` convention check covers everything Biome cannot parse — a `package-lock.json`, `npm-shrinkwrap.json`, `yarn.lock` or `bun.lock` tracked beside `pnpm-lock.yaml`, a missing `pnpm-lock.yaml`, a root `package.json` that does not pin `"packageManager": "pnpm@<version>"`, and `npm`/`npx`/`yarn` invocations inside git hooks, workflows, shell scripts and Dockerfiles. Markdown is out of scope: documentation quotes a third party's install line as a citation, and a stale README is a review problem rather than a build-breaking one.
204
+
205
+ Two exemptions are deliberate, and both are load-bearing rather than courtesies:
206
+
207
+ - **`npm publish`, `npm view`, `npm pkg`, `npm --version`.** npm is matched on its install and run verbs, not on the bare word, because OIDC trusted publishing needs the npm CLI — this package's own release workflow runs all four.
208
+ - **`npx --no -- <bin>`.** It resolves the *locally installed* binary and refuses to fetch one, which is both the behaviour you want in a hook and what keeps zizmor's `adhoc-packages` rule quiet. Bare `npx` is still flagged, because it silently pulls from the registry.
209
+
210
+ > **A repository that deliberately uses another package manager** keeps it — switching is a dedicated change, not a drive-by. The check honours that on its own: it is a no-op unless the repository opts in by naming pnpm in `packageManager` or tracking a `pnpm-lock.yaml`. Biome cannot see a lockfile, though, so the plugin has no such escape hatch — drop its entry from your own `plugins` array.
211
+
108
212
  ---
109
213
 
110
214
  ## pnpm catalog
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vwala/tooling-config",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "description": "Shared tooling configuration for Vwala repositories",
6
6
  "license": "UNLICENSED",
@@ -29,6 +29,17 @@ const CHECKS = [
29
29
  name: "test layout",
30
30
  script: "biome/plugins/_scripts/check-test-layout.mjs",
31
31
  },
32
+ { name: "pnpm", script: "biome/plugins/_scripts/check-pnpm.mjs" },
33
+ { name: "package exports", script: "monorepo/_scripts/check-exports.mjs" },
34
+ {
35
+ name: "agent skills",
36
+ script: "agent-files/_scripts/check-agent-skills.mjs",
37
+ },
38
+ { name: "agent docs", script: "agent-files/_scripts/check-agent-docs.mjs" },
39
+ {
40
+ name: "module context",
41
+ script: "context/_scripts/check-module-context.mjs",
42
+ },
32
43
  ];
33
44
 
34
45
  const failed = [];
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Reads the git index, because the agent-file conventions are about symlinks
3
+ * and `fs.lstat` cannot be trusted to see them.
4
+ *
5
+ * On a checkout with `core.symlinks=false` — the default on Windows without
6
+ * developer mode — git materialises every symlink as a regular file whose
7
+ * contents are the target path. `lstat` reports a regular file, so a check
8
+ * built on it would fail every repository cloned on Windows while passing the
9
+ * one case it exists to catch. The index records the mode git actually tracks:
10
+ * `120000` for a symlink, `100644` or `100755` for a regular file, on every
11
+ * platform.
12
+ *
13
+ * A symlink's target is the blob's contents, so `git cat-file blob <sha>`
14
+ * reads it without touching the working tree either.
15
+ */
16
+ import { execFileSync } from "node:child_process";
17
+ import path from "node:path";
18
+
19
+ const MAX_BUFFER = 1024 * 1024 * 64;
20
+ const WINDOWS_ABSOLUTE = /^[A-Za-z]:[\\/]/;
21
+
22
+ export const SYMLINK_MODE = "120000";
23
+
24
+ /**
25
+ * Every tracked path with the mode git records for it.
26
+ *
27
+ * `-z` because `core.quotePath` is on by default, so without it a path holding
28
+ * a space or a non-ASCII character comes back C-quoted and a check that splits
29
+ * it naively reports a violation nobody can locate.
30
+ *
31
+ * Entries at a stage other than 0 are the three sides of an unresolved merge
32
+ * conflict. They repeat the same path with different modes, which would report
33
+ * one file as several violations, so mid-conflict the working copy is what
34
+ * matters and those are skipped.
35
+ */
36
+ export function readIndexEntries() {
37
+ const output = execFileSync("git", ["ls-files", "--stage", "-z"], {
38
+ encoding: "utf8",
39
+ maxBuffer: MAX_BUFFER,
40
+ });
41
+
42
+ return output
43
+ .split("\0")
44
+ .filter(Boolean)
45
+ .map((record) => {
46
+ // `<mode> <sha> <stage>\t<path>`
47
+ const separator = record.indexOf("\t");
48
+ const [mode, sha, stage] = record.slice(0, separator).split(" ");
49
+ return { mode, sha, stage, path: record.slice(separator + 1) };
50
+ })
51
+ .filter((entry) => entry.stage === "0");
52
+ }
53
+
54
+ /**
55
+ * The blob's contents verbatim. Git stores a symlink target with no trailing
56
+ * newline, so this is not trimmed — a target that needs trimming is itself the
57
+ * bug, and the caller rejects it rather than papering over it.
58
+ */
59
+ export function readBlob({ sha }) {
60
+ return execFileSync("git", ["cat-file", "blob", sha], {
61
+ encoding: "utf8",
62
+ maxBuffer: MAX_BUFFER,
63
+ });
64
+ }
65
+
66
+ /**
67
+ * Where a symlink points, as a repository-relative path, or `null` when the
68
+ * target is not a usable path inside the repository.
69
+ *
70
+ * Targets are relative to the symlink's own directory rather than to the
71
+ * repository root, so `.claude/skills/foo -> ../../.agents/skills/foo` only
72
+ * resolves once joined with `.claude/skills`. Git paths always use forward
73
+ * slashes, so `path.posix` is right even on Windows.
74
+ *
75
+ * The order of the guards matters. `path.posix.join` does not reset on a
76
+ * leading slash — joining `.claude/skills` with `/etc/passwd` yields
77
+ * `.claude/skills/etc/passwd`, which would sail through every later check — so
78
+ * absolute targets have to be rejected before anything is joined.
79
+ */
80
+ export function resolveSymlinkTarget({ linkPath, target }) {
81
+ if (target === "" || target !== target.trim()) {
82
+ return null;
83
+ }
84
+
85
+ if (
86
+ path.posix.isAbsolute(target) ||
87
+ WINDOWS_ABSOLUTE.test(target) ||
88
+ target.includes("\\")
89
+ ) {
90
+ return null;
91
+ }
92
+
93
+ const resolved = path.posix.normalize(
94
+ path.posix.join(path.posix.dirname(linkPath), target),
95
+ );
96
+
97
+ if (resolved === ".." || resolved.startsWith("../")) {
98
+ return null;
99
+ }
100
+
101
+ // `normalize` preserves a trailing slash, and `.agents/skills/foo/` would
102
+ // not compare equal to the path git tracks.
103
+ return resolved.endsWith("/") ? resolved.slice(0, -1) : resolved;
104
+ }
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `AGENTS.md` is the brief; `CLAUDE.md` is a symlink to it.
4
+ *
5
+ * Two real files means two briefs. They start identical, one gets edited, and
6
+ * from then on the instructions a reader reviews are not the instructions the
7
+ * agent loaded — with no error and no diff to notice, because both files are
8
+ * individually valid. A symlink makes the second copy impossible.
9
+ *
10
+ * Both files are optional. A repository with neither passes, and so does one
11
+ * with only `AGENTS.md` — the rule only has something to say once a `CLAUDE.md`
12
+ * exists, and then it says the two must be the same file.
13
+ *
14
+ * This is checked per directory rather than at the root, because a monorepo
15
+ * puts a brief next to each app or package and the pairing has to hold for all
16
+ * of them.
17
+ *
18
+ * Biome cannot express this. Whether a path is a symlink, and what it points
19
+ * at, are properties of the index rather than of any file's syntax.
20
+ */
21
+ import {
22
+ readBlob,
23
+ readIndexEntries,
24
+ resolveSymlinkTarget,
25
+ SYMLINK_MODE,
26
+ } from "../../_scripts/git-index.mjs";
27
+
28
+ // Vendored skills ship their own `AGENTS.md` and `CLAUDE.md`. They belong to
29
+ // the upstream skill, are read-only here, and are not this repository's brief.
30
+ const IGNORED_PREFIXES = [".agents/", ".claude/"];
31
+ const AUTHORITATIVE = "AGENTS.md";
32
+ const ALIAS = "CLAUDE.md";
33
+
34
+ const entries = readIndexEntries();
35
+ const byPath = new Map(entries.map((entry) => [entry.path, entry]));
36
+ const violations = [];
37
+
38
+ const aliases = entries.filter(
39
+ (entry) =>
40
+ (entry.path === ALIAS || entry.path.endsWith(`/${ALIAS}`)) &&
41
+ !IGNORED_PREFIXES.some((prefix) => entry.path.startsWith(prefix)),
42
+ );
43
+
44
+ for (const alias of aliases) {
45
+ const directory = alias.path.slice(0, -ALIAS.length);
46
+ const authoritativePath = `${directory}${AUTHORITATIVE}`;
47
+
48
+ if (alias.mode !== SYMLINK_MODE) {
49
+ violations.push(
50
+ `${alias.path}\n Regular file. ${ALIAS} must be a symlink to ${authoritativePath}.`,
51
+ );
52
+ continue;
53
+ }
54
+
55
+ const target = readBlob({ sha: alias.sha });
56
+ const resolved = resolveSymlinkTarget({ linkPath: alias.path, target });
57
+
58
+ if (resolved === null) {
59
+ violations.push(
60
+ `${alias.path}\n Symlink target ${JSON.stringify(target)} is not a usable path inside the repository.`,
61
+ );
62
+ continue;
63
+ }
64
+
65
+ if (resolved !== authoritativePath) {
66
+ violations.push(
67
+ `${alias.path}\n Symlink resolves to "${resolved}" but must resolve to "${authoritativePath}".`,
68
+ );
69
+ continue;
70
+ }
71
+
72
+ const authoritative = byPath.get(authoritativePath);
73
+
74
+ if (authoritative === undefined) {
75
+ violations.push(
76
+ `${alias.path}\n Symlink target "${authoritativePath}" is not tracked. The brief it points at does not exist.`,
77
+ );
78
+ continue;
79
+ }
80
+
81
+ // A chain of symlinks has the same problem as a copy: the file you edit is
82
+ // not obviously the file that gets loaded.
83
+ if (authoritative.mode === SYMLINK_MODE) {
84
+ violations.push(
85
+ `${authoritativePath}\n Symlink. ${AUTHORITATIVE} is the authoritative file and must be a real file.`,
86
+ );
87
+ }
88
+ }
89
+
90
+ if (violations.length > 0) {
91
+ console.error(`\n ✖ ${violations.length} agent-docs violation(s):\n`);
92
+ for (const violation of violations) {
93
+ console.error(` ${violation}\n`);
94
+ }
95
+ process.exit(1);
96
+ }
97
+
98
+ console.log(" ✔ agent docs clean");
@@ -0,0 +1,144 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `.agents/skills/` is the only place a skill is stored. Every other agent
4
+ * directory — `.claude/skills/`, `.cursor/skills/`, and the rest — holds
5
+ * symlinks into it.
6
+ *
7
+ * The failure this prevents is silent. `npx skills update` rewrites
8
+ * `.agents/skills/`; a materialised copy under `.claude/skills/` is untouched
9
+ * and keeps being the version Claude actually loads. Nothing errors, no diff
10
+ * looks wrong, and the agent quietly follows guidance that was replaced months
11
+ * ago. A symlink cannot drift, which is why the convention is a symlink rather
12
+ * than a sync step.
13
+ *
14
+ * Biome cannot express this. It parses the syntax of source files, and whether
15
+ * a path is a symlink is a property of the index, not of any file's contents —
16
+ * the same wall `check-naming` hits with folder names.
17
+ *
18
+ * Scope is deliberately narrow: only the `skills/` subtree of each agent
19
+ * directory. `.claude/settings.json`, `.claude/commands/` and `.claude/agents/`
20
+ * are genuinely Claude's own and have no `.agents/` counterpart to mirror.
21
+ *
22
+ * Mirror completeness is deliberately not checked. Agent directories are opt-in
23
+ * per tool, and a repository that only uses Claude should not be made to create
24
+ * a `.cursor/` it will never read.
25
+ */
26
+ import {
27
+ readBlob,
28
+ readIndexEntries,
29
+ resolveSymlinkTarget,
30
+ SYMLINK_MODE,
31
+ } from "../../_scripts/git-index.mjs";
32
+
33
+ const SOURCE_OF_TRUTH = ".agents/skills";
34
+ const AGENT_DIRECTORIES = [
35
+ ".claude",
36
+ ".cursor",
37
+ ".gemini",
38
+ ".opencode",
39
+ ".codex",
40
+ ".windsurf",
41
+ ];
42
+
43
+ const entries = readIndexEntries();
44
+ const violations = [];
45
+
46
+ function isTrackedDirectory(directory) {
47
+ return entries.some((entry) => entry.path.startsWith(`${directory}/`));
48
+ }
49
+
50
+ /**
51
+ * Git stores a symlinked directory as a single index entry and never walks into
52
+ * it, so `.claude/skills/foo` appears once at mode `120000` and
53
+ * `.claude/skills/foo/SKILL.md` does not appear at all. That makes any tracked
54
+ * path more than one segment deep the evidence that someone replaced the
55
+ * symlink with a real directory — and grouping by that first segment reports a
56
+ * copied skill once rather than once per file inside it.
57
+ */
58
+ for (const agentDirectory of AGENT_DIRECTORIES) {
59
+ const skillsRoot = `${agentDirectory}/skills/`;
60
+ const bySkill = new Map();
61
+
62
+ for (const entry of entries) {
63
+ if (!entry.path.startsWith(skillsRoot)) {
64
+ continue;
65
+ }
66
+ const [skill] = entry.path.slice(skillsRoot.length).split("/");
67
+ // `.gitkeep` and friends keep an otherwise symlink-only folder in git.
68
+ if (skill.startsWith(".")) {
69
+ continue;
70
+ }
71
+ const group = bySkill.get(skill) ?? [];
72
+ group.push(entry);
73
+ bySkill.set(skill, group);
74
+ }
75
+
76
+ for (const [skill, group] of bySkill) {
77
+ const skillPath = `${skillsRoot}${skill}`;
78
+ const expected = `${SOURCE_OF_TRUTH}/${skill}`;
79
+ const link = group.find((entry) => entry.path === skillPath);
80
+
81
+ if (group.length > 1 || link === undefined) {
82
+ violations.push(
83
+ `${skillPath}\n Materialised copy of a skill. Replace it with a symlink to ${expected}.`,
84
+ );
85
+ continue;
86
+ }
87
+
88
+ if (link.mode !== SYMLINK_MODE) {
89
+ violations.push(
90
+ `${skillPath}\n Regular file where a symlink to ${expected} belongs.`,
91
+ );
92
+ continue;
93
+ }
94
+
95
+ const target = readBlob({ sha: link.sha });
96
+ const resolved = resolveSymlinkTarget({ linkPath: skillPath, target });
97
+
98
+ if (resolved === null) {
99
+ violations.push(
100
+ `${skillPath}\n Symlink target ${JSON.stringify(target)} is not a usable path inside the repository.`,
101
+ );
102
+ continue;
103
+ }
104
+
105
+ // Requiring the exact path rather than a prefix rejects three things at
106
+ // once: a link into another mirror, a link reaching inside a skill, and a
107
+ // link whose name disagrees with the skill it points at.
108
+ if (resolved !== expected) {
109
+ violations.push(
110
+ `${skillPath}\n Symlink resolves to "${resolved}" but must resolve to "${expected}".`,
111
+ );
112
+ continue;
113
+ }
114
+
115
+ if (!isTrackedDirectory(resolved)) {
116
+ violations.push(
117
+ `${skillPath}\n Symlink target "${resolved}" is not tracked. The skill it points at does not exist.`,
118
+ );
119
+ }
120
+ }
121
+ }
122
+
123
+ // The source of truth has to be real files. A symlink here means the content
124
+ // lives somewhere unversioned, and every mirror points at nothing.
125
+ for (const entry of entries) {
126
+ if (
127
+ entry.path.startsWith(`${SOURCE_OF_TRUTH}/`) &&
128
+ entry.mode === SYMLINK_MODE
129
+ ) {
130
+ violations.push(
131
+ `${entry.path}\n Symlink inside ${SOURCE_OF_TRUTH}/. The source of truth must hold real files.`,
132
+ );
133
+ }
134
+ }
135
+
136
+ if (violations.length > 0) {
137
+ console.error(`\n ✖ ${violations.length} agent-skill violation(s):\n`);
138
+ for (const violation of violations) {
139
+ console.error(` ${violation}\n`);
140
+ }
141
+ process.exit(1);
142
+ }
143
+
144
+ console.log(" ✔ agent skills clean");
@@ -49,6 +49,16 @@
49
49
  "formatter": {
50
50
  "enabled": false
51
51
  }
52
+ },
53
+ {
54
+ "includes": ["**/test-support.ts", "**/testSupport.ts"],
55
+ "linter": {
56
+ "rules": {
57
+ "performance": {
58
+ "noReExportAll": "off"
59
+ }
60
+ }
61
+ }
52
62
  }
53
63
  ],
54
64
  "plugins": [
@@ -66,6 +76,7 @@
66
76
  "!**/*.test.tsx"
67
77
  ]
68
78
  },
79
+ "./node_modules/@vwala/tooling-config/src/biome/plugins/use-alias-imports.grit",
69
80
  "./node_modules/@vwala/tooling-config/src/biome/plugins/use-given-when-then-test-names.grit",
70
81
  {
71
82
  "path": "./node_modules/@vwala/tooling-config/src/biome/plugins/use-tests-folder-location.grit",
@@ -75,6 +86,10 @@
75
86
  "!**/__tests__/**",
76
87
  "!**/.agents/**"
77
88
  ]
89
+ },
90
+ {
91
+ "path": "./node_modules/@vwala/tooling-config/src/biome/plugins/use-pnpm-scripts.grit",
92
+ "includes": ["**/package.json"]
78
93
  }
79
94
  ],
80
95
  "linter": {
@@ -102,12 +117,16 @@
102
117
  }
103
118
  },
104
119
  "correctness": {
120
+ "noPrivateImports": "error",
105
121
  "noUndeclaredVariables": "error",
106
122
  "noUnusedFunctionParameters": "error",
107
123
  "noUnusedImports": "error",
108
124
  "noUnusedPrivateClassMembers": "error",
109
125
  "noUnusedVariables": "error"
110
126
  },
127
+ "performance": {
128
+ "noReExportAll": "error"
129
+ },
111
130
  "preset": "recommended",
112
131
  "style": {
113
132
  "noEnum": "error",
@@ -125,6 +144,7 @@
125
144
  }
126
145
  },
127
146
  "useBlockStatements": "warn",
147
+ "useExportType": "error",
128
148
  "useFilenamingConvention": {
129
149
  "level": "warn",
130
150
  "options": {