/live-rules:add-rulefrom live-rules
Create or edit a project rule file in Claude Code's native rule directory, kept current in context by live-rules. Use to add a rule, coding guideline, guardrail, convention, or automatic reminder.
Ships in live-rules. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Turn a request like "always run the linter before committing" or "when editing *.tsx, prefer
function components" into a rule: one Markdown file in a native Claude Code rule directory.
Claude Code reads those files itself. Live Rules owns no storage; it adds timing on top of them, so an edited rule takes effect mid-session and a keyword-scoped rule fires on a matching prompt.
Read references/rule-format.md for the full frontmatter spec and references/example-rules.md for
ready-to-adapt examples before writing a rule.
Do not edit CLAUDE.md or CLAUDE.local.md. Rule files are the delivery mechanism.
Decide where the rule goes before writing it, and ask one short question when the answer is not obvious. The destination is a question about who the rule is true for, never about what is installed.
| True of... | Destination | Committed |
|---|---|---|
| this repo, for anyone who clones it | .claude/rules/<name>.md | yes |
| this repo, for this user only | .claude/rules/<name>.local.md | no, gitignored |
| this user everywhere | ~/.claude/rules/<name>.md | not in this repo at all |
.claude/rules/<name>.md. The project's stack, conventions, tooling, and test
commands. Commit it so the whole team gets the same guidance..claude/rules/<name>.local.md. A local path or a habit confined to
this one project. Claude Code loads it because it sits in that directory; a
.claude/rules/*.local.md line in .gitignore is the only thing keeping it out of git. Confirm
that line exists before choosing this destination and offer to add it when it does not, because
without it the file is a committed rule wearing a personal name. Promoting it later is a rename to
<name>.md.~/.claude/rules/<name>.md, in the user's own config tree, which Claude
Code reads in every project. Response format and length, voice, tone, punctuation, and
cross-project workflow habits are always this row. They are never project rules, so never write
them into the repo however strong this project's evidence looks: the evidence is about the user,
and the repo is the one place the rule would not follow them.Live Rules never writes or reads ~/.claude/rules/. A rule placed there is Claude Code's alone to
load; this skill's job is to put the instruction in the right file.
Pin down two things from the user's request:
httpx, not requests) rather than vague ("write good code").| The user says... | Scope | Frontmatter |
|---|---|---|
| "always", "in general", "house style", no condition | global | no scope fields |
| "when editing / for / in *.tsx", a file type, path, or directory | path | paths: |
| "when I ask about / mention deploy/migration/auth" | prompt-keyword | prompt: plus the never-match sentinel |
paths: is Claude Code's own scope key, and it covers what the retired globs: and dirs: keys
used to split: a bare directory name such as packages/api selects everything under it. globs:
and dirs: still parse for one release with a deprecation notice on stderr, but never write them
into a new rule.
Keyword-only rules need a never-match path scope. A rule with prompt: and no real path scope
must carry this exact value:
paths: [".live-rules-never-match/**"]
Without it, Claude Code sees a file with no paths: and loads it as a global rule, so the keyword
trigger would mean nothing. Live Rules recognises that exact string, never matches it against a real
path at any depth, and keeps delivering the rule on a keyword match. Write it verbatim; do not invent
a variant.
A rule may combine a real paths: with prompt:; it is injected when either condition matches. If
you are unsure whether something is global or scoped, ask one short question rather than guessing,
because an over-broad rule adds noise.
Including a live file. If the request is "load my codebase map", "keep <file> in front of
you", or "inject the contents of <file>", use the include: field, not a scope. Add
include: <path> and write the body as the protocol for using that file. The file is read fresh each
time the rule is injected, and a missing include makes the rule silent. A pure-include rule is global.
See the "Including a live file" section of references/rule-format.md.
Create or edit one file at the destination chosen in Step 1. Use a stable, descriptive filename such
as commit-checks.md. A rule file contains one frontmatter block, one body, and one concern:
---
description: Short human title (also shown as the rule's heading when injected)
paths: ["**/*.tsx"] # include only the scope fields that apply; omit the rest
priority: 0 # optional; higher injects first (default 0)
reground: true # optional; re-say this rule every 20 prompts in a long session
---
- Write the rule body as tight, imperative bullet points.
- One concern per file; add another rule file rather than overloading this one.
Saving the file is the whole operation. There is no index to regenerate and no sync step to run: Claude Code and the hooks both read the directory, and content hashes are computed on every read.
Only *.md at the top level of .claude/rules/ gets live-rules timing. A rule in a subdirectory
still loads natively but is never re-grounded mid-session, so keep new rules at the top level.
There is no enabled: key. Disabling a rule is a rename to <name>.md.off, which hides it from
Claude Code and from the hooks at once. Use manage-rules for that.
A project still holding a pre-2.13 .claude/live-rules/ store or a legacy .claude/live-rules.md
file should be migrated before new rules are added, with the plugin-owned migration script run from
the project root:
node "${CLAUDE_PLUGIN_ROOT}/scripts/migrate-rules.js" --project "${CLAUDE_PROJECT_DIR}"
It moves the rule files to .claude/rules/, rewrites globs:/dirs: to paths:, splits a legacy
single-file store into per-rule files, and adds the .claude/rules/*.local.md line to an existing
.gitignore. It refuses on a filename collision having written nothing, and is idempotent. Pass
--dry-run first to show the user what it would do.
Guidelines for a good rule:
--- in the body. A line that is exactly --- would be read as another rule's fence.
Use *** or ___ for a horizontal rule inside a body.paths: patterns are gitignore-style: a pattern with no / (like *.sql) matches that name at
any depth; a pattern containing / (like src/**/*.ts) is anchored to the repo-relative path.Before finishing:
.local.md choice has its
.gitignore line.paths: patterns correspond to files that exist, or clearly will, in this repo. If a
pattern matches nothing, say so.prompt entry is a /regex/flags, make sure it is valid.paths: sentinel exactly as written above.Tell the user what you added: the rule's title, the file it went in, the scope, and a one-line summary. Explain the cadence honestly:
paths: rule are
already in context without live-rules saying anything. Those reach subagents too.For a committed project rule, remind them to review and commit the file so the team shares it. For a
.local.md or ~/.claude/rules/ rule, say plainly that it is not committed. They can disable any
rule by renaming it to .md.off or by asking manage-rules.
CLAUDE.md or CLAUDE.local.md.~/.claude/rules/,
not into the repo.local.md destination was confirmed against a .claude/rules/*.local.md .gitignore linedescription, the correct scope fields, and a concise bodypaths: sentinelpaths: patterns match real paths; any regex compiles)--- in its bodyCLAUDE.md is untouchedreferences/rule-format.md - full frontmatter spec, the three rule layers, native loading, cadence, scope semantics, and paths: syntaxreferences/example-rules.md - copy-and-adapt examples for each scope type and destinationWhat SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
2 skills in this plugin
npx claudepluginhub poindexter12/loadout --plugin live-rules