rhachet

a framework for reliable, composable, and iteratively improvable thought.
use 🧢 roles & add 🧠 brains to produce 🎭 actors who clone thought routes.
🧢 roles (💪 skills + 📚 briefs)
+ 🧠 brains
= 🎭 actors
→ 💧 .ask() to think
→ 🔩 .act() on your behalf
→ 🪨 .run() curated executables
install
to install locally, with cli use via npx rhachet and npx rhx,
# via pnpm
pnpm add rhachet
# via npm
npm install rhachet
to install globally, with cli use via rhachet and rhx,
# via pnpm
pnpm add -g rhachet
# via npm
npm install -g rhachet
entry points
rhachet provides multiple entry points for optimal load times:
| entry point |
what |
when to use |
rhachet |
full SDK |
need stitchers, templates, full features |
rhachet/brains |
brain objects + operations |
brain discovery, context creation |
rhachet/actors |
actor + role objects + operations |
actor creation, role operations |
lightweight imports
// full SDK — loads all modules
import { genActor, genContextBrain, Stitcher } from 'rhachet';
// brain-focused — loads only brain-related code
import { genContextBrain, BrainAtom, BrainRepl } from 'rhachet/brains';
// actor-focused — loads only actor + role code
import { genActor, Actor, Role } from 'rhachet/actors';
use the lightweight entry points when you only need a subset of rhachet functionality. this significantly improves import time for applications that don't need stitchers, templates, or weave composition.
🧢 roles.<use>
if you want to use rhachet, you want to use roles.
there's two ways to use roles. via cli and via sdk. both are described below.
cli
humans have brains. robots have brains. who would have thought they'd need the same briefs and skills to work well?
the cli powers the most common usecase for rhachet. robots and humans depend on it in day to day operations via their roles.
tldr
# install role repos
npm install rhachet-roles-ehmpathy
# init roles (sets defaults for the repo)
npx rhachet init --roles mechanic
# invoke skills
npx rhachet run --skill show.gh.test.errors
# use enrolled agents (boots with default roles from init)
claude
# spawn with specific roles (overrides defaults)
rhx enroll claude --roles mechanic # only mechanic
rhx enroll claude --roles +architect # defaults + architect
rhx enroll claude --roles -driver # defaults - driver
init
how
install a rhachet-roles package and run init:
# install the role repos you'd like to use. e.g.,
npm install rhachet-roles-ehmpathy rhachet-roles-bhuild rhachet-roles-bhrain
# initialize the roles, to make them available for use to agents in the repo
npx rhachet init --roles mechanic behaver reviewer
if the same role name exists in multiple packages, use $repo/$role syntax to disambiguate
# init the role repos with repo disambiguation. e.g.,
npx rhachet init --roles ehmpathy/mechanic bhuild/behaver bhrain/reviewer
after init, any agents you spawn in the repo will boot with those roles. rhachet configures your brain-repls via hooks (e.g., in .claude/settings.json) so enrollment happens automatically and resiliently.
why
the .agent/ directory is a curated & shared source of truth. robots get their briefs and skills from here. so can humans.
zero magic. full transparency.
.agent/
repo=.this/ # roles specific to this repo
role=any/
readme.md # ← you can read this
briefs/ # ← and these (which robots boot with)
skills/ # ← and these (which robots exec from)
repo=ehmpathy/ # roles linked from rhachet-roles-ehmpathy
role=mechanic/ → # symlink to node_modules/...
# ← same exact structure as above
browse the same briefs robots get booted with. invoke the same skills they dispatch. edit and iterate — changes take effect immediately.
role hooks — one dispatcher per event
for claude code, rhx init --hooks writes each role's hook rules into one manifest per brain dir, and one dispatcher hook per claude event into the settings:
.agent/.actors/<actor>/brain/.claude/
hooks.dispatch.manifest # one row per role rule; tracked, beside the settings
settings.of.repo.json # one hook per event: bash ./node_modules/rhachet/bin/hooks.dispatch.sh <manifest> <Event>
- a tool call starts one process, which runs every rule whose matcher fits, each as it ran alone, and merges their verdicts as claude merges separate hooks
- the manifest reads as plain text: each row follows a
# line that names its event, matcher, timeout, author and command
/hooks and claude --debug show the dispatcher, not each rule. a blocked call ends with one 🪝 hooks.dispatch <Event> blocked by <rule file> line per blocker
- to see why a rule did or did not fire, replay the call by hand (no restart), or trace every event a seat dispatches (set before the seat starts):
printf '%s' '{"tool_name":"Bash","tool_input":{"command":"pwd"}}' \
| bash ./node_modules/rhachet/bin/hooks.dispatch.sh <manifest> PreToolUse; echo "exit $?"
export RHACHET_HOOKS_DISPATCH_TRACE=/tmp/hooks.trace.log # each event appends here; stdout and stderr are unchanged
export RHACHET_HOOKS_DISPATCH_SOURCE=0 # run each rule as `bash <file>`, never sourced, as on bash < 5
- a manifest that is absent, of another version, or malformed fails closed and names the fix:
npx rhx init --hooks. after a merge conflict in the manifest, take either side and rerun npx rhx init --hooks; it rewrites the manifest from the roles
enroll
how
spawn a brain with specific roles via rhx enroll:
rhx enroll <brain> --roles <spec> [passthrough args...]
the --roles spec supports these modes:
| mode |
syntax |
example |
result |
| replace |
role or role1,role2 |
--roles mechanic |
only mechanic |
| append |
+role |
--roles +architect |
defaults + architect |
| subtract |
-role |
--roles -driver |
defaults - driver |
| mixed |
+role1,-role2 |
--roles +architect,-driver |
defaults + architect - driver |
| focus |
role::subject or +role::subject |
--roles +mechanic::flow |
defaults, with mechanic at its flow subject |
a focus boots only that subject's briefs and skills, plus always unless the subject sets
inherit: { always: false }, and keeps every hook of the role. subjects are the subject.<slug>
sections of a role's boot.yml; npx rhachet roles cost --all lists them. one subject per token,
and two of one role union: --roles +mechanic::flow,+mechanic::code.prod.
rhx init --roles +mechanic::flow sets the repo's own focus, which a bare rhx enroll inherits.
its record is gitignored: add --prep so pnpm install replays it in a fresh clone.
# boot.yml — a small subject that sheds the role's always block
subject.101:
inherit:
always: false
briefs:
say:
- briefs/basics.md
# spawn with only mechanic role (replace mode)
rhx enroll claude --roles mechanic
# spawn with defaults plus architect (append mode)
rhx enroll claude --roles +architect
# spawn with defaults minus driver (subtract mode)
rhx enroll claude --roles -driver
# spawn with specific combo (replace mode)
rhx enroll claude --roles mechanic,ergonomist
# spawn with defaults, mechanic focused at its flow subject (focus mode)
rhx enroll claude --roles +mechanic::flow
# passthrough args to brain
rhx enroll claude --roles mechanic --resume
# pass a prompt directly
rhx enroll claude --roles mechanic "review this code"
beyond --roles, enroll accepts:
| flag |
what |
example |
--as @:<slug> |
name the spawned clone with a stable handle, to say/get it by @:<slug> later |
rhx enroll claude --as @:driver |
--reason <text> |
record WHY this enrollment happened in the actor's audit log (accepts @stdin) |
rhx enroll claude --reason "nightly cron" |
--no-socket |
skip the reach socket — spawn the brain plain, no say/get |
rhx enroll claude --no-socket |
--output <mode> |
tree (default, human) or json (a machine handoff of the clone's serial + reachability) |
rhx enroll claude --output json |
# name the clone so a cron can reach it later
rhx enroll claude --roles mechanic --as @:driver
# record the motive; a supervisor reads the serial back as json
rhx enroll claude --reason "nightly cron" --output json
spawn allowance — a leaf spawns no one
a work clone may spawn clones, at any depth. a leaf clone answers, and spawns no one. a leaf's
spawn is refused with a leaf clone may not spawn (exit 2).
| the clone was spawned by |
it is |
a session enroll (rhx enroll claude, --watch, --async) |
a work clone — may spawn |
a print-mode enroll (rhx enroll claude -p '<prompt>') |
a leaf — may not spawn |
a repl brain (rhachet ask, rhachet act, or a skill built on the sdk) |
a leaf — may not spawn |
| a shell or a job a leaf started |
a leaf — may not spawn |
each clone also carries its spawn depth (RHACHET_CLONE_DEPTH): 0 from a fresh terminal, the
caller's depth + 1 otherwise. depth is a record of the chain; it refuses no spawn.
a bare rhx enroll <brain> with no --as still prints the clone's own @:<serial> to stderr,
so you can reach your own clone without a second command. reach the spawned clone with
rhx clone say/get (see the clone section below).
why
init sets the default roles for a repo — every agent spawned inherits those roles automatically.
enroll lets you override those defaults for a single session:
- focus — spawn a mechanic-only clone when you just need code, no driver workflow briefs cluttering context
- specialization — add architect role for a deep refactor without changing repo defaults
- isolation — the enrolled brain boots with only the specified roles' hooks, no inheritance from user or project configs
under the hood:
- generates a unique config (
.claude/settings.enroll.$hash.json)
- filters hooks to only the specified roles
- spawns with
--setting-sources local to skip all default configs
clone
how
an actor is a recipe; bake it into a clone, then talk with the clone easily (from any process, not just the keyboard):
talk — list, message, observe, self-identify, prune:
rhx actor list # actors (the identities)
rhx clone list # clones + state (LIVE|DEAF|DEAD)
rhx clone say @:<serial|slug> --what <m> # dispatch a message (single-line; --what @stdin ok)
rhx clone get @:<serial|slug> --tail 40 # observe (--tail all = whole log; --format blocks|raw)
rhx clone whoami # from within a clone: its own address
rhx clone prune [@<actor>] [--older-than <dur>] # reap dead clones (plan by default; --mode apply)
clone get renders a directioned conversation (🎙️ say / 🎧 reply turns) by default; --format raw
keeps the verbatim pipe-clean stream a comms relay forwards.
clone prune is plan-by-default (a safe preview); --mode apply reaps. it NEVER prunes a LIVE clone,
nor a cross-host clone whose pid it cannot verify.
every talk verb takes --output tree|json (default tree): json emits a machine shape a
cron/comms consumer reads by field, never by tree-glyph. whoami --output json also carries the
clone's own actorHash, so a clone can clone list @<actorHash> to enumerate its peers.
bake — make from a declared actor today; fork and wake are planned (the rhx clone dream):
rhx clone make @<slug> [+role|-role] [--brain <brain>] [--as @:<slug>] # from an actor in .agent/actors.yml
rhx clone @<slug> [+role|-role] [--brain <brain>] [--as @:<slug>] # alias of rhx clone make @<slug>
rhx clone fork @:<serial|slug> [--as @:<slug>] # (planned) from an extant clone
rhx clone wake @:<serial|slug> # (planned) reopen an extant clone
address an actor with @<slug> (≡ actor://<slug>) and a clone with @:<serial> (≡
clone://<serial>) or @:<slug> (≡ clone://<slug>) — the actor is the unmarked base, the clone
wears the : grain-marker, and it answers to two bodies: its serial (the primary ref, always
present) or its slug (the --as unique ref, if named).
howtos — use clones ·
author actors.yml ·
address sigils ·
experience inventory.
why
enroll spawns the same exact clone — equally addressable by any process, not just the keyboard —
it is simply based on a default or ad-hoc actor (anonymous, hash-derived). clone enables
reusable actors (declared by slug in actors.yml, beyond default and ad-hoc), so every actor is
addressable and any process can reach it:
- talk from anywhere — a cron or comms handler can
say into a live clone and get its output, no terminal takeover
- per-brain safety — the interface scopes control to one brain-cli, not your whole terminal (e.g., kitty, tmux)
- recipe reuse — declare an actor once in
actors.yml, bake many clones from it that stay in sync
use
| command |
route |
what it does |
npx rhachet run |
🪨 solid |
execute a shell skill, no brain |
npx rhachet act |
🔩 rigid |
execute a skill with deterministic harness |
npx rhachet ask |
💧 fluid |
converse with an actor, brain decides path |
🪨 solid: run
deterministic operations, no brain.
npx rhachet run --skill gh.workflow.logs --workflow test
shorthand: rhx
rhx is an alias for rhachet run --skill
npx rhx gh.workflow.logs --workflow test
🔩 rigid: act
augmented orchestration, harness controls flow, brain augments.
npx rhachet act \
--role mechanic --skill review \
--input "https://github.com/org/repo/pull/9"
npx rhachet act \
--role mechanic --skill review \
--input "https://github.com/org/repo/pull/9" \
--brain openai/codex
💧 fluid: ask
probabilistic exploration, brain decides the path.
npx rhachet ask \
--role skeptic \
--say "are birds real?"
sdk