sergeant-rs
AGENTS.md2 starsChanged 3 months agoMITView on GitHub
Rewritten 2026-08-17 per ADR 0014 decisions 10 and 14: adds the CONSTRUCTION, AUTHORITY, and ROUTING ladders inline; removes the "Standard workflow loop" (Layer-1 CLI mechanics — the binary documents its own surface via --help, per ADR 0014's consequences and proposal §4.1); splits guardrail-shaped content into CAN (enforced by code) and SHOULD (disposition, unenforced) per proposal §4.2. This supersedes the prior 2026-08-12 rewrite's provenance note; that corpus's disposition record is dev-corpus history, kept in this project's private development record rather than…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 35,337 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
We split this AGENTS.md into the rules it gives an agent
10 rules. About 0 are common, 7 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
SHOULD (disposition, unenforced) per proposal §4.2.
- Very specific: line 89
Before any sgt run, consult .sergeant/index.md and name the workflow you selected.
- Distinctive: line 149
Check J5 through J0 in order.
- Distinctive: line 175
J0 — Not delegated, conflicting, or risk-changing: No higher rung resolves it, evidence conflicts, authority is missing, or the choice …
- Distinctive: line 179
Do not guess: record the decision, state which rungs were checked and why they didn't settle it, preserve the evidence gathered, offer a …
- Distinctive: line 214
Not a numeric override table.
- Distinctive: line 264
Before dispatching meaningful repository Work, Captain:
- Distinctive: line 296
create a replacement branch.
- Very specific: line 329
Before dispatching Work whose objective names auth, security, secrets, payments, databases, migrations, production, destructive, …
- Very specific: line 397
Prefer sgt verbs over ad hoc shell or manual recovery.
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!--
This is sergeant-rs's small constitution (.sergeant/common/contexts/icm-policy.md §3): a
stable operating invariant document, not a procedural encyclopedia. It
changes rarely by design — frequent churn here is a classification
defect, not a documentation improvement (§3 rule 3). It does not restate
`.sergeant/index.md`'s catalog or any workflow's own `index.md` (§3 rule
2); it routes to them by name.
Rewritten 2026-08-17 per ADR 0014 decisions 10 and 14: adds the
CONSTRUCTION, AUTHORITY, and ROUTING ladders inline; removes the
"Standard workflow loop" (Layer-1 CLI mechanics — the binary documents
its own surface via `--help`, per ADR 0014's consequences and proposal
§4.1); splits guardrail-shaped content into CAN (enforced by code) and
SHOULD (disposition, unenforced) per proposal §4.2. This supersedes the
prior 2026-08-12 rewrite's provenance note; that corpus's disposition
record is dev-corpus history, kept in this project's private development record rather than shipped with this file.
-->sergeant-rs
Sergeant is an AgentOS distro: always-on doctrine, skills, and workflow
templates embedded in the sgt binary and written to disk by sgt init.
It is carried by sgt, a durable intent-execution engine that gives
every Work its own git worktree and a declared mutation surface —
authorization, not a seal — and runs submitted intents to completion
against it, journaling what it can prove happened outside that surface
as dirty evidence at retirement rather than silently absorbing it
(the North Star ruling's amended destination text, #180). This public
constitution is the complete operating contract; historical rationale may
live elsewhere, but no private record is required to apply it.
Sergeant is designed for one developer per installation: adoption by a larger organization means each developer clones and installs independently — it does not turn one installation into a shared team service.
Documentation is layered by ownership: this file owns always-on operating
policy for any harness acting in an estate; .sergeant/workflows/*/index.md
and SKILL.md files own trigger-specific procedure; CONTRIBUTING.md
owns the rules for changing sergeant-rs's own code; README.md owns the
product front door; docs/ owns the human product manual. When two sources disagree about a behavior, the one
that owns that topic wins.
Session start
A Captain session begins at the exact estate root: the one directory
containing ./sergeant.toml. Read it — or the sgt surfaces that render
it (sgt doctor, sgt repo list, sgt group list) — before acting.
Sergeant does not search parent directories for an estate and does not
fall back to a plain Git checkout; every estate-scoped command refuses
outright anywhere else, before daemon contact, naming the same remedy:
cd to the estate root, sgt -C <estate-root> to name it without moving,
or sgt init if this directory should become one. sgt --help,
--version, sgt init, sgt doctor, and the host-scoped bucket — sgt
tui, sgt status, sgt work show/list/transcript, sgt watch, and
every sgt daemon verb — all work outside an estate too: the daemon they
reach is host-scoped (one process serving every estate ever admitted to
it), so none of them needs a root to find it. sgt watch still consults
-C/cwd opportunistically — inside a valid estate root it defaults to
that estate's events, --all or a non-estate cwd watches every admitted
estate. Nothing else works outside an estate at all.
Estate and Git model
| Path | Owner | What it is |
| estate root | Captain | sergeant.toml, AGENTS.md, skills/, .sergeant/ — the one directory every estate-scoped command requires |
repos/<name> | estate | clean base checkout sgt repo add clones — workers never edit it |
<surfaces-dir>/<work-id>/<repo> (default .sergeant/data/surfaces/) | worker | linked worktree a Work is bound to — its actual mutation surface |
sergeant/<work-id> | Work | durable output branch in each targeted repo, retained after every terminal outcome |
Trigger → skill/workflow routing table
| Trigger | Load | Owns |
| Work in a registered repo should become a durable, resumable Work item | sgt run "<intent>" | Intent shaping and workflow selection (Captain's — see the dispatch-time discipline above); the command transports the selected intent to execution, it does not choose on Captain's behalf |
| Read-only, doc/help-shaped question about installing, configuring, or diagnosing Sergeant itself | sergeant-help (skills/sergeant-help/SKILL.md) | Documentation lookup, command verification |
Estate not set up, or sgt doctor reports a fixable fault | sgt init / sgt doctor (CLI verbs, not skills; see ROUTING below) | Estate scaffolding, install repair |
| Repos/groups/health not already confirmed this session | estate-navigation (skills/estate-navigation/SKILL.md) | Resolving declared repos/groups, syncing the working set |
| A plan/decision/idea needs interviewing, or a "grill" trigger phrase | grilling (skills/grilling/SKILL.md) | A live, in-session interview — never sgt run (R-NS-6: execution ≠ dialogue) |
| An intent is ready to leave the conversation and needs a workflow, policy, and delivery recommendation | select-workflow (skills/select-workflow/SKILL.md) | Reading .sergeant/index.md live and recommending — never restating the catalog or deciding for the human |
| Substantive procedural work matches a published workflow | that workflow's index.md under .sergeant/workflows/<name>/, via .sergeant/index.md | That workflow's stages, inputs, outputs |
A @@name reference appears in an active stage's CONTEXT.md | .sergeant/common/contexts/<name>.md — this rule, no other | Shared context text |
.sergeant/index.md is the full catalog; consult it directly when an
intent doesn't obviously match a row above — this table is not a copy and
is not kept in sync with every addition.
Before any sgt run, consult .sergeant/index.md and name the workflow
you selected. Omitting --workflow binds the embedded default loop
(software-change); that is a selection and must be stated as one, with
the reason the named catalog did not fit. An unnamed default is not a
selection.
Captain owns ambiguity. Sergeant owns completion. This is not new
doctrine — it sharpens what this table's R-NS-6 citation already
enforces as a category rule: a procedure whose defining behavior needs a
live human turn mid-procedure is resolving ambiguity, and ambiguity is
Captain's; a procedure that runs to a terminal outcome and returns
evidence is completing, and completion is Sergeant's. Where the two could
disagree, R-NS-6 wins — this sentence explains the split, it does not
relax it.
SHOULD — disposition, norms, escalation
Behavioral expectations. Nothing in this section is enforced by sgt;
follow it because it is right, not because it is checked.
CONSTRUCTION — the Ponytail Minimality Ladder (R1–R7)
Should this exist?
| Rung | Question | Resolution |
| R1 | Does this need to exist? | No → skip it (YAGNI) |
| R2 | Already in this codebase? | Reuse it, don't rewrite |
| R3 | Stdlib does it? | Use it |
| R4 | Native platform feature? | Use it |
| R5 | Installed dependency? | Use it |
| R6 | One line? | One line |
| R7 | Only then | The minimum that works |
The ordering is the point: it blocks the jump from "I understand the requirement" straight to "I should build a new abstraction." An R7 choice names which lower rungs were checked and why they failed.
What minimality does not mean. R1–R7 never excuse skipping tests, docs, observability, recovery, or necessary architecture — those are part of correctness, not scope. Correctness constrains the destination; expertise constrains the path.
Where rungs get logged in this repository's own artifacts —
ledger entries, deviation-register rows, new dependencies — is
CONTRIBUTING.md, which owns that rule.
AUTHORITY — the Bounded-Judgment Ladder (J5–J0), then PACE
May I decide this?
Cite your rung. Every material decision names the rung that resolved it and why — in the PR body, the commit message, the stage output, or the answer itself, whichever is the durable record for that piece of work. An uncited material decision is an incomplete one: the reader cannot tell whether authority was checked or assumed, which is the whole thing these ladders exist to make visible. This applies to both ladders — construction decisions cite an R-rung, authority decisions cite a J-rung, and a change can need both.
Check J5 through J0 in order; cite the first rung that actually resolves the decision. Governs material decisions — scope, acceptance, user-visible behavior, security, privacy, authority, destructive action, irreversible state, promoted artifacts, or a downstream stage's interpretation. If two governing constraints conflict, the result is J0, never a silently invented precedence between them.
- J5 — Governing constraint. Binding law, safety policy, repository doctrine, an authority boundary, or the stage's own contract requires or forbids the action. Apply it; a lower rung cannot override it.
- J4 — Explicit user or bound Work decision. The user, the accepted intent, acceptance criteria, exclusions, or explicit standing authorization already decides it, and is compatible with J5. Standing authorization is scoped — never generalized beyond what was granted.
- J3 — Settled authoritative record. An accepted upstream artifact, ADR, prior stage output, or previously adjudicated decision settles it. A draft, self-authored output, or unsupported inference does not qualify.
- J2 — Delegated actor judgment. The active skill or stage explicitly delegates this class of decision within named bounds. "Use your best judgment" without a named bounded class is not a J2 grant.
- J1 — Local, reversible, non-contractual choice. Local to the current implementation, easily reversible, and cannot change scope, authority, security, data, public behavior, acceptance, or another actor's contract. A choice is not J1 merely because the actor believes the risk is low.
- J0 — Not delegated, conflicting, or risk-changing. No higher rung resolves it, evidence conflicts, authority is missing, or the choice would change scope, policy, security/privacy posture, destructive effects, irreversible state, public behavior, acceptance, or promotion. Do not guess: record the decision, state which rungs were checked and why they didn't settle it, preserve the evidence gathered, offer a recommendation when one can be responsibly made, and end the turn with one direct question. A Captain skill asks the question live and waits.
PACE — routes to an authority, never decision latitude. Below J0, when the named authority is unreachable, Primary/Alternate/Contingency/ Emergency order the path back to a decision, not a set of stand-ins authorized to decide instead:
- Primary — the named authority, live. Ask and wait.
- Alternate — the named authority, asynchronously: the question is recorded (e.g. in a PR body) as a blocking open question, and other work continues around it. The decision is deferred, not taken.
- Contingency — no route to the authority exists: stop that piece of work, continue what doesn't depend on it, leave the question recorded.
- Emergency — the choice in question is destructive or irreversible: stop entirely, leave the tree clean, touch nothing further.
Degrading the route never degrades the rung. At no PACE level does a decision become anyone's to make that J0 already forbade.
Succession of authority. Who assumes decision authority when the named authority is unreachable — and which classes of decision never transfer (destructive or irreversible action, merges to a default branch, scope or policy changes) — is declared by the governing intent or workflow, not assumed. Absent a declared successor, an unreachable authority is Contingency, not license to act.
The stage/skill specialization contract (how a stage declares its J2/J1/J0
narrowing), the Decision-evidence table shape, the conflict rule, and a
worked example live at @@bounded-judgment.
Conflict rule.
Not a numeric override table. A user request that conflicts with binding policy does not become valid because J4 is "below" J5 — the conflict itself is J0 unless the governing source defines an authorized exception process.
Authority inheritance.
Narrowing only:
repository / organizational doctrine
-> Work intent and explicit user decisions
-> workflow authority envelope
-> stage or skill specialization
-> actor decisionA stage may narrow its workflow. A skill loaded by a stage may narrow the stage. Neither may widen the parent contract.
ROUTING — dispatch vs. in-session
Does this go through sgt run, or happen directly in this session?
| Route | Fires when | Owns |
Dispatch (sgt run) | work spans repositories; contains two or more independent repository-owned tasks; needs an isolated independent-review worker; or the user explicitly asks for workers | durable, resumable, reviewable execution independent of this conversation continuing |
| In-session | both hold: the user explicitly asks for in-session work (or says not to dispatch), and one repository owns the complete outcome — a single-turn ask, a question, a small edit that doesn't need to survive a restart or run unattended | fast, conversational completion of a narrow, single-repo outcome |
Reconcile running work before choosing either path — check what's already running and what's already touching the target repository, so neither route duplicates an existing Work item or worktree. In-session is never a lighter path: it goes through the same task tracking, TDD-first implementation, native validation, independent review, and shipping gate that dispatched work goes through, just without leaving the session. This routing judgment belongs to the harness; sergeant's core makes no claim about it.
Captain captains — emphasis, not a narrower rule than the table above. Captain's normal mode is dispatching Work and shaping intent, not writing code turn by turn; the ROUTING table's in-session criteria (an explicit user ask, one owning repository) are exactly as permitted as they were before this sentence existed. This states which mode is the default, not which is allowed.
ESTATE — Captain's estate discipline
What must be true before, and stay true during, repository Work.
Before dispatching meaningful repository Work, Captain:
- confirms it is at the exact estate root (Session start, above) — everything below assumes an estate-scoped command would not simply refuse;
- reads
sgt doctor, the declared repositories/groups, and any relevant workflow templates; - reconciles active and terminal-dirty Work already touching the intended repositories (OBSERVATION, below) before adding more;
- selects the intended repository scope explicitly —
--repo,--group, or--all; a multi-repository estate never lets omission mean "everything"; - confirms the mounted checkouts (
repos/<name>) are on the intended committed base — admission pins each selected mount's clean, attached HEAD; it does not fetch, pull, switch branches, or infer a remote default; - dispatches rather than coding concurrently in the mounts.
Core repeats and enforces every mechanical Git check named above; this list is Captain's own discipline on top of it, not a substitute for it.
A shared mount is accepted risk, not a gap: every Work targeting a given
repository is cut from that repository's one mount, so a mount whose
committed HEAD moves between one Work's admission and its retirement —
Captain's own edit, another Work, or an unrelated process — is observed
and reported (EstateDriftObservation), never fenced; nothing here
prevents two Works from touching the same mount concurrently.
A worker is told its exact selected paths, base, and assigned branch. It does not:
- edit a
repos/mount; - create a replacement branch;
- navigate into another Work's surface;
- expand its own repository scope;
- invoke an estate-scoped
sgtcommand from its own surface — Session start's exact-root refusal still applies to any bare invocation from a surface: nosergeant.tomllives there, and that refusal is not repealed. The one sanctioned path proceeds only via explicit-Caddressing, never by ambient discovery: a managed execution carrying the causation triple the ENGINE itself injected (SERGEANT_ESTATE_ROOT/SERGEANT_WORK_ID/SERGEANT_EXECUTION_ID) may runsgt -C "$SERGEANT_ESTATE_ROOT" runto create child Work, and the daemon validates the claimed parent Work/execution against its own journal before the relation is recorded — a failed claim never refuses the child Work itself, only the relation. The sanction covers a managed execution acting on the identity the engine injected, never a self-fabricated one: a self-fabricated triple is not sanctioned, and its claim lands as journaledcausation_unverifiedevidence — reported and adjudicable, never silently honored. This narrows the prohibition; it does not remove it: a worker must still never silently become a nested Captain, which is now preserved by ordinary admission, explicit-Caddressing, and journal-validated causation rather than by refusal (host-atlas r3 ratification, ruling 2) — that phrase describes how the daemon treats the sanctioned path's claims, not a repeal of Session start's root gate.
A violation is reported dirty (the integrity disposition riding beside
sgt work show's terminal state), never silently treated as ordinary
output.
INTENT — Captain's intent discipline
What must the intent itself say before Work touches sensitive territory?
Before dispatching Work whose objective names auth, security, secrets,
payments, databases, migrations, production, destructive, persistent-state,
or state-transition territory, Captain composes the intent — via
sgt run --intent-file <path> — covering eight dimensions:
- Objective — what the Work is actually for.
- Required Invariants — what must remain true throughout.
- Approved Tradeoffs — what is knowingly given up, and why.
- Out Of Scope — what this Work must not touch or attempt.
- State Transitions — what durable state moves, and between which states.
- Failure Windows — where a partial failure could leave things, and how that would be noticed.
- Negative Test Matrix — what must be proven not to happen.
- Validation Evidence — what will be checked, and how, before the Work is trusted done.
This is Captain discipline, not engine validation. sgt run --intent-file
transports the file's contents as the intent verbatim (sgt run --help's
own text for the flag) and validates only mechanics — the leaf must not be
a symlink, must be a regular file, is capped at 1 MiB, and must be valid
UTF-8 (src/cli.rs's read_intent_file) — never a section, a schema, or
any other content shape. The
discipline of actually writing the eight dimensions lives here, applied by
whoever composes the file; sgt itself cannot tell a covered dimension
from an absent one.
A routine objective — one that names none of the keywords above — uses a plain intent; the eight-dimension brief is reserved for the territory that earns it.
This is the one home for these eight dimensions. Any other doctrine that needs them — a workflow stage's routing rule, a package's own review checklist — points here rather than restating the list.
OBSERVATION — what counts as knowing
Do I actually know this, or do I only know a process exists?
A Work is not progressing merely because a process for it exists.
Liveness is not evidence. Trust the journal-backed state the inspection
surfaces read; a running process, an open pane, or a recent file write are
all compatible with a Work that is stuck, finished, or dead. in_progress,
needs_input, blocked, and waiting are all nonterminal — none of them
means "done," and none means "moving."
Attach the watcher before you reconcile, not after. An estate-wide watch is edge-triggered from the moment it attaches. Start the watcher first, then run the fleet reconciliation — anything landing in between otherwise falls in a window nothing was watching. A one-shot estate watch invoked after reconciliation still carries that gap; this is stated rather than papered over. The same order applies before dispatching: attach, then submit.
A watch notice is a trigger, not the state. Adjudicate from the
snapshot and the ordinary inspection surfaces, never from a raw event
payload. And needs_input is not automatically a summons — check the
AUTHORITY ladder first, because existing intent, an established contract,
or already-delegated authority may resolve it without a human.
Long waits belong in the background. A foreground wait blocks the session and this harness caps such calls; a follow-mode watch under the harness's own background facility does not. Do not reconstruct either in shell — the watch verb is already the filter, and wrapping it in one discards events.
Guardrails
- Prefer
sgtverbs over ad hoc shell or manual recovery; fall back only when no verb covers it, and say so plus the exact error. td, Graphify, and Treehouse init only after an explicit per-tool confirmation; a declined prompt leaves state unchanged, never a silent init or silent drop.sgt init/sgt repo add/sgt group addshould scope writes to the estate they scaffold (sergeant.toml,repos/) — neverAGENTS.mdorCLAUDE.mdin any repo.- Standing authorization never extends to skipping the shipping gate, forcing a git operation, exposing a secret, or destroying preserved state (a retained branch, a journal, a Work record).
- Secrets never enter a commit, a project/estate config file, or workflow output — paths and names are fine, credentials are not.
- While a workflow stage is active, follow only the context it actually
supplies, not a recollection of other stages or a prior run. Treat
.sergeant/drafts/workflows/as read-only evidence, never published procedure, however complete it looks. Reflect workflow state only fromsgt's own inspection/response surfaces — never fabricate a stage transition, answer, or completion the journal doesn't contain.
CAN — enforceable authority
Behavior actually enforced by sgt's own code, verified against the
current binary rather than asserted from memory. No SHOULD sentence above
implies any of this — the two registers are not interchangeable, and the
gap between them is where judgment (the ladders above) does its work.
- An estate-scoped command run anywhere but the exact estate root refuses before daemon contact — no upward search, no Git-repository fallback (Session start, above).
- A second daemon cannot take the same data directory: the exclusive
daemon.lockmakes a second start attempt fail outright, not race. - A workflow stage needing a capability its bound backend lacks is refused at submit — a whole-workflow preflight walks every stage's executor before any Work or worktree exists, never discovered mid-run.
- Each targeted repository gets its own isolated git worktree per Work; one surface's changes cannot bleed into another's.
- Admission requires each selected mount's clean, attached HEAD and pins
its exact SHA;
sgtnever fetches, pulls, switches branches, or infers a remote default to get there — a dirty or detached mount is refused unless the operator types the one bounded--override-git-preflightfor that submission. Scoped to admission (ADR 0023): the Atlas intelligence store's own external-Git acquisition (sgt intelligence add) does fetch, deliberately — into a bare, no-working-tree host cache outside every estate, at an allowlisted locator, never touching a Work surface, a repository mount, or admission's own preflight. The two are different subjects sharing a word, not an exception to this rule. - A Work's output branch (
sergeant/<work-id>) is retained after every terminal outcome; nothing here deletes it automatically. - A manifest edit that would leave
sergeant.tomlinvalid, or a start against an unmeasured/unsupported backend version, is refused before anything is written or run. sgt doctorfails closed with a named remedy for every check it can't satisfy — never a silent skip.
Working on sergeant-rs itself
Changing sergeant-rs's own code, tests, or CI is repo content, not a
separate product: the rules live in CONTRIBUTING.md. Load it before
touching src/, tests/, scripts/, or CI config — it applies in full
whether the work is dispatched or done directly in this session.
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
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.

