Overview/Architecture

A small engine, and data around it

Behaviour that must hold is Python. Behaviour that guides is data. That single split decides the module boundaries, the file formats and the test strategy.

Layers

Three layers, in one direction. Canonical source is written by a human. The engine reads it. Adapters render it outward.

Layer diagram Canonical source files are loaded by the engine, which is used by the command line and rendered by the adapters into five platform trees. canonical source skills/<name>/SKILL.md · agents/<role>.md · hooks/rules/<Event>/*.json core/zyrompts classify prompts policy review workflow state research decorum agents telemetry hooks handlers adapters evals cli no third-party imports cli.py 13 commands, each with an exit code adapters.py pure renderers, five platforms

Canonical source

Skills carry frontmatter for name, description, allowed-tools, argument-hint, depends-on and optional-depends-on. The body is the procedure. Six of the thirteen roles also have a written contract in agents/; a parametrised test checks each of those against agents.py:REGISTRY and fails if they drift apart. Hook rules are one JSON file per rule.

Everything else in the repository is generated or derived.

The engine

Fifteen modules in core/zyrompts/. No third-party imports, so the same code runs inside a hook, in a CI job, or on an air-gapped machine with only Python 3.9 or newer.

Module, responsibility, and the invariant that matters
ModuleResponsibilityInvariant
classify.pyintent, complexity, tier, injection signalsa code-changing request with no anchor is never DIRECT
prompts.pyscore, framework choice, rewritean explain request is not graded on success criteria
policy.pyautonomy levels, hard denials, redactionhard denials fire under YOLO
hooks.pyrule loading, validation, priority mergeexit 0 on every path
handlers.pynamed handlers and matchersstring names only, never eval or importlib
state.pyproject state and event logatomic write; schema downgrade refused
workflow.pyphases, gates, bounded loopsa block records where to resume
review.pyplan, spec and diff critiquea finding is reported only after refutation
research.pysource tiering, confidenceconfidence needs evidence, not vibes
agents.pyroles, delegation, schedulingno agent reviews its own output
adapters.pycanonical to platform rendererspure functions; no I/O except write
evals.pyJSONL datasets, evaluatorsone failing case does not stop the suite
decorum.pybehaviour policy, plus a checkerclaims without evidence are flagged
telemetry.pycost and duration accountingpriced by tier, not by product name
cli.pythe command lineevery capability scriptable without a model

Hook dispatcher

The dispatcher loads every rule, validates it against the capability matrix, evaluates its criteria against the payload, and merges matching fragments by priority. Lower number runs first.

Handlers are named, not imported

A rule says "handler": "intake", and the dispatcher looks the name up in a dictionary. There is no path-based import, no getattr, no eval. A rule file stays data even if an attacker controls it.

The dispatcher never fails loudly

Missing event, unparsable stdin, unknown rule, bad regex: each returns an empty result and exit 0. A hook that crashes blocks the user's prompt, which is worse than a hook that does nothing.

Bypass is a contract

* skips, # memorises, / is a slash command, and harness machine events such as <task-notification> and <system-reminder> are silent. The handler layer mirrors the engine's own check, so a handler-backed rule cannot diverge from an action-backed one.

payload on stdin
  -> load rules for the event
  -> validate each against CAPABILITY_MATRIX
  -> evaluate criteria
  -> merge inject_context fragments by priority
  -> print one hookSpecificOutput object
  -> exit 0

Adapters

An adapter is a pure function from a list of skills to a mapping of paths to contents. Writing is the only I/O. That makes the generated trees byte-reproducible, and scripts/generate-adapters.py --check turns drift into a CI failure rather than a review comment.

Canonical frontmatter, and what each renderer keeps
Canonical keyClaude CodeGeminiCopilotOpenCode
nameas-iszy-slugzy-slugomitted
descriptionyesyesyes, with a use-when suffixyes
allowed-toolsyesyesdroppedas tools:
argument-hintyesdroppeddroppeddropped
depends-onnot emittednot emittednot emittednot emitted

depends-on is validated at build time for unknown names and cycles, and used to order the Codex index. It is not emitted into platform frontmatter because no platform reads it.

The hook engine is Claude Code only. It is the only one of the five platforms with a hook protocol this engine targets. On the others, the procedures still say to classify first, and zyrompts classify works as a CLI step.

Lifecycle

Thirteen phases with a gate each, and four tiers that select a prefix. The tier is a floor, never a ceiling.

INTAKE -> CLARIFY -> RESEARCH -> SPECIFY -> PLAN -> CRITIQUE -> APPROVE
       -> IMPLEMENT -> REVIEW -> FIX -> VERIFY -> ARCHIVE -> DONE

A blocked phase records resume_at, so the workflow stays blocked until the gate is met instead of skipping forward. Two loops are bounded: critique stops after 3 iterations and fix stops after 2, both recorded in history when the cap is reached.

State

The state store writes .zyrompts/state/project.json atomically: temporary file, flush, rename. It appends to an event log in JSONL. The state file carries a schema version, and loading a newer version raises rather than silently dropping fields the running code does not understand.

The reason is narrow. A long agent run that loses its state has to re-derive every decision, and the second derivation will not match the first.

Data flow, end to end

  1. UserPromptSubmit fires. The dispatcher loads the intake rule, which calls the classifier and injects the tier, the intent and the first phase.
  2. The agent follows the named skill. Each skill's procedure is the contract, and its dependencies say what must exist first.
  3. Before every mutating tool, PreToolUse fires. The policy engine returns allow, ask or deny, with the rule that fired.
  4. On Stop, the completion check runs. A completion claim is checked against evidence in the transcript, and the missing proof is injected back.
  5. Archive writes the handoff. The state store records the decision so the next session starts from it.

Extending it

What you change, where, and whether a rebuild is needed
Want to changeWhereRebuild
a nudge's wording or triggerhooks/rules/<Event>/*.jsonno
a skill's procedureskills/<name>/SKILL.mdadapters --write
a platform's output formatadapters.py rendereradapters --write
a policy rulepolicy.py tablesno
a lifecycle gateworkflow.pyno
an eval expectationevals/datasets/*.jsonlno

Adding a platform means writing one renderer, one builder, and a test, then running the generator. The builder must be pure, because that is what makes the drift check meaningful.

Why no framework

The core is a few thousand lines of standard library. A dependency-free core is what makes the hooks safe to install, the evals fast enough to run on every commit, and the behavior reproducible on a machine with no network.

A framework would add an install step to a tool whose whole job is to run before the agent does. That trade is not worth it here.

Next: the security model

Every hard denial, the injection floor, and what is explicitly out of scope for a report.