Cross-tool agent instructions for any AI coding assistant working on this repository.
No piece of state lives in two places. Ever. Anywhere in this codebase.
This is not a guideline. It is not a preference. It is not deferrable to a follow-up PR. If a fact already lives somewhere in this codebase, you do NOT copy it into a new field, struct, config block, schema entry, runtime cache, or anywhere else. You reference it. You resolve it from its source on demand.
Why this matters more than anything else you're tempted to ship: every
duplicate state breeds a drift bug whose symptoms surface months later in
production β operator edits the canonical location, the cached copy serves
stale data, the agent silently misbehaves. The previous incarnation of this
codebase had channel allowed_users Vec fields cached inside channel handles
while the truth lived in config TOML; reloading config didn't refresh the
channels; an authorized user couldn't talk to the bot until daemon restart.
Every such field is now banned by this rule.
Adding a duplicate state field is an automatic-revert-on-detect change. The
pre-push gate runs dev/ci.sh dry-check. If it fires, the maintainer will
git reset --hard your branch back to the prior good state, and the time you
spent is wasted. Save yourself the burn: do not write the duplicate in the
first place.
State, in your response text, the source of truth for the new data BEFORE you write the field. Two valid answers:
- "This is the source of truth β created here." OK to write the field. State what it represents.
- "Source of truth is
<path/to/canonical>β this would be a duplicate." Do NOT write the field. Resolve from the canonical location at use-time (closure, helper,&Configparameter, getter trait, whatever fits β never a cache).
Any third answer ("we'll only refresh on restart", "snapshot is fine", "orchestrator passes a Vec in") is a duplicate. Refuse the edit. Find the canonical source and resolve from there.
- A channel handle struct holding
Vec<String>of "authorized users" alongsidepeer_groupsinConfig. - A schema enum variant list duplicated across an enum and a
const &[Variant]table that aren't generated from the same macro. - A
ConfigSnapshotstruct that clones liveConfigfields the runtime can already reach through itsArc<RwLock<Config>>handle. - Re-emitting a model-provider's API key into a runtime struct field when the runtime already has the typed alias config.
- Resolver closures (
Arc<dyn Fn() -> T + Send + Sync>) that close overArc<RwLock<Config>>and resolve on call. &Config/&AgentConfigparameters threaded through call sites.- Materialized views built ON-DEMAND from canonical state (cached per-call, not stored).
- Derive macros that emit multiple surfaces from one input table (e.g. enum + const list from one macro invocation β both come from the same source of truth at expansion time).
cargo fmt --all -- --check
cargo clippy --all-targets -- -D warnings
cargo testFull pre-PR validation (recommended):
./dev/ci.sh allDocs-only changes: run markdown lint and link-integrity checks. If touching bootstrap scripts: bash -n install.sh.
Subagents (via spawn_subagent or cron JobType::Agent) inherit the parent's identity and permissions but run in isolated sessions. Before running any shell commands or filesystem operations, subagents must explicitly set their working directory to the repository root (the directory containing the top-level Cargo.toml and AGENTS.md). Do not assume the shell starts at repo root; always cd to it first (or use the equivalent in the tool's context).
This guarantees consistent command behavior across parent and child runs.
ZeroClaw is a Rust-first autonomous agent runtime optimized for performance, efficiency, stability, extensibility, sustainability, and security.
Core architecture is trait-driven and modular. Extend by implementing traits and registering in factory modules.
Key extension points:
crates/zeroclaw-api/src/provider.rs(Provider)crates/zeroclaw-api/src/channel.rs(Channel)crates/zeroclaw-api/src/tool.rs(Tool)crates/zeroclaw-api/src/memory_traits.rs(Memory)crates/zeroclaw-api/src/observability_traits.rs(Observer)crates/zeroclaw-api/src/runtime_traits.rs(RuntimeAdapter)crates/zeroclaw-api/src/peripherals_traits.rs(Peripheral) β hardware boards (STM32, RPi GPIO)
Every workspace crate carries a stability tier per the Microkernel Architecture RFC.
| Crate | Tier | Notes |
|---|---|---|
zeroclaw-api |
Experimental | Stable at v1.0.0 (formal milestone) |
zeroclaw-config |
Beta | Stable at v0.8.0 |
zeroclaw-log |
Beta | Unified log emission + JSONL persistence + broadcast hook |
zeroclaw-providers |
Beta | β |
zeroclaw-memory |
Beta | β |
zeroclaw-infra |
Beta | β |
zeroclaw-tool-call-parser |
Beta | Stable at v0.8.0 |
zeroclaw-channels |
Experimental | Plugin migration at v1.0.0 |
zeroclaw-tools |
Experimental | Plugin migration at v1.0.0 |
zeroclaw-runtime |
Experimental | Agent runtime (agent loop, security, cron, SOP, skills, observability) |
zeroclaw-gateway |
Experimental | Separate binary at v0.9.0 |
zerocode |
Experimental | TUI onboarding wizard |
zeroclaw-plugins |
Experimental | WASM plugin system β foundation for v1.0.0 plugin ecosystem |
zeroclaw-hardware |
Experimental | USB discovery, peripherals, serial |
zeroclaw-macros |
Beta | Tightly coupled to config schema |
Tiers: Stable = covered by breaking-change policy. Beta = breaking changes permitted in MINOR with changelog notes. Experimental = no stability guarantee.
Tiers are promoted, never demoted, through deliberate team decision.
src/main.rsβ CLI entrypoint and command routingsrc/lib.rsβ module re-exports and CLI command enum definitionscrates/zeroclaw-api/β public trait definitions (Provider, Channel, Tool, Memory, Observer, Peripheral)crates/zeroclaw-config/β schema, config loading/mergingcrates/zeroclaw-log/β unified log surface (record! macro, LogEvent schema, JSONL persistence, broadcast hook, Observer bridge)crates/zeroclaw-macros/β Configurable derive macrocrates/zeroclaw-providers/β model providers and resilient wrappercrates/zeroclaw-channels/β messaging platform integrations (30+ channels)crates/zeroclaw-channels/src/orchestrator/β channel lifecycle, routing, media pipelinecrates/zeroclaw-tools/β tool execution surface (shell, file, memory, browser)crates/zeroclaw-runtime/β agent loop, security, cron, SOP, skills, onboarding wizard, observabilitycrates/zeroclaw-memory/β memory backends (markdown, sqlite, embeddings, vector merge)crates/zeroclaw-infra/β shared infrastructure (debounce, session, stall watchdog)crates/zeroclaw-gateway/β webhook/gateway server (separate binary)crates/zeroclaw-hardware/β USB discovery, peripherals, serial, GPIOcrates/zerocode/β TUI onboarding wizardcrates/zeroclaw-plugins/β WASM plugin systemcrates/zeroclaw-tool-call-parser/β tool call parsingdocs/β topic-based documentation (setup-guides, reference, ops, security, hardware, contributing, maintainers).github/β CI, templates, automation workflows
- Low risk: docs/chore/tests-only changes
- Medium risk: most
crates/*/src/**behavior changes without boundary/security impact - High risk:
crates/zeroclaw-runtime/src/**(especiallysrc/security/),crates/zeroclaw-gateway/src/**,crates/zeroclaw-tools/src/**,.github/workflows/**, access-control boundaries
When uncertain, classify as higher risk.
- Read before write β inspect existing module, factory wiring, and adjacent tests before editing.
- Map non-trivial changes β before architecture, config, security, workflow, governance, CI, or agent-assisted contribution changes, read
docs/book/src/contributing/architecture-map.mdto choose the relevant architecture and foundation docs. - One concern per PR β avoid mixed feature+refactor+infra patches.
- Implement minimal patch β no speculative abstractions, no config keys without a concrete use case.
- Validate by risk tier β docs-only: lightweight checks. Code changes: full relevant checks.
- Document impact β update PR notes for behavior, risk, side effects, and rollback.
- Queue hygiene β stacked PR: declare
Depends on #.... Replacing old PR: declareSupersedes #....
Branch/commit/PR rules:
- Work from a non-
masterbranch. Open a PR tomaster; do not push directly. - Use conventional commit titles. Prefer small PRs (
size: XS/S/M). - Follow
.github/pull_request_template.mdfully. - Never commit secrets, personal data, or real identity information (see
@docs/book/src/contributing/privacy.md).
- Do not add heavy dependencies for minor convenience.
- Do not silently weaken security policy or access constraints.
- Do not add speculative config/feature flags "just in case".
- Do not mix massive formatting-only changes with functional changes.
- Do not modify unrelated modules "while here".
- Do not bypass failing checks without explicit explanation.
- Do not hide behavior-changing side effects in refactor commits.
- Do not suppress unused production code with underscore prefixes or
#[allow(dead_code)]; delete it, wire it into behavior, or track a follow-up issue. Reserve underscore names for required but intentionally unused API, trait, or callback parameters. - Do not leave
unwrap()/expect()in production paths; propagate errors or document the invariant that makes panic impossible. - Do not include personal identity or sensitive information in test data, examples, docs, or commits.
AI coding assistant skills live in .claude/skills/. Use the right one for the job:
.claude/skills/github-pr-review-session/SKILL.mdβ PR review co-pilot; assists you as the human reviewer. Resolves the active reviewer from session state orgh, uses the RFC feedback taxonomy (π΄/π‘/β /π΅/π’), and formats formal review findings as H3 headings that start with the taxonomy emoji. Trigger:review 1234,re-review 1234,go through the queue..claude/skills/changelog-generation/SKILL.mdβ generatesCHANGELOG-next.mdbetween stable tags, resolves contributors via GraphQL, feeds the release workflow. Trigger:generate changelog,release notes for v0.7.x..claude/skills/github-issue-triage/SKILL.mdβ Issue triage and lifecycle management; manages the backlog, labels, and stale policies. Trigger:triage issues,sweep issues,handle issue #N..claude/skills/github-issue/SKILL.mdβ Interactively files structured GitHub issues (bug reports or feature requests) using repo templates. Trigger:file issue,report bug,feature request..claude/skills/github-pr/SKILL.mdβ Opens or updates GitHub PRs, handles validation evidence, and manages PR descriptions. Trigger:open PR,update PR,submit for review..claude/skills/skill-creator/SKILL.mdβ Framework for creating, testing, evaluating, and optimizing new AI skills. Trigger:create skill,improve skill,run skill evals..claude/skills/squash-merge/SKILL.mdβ Performs conventional squash-merges into master with preserved commit history. Trigger:squash-merge #123,land #789..claude/skills/zeroclaw/SKILL.mdβ Operational guide for interacting with a ZeroClaw agent instance via CLI or API. Trigger:check agent status,manage memory,zeroclaw config.
- All user-facing output (CLI messages, tool descriptions, onboarding prompts) must use
fl!()/ Fluent strings β never bare string literals. - Log messages,
tracing::spans/events, and panic messages stay in English with stableerror_keyfields (RFC #5653 Β§4.6). - Panics and
tracing::lines are never translated. - The Wiki and internal developer docs are English only.
Dev-operational contracts β files consumed by AI coding skills and development tooling. Do not move or delete without updating all consuming skills and AGENTS.md:
| Protected file | Consuming skill / tool |
|---|---|
docs/book/src/contributing/pr-review-protocol.md |
github-pr-review-session β review protocol |
docs/book/src/maintainers/changelog-generation.md |
changelog-generation β release procedure |
docs/book/src/maintainers/reviewer-playbook.md |
github-issue-triage β triage governance |
docs/book/src/maintainers/pr-workflow.md |
github-issue-triage β triage discipline |
docs/book/src/contributing/privacy.md |
github-issue-triage, PR template β privacy rules |
docs/book/src/foundations/fnd-00*.md |
github-pr-review-session β RFC reference data; public transparency documents |
@docs/book/src/contributing/architecture-map.mdβ start-here map for humans and coding agents before non-trivial architecture, workflow, config, security, CI, governance, or agent-assisted contribution changes@docs/book/src/developing/extension-examples.mdβ adding providers, channels, tools, peripherals; tool shared-state contract; architecture boundary rules@docs/book/src/contributing/privacy.mdβ privacy rules and neutral-placeholder palette@docs/book/src/maintainers/superseding.mdβ superseded-PR attribution, PR/commit templates, handoff template