OpenClaw Agent Rules

A personal AI assistant that runs across your own devices and channels.

On this page

Overview

OpenClaw asks contributors to extend existing commands, skills, or plugins before adding to the core. It also requires clean cutovers, stable conversation history, and permission checks immediately before privileged actions. Local guides cover the details.

Documents

├── 
├──  · symlink → AGENTS.md
├── .agents
│   └── skills
│       └── autoreview
│           ├── 
│           └──  · symlink → AGENTS.md
├── **
│   └── AGENTS.md — Nearest scoped instructions
├── apps
│   ├── android
│   │   ├── 
│   │   └──  · symlink → AGENTS.md
│   ├── ios
│   │   ├── 
│   │   └──  · symlink → AGENTS.md
│   └── macos
│       ├── 
│       └──  · symlink → AGENTS.md
├── docs
│   ├── gateway
│   │   ├── doctor
│   │   │   └── 
│   │   ├── 
│   │   └── 
│   ├── help
│   │   └── testing
│   │       ├── 
│   │       └── 
│   ├── platforms
│   │   └── mac
│   │       └── 
│   ├── plugins
│   │   ├── 
│   │   └── 
│   ├── reference
│   │   ├── templates
│   │   │   ├── roles
│   │   │   │   ├── coordinator
│   │   │   │   │   └── workspace
│   │   │   │   │       └── 
│   │   │   │   ├── researcher
│   │   │   │   │   └── workspace
│   │   │   │   │       └── 
│   │   │   │   ├── reviewer
│   │   │   │   │   └── workspace
│   │   │   │   │       └── 
│   │   │   │   └── writer
│   │   │   │       └── workspace
│   │   │   │           └── 
│   │   │   └── 
│   │   ├── 
│   │   ├── 
│   │   └── 
│   ├── 
│   ├── 
│   └──  · symlink → AGENTS.md
├── extensions
│   ├── acpx
│   │   ├── 
│   │   └──  · symlink → AGENTS.md
│   ├── telegram
│   │   ├── 
│   │   └──  · symlink → AGENTS.md
│   ├── 
│   └──  · symlink → AGENTS.md
├── scripts
│   ├── 
│   └──  · symlink → AGENTS.md
├── src
│   ├── agents
│   │   ├── embedded-agent-runner
│   │   │   └── run
│   │   │       ├── 
│   │   │       └──  · symlink → AGENTS.md
│   │   ├── tools
│   │   │   ├── 
│   │   │   └──  · symlink → AGENTS.md
│   │   ├── 
│   │   └──  · symlink → AGENTS.md
│   ├── channels
│   │   ├── plugins
│   │   │   └── contracts
│   │   │       └── test-helpers
│   │   │           ├── 
│   │   │           └──  · symlink → AGENTS.md
│   │   ├── 
│   │   └──  · symlink → AGENTS.md
│   ├── gateway
│   │   ├── server-methods
│   │   │   ├── 
│   │   │   └──  · symlink → AGENTS.md
│   │   ├── 
│   │   └──  · symlink → AGENTS.md
│   ├── infra
│   │   └── outbound
│   │       ├── 
│   │       └──  · symlink → AGENTS.md
│   ├── plugin-sdk
│   │   ├── 
│   │   └──  · symlink → AGENTS.md
│   ├── plugins
│   │   ├── 
│   │   └──  · symlink → AGENTS.md
│   └── tui
│       ├── 
│       └──  · symlink → AGENTS.md
├── ui
│   ├── 
│   └──  · symlink → AGENTS.md
├── 
├── 
└── 

Patterns in this file

01 / Context budgeting

Account for the cost of core capabilities

The capability ladder starts with existing commands and skills, then plugins, then narrow shared contracts. Adding an integration does not by itself justify a new core manager or tool.

Source excerpt starting at line 13.
- **Small core, capable plugins.** Model-facing core additions have an ongoing context cost. Optional capability belongs at the edges; core supplies generic contracts. A feature needing a new integration is not, by itself, a reason to add another core tool or manager. [VISION.md](VISION.md) owns product scope.

02 / Pointing at the source of truth

Define a complete ownership cutover

The file makes removal part of the migration plan. A new owner is incomplete while duplicate state, registrations, or callers continue to encode the old policy.

Source excerpt starting at line 33.
3. **Cutover:** migrate all affected internal/bundled callers together. Remove superseded code, duplicate policy/state, wrappers, registrations, exports, tests, and docs. Every retained path needs a cited contract. Workers sharing an owner agree on one interface and cutover plan.

03 / Context budgeting

Preserve the prompt prefix

The context guidance links deterministic history to prefix reuse and reserves history rewriting for compaction. This turns prompt assembly into a maintained runtime invariant.

Source excerpt starting at line 14.
- **Stable conversation context.** Rebuilding past context defeats prompt-prefix reuse. Keep generated prompt/tool/context additions bounded and deterministic, preserve transcript bytes, and serve required instructions whole. Only compaction rewrites history. Defer changes to stable prompt state until the next session unless its owner defines explicit invalidation; preserve existing skill, tool, and memory refresh contracts.

04 / Hard prohibitions

Recheck authority after waiting

Authorization depends on current owner-held state, not only a valid-looking token. The instruction places another check after awaited work and immediately before the effect.

Source excerpt starting at line 59.
- Privileged actions require current owner-held authority. Revalidate after awaited work and immediately before side effects; tokens, signatures, expiry, and matching IDs alone do not prove live authority.

05 / Nested instruction files

Route callers to the owner's guide

Scope follows the responsibility being changed, including callers outside its directory. The root links channel, plugin, agent, gateway, UI, testing, release, and security documentation.

Source excerpt starting at line 6.
authorization boundaries still apply. Read the nearest scoped `AGENTS.md` and thematching references below, including when changing callers outside an owner's directory.

Ideas for your repo

  1. Require a reason to put an optional capability into core.
  2. Make removal of superseded state and policy part of a migration checklist.
  3. Document which operations may rewrite stored conversation history.
  4. Revalidate mutable authority after asynchronous work.
  5. Route changes in callers to the guide for the capability they depend on.
Sponsored byModem

Give your agents the whole story.

These instructions explain how to work in OpenClaw. Modem shows your agents what customers said, who is affected, and what changed.

See how Modem works