Repository navigation
TML-2705: consolidate agent rules into one tracked home, symlinked into .cursor/.claude - #609
Conversation
Agent rules now mirror the skills-contrib model: `.agents/rules/` is the only git-tracked home, and `.cursor/rules` + `.claude/rules` are git-ignored presentation trees containing nothing but relative symlinks back into it. - Add scripts/sync-agent-rules.mjs (+ tests): consolidates stray real-file rules into the canonical dir, regenerates the symlink trees, and prunes dangling/orphan symlinks. `--check` is the lint gate. - Wire `rules:sync` into `prepare` and `lint:rules:symlinks` into CI. - Fix .gitignore so `.agents/rules/**` is tracked (the missing whitelist exception was the root cause: rules added only to `.cursor/rules` were silently git-ignored and lost). - Migrate 68 rules into `.agents/rules`, remove the dangling drive-project-workflow symlink, and add frontmatter to three rules that had none. - Point validate-rules at the canonical dir; bump footprint thresholds for the previously-orphaned alwaysApply rules now actually loaded. - Rewrite the rules index and the AGENTS.md/CLAUDE.md "where rules live" section to match the new model. Closes TML-2705 Signed-off-by: Will Madden <[email protected]>
@prisma-next/extension-author-tools
@prisma-next/mongo-runtime
@prisma-next/family-mongo
@prisma-next/sql-runtime
@prisma-next/family-sql
@prisma-next/extension-arktype-json
@prisma-next/extension-cipherstash
@prisma-next/middleware-cache
@prisma-next/mongo
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/extension-postgis
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/sqlite
@prisma-next/target-mongo
@prisma-next/adapter-mongo
@prisma-next/driver-mongo
@prisma-next/contract
@prisma-next/utils
@prisma-next/config
@prisma-next/errors
@prisma-next/framework-components
@prisma-next/operations
@prisma-next/ts-render
@prisma-next/contract-authoring
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/psl-printer
@prisma-next/cli
@prisma-next/cli-telemetry
@prisma-next/emitter
@prisma-next/migration-tools
prisma-next
@prisma-next/vite-plugin-contract-emit
@prisma-next/mongo-codec
@prisma-next/mongo-contract
@prisma-next/mongo-value
@prisma-next/mongo-contract-psl
@prisma-next/mongo-contract-ts
@prisma-next/mongo-emitter
@prisma-next/mongo-schema-ir
@prisma-next/mongo-query-ast
@prisma-next/mongo-orm
@prisma-next/mongo-query-builder
@prisma-next/mongo-lowering
@prisma-next/mongo-wire
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-builder
@prisma-next/target-postgres
@prisma-next/target-sqlite
@prisma-next/adapter-postgres
@prisma-next/adapter-sqlite
@prisma-next/driver-postgres
@prisma-next/driver-sqlite
commit: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughCentralizes agent rules in ChangesAgent rules canonical home and sync workflow
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@AGENTS.md`:
- Around line 38-39: Update the doc links that point to the gitignored mirror
paths so they reference the canonical repository location; locate occurrences of
".cursor/rules/" and ".claude/rules/" in AGENTS.md (e.g., the links referenced
near the top and the block later in the file) and replace them with
".agents/rules/<rule-name>..." so documentation always points to the canonical
`.agents/rules/` files, then run the docs/lint checks (e.g., `pnpm
lint:rules:symlinks`) to ensure consistency.
In `@scripts/sync-agent-rules.mjs`:
- Around line 56-59: The comment incorrectly references statSync; update the
comment near the try block that calls readFileSync(fullPath) to state that
readFileSync is being used to verify the symlink target exists and is readable
(i.e., it follows the symlink and will throw if the target is missing), so
change the misleading "statSync follows the link" text to explicitly mention
readFileSync and fullPath and why it's called here.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 80231aa3-f593-4600-9fc1-388a748b986c
📒 Files selected for processing (85)
.agents/rules/README.md.agents/rules/adr-examples-must-match-code.mdc.agents/rules/adr-writing.mdc.agents/rules/arktype-usage.mdc.agents/rules/as-contract-cast-smell.mdc.agents/rules/avoid-cleavage-in-prose.mdc.agents/rules/capabilities-ownership.mdc.agents/rules/cli-e2e-test-patterns.mdc.agents/rules/cli-error-handling.mdc.agents/rules/cli-package-exports.mdc.agents/rules/cli-test-fixture-cleanup.mdc.agents/rules/config-validation-and-normalization.mdc.agents/rules/contract-default-values.mdc.agents/rules/contract-space-package-layout.mdc.agents/rules/control-plane-descriptors.mdc.agents/rules/cursor-markdown-file-links.mdc.agents/rules/declarative-config.mdc.agents/rules/directory-layout.mdc.agents/rules/doc-maintenance.mdc.agents/rules/family-instance-domain-actions.mdc.agents/rules/generic-parameters.mdc.agents/rules/import-validation.mdc.agents/rules/include-many-patterns.mdc.agents/rules/interface-factory-pattern.mdc.agents/rules/mermaid-compat.mdc.agents/rules/modular-refactoring-patterns.mdc.agents/rules/mongo-no-obsolete-commands.mdc.agents/rules/mongodb-memory-server-setup.mdc.agents/rules/moving-packages.mdc.agents/rules/multi-plane-entrypoints.mdc.agents/rules/multi-plane-packages.mdc.agents/rules/namespace-diagnostic-wording.mdc.agents/rules/no-backward-compatibility.md.agents/rules/no-barrel-files.mdc.agents/rules/no-direct-lockfile-edits.mdc.agents/rules/no-inline-imports.mdc.agents/rules/no-linear-sub-issues.mdc.agents/rules/no-target-branches.mdc.agents/rules/no-tautological-tests.mdc.agents/rules/object-hasown.mdc.agents/rules/omit-should-in-tests.mdc.agents/rules/postgres-lateral-patterns.mdc.agents/rules/prefer-assertions-over-defensive-checks.mdc.agents/rules/prefer-object-matcher.mdc.agents/rules/prefer-to-throw.mdc.agents/rules/query-patterns.mdc.agents/rules/read-agents-md.mdc.agents/rules/resolving-cyclic-dependencies.mdc.agents/rules/review-scope-overrides.mdc.agents/rules/schema-driven-architecture.mdc.agents/rules/shared-plane-packages.mdc.agents/rules/sql-types-imports.mdc.agents/rules/storage-type-hooks.mdc.agents/rules/test-database-limitations.mdc.agents/rules/test-file-organization.mdc.agents/rules/test-import-patterns.mdc.agents/rules/test-intent-readability.mdc.agents/rules/test-mocking-patterns.mdc.agents/rules/tsdown-config-package-source-only.mdc.agents/rules/tsdown-dist-layout-in-tests.mdc.agents/rules/type-extraction-from-contract.mdc.agents/rules/type-predicates.mdc.agents/rules/typed-contract-in-tests.mdc.agents/rules/typescript-patterns.mdc.agents/rules/use-ast-factories.mdc.agents/rules/use-contract-ir-factories.mdc.agents/rules/use-hash-constructors.mdc.agents/rules/use-if-defined.mdc.agents/rules/use-pathe-for-paths.mdc.agents/rules/use-timeouts-helper-in-tests.mdc.agents/rules/vitest-expect-typeof.mdc.claude/rules/drive-project-workflow.mdc.claude/rules/no-bare-casts.mdc.claude/rules/optimize-for-human-time-on-prs.mdc.cursor/rules-footprint.config.json.cursor/rules/README.md.cursor/rules/no-bare-casts.mdc.cursor/rules/optimize-for-human-time-on-prs.mdc.github/workflows/ci.yml.gitignoreAGENTS.mdpackage.jsonscripts/sync-agent-rules.mjsscripts/sync-agent-rules.test.mjsscripts/validate-rules.mjs
💤 Files with no reviewable changes (6)
- .claude/rules/drive-project-workflow.mdc
- .claude/rules/no-bare-casts.mdc
- .cursor/rules/no-bare-casts.mdc
- .claude/rules/optimize-for-human-time-on-prs.mdc
- .cursor/rules/README.md
- .cursor/rules/optimize-for-human-time-on-prs.mdc
…; fix misleading comment Addresses CodeRabbit review on PR #609: - AGENTS.md linked to the gitignored .cursor/rules mirror; durable docs now point at the canonical .agents/rules paths. - classify() comment said statSync but the code uses readFileSync. Signed-off-by: Will Madden <[email protected]>
## Why Follow-up fix to the merged TML-2705 work (#609, commit `74cb2c1`). That change consolidated agent rules into `.agents/rules/` and treated **both** `.mdc` and `.md` as valid rule extensions. But the agent harnesses (Cursor, Claude Code) only load `.mdc` files — a rule with a `.md` extension is silently never picked up. So: - `no-backward-compatibility.md` was a **dead rule**: tracked, symlinked into both presentation trees, and never loaded by anything. - The sync script and docs actively *blessed* the `.md` extension, so the same mistake could recur on the next rule someone authored. ## What changed - **Renamed** `.agents/rules/no-backward-compatibility.md` → `.mdc` so the rule actually loads (its frontmatter was already valid). - **`scripts/sync-agent-rules.mjs`**: rules are now `.mdc`-only. `README.md` remains the single mirrored `.md` (it's the index, not a rule). Any *other* `.md` in the canonical dir is rejected — a hard error in sync mode (`pnpm rules:sync` / the `prepare` hook), and reported as drift in `--check` mode (`pnpm lint:rules:symlinks`). The mistake now fails CI instead of shipping a dead rule. - **Docs**: `AGENTS.md` and the rules `README.md` no longer document `.{md,mdc}`; they state plainly that rule files must be `.mdc`. - **Tests**: updated/added cases covering the README-only `.md` exemption and the dead-`.md`-rule rejection in both modes. ## Scope Rules + the sync tool + its docs only. No product code touched. `pnpm lint:rules`, `pnpm lint:rules:symlinks`, `pnpm lint:rules:footprint`, and `pnpm test:scripts` (118 tests) all pass locally. Signed-off-by: Will Madden <[email protected]>
Linked issue
Refs TML-2705
At a glance
Cursor reads its rules from
.cursor/rules/, Claude Code from.claude/rules/. Our convention is that the real file lives once in.agents/rules/and each tool dir just symlinks to it. But.cursor/rulesis git-ignored — so when an agent drops a new rule straight into.cursor/rules(the obvious place), git silently ignores it and the rule is lost on the next clone. That's exactly what kept happening.The root cause:
.agents/ruleswas also git-ignored. There was no.gitignorewhitelist for it, so the "canonical" path couldn't actually hold a tracked file. The convention was documented but never enforceable.This PR makes the convention real and self-healing.
.agents/rules/becomes the one tracked copy; the tool dirs become regenerated symlink mirrors:Decision
.agents/rules/is the single source of truth;.cursor/rules/and.claude/rules/are git-ignored symlink mirrors regenerated from it — the same arrangement skills already use (skills-contrib/is canonical, the tool dirs are generated). Concretely, three pieces:scripts/sync-agent-rules.mjsconsolidates any stray real-file rule into.agents/rules, rebuilds both mirrors, and prunes dangling/orphan symlinks. Idempotent; errors on a real content conflict.--checkmode (pnpm lint:rules:symlinks) fails when a mirror drifts from canonical, wired into CI..gitignorefix — the actual bug..agents/rules/**is now tracked; the two mirrors stay ignored and are rebuilt byprepare, sopnpm installheals them automatically.How it fits together
.gitignoregoes from a blanket.agents/to.agents/*plus!.agents/rules/. A wholesale.agents/ignore can't have a subdir re-included; ignoring the children and re-includingrules/can. Skills and everything else under.agents/stay ignored. (Verified withgit check-ignore.)scripts/sync-agent-rules.test.mjs(13 cases on temp fixtures) pins consolidation, both-mirror symlinking, idempotency, dangling-symlink pruning, conflict detection, and read-only--check.rules:syncis appended toprepare(so install rebuilds the mirrors, exactly likeskills add),lint:rules:symlinksjoins the CI lint job, and the test joinstest:scripts..cursor/rulesmove into.agents/rules(git records them as clean renames), both mirrors become pure symlinks, and a long-dangling.claude/rules/drive-project-workflow.mdcis removed.validate-rulesnow reads canonical.agents/rules(present even beforeprepareruns). Doing so surfaced three rules with no frontmatter at all — fixed. The footprint thresholds are raised because consolidation finally loads several rules that were canonical-but-never-mirrored (see Reviewer notes).By the numbers
Before:
.cursor/rulestracked ~70 rule files directly, only 2 of them symlinks;.agents/rulesheld 11 canonical rules;.claude/ruleshad 3 symlinks, one dangling. After: all 78 rules live in.agents/rules, and.cursor/rules+.claude/rulesare 78 symlinks each and nothing else. (The 68 real files move; the 2 pre-existing symlinks and 11 already-canonical rules stay put.)Where to look
scripts/sync-agent-rules.mjs(+.test.mjs)--check; 13 tests.gitignore.agents/rules/**; keep the mirrors ignoredpackage.jsonrules:sync,lint:rules:symlinks; sync inprepare; test intest:scripts.github/workflows/ci.ymlscripts/validate-rules.mjs,.cursor/rules-footprint.config.json.agents/rules/README.md,AGENTS.md/CLAUDE.mdReviewer notes
.cursor/rules/* -> .agents/rules/*moves; the real review surface is the script,.gitignore,package.json, CI, and the docs.alwaysApply: truerules that were stranded in.agents/rulesand invisible to Cursor — e.g.git-staging,prefer-psl-in-design-docs,no-transient-project-ids-in-code— about 5 KB more always-on context. Worth a separate decision whether they should all stay always-on (see Follow-ups); this PR only raises the ceiling so CI reflects reality.fs.rmSyncgotcha. The script deletes symlinks withunlinkSync, notrmSync:rmSyncstats the link target and silently no-ops on a dangling symlink, so the dangling rule would never get cleaned up. There's a comment at the call site..agents/rules/README.md, symlinked into both mirrors). Full index reconciliation: dropped 7 entries for rules that no longer exist, added 14 that were missing — it now lists exactly the 78 real rules.Verification
pnpm lint:rules— passes (reads canonical; 3 newly-surfaced frontmatter gaps fixed)pnpm lint:rules:symlinks— consistent;rules:syncidempotent (second run = 0 changes); no broken symlinkspnpm lint:rules:footprint— passespnpm test:scripts— 114 pass (incl. 13 new)pnpm-lock.yamlunchanged; biome cleanFollow-ups
alwaysApply: truerules should stay always-on or be scoped (globs+alwaysApply: false).Alternatives considered
prepare, but it diverges from how skills work and means committing 156 symlink entries (78 rules × 2 mirrors) that move in lockstep with canonical anyway. We chose to mirror the skills model so there's one mental model for both.skillsCLI for rules.skills addonly understands SKILL.md packages; it has no notion of a.mdcrule file, so a bespoke script was needed regardless.Summary by CodeRabbit
New Features
Documentation
Chores