Install
sloprail runs inside your agent as a plugin, and its hooks call a separate
set of binaries (sr, sr-session, sr-file, sr-mark, sr-agent, sr-eval, sr-checks). The
plugin installs those itself, so installing the plugin is the whole install.
Install sloprail per project. Run the commands below from the project’s root,
once for each project you want guarded, with the scope set to that project. The
rules a project writes live in its .sloprail/ directory, and the plugin that
enforces them is declared in the same repository. A project with a .sloprail/
directory is guarded; a project with none is an ordinary project until its first
rule.
Install the plugin
Section titled “Install the plugin”claude plugin marketplace add sloprail/sloprail --scope projectclaude plugin install sloprail@sloprail-marketplace --scope projectBoth commands write the project’s .claude/settings.json, so the plugin
is part of the repository and a teammate who opens it is offered the same
install. The marketplace pins each plugin to the latest release tag, so the
plugin files (hooks, skills) and the binaries below always come from the
same release, never from unreleased work on main.
Verify. Start a session in the project; the first one fetches the
binaries and says so. Then sr-session --version (see
Verify it worked) must print a version.
codex plugin marketplace add sloprail/sloprailcodex plugin add sloprail@sloprail-marketplaceThen enable the plugin for the project in .codex/config.toml at the
project’s root:
[plugins."sloprail@sloprail-marketplace"]enabled = trueRegistering the marketplace and fetching the plugin are per user: Codex keeps
them in ~/.codex/config.toml and its plugin cache. The project’s
.codex/config.toml decides where the plugin is on. codex plugin add
also enables it for your user; to have it on only in projects that say so, set
enabled = false for it in ~/.codex/config.toml. Codex reads a project’s
.codex/config.toml only when the project is trusted, so an untrusted
project does not load the plugin at all.
Hooks must be trusted. Codex runs a plugin’s hooks only after they have
been reviewed and trusted, and skips the others without any message: a plugin
that is enabled but untrusted guards nothing and shows nothing. Enabling or
upgrading the plugin does not trust its hooks, and changing a hook’s
definition in the plugin’s hooks.json drops the trust for that hook again.
sr-session codex-trust asks Codex which of sloprail’s hooks it would
skip and records trust for them (the same thing Codex’s own review dialog
does); install.sh runs it for you.
Verify. From the project’s root:
sr-session codex-trust --checkIt prints all N sloprail hooks are trusted, or names the hooks Codex would
skip and exits 1; run sr-session codex-trust to trust them.
curl -fsSL https://raw.githubusercontent.com/sloprail/sloprail/main/install.sh | sh -s -- --harness cursorThis installs the binaries and copies the plugin into
~/.cursor/plugins/local/sloprail, the directory Cursor loads local plugins
from when it starts. Run from the project root, it also adds sloprail’s
stop and sessionStart hooks to the project’s .cursor/hooks.json:
Cursor never fires a plugin’s stop hook and loads a local plugin after
sessionStart, but it fires both from the project’s hooks file. The merge
keeps your other entries and is safe to repeat (sr-session project-hooks install --plugin-dir ~/.cursor/plugins/local/sloprail, and sr-session project-hooks remove takes them out). Cursor has no project-scope plugin
install: plugins
are per user. The closest thing to a project scope is that sloprail does
nothing in a project without a .sloprail/ directory, and, for a single run,
cursor-agent --plugin-dir <path> loads a plugin from any directory
(marketplace/plugins/sloprail in a checkout of
sloprail/sloprail).
Verify. The plugin is in place when
ls ~/.cursor/plugins/local/sloprail/.cursor-plugin/plugin.jsongrep sr-session-hook-cursor .cursor/hooks.jsonlist the file and the two entries. Then start cursor-agent in a project that has a rule, write
a file the rule forbids, and watch the write be refused: that is the hooks
running. (A turn-end gate shows up only in the interactive terminal UI; see
below.)
install.sh takes --harness claude|codex|cursor|all to set up one harness (or
several, comma-separated), and with no flag sets up each harness it finds on the
machine. For Claude Code it only prints the project commands above.
install.sh also installs jq and yq when they are not on your PATH (the
tests and some shipped scripts need them): with brew on macOS, with apt-get,
dnf or apk on Linux when one is available (through sudo only when you are
not root and sudo needs no password), otherwise the official static binary into
the same directory as the sr* binaries. It prints what it installed and fails
with the reason if it cannot. install.sh --tools-only [DIR] does just that step.
Differences between the harnesses
Section titled “Differences between the harnesses”The rules a project writes don’t change between harnesses; these are the places the harnesses themselves differ.
| Claude Code | Codex | Cursor | |
|---|---|---|---|
| Scope | project (--scope project) |
enabled per project, installed per user | per user, plus the project’s .cursor/hooks.json for stop and sessionStart |
| Hooks | run once the plugin is enabled | run only once trusted (sr-session codex-trust) |
run once the plugin is loaded (stop and sessionStart: from the project’s .cursor/hooks.json) |
| Turn-end gates (Stop) | every session | every session | only in the interactive terminal UI, not in cursor-agent -p |
| Skills | loaded with the Skill tool | loaded with the Skill tool | there is no Skill tool: a skill counts as loaded when its SKILL.md is read |
A rule that gates the end of a turn therefore does not run in
cursor-agent -p, which has no Stop hook; guard that action at the tool call
(a gate) or at the commit (a file-guard) instead.
The binaries
Section titled “The binaries”The first session after the install fetches them, once: the GitHub release
matching the plugin’s version (never “latest”), verified against the
release’s checksums, into ~/.local/bin (set SLOPRAIL_INSTALL_DIR to
choose another directory). The session says it is doing this, and says so
loudly if it fails.
To install them yourself instead, set SLOPRAIL_NO_AUTO_INSTALL=1 and run
curl -fsSL https://raw.githubusercontent.com/sloprail/sloprail/main/install.sh | shor, with Go, go install ./services/... from a checkout of
sloprail/sloprail. Either way, if the
binaries are missing the next file write is refused with the install command,
never silently let through.
A missing binary does not, however, block a plain shell command — a
git commit guarded only by a gate on Bash goes through silently if
sr-session can’t be found, since there is no file write for that check to
attach to. Confirm the install actually worked (see below) before you rely on
a guardrail whose action runs through Bash rather than a file write.
Verify it worked
Section titled “Verify it worked”sr-session --versionshould print a version, not a “command not found” error. If you skipped step
1 or ~/.local/bin isn’t on $PATH, this is how you find out — check it
before trying a guardrail, especially one that guards a Bash command rather
than a file write. Once it prints a version, a file-write guardrail’s own
missing-binary refusal (the install command, repeated until it can find
sr-session) is the fallback safety net, not the first check.
Write your first guardrail and watch it refuse — the Quickstart.