AI Rulebook — Cursor / VS Code extensionOne-line: This extension drops a curated set of AI agent rules into your project so Cursor (and Cline) reply more consistently — write cleaner code, keep docs current, frame answers for the right audience, and write proper tests when you ask for them.
What are AI rules and why use them?A "rule" is a short Markdown file you give the AI assistant. It tells the assistant how you want it to behave in this project — coding style, security defaults, doc-keeping habits, who the answer is for, what to test, etc. Cursor and Cline both load rules automatically when you chat with them, so the assistant follows your team's conventions without you having to remind it every message. This extension ships 27 ready-made rules grouped into 5 folders, plus a sidebar to turn them on and off, plus four modes (Plan / Build / Test / Role) that flip presets in one click. You don't have to write any rules yourself to get value — install, click "Install / update rules in workspace", and start chatting.
Quickstart
To opt out of the first-time auto-install, set
Sidebar tree view — turn rules on and offThe AI Rulebook sidebar (activity-bar icon, looks like a checklist) is the primary place to enable / disable rules. It shows every shipped rule grouped by subfolder and uses color so the on / off state is obvious at a glance:
What you can do from the sidebar:
Switching modes from the sidebar buttons only flips role and test rules — your always-on coding, documentation, and meta rules stay enabled. Manual changes you make via the checkboxes always win until the next mode switch. Same colors in the workbench ExplorerThe same color scheme also applies to rule files in VS Code's built-in
Explorer view: any All commandsEvery command lives under the AI Rulebook: prefix in the command palette. Install / update
Turn rules on or off
Modes
Global mirror (cross-project)The "global mirror" is a per-extension copy under VS Code / Cursor's global storage. You can populate it once and then push it into any project.
Inspect / refresh
ModesA "mode" is a one-click preset that turns specific rules on and others off. Always-on coding, documentation, and meta rules are not touched by modes — they keep running across every mode.
You can also flip individual rules manually any time, in the sidebar or via the command palette. Settings
Every rule that ships with this extensionFor longer descriptions read
|
| Rule | What it does |
|---|---|
write-clean-code.mdc |
Naming, function size, comments, explicit dependencies, clear errors. |
reuse-code-before-duplicating.mdc |
Search for existing helpers before adding new ones; extract on the third copy. |
organize-repository-by-feature.mdc |
Feature-first folders, tidy root, stable entry points, colocated tests. |
secure-code-data-and-dependencies.mdc |
Secrets, input handling, authorization, crypto, dependencies, logging. |
prefer-lts-stable-runtimes-and-libraries.mdc |
LTS or current stable releases, sensible pinning, security patches. |
verify-syntax-and-fix-before-finishing.mdc |
Re-checks touched files for syntax / type issues and fixes what's safe. |
remove-dead-code-and-unused-files.mdc |
Looks for unused code and orphan files; removes only when clearly safe. |
documentation-rules/
| Rule | When it runs | What it does |
|---|---|---|
update-changelog-for-notable-changes.mdc |
Always. | Keeps CHANGELOG.md current for user-visible changes. |
append-and-deduplicate-requirements.mdc |
Always. | Captures stated requirements in REQUIREMENTS.md; merges near-duplicates. |
use-this-format-for-markdown-files.mdc |
Only when editing *.md / *.mdx (or @-mentioned). |
Standard Markdown structure, lists, code samples, links. |
role-rules/ — off by default; turned on by mode commands
These change who the assistant is talking to.
| Rule | Audience framing |
|---|---|
role-developer.mdc |
Working software developer — skip basics, lead with code and trade-offs. |
role-architect.mdc |
Lead with constraints, boundaries, and 2–3 viable approaches. |
role-tester.mdc |
Lead with what to verify, expected vs. actual, and risk. |
role-cyber-expert.mdc |
Treat everything as threat surface; STRIDE / OWASP framing. |
role-product-manager.mdc |
Lead with user value, scope, sequencing, rollout risk. |
role-beginner.mdc |
Define jargon; full commands; one safe path; explain why. |
role-expert.mdc |
Skip foundations; surface non-obvious edge cases; primary sources. |
role-end-user.mdc |
No code or jargon; describe what the user sees, clicks, and gets. |
rules-for-rules/
| Rule | When it runs | What it does |
|---|---|---|
state-active-project-rules-in-prompt-response.mdc |
Always. | Makes the AI start its first reply with a list of every active rule, so you can verify what's loaded. |
evolve-rules-when-codebase-patterns-change.mdc |
Always (when not disabled). | Suggests new / updated rules when patterns stabilize across the codebase. |
write-cursor-rules-for-this-project.mdc |
Only when editing files under .cursor/rules/ai-rules/ (or @-mentioned). |
Spec for authoring & maintaining rule files: location, frontmatter, scope, quality bar. |
test-rules/ — off by default; turned on by Mode — Test
| Rule | Test type |
|---|---|
write-unit-tests.mdc |
Pure-logic units; arrange / act / assert; deterministic, fast. |
write-smoke-tests.mdc |
Critical happy paths only; fail-fast; block builds. |
write-regression-tests.mdc |
One test per fixed bug; reference issue / PR. |
write-integration-tests.mdc |
Real boundaries (DB, HTTP, queue); ephemeral environments. |
write-end-to-end-tests.mdc |
Top user journeys; stable selectors; flakes are bugs. |
Limitations — read this before you blame the rules
Rules are instructions to the model, not enforcement. The assistant chooses how to weigh them on every reply. In practice this means:
- Context is limited. Every active rule eats space in the model's context window. If you turn on 27 rules and include large files and a long chat history, the model may quietly drop or compress some rules. Symptom: rules you turned on don't appear to fire.
- Some rules are stronger than others. Always-on rules are loaded every
turn; glob-scoped rules only when matching files are open;
@-mentionedrules only on the turn you mention them. If a rule isn't firing, check the scope. - Models drift between turns. A rule may apply on the first reply and not
on the third. Re-mention it (
@write-clean-code) or restate the relevant expectation. - Different products read rules differently. Cursor and Cline don't have identical engines; Cline mirrors are best-effort.
- The "Active project rules" header is not guaranteed. Cursor depends on
the model to honor
state-active-project-rules-in-prompt-response.mdc. If the model skips it, mention@state-active-project-rules-in-prompt-responseonce in the chat.
Practical advice:
- Don't enable everything by default. Use Mode — Plan / Build / Test to match the work you're actually doing.
- For a big or complex task, turn off the rules you don't need that turn.
- If you want a rule to fire definitely,
@-mentionit in your message. - If a rule keeps getting ignored, shorten it. Compressed rules survive truncation better.
Security model
This extension only writes inside three well-known locations:
- the open workspace folder, under
.cursor/rules/ai-rules/and (if Cline is installed).clinerules/ai-rules/; - the extension's global storage under
<globalStorage>/ai-rules-mirror/ai-rules/— used by the global mirror commands; - nothing outside those paths.
Defenses applied:
- Manifest validation at activation. Each entry in
bundled/manifest.jsonmust be a forward-slash relative path matching^[A-Za-z0-9_./-]+$, with no..segments, no leading/or./, and ≤ 200 chars. A tampered or malformed manifest aborts activation with a clear error. - Path containment. Every operation that resolves a manifest entry under a base directory re-checks that the resolved path stays inside that base. Out-of-tree paths throw before any filesystem call.
- Destructive operations are gated by an explicit suffix check. The
workspace rules folder must end with
.cursor/rules/ai-rules; the global mirror withai-rules-mirror/ai-rules. A misconfigured constant cannot widen the blast radius ofrm -rf. - No symlinks during recursive copies. The
fs.cpcalls used to mirror the bundle filter out symbolic links; the directory walker skips them too. - No network access. The extension never makes outbound HTTP calls.
- No runtime dependencies.
package.jsonhas zerodependencies. The VSIX ships only compiled JS, the bundled rule files, an icon, the readme, changelog, and license. - No secret material. The extension never reads or writes credentials, environment variables, or anything outside the rule files listed above.
If you find a security issue, please open a private report on the issues
tracker (linked in package.json → bugs).
Develop
npm install
npm run sync-bundled # copy .cursor/rules/ai-rules → bundled/ai-rules
npm run verify:bundled # fail if bundled ≠ source (run after sync)
npm run compile # tsc → out/
Press F5 with this repo open in VS Code (or Cursor) to launch the Extension Development Host with the dev build.
The source of truth for rule text is .cursor/rules/ai-rules/. The VSIX
ships bundled/ai-rules/; the vscode:prepublish script runs
sync → verify → compile to keep them identical.
Package the VSIX (for the marketplace)
npm install
npm run sync-bundled
npm run verify:bundled
npm run compile
npx --no-install vsce package
This produces ai-rulebook-<version>.vsix in the repo root. To upload it
to the VS Code Marketplace:
- Sign in as the publisher (
WyvernSystemsLLC). - Choose New extension → Visual Studio Code.
- Upload the
.vsix.
For the Open VSX registry (used by Cursor's gallery), follow their publishing guide.
Notes
- Cursor user rules (app-wide) still live in Cursor Settings → Rules; this extension's "global mirror" is separate per-extension storage unless you copy it into a workspace.
- Cline may interpret YAML (
globsvspaths) differently from Cursor; treat Cline output as best-effort.