agentinit / rules
Cursor rule1 starsChanged 12 days agoMITView on GitHub
Safety rules for writing to users' projects (manifest, managed blocks, apply engine)
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 4,144 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/agentinit-vitest.mdcCursor rule
- .cursor/rules/git-commits.mdcCursor rule
- .cursor/rules/pure-modules.mdcCursor rule
- .cursor/rules/registry-content.mdcCursor rule
- .cursor/rules/tests.mdcCursor rule
- commit-changesSkill
- implement-taskSkill
- new-featureSkill
- pr-summarySkill
- refactorSkill
- review-archSkill
- review-taskSkill
- write-fragmentSkill
- write-testsSkill
The file
We split this io-safety.mdc into the rules it gives an agent
7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 11
NEVER modify bytes outside a managed block (<!-- agentinit:begin id=… --> … <!-- agentinit:end id=… -->).
- Very specific: line 12
NEVER guess on malformed markers (missing end, nested, duplicate ids).
- Very specific: line 13
NEVER overwrite a file that is unmanaged or hand-edited (hash mismatch) without the user's choice or --force.
- Distinctive: line 15
ALWAYS hash content with line endings normalized to LF.
- Distinctive: line 16
ALWAYS write atomically: temp file in the same directory, then rename.
- Very specific: line 17
ALWAYS make dryRun and doctor paths write nothing, including .agentinit/.
- Distinctive: line 19
ALWAYS test in temp directories and assert byte-for-byte preservation of user content.
≈ “Common” is an estimate: at least 1 in 5 of the 6,668 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: Safety rules for writing to users' projects (manifest, managed blocks, apply engine)
globs: src/io/**/*.ts
alwaysApply: false
---
# Safe Writes
The product promise is "never overwrite user content." Every change here must keep that promise.
- NEVER modify bytes outside a managed block (`<!-- agentinit:begin id=… -->` … `<!-- agentinit:end id=… -->`).
- NEVER guess on malformed markers (missing end, nested, duplicate ids); throw an `AgentInitError` naming the file.
- NEVER overwrite a file that is unmanaged or hand-edited (hash mismatch) without the user's choice or `--force`; `--force` ALWAYS backs up first to `.agentinit/backups/<timestamp>-<suffix>/`.
- **Exception (PRD §6.3):** a stale hand-edited `.cursor/commands/*.md` leftover from 0.1.0 is backed up and removed even with `--yes`, so Cursor does not list the old command alongside the new skill.
- ALWAYS hash content with line endings normalized to LF; ALWAYS preserve a file's existing line endings when writing.
- ALWAYS write atomically: temp file in the same directory, then rename; write the manifest last.
- ALWAYS make `dryRun` and `doctor` paths write nothing, including `.agentinit/`.
- Inject the clock and the `Prompter`; NEVER call `Date.now()` or prompt directly.
- ALWAYS test in temp directories and assert byte-for-byte preservation of user content.
```ts
// ✅ Good: replace only the block's inner content
const next = upsertBlock(current, 'core', inner);
// ❌ Anti-pattern: regenerate the whole file
await writeFile('AGENTS.md', renderAgentsMd(plan));
```
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

