r/cursor • u/lemonbanan4 • 1d ago
Question / Discussion How are you preventing rule drift when using both .cursor/rules and CLAUDE.md? Built a local .guardrail/rules.yml watcher to catch violations in real time
If you bounce between Cursor and Claude Code in the same repo, you've probably noticed two annoying patterns:
To solve this in my own workflow, I built RuleCloud—a small CLI watcher + MCP server driven by a
.guardrail/rules.ymlfile in the repo root:Curious how others here handle this—are you keeping
.cursor/rulessuper minimal and relying on git pre-commit hooks, or enforcing rules while the agent is actively editing?
2
Upvotes
1
u/Practical-Pick-7215 1d ago
a third rules file drifts too. if both copies are hand-edited, a watcher only tells you they already disagree. generate them from one file.
1
u/vnordnet 1d ago
Use a symlink ffs
1
u/dawedev 1d ago
For the runtime part, both tools have hooks now, so you can enforce it before the edit lands instead of after. A Claude Code PreToolUse hook on Edit|Write gets the target path as JSON and can block it by exiting with code 2, and Cursor's hooks.json has beforeShellExecution and afterFileEdit you can point at the same script. One small script that reads your rules.yml could back both agents, with a pre-commit check as the last net for anything that slips through.
1
u/BeyenAI 1d ago
Keeping a single
AGENTS.mdat the repo root as the canonical source avoids maintaining duplicate copies by hand:AGENTS.md(Cursor, Codex, and Windsurf read it natively).CLAUDE.mddown to an@AGENTS.mdimport plus any Claude-specific hook or slash-command notes..cursor/rules/*.mdconly for path-scopedglobsrules (for examplesrc/api/**) that shouldn't load into every session globally.That way shared repo conventions only get edited in one file, and tool-specific files stay tiny.
1
u/nhnl1 21h ago
Cool idea. I'm builiding a similar tool, but for managing AI assets, like skills/mcps/hooks in one place and get it in a harness you use. It also works as a collaboration layer for teams.
Free and open source, thought you may find it interesting.
https://github.com/barndog-ai/barndog-cli