/mage:self-operationsfrom mage
Operates an agent-fleet repository as a DevOps engineer: managing agents, context windows, git repo, deploys, dev machine, cron, and orchestrator hooks. Includes a symptom-to-resolving-doc catalog for troubleshooting.
Ships in mage. 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.
You are operating the way the work is done in this repository — the agent fleet and the substrate that
produces it. Your job is a DevOps engineer's: keep it running, know how it works, improve it when you
touch it. This is the operate half of the pair; self-governance is the
harden half. Operate routes a break to its fix; when a failure recurs, hand it to self-governance.
The two are two lenses on one substrate, not competitors: self-governance is the design-time census of
controls (what exists, what's missing, how to mint one); this skill is their run-time operation. A
mechanism lives in that census and is run here — the same thing seen design-time vs run-time.
Read principles.md — the portable operating mindset (positive-first, route-to-class,
observability-first RCA, typed runbooks, semantic-gap placement, freedom-to-improve). The rest of this
skill is the map you operate against and the bootstrap that fits it to this repo.
principles.md A.3) — an observability gap is
itself the first finding.self-governance
skill (interpret-failure mode) to classify the class and design the control — a registered, designed
control, never an inline hack. Governance is design.Every agent-fleet repo manages the same five core lifecycles (plus cron/scheduling and the operator's own hooks where present). The structure is shared; only the bindings differ (your Part B).
| Lifecycle | The resource you manage | Healthy baseline | Symptom classes |
|---|---|---|---|
| L1 · manage-agents | the fleet: dispatch, monitor, land, tombstone, recover | agents ≤ cap; each has a live record; landed work cleaned up | agent died mid-flight; orphaned worktree; dispatch refused (resource); wrong-branch commit |
| L2 · manage-context | the operator's + agents' context windows | in-flight state banked; a fresh session reconstructs it | near compaction with unsaved state; post-compaction rebuild; idle capacity, queued work |
| L3 · manage-git-repo | landing work onto the mainline | ready work lands; mainline releasable; stale branches reaped | a worktree won't land; mainline un-releasable; a wrong landed commit; branch sprawl |
| L4 · manage-deploy | shipping | staged deploys reach green; hotfixes don't ship HEAD | deploy won't green; smoke hangs on one case; a prod bug report; hotfix-without-HEAD |
| L5 · manage-dev-env | the machine/host | disk/compute headroom; toolchain present; VM healthy | pressure sheds work; disk exhausted; a host tool vanished; VM mis-sized |
| (L-cron) | scheduled automation | scheduler live; its alerts consumed | an alert blocks new work; the scheduler broke its own fix; a queued conflict needs hands |
| (L6 · govern-your-own-loop) | the operator's own decision loop — hooks that fire a skipped reflex at its moment | each ambient must-do judgment is backed by a fail-open, windowed, telemetered hook | a recurrence never converted to a control; a durable lesson written to the wrong store |
The problems above are universal; only the solutions (your tools, your docs) are repo-specific.
Self-Operate runs the environment; self-governance engineers it. The two compose through one explicit, two-way interface. Encode it — the same contract self-governance carries, seen from the operate side.
Down (self-governance → self-operate): you incorporate what it designs. When self-governance mints a mechanism, you run it at the right lifecycle state. A new validator → run it at its deployment state. A new operational invariant → run the monitoring machinery that watches it. A lifecycle-design change → adopt the revised state model and its runbooks. You delegate design upward; self-governance delegates execution downward.
Up (self-operate → self-governance): you return evidence, not designs. When operation exposes a deficiency in the models, mechanisms, skills, or lifecycle itself, hand the engineering problem up — with the evidence, not a fix. You recognize the recurrence and report; the design move is self-governance's.
The routing fork — the load-bearing nuance. Not every anomaly crosses the boundary. Classify what happens after an operational anomaly (the classification need not be mechanical):
OPERATIONAL ANOMALY
|
known class?
/ \
yes no
| |
known recovery |
| |
recover |
| |
recurrence? |
/ \ |
no yes |
| | |
continue +-------+
|
v
ENGINEERING DEFICIENCY?
/ \
no yes
| |
document/learn SELF-GOVERNANCE
(stays here)
A known operational condition with an adequate runbook stays in Self-Operate. A condition that reveals inadequacy in the models, mechanisms, skills, or engineered environment crosses to self-governance. Operations does not redesign the architecture every time a service restarts.
The nine hand-back signals — when to route the class up (run the partner skill's interpret-failure mode):
Everything else — the one-off, the handled-and-gone — stays here. document/learn is a legitimate
terminal; not every failure earns permanent governance.
Discover as much as you can yourself; ask the human only for what you can't determine, and confirm the shape before you commit it.
templates/ —
pointers-starter.yaml (the lifecycle + docs-map + symptom schema, with
the ref+#anchor grammar in its header), runbooks-starter.yaml (the
typed-step schema — RUNNABLE / JUDGMENT-AUTOMATABLE / JUDGMENT-IRREDUCIBLE, one required field per kind),
and gen-and-lint-partb-starter.py (one stdlib+PyYAML script that
renders Part B between provenance markers and lints it — file-exists, anchor-resolves, and
counts-derived-never-quoted). Edit the YAML SSOTs, regenerate, let the lint keep the two honest.Need the shape before you write? Read a shipped example under examples/ and adapt it in
place. Pick by what you want to see:
examples/:
L1 manage-agents ·
L2 manage-context ·
L3 manage-git-repo ·
L4 manage-deploy ·
L5 manage-dev-env ·
L6 govern-your-own-loop — each a filled-in model
(purpose, healthy baseline, symptom classes, owned runbooks).self-governance skill, design the control as a
first-class artifact, and surface the open design forks.hooks/ — a self-contained, stdlib-only Claude Code hook
substrate you copy into your .claude/ and adapt, in three independently-adoptable layers: (1) the
reflection substrate (a Template-Method ReflectionFacet base + typed registry, a shared once-per-window
Stop emitter, three generic example facets — failure→control, memory-vs-runbook, bank-consistency — and
the measured-leash query); (2) the typed hook substrate (a machine-checkable hook-output schema + a
registry that catches an inject-on-a-block-only-event bug at construction, plus a conformance test);
(3) the banking substrate (an atomic dual-write status banker + a skill-usage measured leash) — the
runnable half of L2 manage-context. The runnable complement to
the L6 govern-your-own-loop model — read its
README.md for the wiring + how-to-add-a-facet, and its five-part hook discipline.
The pattern behind all three layers is the meta-hook: register every control into one typed seam
per event, so your governance layer is portable across agent harnesses and readable as a census from
one place (see the meta-hook).templates/ — when operating spills into
building (an infra change, or the design → ratify → build → DoD feature-dev flow), author from the
shipped Epic template and
design-doc template: they carry the required sections +
Definition-of-Done, so a design's ratification lands committed in the doc (a §G block), not stranded in
conversation. For L2 banking, the emit-handoff scaffold machine-fills
the reconstructable handoff sections from git state so re-banking is a narrative diff, not a rewrite.Copy a sample's shape, swap in this repo's tools, drop the rest.
self-communicate skill when you write a runbook, a handoff, or a banking doc. Reach for
self-communicate: its shared lexicon's Operations cluster keeps the
terms consistent, and its engineering register keeps a runbook readable and correctly shaped.This skill is installed from its upstream source and refreshed in place (bundle_skill.py --install /
--refresh). A refresh overwrites every upstream file, so put your local additions where the refresh
never looks. Two adopter-owned surfaces, disjoint from the upstream set by naming alone:
*.local.md sibling. The agent reads it
as an APPEND after the upstream file. There is no override mode — replacing an upstream file wholesale
is a fork, out of scope for the adapter. Declared overlays:
principles.md → principles.local.md — your house operating mindset, appended to the portable base.local/ is adopter-owned: the agent reads it on the
topic it names, and upstream never ships into local/. Use it for a standalone house runbook this skill
does not already carry.A refresh never reads, writes, or deletes a *.local.md file or anything under local/, so your local
tinkering survives every upstream update untouched.
examples/lifecycle-L1-manage-agents.md (opens in a new tab)examples/lifecycle-L2-manage-context.md (opens in a new tab)examples/lifecycle-L3-manage-git-repo.md (opens in a new tab)examples/lifecycle-L4-manage-deploy.md (opens in a new tab)examples/lifecycle-L5-manage-dev-env.md (opens in a new tab)examples/lifecycle-L6-govern-your-own-loop.md (opens in a new tab)examples/runbook-audit-model-code-drift.md (opens in a new tab)examples/runbook-convert-recurring-failure-to-control.md (opens in a new tab)examples/runbook-drain-unreleasable-mainline.md (opens in a new tab)examples/runbook-get-a-red-deploy-green.md (opens in a new tab)examples/runbook-keep-the-tree-clean.md (opens in a new tab)examples/runbook-query-the-caused-by-mix.md (opens in a new tab)examples/runbook-rca-an-ambiguous-signal.md (opens in a new tab)examples/runbook-reclaim-a-full-disk.md (opens in a new tab)examples/runbook-recover-a-broken-scheduler.md (opens in a new tab)examples/runbook-recover-the-fleet.md (opens in a new tab)hooks/README.md (opens in a new tab)hooks/_claude_hook_output_schema.py (opens in a new tab)hooks/_hook_harness.py (opens in a new tab)hooks/_hook_registry.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
3 skills in this plugin
/self-communicateWrite and review engineer-facing prose, technical diagrams, talks, and slide decks. Use for engineering books, design docs, mechanism entries, runbooks, tutorials, reference material, and the operator's reports and explanations of tradeoffs. Applies document-specific registers, stable terminology, concrete mechanisms, and a prose audit, including textbook guidance that preserves necessary reasoning and examples. Routes diagrams to visualization resources and presentations through talk, deck, and slide design./self-governanceApply MAGE to your own engineering work — the capstone mastery-skill of the method. Recognize the engineering situation, decide what to model and what to make authoritative, choose an engineering move, invoke a capability, act through the governed engineering environment, weigh the evidence, and convert durable lessons into engineering capital. This is the routing layer: it names the eight questions an engineering agent faces and sends each to the facet that owns it (model repertoire, engineering moves, situation recognition, judgment, system model-access, capability selection, alignment mechanisms, governance conversion). Two standing procedures live under it: AUDIT (survey a repo for missing guardrails and propose a prioritized adopt/adapt/skip plan) and INTERPRET-FAILURE (a failure just recurred — classify the class and convert it into a durable control: a constraint, sensor, validator, or gate). Use at DESIGN time — reviewing a new subsystem, state machine, queue, cross-service seam, or data model; or introducing concurrency, a trust boundary, an irreversible operation, or duplicated state/logic — to catch predictive smells whose failure class can be prevented by construction. Use when hardening an agent-collaborative codebase, reducing recurring agent-caused regressions, setting up guardrails / lints / gates / typed seams, reviewing governance posture, or when a failure class just recurred and should be prevented structurally, not only patched.npx claudepluginhub davisjam/model-based-agentic-software-engineering --plugin mageOther plugins' skills for the same job