Repository navigation
chore(repo): replace agent instruction prose with checks - #7954
kanadgupta wants to merge 12 commits into
Conversation
Add tools/repo-policy.ts and run it from check:all. It verifies test tier names, commit scope lists, script runners, lint-disable reasons, vendor imports, agent instruction symlinks, links and byte budgets, and the comment rules. Rules with existing violations hold at their current count. Generated with AI Co-Authored-By: Claude <noreply@anthropic.com>
Generated with AI Co-Authored-By: Claude <noreply@anthropic.com>
Drop instruction prose that restates code or that a lint, type check or guard test already enforces. Move the config build and release runbook and the e2e replay-server guide into docs, where people look for them. Generated with AI Co-Authored-By: Claude <noreply@anthropic.com>
Every eval submission for the stack start bucket check reloaded the resolved config instead of reusing the one the handler already held. Generated with AI Co-Authored-By: Claude <noreply@anthropic.com>
…tructions In a blinded ablation over two real CLI tasks, sessions given the skills and the longer root instructions did not score higher than sessions given the minimal root file alone. Generated with AI Co-Authored-By: Claude <noreply@anthropic.com>
The same ablation found no gain from the apps/cli, apps/cli-e2e and packages/config guides. Repoint references to the docs that hold the content people still need. Generated with AI Co-Authored-By: Claude <noreply@anthropic.com>
Add a root types:check script so turbo's types:check task covers tools/, and fix the errors it found in the repo policy check and the local release script. Generated with AI Co-Authored-By: Claude <noreply@anthropic.com>
CLI benchmark (Lightweight Commands): no changes foundCommit
API calls: unchanged for all 9 commands. Binary size: 134.1 MB, unchanged. Details: timing ranges, API calls per command, slowest phasesTiming ranges
API calls per command
Slowest phasesNo command moved beyond noise, so there are no phase deltas. Comment |
There was a problem hiding this comment.
Superseded by a newer AI review
🤖 AI Review
CLI reference prose guidance: not applicable (no reference sources changed).
Both independent reviews were available. The PR removes contributor guidance and adds a repository policy checker. The checker can reject valid source and commands, miss violations, and let new comment violations replace existing ones. A read-only scan reproduced the checkout’s comment baselines and verified that pending next work drops the comment-ratio count below the required total. Turbo 2.11.13 and the workspace dependencies were unavailable, so scheduling of the two new root checks remains unverified. The diff changes no CLI behavior or reference prose. The CLI reference style snapshot was marked not applicable.
Findings
| Severity | Location | Category | Sources | Claim |
|---|---|---|---|---|
| 🟠 MAJOR | turbo.json:26 |
task-wiring |
codex | pnpm check:all may omit the new root policy check and the tools type check. |
| 🟡 MINOR | AGENTS.md:6 |
documentation |
claude | The PR removes the session-start guidance on what internal information to omit from public PRs, issues, and comments, along with the CLI guide’s consolidated compatibility guidance. |
| 🟡 MINOR | .github/ai-review/README.md:117 |
agent-guidance |
codex | The rule requiring explicit authorization to edit CLI overlays disappears from the guidance loaded for CLI implementation work. |
| 🟡 MINOR | tools/repo-policy.ts:121 |
config-validation |
codex | The config reload guard misses repeated calls through CliConfigValues.load and can flag a single helper call that is also mentioned in a comment. |
| 🟡 MINOR | tools/repo-policy.ts:432 |
policy-baseline |
codex | A new comment violation passes when an unrelated existing violation of the same rule is removed. |
| 🟡 MINOR | tools/repo-policy.ts:120 |
command-parsing |
codex | The runner check rejects quoted Bun file paths and misses some package-script invocations. |
| 🟡 MINOR | tools/repo-policy.ts:143 |
import-validation |
codex | The vendor import check misses multiline imports and can flag import text inside strings. |
| 🟡 MINOR | tools/repo-policy.ts:151 |
lint-directives |
codex | The lint-disable check can flag string literals and accepts directives with an empty reason. |
| 🟡 MINOR | tools/repo-policy.ts:107 |
comment-parsing |
codex | The comment checks can count executable code and template-literal contents as comments. |
| 🟡 MINOR | tools/repo-policy.ts:309 |
symlink-validation |
codex | The agent link check accepts dangling symlinks when their stored target path is correct. |
| 🟡 MINOR | tools/repo-policy.ts:370 |
link-validation |
codex | The instruction link checker silently accepts links to deleted Markdown headings. |
| 🟡 MINOR | tools/repo-policy.ts:401 |
worktree-handling |
codex | During local checks, untracked additions are skipped and an unstaged deletion of a scanned file aborts the scan. |
| 🟡 MINOR | tools/repo-policy.ts:282 |
workflow-validation |
codex | An unrelated workflow step can mask a missing scope on the PR-title validator. |
| 🟡 MINOR | apps/cli/src/command-internal/management-api-runtime.layer.ts:75 |
documentation |
claude | Deleting the CLI agent guide leaves source comments pointing to missing numbered layer invariants. |
| 🟡 MINOR | docs/adr/0020-config-naming-vocabulary.md:54 |
documentation |
claude | ADR 0020 still directs readers to the root AGENTS.md for a config naming section that the PR removes. |
| ⚪ NIT | AGENTS.md:4 |
documentation |
claude | The root guide’s blanket wording about bun run conflicts with the new checker’s allowance for direct file invocations. |
Findings outside the diff
- 🟡 MINOR
apps/cli/src/command-internal/management-api-runtime.layer.ts:75— Deleting the CLI agent guide leaves source comments pointing to missing numbered layer invariants. - 🟡 MINOR
docs/adr/0020-config-naming-vocabulary.md:54— ADR 0020 still directs readers to the rootAGENTS.mdfor a config naming section that the PR removes.
Next impact (advisory)
Possible conflicts with work on the next branch. Informational only; this does not affect merging.
- 🟡 MINOR
tools/repo-policy.ts:439— The comment-ratio check rejects a tree that combines this PR with the pending typedfunctions serveerrors onnext.
Stats
Claude findings: 4 · Codex findings: 12 · Confirmed: 16 · Refuted: 0 · Uncertain: 1
Models: claude-opus-5-5 + gpt-6.2-sol · Trigger: auto · Workflow run
This review runs once per PR. A maintainer can request another with a /ai-review comment.
Comments cited invariants from the deleted apps/cli/CLAUDE.md and the removed Go porting status doc. They now state the reason inline. ADR 0020 notes that the root AGENTS.md section it lists was removed. Generated with AI Co-Authored-By: Claude <noreply@anthropic.com>
Also scope the runner rule to package scripts, since `bun run file.ts` is allowed. Generated with AI Co-Authored-By: Claude <noreply@anthropic.com>
- Fail comments that name a Markdown path that does not exist. - Require reason text after ` -- ` in lint-disable comments and ignore directive text outside comments. - Match vendor/effect imports split across lines and skip comments. - Count resolved-config loads in code only, not comments. - Read scopes only from the PR-title validator step and report it missing. - Scan untracked files and skip deleted ones during local runs. Generated with AI Co-Authored-By: Claude <noreply@anthropic.com>
|
Follow-up on the AI review findings outside the diff:
|
|
/ai-review |
There was a problem hiding this comment.
🤖 AI Review
CLI reference prose guidance: snapshot supabase/supabase@6d14282 supplied to reviewers (advisory, not a style pass).
The new repository policy check and root tools type-check lack Turborepo root-task registration. The policy checker also has false positives, enforcement gaps, and two checkout-dependent failures. This PR changes no shipped CLI behavior or CLI reference prose, and the supplied next context shows no fundamental conflict. Validation included code inspection and isolated checks of the policy rules. Turbo was unavailable for a task-graph dry run.
Findings
| Severity | Location | Category | Sources | Claim |
|---|---|---|---|---|
| 🟠 MAJOR | turbo.json:26 |
ci |
codex | pnpm check:all does not schedule the new root policy check or the root tools type-check. |
| 🟡 MINOR | tools/repo-policy.ts:527 |
ci-reliability |
claude | The exact-count ratchet rejects unrelated cleanups and can fail a combined merge candidate even when each PR passes separately. |
| 🟡 MINOR | tools/repo-policy.ts:437 |
correctness |
codex | A CRLF checkout of the current AGENTS.md fails the new instruction budget. |
| 🟡 MINOR | tools/repo-policy.ts:387 |
correctness |
codex | The policy check rejects an unchanged CLAUDE.md in a checkout using core.symlinks=false. |
| 🟡 MINOR | tools/repo-policy.ts:110 |
correctness |
codex | The source checker treats some TypeScript string contents as comments and can reject valid source. |
| 🟡 MINOR | tools/repo-policy.ts:124 |
correctness |
codex | The package-runner rule rejects quoted Bun script paths and accepts dotted package script names. |
| 🟡 MINOR | tools/repo-policy.ts:163 |
correctness |
codex | The config reload guard can miss repeated loads within a command and flag separate entrypoints in the same file. |
| 🟡 MINOR | tools/repo-policy.ts:520 |
correctness |
codex | Fixing one grandfathered violation can conceal a new violation of the same rule elsewhere. |
| 🟡 MINOR | tools/repo-policy.ts:312 |
correctness |
codex | Deleting an instruction symlink and its target can fail the local policy check until the deletion is staged. |
| 🟡 MINOR | tools/repo-policy.ts:387 |
correctness |
codex | The agent-link guard accepts dangling instruction and skill symlinks when their target text matches. |
| 🟡 MINOR | tools/repo-policy.ts:85 |
ci |
codex | Adding an unrelated reusable-workflow job to the PR lint workflow would break the commit-scope check. |
| 🟡 MINOR | AGENTS.md:6 |
docs-consistency |
claude | The review prompts still direct reviewers to package-level CLAUDE.md files after this PR deletes the CLI copy and its convention guide. |
| 🟡 MINOR | .github/ai-review/README.md:117 |
agent-instructions |
codex | The overlay authorization rule disappears from the instructions loaded by CLI authors. |
| ⚪ NIT | docs/adr/0020-config-naming-vocabulary.md:54 |
docs-consistency |
claude+codex | The naming ADR still describes three current sources even though the PR removes the root AGENTS.md copy. |
| ⚪ NIT | tools/repo-policy.ts:289 |
error-handling |
claude | A failed git ls-files loses the diagnostic Git writes to stderr. |
Stats
Claude findings: 4 · Codex findings: 10 · Confirmed: 15 · Refuted: 0 · Uncertain: 0
Models: claude-opus-5-5 + gpt-6.2-sol · Trigger: manual · Workflow run
This review runs once per PR. A maintainer can request another with a /ai-review comment.
| "policy:check": { | ||
| "cache": false | ||
| }, |
There was a problem hiding this comment.
🟠 MAJOR · ci · source: codex
pnpm check:all does not schedule the new root policy check or the root tools type-check.
Evidence: package.json:17 invokes turbo run. Lines 19 and 30 define the new root scripts. turbo.json:10–13 and :26–28 use bare task keys and omit //#types:check and //#policy:check. The repository previously used //#test:e2e:run for a root task in commit aa3bb6b.
Suggested fix: Register //#policy:check with caching disabled and add //#types:check alongside the workspace type-check task. Verify both root task IDs appear in the dry-run graph.
| if (found.length === allowed) continue; | ||
| if (found.length < allowed) { | ||
| failures.push(`${rule}: ${found.length} left; lower its ALLOWED entry from ${allowed}.`); | ||
| continue; | ||
| } |
There was a problem hiding this comment.
🟡 MINOR · ci-reliability · source: claude
The exact-count ratchet rejects unrelated cleanups and can fail a combined merge candidate even when each PR passes separately.
Evidence: tools/repo-policy.ts:43–46 stores exact totals, and :527–531 fails when a count drops below its total. Two PRs can each remove a different counted comment and make the same baseline edit from 176 to 175. The combined tree contains 174. .github/workflows/test.yml:24–29 and :60–78 configure the quality job to run on merge groups.
Suggested fix: Keep counts above the baseline as failures and report decreases as advisory baseline updates.
There was a problem hiding this comment.
Fixed in 3f0ed91: a count below its allowance now prints a note to lower it instead of failing.
🤖 Addressed by Claude Code
| const budget = file.endsWith("AGENTS.md") | ||
| ? (INSTRUCTION_BUDGET[file] ?? DEFAULT_INSTRUCTION_BUDGET) | ||
| : undefined; | ||
| const bytes = new TextEncoder().encode(text).length; | ||
| if (budget !== undefined && bytes > budget) { | ||
| violations.push({ | ||
| rule: "instruction-budget", | ||
| file, | ||
| message: `${bytes} bytes exceeds the ${budget}-byte budget; replace prose with a check or a link before adding more.`, |
There was a problem hiding this comment.
🟡 MINOR · correctness · source: codex
A CRLF checkout of the current AGENTS.md fails the new instruction budget.
Evidence: tools/repo-policy.ts:50–52 sets a 1,000-byte limit, and :437–445 measures the raw working-tree text. Git's checkout filters produce 985 bytes with LF and 1,002 with core.autocrlf=true. git check-attr reports no line-ending override for AGENTS.md.
Suggested fix: Normalize CRLF to LF before measuring the instruction budget.
There was a problem hiding this comment.
Fixed in 3f0ed91: the instruction budget is measured after normalizing CRLF to LF.
🤖 Addressed by Claude Code
| const expectLink = Effect.fnUntraced(function* (file: TrackedFile, target: string) { | ||
| const actual = file.symlink | ||
| ? yield* fs.readLink(path.join(repoRoot, file.path)).pipe(Effect.orElseSucceed(() => "")) | ||
| : ""; | ||
| return actual === target | ||
| ? [] | ||
| : [ | ||
| { | ||
| rule: "agent-file-link" as const, | ||
| file: file.path, | ||
| message: `Must be a symlink to \`${target}\` so every agent reads one source.`, | ||
| }, | ||
| ]; |
There was a problem hiding this comment.
🟡 MINOR · correctness · source: codex
The policy check rejects an unchanged CLAUDE.md in a checkout using core.symlinks=false.
Evidence: The root CLAUDE.md has index mode 120000 and blob content AGENTS.md. Git preserves that index mode with core.symlinks=false and materializes the blob as a regular file. tools/repo-policy.ts:312–315 marks it as a symlink from the index, then :387–399 treats the failed working-tree readLink as a violation.
Suggested fix: When Git's symlink emulation is enabled, validate the tracked link mode and target against the index and verify that the working-tree file contains that same target.
There was a problem hiding this comment.
Fixed in 3f0ed91: when the link is checked out as a plain file, its content is compared with the expected target.
🤖 Addressed by Claude Code
| const commentText = (line: string) => { | ||
| const trimmed = line.trimStart(); | ||
| return trimmed.startsWith("//") || trimmed.startsWith("/*") || trimmed.startsWith("*") | ||
| ? trimmed | ||
| : undefined; |
There was a problem hiding this comment.
🟡 MINOR · correctness · source: codex
The source checker treats some TypeScript string contents as comments and can reject valid source.
Evidence: tools/repo-policy.ts:110–114 classifies lines by their first characters. Lines 185–201 search raw lines for lint directives and count comment-like lines. An isolated run of the source predicate emitted lint-disable-reason for a literal // eslint-disable-next-line inside a template string.
Suggested fix: Use TypeScript lexical comment ranges for comment counts and lint directives.
| const PullRequestLintWorkflow = Schema.Struct({ | ||
| jobs: Schema.Record( | ||
| Schema.String, | ||
| Schema.Struct({ | ||
| steps: Schema.Array( | ||
| Schema.Struct({ | ||
| uses: Schema.optional(Schema.String), | ||
| with: Schema.optional(Schema.Struct({ scopes: Schema.optional(Schema.String) })), | ||
| }), | ||
| ), | ||
| }), | ||
| ), |
There was a problem hiding this comment.
🟡 MINOR · ci · source: codex
Adding an unrelated reusable-workflow job to the PR lint workflow would break the commit-scope check.
Evidence: tools/repo-policy.ts:85–96 requires a steps array for every job. Lines 340–351 decode the whole PR lint workflow before looking for the validator. The current validator is at .github/workflows/lint-pull-request.yml:43–50. Reusable-workflow callers use job-level uses and have no steps array.
Suggested fix: Allow reusable-workflow jobs in the schema and search the step-based jobs for the validator.
There was a problem hiding this comment.
Fixed in 3f0ed91: jobs without steps (reusable-workflow callers) are allowed, and only step-based jobs are searched for the validator.
🤖 Addressed by Claude Code
| `pnpm check:all` (lint, format, knip, types, workflows, `tools/repo-policy.ts`) and the guard tests | ||
| own the mechanical rules; when one fails, its message is the rule. Run the type, lint, and format | ||
| checks plus the affected `*.unit.test.ts` and `*.integration.test.ts` files for what you changed |
There was a problem hiding this comment.
🟡 MINOR · docs-consistency · source: claude
The review prompts still direct reviewers to package-level CLAUDE.md files after this PR deletes the CLI copy and its convention guide.
Evidence: .github/ai-review/claude-review-prompt.md:11–13, .github/ai-review/codex-review-prompt.md:11–13, and .github/ai-review/adjudicate-prompt.md:20–23 retain the package-level directions. The PR removes apps/cli/AGENTS.md and its CLAUDE.md symlink. The trusted CLI guide at lines 82–110 documented sibling layer provisioning, output flag precedence, and command tombstones.
Suggested fix: Point reviewers to the maintained ADRs and guard tests, and preserve the CLI conventions those sources do not cover in a durable reference.
There was a problem hiding this comment.
Fixed in 32a1455: the three review prompts now point to the root CLAUDE.md, docs/adr/, and the checks under tools/.
🤖 Addressed by Claude Code
| completeness, and does not edit overlays or propose replacement prose. Overlays under | ||
| `apps/cli/docs/supabase/` are human-authored: adding, rewriting, or removing one requires explicit | ||
| human authorization, and a command implementation request does not grant it. | ||
| Reviewers do not infer authorship or authorization from writing style or absent PR metadata. | ||
| This is an AI review instruction, not a deterministic guarantee that every contradiction will be found. |
There was a problem hiding this comment.
🟡 MINOR · agent-instructions · source: codex
The overlay authorization rule disappears from the instructions loaded by CLI authors.
Evidence: The deleted CLI guide stated the authorization rule at lines 112–117. .github/ai-review/README.md:117–121 preserves it in reviewer guidance. The replacement root AGENTS.md:1–17 omits the rule and a link to it.
Suggested fix: Keep the rule in scoped author instructions or link to the existing rule from the root AGENTS.md.
| - repo-root `AGENTS.md`, in a "Config Naming Vocabulary" section (since removed; the two places | ||
| below still carry it) |
There was a problem hiding this comment.
⚪ NIT · docs-consistency · source: claude+codex
The naming ADR still describes three current sources even though the PR removes the root AGENTS.md copy.
Evidence: docs/adr/0020-config-naming-vocabulary.md:51 says the convention is documented in three places. Lines 54–55 mark one of them removed, and :72–74 and :82–84 still rely on the root copy being available at session start.
Suggested fix: List the two current sources and update the affected rationale and consequences, or record the removal in a dated addendum.
There was a problem hiding this comment.
Fixed in 32a1455: reverted the inline edit and added a dated addendum that lists the two current sources and notes the rationale change.
🤖 Addressed by Claude Code
| const handle = yield* spawner.spawn(ChildProcess.make(command, args, { cwd })); | ||
| const [stdout, exitCode] = yield* Effect.all( | ||
| [Stream.mkString(Stream.decodeText(handle.stdout)), handle.exitCode], | ||
| { concurrency: "unbounded" }, | ||
| ); | ||
| if (exitCode !== ChildProcessSpawner.ExitCode(0)) { | ||
| return yield* fail(`\`${command} ${args.join(" ")}\` exited with code ${exitCode}`); | ||
| } | ||
| return stdout; |
There was a problem hiding this comment.
⚪ NIT · error-handling · source: claude
A failed git ls-files loses the diagnostic Git writes to stderr.
Evidence: tools/repo-policy.ts:289–295 consumes stdout and the exit code, then constructs an error with the command and exit code. The Bun spawner delegates to the shared implementation, which pipes stderr by default in vendor/effect/packages/platform/node-shared/src/NodeChildProcessSpawner.ts:278–289.
Suggested fix: Drain stderr concurrently with stdout and include the captured diagnostic on nonzero exit.
There was a problem hiding this comment.
Fixed in 3f0ed91: stderr is drained with stdout and included in the error on a nonzero exit.
🤖 Addressed by Claude Code
…ources Review prompts no longer send reviewers to package-level CLAUDE.md files, which this PR removes. ADR 0020 records the root section's removal in a dated addendum instead of editing the original body. Generated with AI Co-Authored-By: Claude <noreply@anthropic.com>
- Report a count below its allowance as a note, not a failure, so unrelated cleanups and merge queues do not break. - Measure instruction budgets with LF line endings. - Accept a CLAUDE.md written as a plain file under core.symlinks=false, and flag links whose target is missing. - Skip tracked links deleted from the working tree. - Allow reusable-workflow jobs in the PR lint workflow. - Include git's stderr when a git command fails. Generated with AI Co-Authored-By: Claude <noreply@anthropic.com>
Summary
Most of the agent-facing instruction text either restated code or described rules a check could enforce. This PR moves the enforceable rules into a check, deletes the prose, and keeps only a short root
AGENTS.md.tools/repo-policy.tsand run it fromcheck:all. It verifies test tier names, commit scope lists, script runners, lint-disable reasons,vendor/effectimports,CLAUDE.mdlinks, instruction links and a byte budget for the root instructions.loadResolvedConfigContextcall in one file.AGENTS.mdto the commands and constraints no check covers.apps/cli,apps/cli-e2eandpackages/configagent guides and theeffectandtest-auditskills. Thecli-referenceskill stays because the CI review prompts read it.packages/config/docs/build-and-release.mdand the e2e replay-server guide toapps/cli-e2e/README.md.Why the guides and skills are removed
A blinded ablation ran two real CLI changes three times each under three instruction sets: everything, workspace guides only, and the minimal root file only. All runs passed the hidden behaviour tests and repository checks, and the larger instruction sets did not score higher than the minimal one. The evaluation could not exercise every rule in the removed guides, so this shows no measured benefit rather than proof of none.
Reviewer notes
config-v*tag rules and telemetry event stability. The overlay authorization rule now lives in.github/ai-review/README.md.AGENTS.md, which no longer carries it.Fixes CLI-3390
🤖 Generated with Claude Code