agentleFS
pahlevikunpahlevikun/levistack/skills/agent-authoring/create-rule/SKILL.md

create-rule

Skill0 starsChanged 57 days agoMITView on GitHub

Create, audit or tighten persistent rules for coding agents: .claude/rules/*.md, .cursor/rules/*.mdc, a catalog rules/ tree, CLAUDE.md or AGENTS.md. Use when asked to add a rule or coding standard, scope a rule to file globs or paths, fix a rule the agent ignores, or decide whether something is a rule, a skill or a hook.

10 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use review-security and create-pr.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • PydanticSkill

    review-security

    Security review of the current branch against its merge base — sandbox escapes, memory errors, panics and resource-limit bypasses. Use when reviewing changes for security risk, or before merging anything touching the heap/ module, path_security.rs, the wire protocol or the pool.

    Also in 3 projects that use this

  • SentrySkill

    create-pr

    Create pull requests following Sentry conventions. Use when opening PRs, writing PR descriptions, or preparing changes for review. Follows Sentry's code review guidelines.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 6 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 10 edited versions we read keep these.

  • 6

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    A rule earns its tokens every session: If it only matters for one task, make it a skill.

    line 12
  2. Distinctive:

    Give the reason in one clause: when it is not obvious, so the agent can judge edge cases.

    line 15
  3. Distinctive:

    No contradictions: Read the existing rules first.

    line 17
  4. Distinctive:

    Scope as narrowly as is true: Always-on only for what holds in every task.

    line 18
  5. Distinctive:

    Test it: Start a fresh session, do a task the rule covers, and confirm it was followed.

    line 48
  6. Distinctive:

    Put secrets, personal paths or employer names in a shared rule.

    line 52
  7. Very specific:

    Write globs: *.ts unquoted (YAML reads * as an alias).

    line 53

“Common” is measured: kept by at least 6 in 10 of the 10 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Create a rule

A rule is a short, standing instruction that is loaded into context, always or when matching files are touched. It guides; it does not enforce. If an action must be blocked every time, use a hook.

Principles

  1. A rule earns its tokens every session. If it only matters for one task, make it a skill. If it must be enforced, make it a hook.
  2. One concern per rule, under 50 lines. Split a long rule by topic.
  3. Say what to do, concretely. "Use snake_case for Python functions" beats "follow naming conventions". Give a good and a bad example when the fix is not obvious.
  4. Give the reason in one clause when it is not obvious, so the agent can judge edge cases.
  5. Do not restate a linter or formatter. Point to the tool's command instead.
  6. No contradictions. Read the existing rules first. Edit an overlapping rule rather than adding a competing one.
  7. Scope as narrowly as is true. Always-on only for what holds in every task; otherwise scope by globs or by description.

Rule, skill, hook, or AGENTS.md?

It is...Use
A standing preference or constraint for every taskAlways-on rule, or AGENTS.md / CLAUDE.md for repo facts and commands
A convention for certain files (**/*.ts, migrations/**)File-scoped rule
A procedure with steps, run on demandSkill (create-skill)
Must be enforced, blocked or automatedHook (create-hook)

Steps

  1. Gather requirements. Infer from the conversation; ask only for what is missing:
    • what the rule enforces or teaches;
    • scope: always, certain files (concrete globs, not "the backend"), or by description only;
    • target: which tool and which folder (step 3). You may write several rules when the conversation covers distinct topics.
  2. Check overlap. List the rule files in the target tree and read the nearest ones.
  3. Pick the format by target. Details and frontmatter are in formats.md.

    TargetFile
    Claude Code.claude/rules/<name>.md, optional paths:
    Cursor.cursor/rules/<name>.mdc with description, globs, alwaysApply
    A shared catalogrules/<topic>/<name>.md; a sync step may generate the .mdc copies
    Both tools, one repoFollow what the repo already does (often one tree symlinked into the other)
  4. Write it from templates/rule.md. Lead with the instruction, not a title paragraph. Quote YAML values that contain :, # or start with *.
  5. Check it. node scripts/check-rule.mjs <file-or-dir> catches YAML traps, a rule that can never apply, contradictory scope fields and oversize. In a repo with its own validation (for example npm run validate), run that too.
  6. Test it. Start a fresh session, do a task the rule covers, and confirm it was followed. For a file-scoped rule, open a matching file and a non-matching one. If it is ignored, shorten it, make it more specific, or move enforcement to a hook.

Do not

  • Put secrets, personal paths or employer names in a shared rule.
  • Write globs: *.ts unquoted (YAML reads * as an alias). Write globs: "**/*.ts".
  • Mark everything alwaysApply: true. Always-on rules compete for attention.
  • Duplicate a rule in two folders by hand. Generate or symlink instead.

Done when

  • The file is in the right folder for its tool, with frontmatter that tool reads.
  • check-rule.mjs reports no errors and the repo's own validation passes.
  • The rule is one concern, concrete, and does not contradict another rule.
  • A fresh session followed it on a real task.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.