Agent Rituals
The fixed steps an agent performs every time it
runs, declared once in the harness's context file
(CLAUDE.md / AGENTS.md) and framed around the
lifecycle of a run: beginning → middle → end. At the
start of a session the agent primes context; while working it applies
conventions and records what it learns; before finishing it writes back
learnings and closes out. Because the ritual lives in the context file,
every agent that reads that file — any model, any harness, any
contributor's session — performs the same steps, which is the point:
rituals are how you make agent behaviour consistent and
repeatable rather than dependent on how a given person happened
to prompt.
Rituals are the declarative, always-on, harness-native cousin of Loop Engineering: loop engineering
replaces the human as prompter with a designed loop; a ritual
instead bakes the recurring scaffolding into the context
substrate so it fires on every run without a bespoke loop. They are
also where a Context Substrate is
wired in — "at the start of every session run ml prime;
before you finish run ml record" is a ritual that plugs the
substrate into the run. In the demo, mulch's
ml onboard and seeds' sd onboard
commands literally write the ritual snippet into
CLAUDE.md, so setup is one command and the ritual is
baked into every subsequent agent run.
Claims
Standardising the begin/middle/end steps every agent runs — declared in the context file — is how you make agent behaviour consistent and repeatable. principle — durable: reliability at the run level comes from removing per-session variance; the steps that must happen every time belong in the shared context, not in each operator's head.
Define rituals in
CLAUDE.md/AGENTS.mdso every agent that reads the file follows the same steps, regardless of model, provider, or harness. best practice — context: any codebase driven by agents; the context file is the portable place to put run-invariant steps, and "best" holds because the techniques are deliberately harness-agnostic — the details are customised per stack.For teams, consistent rituals across contributors are make-or-break — without them every engineer's agents behave differently and you get variance ("splay") in how the codebase is worked. best practice — context: teams of dozens/hundreds of engineers all using agents; consistency, not model capability, is the binding constraint at that scale, so shared rituals earn their keep precisely where many contributors touch one codebase.
Rituals build trust incrementally — it is not a one-shot setup; you strengthen the ritual system over time as it grows with the codebase. observation — the payoff (trusting every agent in the codebase "a little bit more") accrues as the rituals are refined, not from dropping three files in once.
Schedule recurring runs as "routines" that reference a skill (not inline instructions), so updating the skill updates the routine, and keep distinct processes as separate routines so a failure localizes. best practice — context: a second source (Austin Marchese) uses Claude desktop's local "Routines" to run a self-improving system's data-ingestion and improvement skills on a cron-like schedule (e.g. Tue/Fri 9am); referencing skills keeps the schedule a thin pointer, and separating ingestion from improvement means a failure names which process broke. See Self-Improving System.
The heaviest scheduled ritual is one that rewrites the skills the other rituals invoke — a nightly consolidation cycle over the agent's own session history. observation — SkillOpt-Sleep (see Offline Consolidation Cycle); it inverts the usual direction, since a routine that edits the context substrate needs a promotion gate and an audit trail, not just a cron entry.
Related
- Offline Consolidation Cycle — a scheduled routine that mines past sessions and rewrites the skills; the ritual with write access to tomorrow's context.
- Knowledge-Graph Lint — a begin/pre-write ritual delivered as a deterministic code hook rather than a context-file instruction; Taoufik's session-start hook (load who-you-are) and pre-write brain-lint hook are rituals the harness fires, not steps the model must remember.
- Distillate: I Gave Claude Code a Permanent Memory — session-start + pre-write Python hooks as the deterministic, harness-fired form of a begin/before-write ritual.
- Loop Engineering — the imperative cousin: loop engineering designs a loop that prompts the agent; rituals declare recurring steps in the context file so they fire on every run.
- Context Substrate — what rituals usually wire in: "prime the substrate at the start, record to it before you finish" is the canonical ritual.
- Context Routing —
CLAUDE.mdas the router that tells every agent where to look and what to do; rituals are the "what to do every time" half of that file. - Meta-Prompt — an adjacent way to standardise agent behaviour by templating the prompt; rituals standardise the lifecycle steps instead.
- Reusable Workflow Library — rituals are the codebase-scoped, always-on version of a shared workflow: solve "what every agent should do here" once, reuse on every run.
- Agent Loop — the begin/middle/end framing mirrors a loop's trigger → execute → output+memory anatomy, pinned to a session instead of an autonomous cycle.
- Distillate: The Agentic Engineering Meta
- Managed Agent — CMA scheduling is a managed, vendor-hosted instance of scheduled "routines"; the bonus "wrap-up" skill (congratulate → overview page → 1–2 next upgrades) is an end-of-run closeout ritual.
- Distillate: How to Build a Self-Improving System with Claude Code — scheduled "routines" that reference skills as the recurring scaffolding for a self-improving system.
- Distillate: Claude Code's New Open-Source "Launch Your Agent" Skill — Loops as a Managed Cloud Service — managed scheduling and a closeout "wrap-up" skill as hosted instances of the scheduled/end-of-run ritual.
- Distillate: microsoft/SkillOpt —
training skills like weights, without touching weights — the nightly
skillopt-sleepcycle as a ritual that rewrites the skills.
Linked from
- Agent-Native Cron
- Agent Task Graph
- Claude Code's New Open-Source "Launch Your Agent" Skill — Loops as a Managed Cloud Service
- Context Substrate
- How to Build a Self-Improving System with Claude Code
- I Gave Claude Code a Permanent Memory
- This Week
- Knowledge-Graph Lint
- Managed Agent
- microsoft/SkillOpt — training skills like weights, without touching weights
- Offline Consolidation Cycle
- Self-Improving System
- Spec-Driven Development
- The Agentic Engineering Meta