agentleFS
paultyngpaultyng/skill-issue/skills/create-rule/SKILL.md

create-rule

Skill8 starsChanged 3 months agoMITView on GitHub

Use when creating, writing, or updating a Claude Code rule file (.claude/rules/*.md or ~/.claude/rules/*.md), or when asking about rule format, path scoping, or rule best practices.

We split this skill into the rules it gives an agent

8 rules. 0 are common, 6 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 18 edited versions we read keep these.

  • 6

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If the instruction only makes sense for certain file types (e.g.

    line 18
  2. Distinctive:

    Use always-load (no frontmatter) for:

    line 48
  3. Very specific:

    Test files: /*_test.go, /*.test.ts, /*.spec.ts

    line 54
  4. Distinctive:

    Markdown structure: use headers and bullets, not dense paragraphs

    line 64
  5. Very specific:

    Use RFC 2119 key words for requirement levels (MUST / SHOULD / MAY), sparingly and only for genuine requirements.

    line 66
  6. Distinctive:

    New or update?: Check existing rules in the target directory for overlap

    line 70
  7. Distinctive:

    Duplicating defaults: don't document what Claude already does correctly

    line 89
  8. Distinctive:

    Workflow steps in rules: if it's a multi-step process, use a skill instead

    line 93

“Common” is measured: kept by at least 6 in 10 of the 18 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 Rule

Rules vs CLAUDE.md vs Skills

Choose the right mechanism before writing anything:

MechanismWhen to useLoads
RuleBehavioral instructions scoped to a topic or file typeEvery session (or on path match)
CLAUDE.mdBroad project context: build commands, architecture, workflowsEvery session
SkillRepeatable on-demand workflowsOnly when invoked

If the instruction only makes sense for certain file types (e.g. Go, test files), use a path-scoped rule. If it's a repeatable task workflow, use a skill instead.

Storage Locations

ScopePath
Personal, all projects on this machine~/.claude/rules/<topic>.md
Project, shared with team via git.claude/rules/<topic>.md

Rules in subdirectories are discovered recursively (e.g. .claude/rules/frontend/react.md works).

Rule File Format

---
paths:            # optional; omit for always-load
  - "**/*.go"
  - "**/*_test.go"
---

# rule-name

Instructions...

No paths frontmatter → rule loads every session. paths present → rule loads only when Claude opens a matching file.

Path Scoping Decision

Use always-load (no frontmatter) for:

  • Universal behaviors: commit style, escalation policy, output verbosity
  • Toolchain choices: task runner, package manager, CI tooling

Use path-scoped for:

  • Language conventions: **/*.go, **/*.ts, **/*.py
  • Test files: **/*_test.go, **/*.test.ts, **/*.spec.ts
  • Domain directories: src/api/**/*, e2e/**/*.go, migrations/**/*.sql

See references/rule-patterns.md for glob pattern examples.

Writing Effective Rules

  • Specific and verifiable: "Use 2-space indentation" not "format code nicely"
  • One topic per file with a descriptive filename (testing.md, api-design.md)
  • Under 200 lines. Longer files reduce adherence; split if growing large
  • Markdown structure: use headers and bullets, not dense paragraphs
  • No contradictions across rule files; audit when adding new ones
  • Use RFC 2119 key words for requirement levels (MUST / SHOULD / MAY), sparingly and only for genuine requirements. See the normative-language rule. For a requirement that is also frequently violated, add a short "Frequently missed:" lead-in.

Workflow

  1. New or update? Check existing rules in the target directory for overlap
  2. Scope: personal (~/.claude/rules/) or project (.claude/rules/)?
  3. Path scope: universal (no frontmatter) or file-type specific?
  4. Check for conflicts: scan existing rules for contradictions or duplication
  5. Write the file: concrete, verifiable instructions; one topic
  6. Verify: confirm file is under 200 lines and uses specific language

Authoring Checklist

  • Description starts with "Use when..." if this is actually a skill (wrong tool if so)
  • Topic is focused: one concern per file
  • Path scope matches actual applicability (don't always-load a Go-only rule)
  • Instructions are concrete and verifiable, not vague
  • No contradictions with existing rules in the same directory
  • File is under 200 lines

Anti-Patterns

  • Vague rules: "write clean code", "be consistent". Not actionable
  • Duplicating defaults: don't document what Claude already does correctly
  • Over-specifying: bloated rule files cause Claude to ignore them
  • Wrong scope: file-type-specific rules (Go, SQL) in always-load waste context
  • Contradictions: two rules giving conflicting guidance on the same behavior
  • Workflow steps in rules: if it's a multi-step process, use a skill instead

Additional Resources

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.