/rerail:rerail-createfrom rerail
Suggests, writes, tests, tunes, and approves Rerail rules for a repository. Uses session history, standards, and design docs to create code/command/architecture rules, tests them, and manages approval workflow.
Ships in rerail. 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.
A Rerail rule checks the coding agent's work while it works, and tells the agent ("steers" it) when the work breaks the rule. A good rule catches what a reviewer of this repo would catch, and is right every time it fires. One that steers the agent to break working code is worse than no rule.
You do four things here. You suggest rules from evidence, you write and test one, you tune a rule that misfires, and you audit a
rule that waits for approval. The person decides what steers, and approves each rule themselves on its page in the
dashboard: from your session rerail rules approve is refused. Every rule you add runs in Log until then, so the person
sees it on the dashboard before it steers.
A rule Rerail did not publish (one created by you, one in a worktree's .rerail/rules/, a third party's or a folder's pack)
steers no one until a person approves its content; until then it runs in Log. A dashboard link you pass on shows the
dashboard only in a browser already connected to Rerail: say so with it, and that for another browser the person runs
rerail manage in a terminal. An edit waits again. From your session, an
edit of the person's approved rule is saved as a copy (<id>-copy) that runs in Log beside it, and the rule keeps running
as it is until the person approves the copy, which turns the original off.
/rerail-create command named. Without one, use ~/.rerail/bin/rerail if it exists, else
rerail. Below it is written rerail. Paste it in full each time; it may start with an environment assignment, which does not
survive being put in a shell variable.<tmp>/<short-kebab-name>.rerail, the rule
and its tests in one file. Never write rule files, instruction files (CLAUDE.md, AGENTS.md, Cursor rules) or tests into
the repository. The one rule file you write in the repo is a rule the person keeps to this worktree, and only once they
say yes (Write, step 7).| File | Read it when |
|---|---|
| references/suggesting-rules.md | you suggest rules: evidence, the value model, the shortlist |
| references/code-rules.md | you draft a rule over the code in files |
| references/conversation-rules.md | you draft a rule over a command the agent runs (internal testing) |
| references/architecture-rules.md | the rule is about where code belongs or which way dependencies run, or the person asks for architecture rules |
| references/rule-quality.md | you check a draft before showing it, and when you tune a rule |
| references/approving-rules.md | you approve a rule or pack you did not write in this session |
◆ Rerail message the person disputes): go to Tune. A change the person
asks for is its misfire: the code the rule now gets wrong.rerail rules approve lists them, rerail packs list says
"waiting for approval"): go to Approve.Read references/suggesting-rules.md first, and the Harmful steering section of rule-quality.md, which the scoring needs.
Gather the evidence. Do these at the same time:
rerail rules evidence --json. This returns the person's corrections in this repo's sessions with what the agent had just
done, risky commands the agent ran, how often each rule steered, and the files where the repo writes down its standards.
It covers every coding agent and every worktree of the repo, for the last 30 days. Add --days 90 if that is thin.
repository.known: false means Rerail has recorded no session here yet; suggest from the standards and the code, and
mention that /rerail-start lets Rerail gather evidence for next time.logger
and 3 call console.log.rerail rules export --output <tmp>/rules.json, to see the person's own rules and avoid duplicating them.Turn the evidence into candidates. Write one checkable sentence each, in the person's own words. Never turn a "should" into a "must". Score each candidate with the value model and drop the ones it says to skip.
Pick the shortlist: at most five, best first. If nothing is worth a rule, say so in one line, ask what the person finds themselves correcting, and add nothing.
Write and test each one, as Write steps 1 to 5, without the read-back: pin down what it means, choose the kind, write the cases, test, get it reviewed. Only code rules: leave out a candidate that would be a conversation rule, and name it under Left out. A candidate that fails a gate, or does not pass after about five rounds, is left out too.
Add the ones that pass, in Log. First leave out a candidate that does the same as a rule in rules export, and say
so under Left out. Then give each a new id if its id is taken, by a rule in rules export or a By Rerail rule
(rerail rules show <id> prints one): rules add would change that rule, or save the draft as an edited copy of it.
For each: rerail rules add <tmp>/<name>.rerail. A rule that is added but not approved runs in Log whatever its mode:
Rerail records what it would catch and tells the agent nothing. It waits on the dashboard's Overview, under "Your coding
agent added …", and the person approves it from its page there.
List them, in exactly this form. One block per rule added, in the order added:
I added <N> rules to <repo>. Until you approve them, they run in Log: Rerail records what each would catch and tells
no one. Approve each one you want on its page in the dashboard; once approved, each runs in its own mode.
1. <the title, as the dashboard will list it>
From <the evidence, e.g. "you corrected this 3 times">
Where it runs When I edit a file under <folder>
Tells the agent "<its message, quoted exactly>"
Once approved Steer: I'm told in the session and fix it | Log: Rerail keeps a record. I'm not told.
Tested Would have caught <N> places in this repo (<path:line>, …)
2. …
Left out: <candidate>: <why, in one line>
Approve them on their pages: <the dashboard link rules add printed for each>. The dashboard's Overview also sends you
to them, in Created by you. Want one changed first, or to see one's rule file? Say which.
.description word for word, so the person approves the name they will find in
Created by you. The rows follow Write step 6's card: name the excludes that matter in Where it runs, and the folders
in Tested where repository.folders is not [""]. A row you are unsure of reads Not sure, and that rule's Once
approved is Log.Reviewed: by me only above the list when no fresh subagent reviewed the drafts.rules add printed no link (the daemon is not running),
write rerail manage opens the dashboard in its place. Pass on its line saying the repo was set up, if it printed one.rerail rules approve <id> for the person: it is refused from your session, and their approval on the
rule's page is the point.Answer what the person says. To see a rule, print its file. To change one before they approve it, change it as Tune does (raise its revision, test again), add it again, and show its block alone. Any rule can be removed from its page on the dashboard.
Offer to show one working, as Write step 8, once the person says they approved one set to Steer.
Pin down what it means. Restate the rule to yourself as one sentence: what is forbidden, where, and what to do instead. If
the person's words can be read two ways, ask one question. If it cannot be checked mechanically ("write clean code", "good
names"), say "I can't check this reliably", offer a narrower version that can be checked, and add nothing. Check
rerail rules export --output <tmp>/rules.json for a rule of the person's that already does this; offer to change that one
instead.
Choose the kind. A code rule checks files, and is written in .rerail; read
references/code-rules.md. Write it in JSON only for what .rerail cannot do yet
(When to write JSON), and say why in the read-back. A conversation rule
checks a command the agent runs, and is JSON; read references/conversation-rules.md. Conversation
rules are experimental and off unless RERAIL_EXPERIMENTAL_CONVERSATION_RULES=1 is set; Rerail's latest release ships
code rules only. Write one only when the person asks for a rule over a command, and only while rerail rules test
accepts the draft: when it answers that conversation rules are experimental and off, tell the person in one line and
offer a code rule if one would do.
local:<short-kebab-name> and revision 1 (.policy "local:<short-kebab-name>" revision 1). Check
the id is free: not in rules export, and rerail rules show <id> finds no rule..description in the person's own words, as they wrote or said it, cut down to the rule itself: the
dashboard lists the rule by it, and rules add refuses a rule without one. With no words of theirs (a rule from
evidence), write the sentence they would put in a list of house rules.
Writing the description says how. A JSON rule carries the same
words as its title..mode). Use steer when you are sure of the rule. Use log when the repo pass or the meaning leaves
doubt. Never use block.Write the tests before the rule. A code rule's cases are its .test blocks
(Tests); a JSON rule's are its cases. You need at least two places the rule must
report and at least two it must let through.
exactly, so a test of what it reports also shows what it lets through.Test, and fix the draft until it passes:
rerail rules test <tmp>/<name>.rerail --json
It runs the file's tests, then the rule over the repository (a JSON draft: its cases, then the same repo pass). Then apply the gates in references/rule-quality.md:
tests passes, and the tests you wrote are among them: a test in testsNotRun did not run and proves
nothing (a JSON draft: every one of cases comes out right; one marked not checked, notChecked, is not right).repository.matches, and decide whether each is a real violation. A match with no line is the
file's path. A rule across files reports one side: check the other side is there for each match.repository.folders are the folders the repo pass covered: where rules add would have the rule run ("" is the
whole repo). A match outside them is not counted, since the added rule would not catch it.refusal, when the report has one, is why rules add would refuse the draft as it is. Fix the draft and test it
again before the card. repository.notNarrowed, when there, means the count may not be what the rule would catch:
say so on the card.repository.notCompleted: the run stopped past its deadline or memory budget, or failed, and says why. It lists
no match and is never a pass. Past a budget, the rule costs too much: make it cheaper
(Cost) and test again.repository.unchecked is what the rule could not check: per file for a JSON draft (unchecked.files), for the
whole rule for a .rerail one (unchecked.unattributed). repository.leftOut counts files and folders the repo pass did not read: hidden, secret-named, or ignored
by Git. Its matches say nothing about those. repository.binary counts files in scope it skipped as binary.After about five rounds without passing, stop and tell the person what does not work.
Get it reviewed. If you can start a fresh subagent, give it the draft, the test report and
references/rule-quality.md, and ask it to find a way the rule misfires or misleads. Fix what it
finds, then test again. If you cannot, make a separate pass yourself: go through every question under
Harmful steering against the draft, try to write one case that breaks it, and
put Reviewed: by me only above the card.
Read it back, in exactly this form, and ask once:
Here is the rule as I understand it.
Listed as <the description, as the dashboard will list it>
What it checks <in plain words>
Where it runs When I edit a file under <folder> | When I run <command> | When you or I say <…>
Applies to All of <this repo's name> | This worktree only (<its folder name>)
What happens Steer, once you approve it: Rerail tells me as I work, and I fix it. Until then it runs in Log.
How often Every time | The first time only
Tested Would have caught <N> places in this repo | Would have caught <N> places under <folder>/
Add this rule?
1. Yes, add it
2. Change something
3. Show me the rule
4. Cancel
.description word for word (a JSON rule's title), so the person sees the name
they will find in the dashboard.
Applies to is "All of " unless the person asked for this worktree, branch or experiment only; repo is the
name rules test and rules add use (the checkout's folder name). Where it runs names the
excludes that matter: "When I edit a file under src/ (not src/scripts/ or tests)", "When I edit any .py file (not
under .venv/)", and both sides of a rule across
files: "When I edit a module in src/cli/ or its test in test/cli/". How often is "Every time" for a code
rule; for a command rule it follows repeat.mode (always: Every time, once: The first time only).repository.folders is not [""], the
count covers only those folders, so name them in place of "in this repo": "Would have caught 2 places under src/,
web/ (…)". A rule across files says what is missing, as the whole row: "3 modules in src/cli have no test in
test/cli (src/cli/deploy-cli.ts:1, …)". A run
that did not complete makes the row Not sure: its run over this repo did not complete, and the rule Log. A command
rule gets no repo pass, so its Tested row gives the cases: "Caught 4 of 4 cases, let 5 of 5 through". That alone is
no reason for Not sure.rerail state must print started and rerail state --set-up must print set-up. Otherwise put one line above the card: the rule will not run until Rerail is started
here and the repo set up (/rerail-start does both).Not sure. Below the card, show one line from this repo that the rule catches and
one that it misses, and set the rule to Log.Checked against history: caught the first draft of #123; quiet on its merge and on 15 recent merged PRs.Experimental: this kind of rule is not part of Rerail's latest release, and runs only while RERAIL_EXPERIMENTAL_CONVERSATION_RULES=1 is set for the daemon, or for Pi itself when Pi runs Rerail in process.Add it, only after the person says yes. For all of the repo:
rerail rules add <tmp>/<name>.rerail
It runs the file's tests again, and refuses the rule if one fails. It runs in Log until the person approves it on its page in the dashboard; rerail rules approve is refused from your
session. Reply in one line, ● <what it checks> is added, set to <Steer|Log>. It runs in Log until you approve it on its page: <the link the command printed>. (the command prints the link when the Rerail daemon is running; without one, say
rerail manage opens the dashboard). Pass on its line saying the repo was set up with this rule, if it printed one.
For this worktree only, write the rule into the worktree's own rules folder instead; there is nothing to add:
<worktree top level>/.rerail/rules/<short-kebab-name>.rerail (git rev-parse --show-toplevel gives the top level). A file it includes from beside it goes in .rerail/rules/lib/. A JSON rule is
the draft's rule object alone, without kind or cases, in .rerail/rules/<short-kebab-name>.json.rerail packs list there. The rule must be listed under "This worktree's own rules". A left out: line naming the
file says why it did not load; fix the file, or delete it and tell the person. A Not running: line means Rerail is off
here or the repo is not set up; pass it on as written.git check-ignore -q .rerail/rules/<short-kebab-name>.rerail fails, the file is not ignored: say that committing it puts
the rule in every checkout of the branch, and offer to add .rerail/rules/ to .git/info/exclude. Change nothing in Git
without a yes.● <what it checks> is in this worktree only, set to <Steer|Log>. It runs in Log until you approve it on its page in the dashboard. (rerail manage opens the dashboard.)Offer to show it working (code rules only), once the person says they approved it. Ask: "Want to see it fire? I'll write a throwaway file that breaks the rule, show you Rerail's message, then delete it."
.rerail rule runs once the checkout has had no write for 10 seconds,
or your turn ends, and its ◆ Rerail message reaches you at your next step after that: wait about 15 seconds without
writing, then check. Show the message, then delete the file. This file is the one exception to not writing in the
repository, and it must be gone before you reply./rerail-start starts it.A rule the person wrote by hand into .rerail/rules/ can be checked as it is: rerail rules test .rerail/rules/<name>.rerail --json runs its tests and the repo pass, and rerail rules test .rerail/rules/<name>.json --json validates a JSON one and runs the repo pass, with no cases. To prove or tune a JSON one, build a draft with cases
around it.
◆ Rerail message names the rule id and the path:line. Without one, ask for the code
it fired on, or reproduce it: a probe draft with the rule and the suspect code as cases. If what the person describes does
not reproduce, show what does fire and ask before changing anything..rerail/rules/ (rerail packs list lists them under "This worktree's own rules", and
rules show says so) is the person's, whatever its id. Copy its file to <tmp>, change and test the copy, and after
the read-back write it over the file; Rerail reads it again at the next edit, in Log until the person approves it.local: rule, or any rule in rerail rules export, is the person's. rerail rules show <id> prints it: a rule
written in .rerail as its file, tests included, which you save as <tmp>/<name>.rerail and change; a JSON rule as a
draft.rerail rules show <id> prints it (a rule written in .rerail as its file, a JSON one as a draft), and rules add of
it with its id kept stores the person's copy (<id>-copy) where the original is; approving the copy turns the
original off there. Save a pack's .rerail rule as <tmp>/<name>.rerail and work on that copy: the files it includes
from beside it in the pack (lib/<name>.rerail) come with it. A test of the pack's that reads its files from beside
it in the pack (from "…") cannot run from your copy, whose folder does not have those files: remove it first, write the
cases your change touches inline (rules test fails, and rules add refuses the copy, until one of its tests
runs), and say in the read-back that the pack's own tests are left out. To read what a
relation such as dj_qs means, look in the installed pack's library
(~/.rerail/packs/node_modules/<package>/rules/lib/, such as @neralabs/rerail-pack-django) and in core's library
(More). If the person's change goes against what the rule's description or
comments say it reports, say so in one line before the card. Offer that, or setting it to Log or off in
this repo from the dashboard (rerail manage --print gives the link). If the person wants it changed for everyone,
/rerail-bug-report reports it to the Rerail team in an issue.exactly test as a file it
must let through (a passed case in a JSON draft), and show it was wrong before: run it against the current rule and see
it reported. Code it should report and misses is the other way round: an .expect (a caught case) that fails
against the current rule. Keep every earlier test, except a pack's test that reads files from beside it (step 2); a
JSON rule's cases come from its draft file or, without it, are rebuilt from the rule's description and the repo. A change to what the rule checks may need its scope too (a rule across files reads
both sides): change both here, not in Scope. Where what it catches changes, rewrite its description and message to
match, and name a new description in the Changed line. Raise the revision by one for the person's own rule; keep it
for a rule that ships with Rerail, whose copy is new. For such a copy, add a line above the card: Saved as your copy <id>-copy; approving it turns <id> off here. A JSON rule from before titles has none: add one, as Write
step 2 says, and show it in the read-back.<id>-copy, which
rules add names): the rule keeps running as it is until they approve the copy, which turns it off. In the read-back,
add one line above the card, at most two sentences:
Changed: inline type imports (import { type User }) now pass; a mixed import is still caught.The person changes only where a rule applies. Change its scope and nothing else: what it checks, its message, its
mode, its title and its id stay as they are. Write's review and quality gates are about those, so skip them; this takes a
handful of commands, not a new rule. rules show gives a rule that ships with Rerail the title its pack lists.
Read the rule: rerail rules show <id>. It prints a rule written in .rerail as its file, which you save as
<tmp>/<name>.rerail, and a JSON rule as a draft, as it runs in this repo, which you save as <tmp>/draft.json. A line
on stderr says what saving does. Go on after the first three lines below, start again with
the rule they name after the next two, and after the rest say what the line says, and stop:
rules show on the copy's id and start again with that one.rules show <original> and start again with that one.A rule with no scope (one about commands, not files) has no paths to change: say so, and stop. A second line, "has no
title", means a rule of the person's from before titles: rules add refuses it without one, so add a title as Write
step 2 says, and show it in the card's diff as title + "<title>".
Change only the scope: the .scope include and .scope exclude lines of a .rerail rule, or rule.scope of a
JSON one. Turn the person's words into include and exclude globs (an exclude wins; **/ matches any folder). Name what this repo really has: one listing of its files shows, for example, where tests live
(tests/, test_*.py, *_test.py, conftest.py, *.test.ts, __tests__/). If the words can be read two ways, ask
one question. If the scope already does what they ask, say so with the globs that do it, and stop. Raise the revision
by one for the person's own rule; keep it for a rule that ships with Rerail.
Check the paths. For each path the change keeps or leaves out, one file at that path with the same content, a
line the rule catches (take it from the rule's description, its tests or one of its matches). In a .rerail rule,
add one exactly test holding them all, with an .expect for each path still in scope and none for a path left out.
In a JSON draft, add them as cases: a path still in scope is caught, a path left out passed, and reads "(outside
the files this rule covers)". Run rerail rules test <tmp>/<name>.rerail --json (or <tmp>/draft.json) once. Every
test or case must come out right. Count repository.matches for the card; do not review them. The repo pass covers
only the folders the rule runs in (repository.folders), so the count is what the saved rule will catch. Where they
are not [""], the Tested row names them in place of "in this repo": "Would catch 2 places under src/, web/".
Show the change, in this form, and ask once:
Change where <id> applies?
exclude + "**/tests/**"
+ "**/conftest.py"
Still checked src/app/models.py, scripts/sync.py
Left out now tests/test_api.py, conftest.py
Tested Would catch <N> places in this repo | Would catch <N> places under <folder>/
Unchanged What it checks, its message, <Steer|Log>
Saved as Your copy of <id>; the original turns off where the copy is added once you approve it
| <id>, revision <n>, here (and in <other repositories>)
1. Yes, save it
2. Change something
3. Cancel
The diff lists only the globs added (+) and removed (-). If the person already said yes in this conversation to
exactly these globs, every test or case passed, and that earlier preview said what saving does (what the Saved as row says),
that yes stands: show the card without its question and save. Otherwise ask.
Save it, only after the person says yes. rerail rules add <tmp>/<name>.rerail, or <tmp>/draft.json for a JSON
rule. The change runs in Log until the person approves it on its page in the dashboard, and a copy's approval turns
the original off. A rule in
.rerail/rules/ is saved by writing its file, and waits for approval the same way. Reply in one line:
● <id> applies to <the person's words> once you approve it on its page: <the link rules add printed>.
Anything else you notice on the way (a message you would word differently, a match that looks wrong) is one line after the reply, offered as its own change. Never fold it into this one.
Read references/approving-rules.md first.
rerail rules approve with no name lists every rule and pack waiting here, each with where it comes from.rerail rules approve is refused from your session: give them
the page's link (rerail manage --print prints the dashboard's; a rule's page is #rule/<id> on it), or tell them
rerail manage opens the dashboard.rerail rules approve and rerail rules import are the person's, and
refused from your session. Never get around that: not by unsetting the variable that marks your session, nor through
the dashboard's API or Rerail's database.block mode..rerail/rules/ after their yes, and Write step 8's throwaway file, deleted before you
reply.examples/no-hand-edits-to-generated-files.md (opens in a new tab)references/approving-rules.md (opens in a new tab)references/architecture-rules.md (opens in a new tab)references/code-rules.md (opens in a new tab)references/conversation-rules.md (opens in a new tab)references/rule-quality.md (opens in a new tab)references/suggesting-rules.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
rerail, rule-creation, rule-testing, rule-approval, architecture-rules
2 skills in this plugin
Generated from the plugin's indexed repository (neralabs/rerail) — no native marketplace selected
npx claudepluginhub p/neralabs-rerailOther plugins' skills for the same job