agentleFS
d3v0psdand3v0psdan/claude-skills/skills/cc-create-rule/SKILL.md

cc-create-rule

Skill0 starsChanged 5 months agoMITView on GitHub

Create a Claude Code rule file in .claude/rules/. Use whenever the user wants to add a rule, coding standard, convention, guideline, or persistent instruction that loads alongside CLAUDE.md — including path-scoped rules that only load for matching files (e.g. "only apply this to API files" or "a testing rule for test files"). Keeps instructions modular instead of bloating CLAUDE.md. Trigger this even if the user just says "add a convention/standard/rule for X" without naming the rules folder.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    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:

    Ask one question: does this apply everywhere, or only to certain files?

    line 29
  2. Distinctive:

    When in doubt, scope it. A path-scoped rule is the lighter choice, and it's the main reason to use a rule over CLAUDE.md.

    line 34
  3. Distinctive:

    Keep it like good CLAUDE.md content: short, specific, verifiable.

    line 38
  4. Distinctive:

    No contradictions: if two rules (or a rule and CLAUDE.md) disagree, Claude may pick one at random.

    line 91
  5. Very specific:

    Verify it loaded: run /memory in Claude Code — it lists every CLAUDE.md and rules file in the session.

    line 92
  6. Distinctive:

    If it's a procedure with steps, it's probably a skill.

    line 100

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill 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.

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

Create a Claude Code rule

A rule is a small markdown file in .claude/rules/ that loads into context as instructions — same priority as .claude/CLAUDE.md, but split out by topic so things stay tidy. A rule can also be path-scoped so it only loads when Claude touches matching files, which saves context.

Three quick steps.


Step 1 — Name the file by topic

One topic per file, descriptive name. It lives at .claude/rules/<topic>.md. Subfolders are fine (discovered recursively):

.claude/rules/
├── code-style.md
├── testing.md
├── security.md
└── frontend/
    └── components.md

Step 2 — Decide the scope

Ask one question: does this apply everywhere, or only to certain files?

  • Everywhere → no frontmatter. The rule loads at the start of every session.
  • Only certain files → add paths: frontmatter with glob patterns. The rule loads only when Claude reads a file that matches — keeping it out of context until it's relevant.

When in doubt, scope it. A path-scoped rule is the lighter choice, and it's the main reason to use a rule over CLAUDE.md.

Step 3 — Write it

Keep it like good CLAUDE.md content: short, specific, verifiable. Bullets over paragraphs. Aim well under ~50 lines.

Always-on rule (no frontmatter):

# Testing

- Run `npm test` before committing.
- Co-locate tests next to the source file as `*.test.ts`.
- Mock network calls; never hit live services in unit tests.

Path-scoped rule (paths: frontmatter):

---
paths:
  - "src/api/**/*.ts"
---

# API rules

- Every endpoint validates its input.
- Use the standard error response format.
- Include OpenAPI doc comments on each handler.

That's it — Claude Code discovers the file automatically. No wiring, no restart.


Glob cheat sheet for paths:

PatternMatches
**/*.tsall TypeScript files, any directory
src/**/*everything under src/
*.mdmarkdown files in the project root only
src/components/*.tsxReact components in one specific directory

Multiple patterns and brace expansion both work:

---
paths:
  - "src/**/*.{ts,tsx}"
  - "tests/**/*.test.ts"
---

Writing tips

  • Specific beats vague: "Use 2-space indentation" lands better than "format code nicely."
  • No contradictions: if two rules (or a rule and CLAUDE.md) disagree, Claude may pick one at random. Skim existing rules before adding.
  • Verify it loaded: run /memory in Claude Code — it lists every CLAUDE.md and rules file in the session.

Rule vs CLAUDE.md vs skill — quick pick

  • Rule → a standing instruction, especially one that only matters for certain files. Loads automatically.
  • CLAUDE.md → the few "always true everywhere" facts (build commands, layout, top conventions). Loads every session.
  • Skill → a multi-step procedure or workflow you invoke. Loads on demand, not always in context.

If it's a procedure with steps, it's probably a skill. If it's a "do it this way" instruction, it's a rule.

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.