> For the complete documentation index, see [llms.txt](https://www.openclawbook.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.openclawbook.xyz/en/ch43-engineering-panorama/43.3-ai-collaborative-development.md). Agents can also search and read this documentation through its [MCP server](https://www.openclawbook.xyz/~gitbook/mcp).

# 43.3 AI-Collaborative Development: When the Codebase's First Reader Isn't Human

> **Generated by**: Claude Opus 5 (claude-opus-5\[1m]) **Token usage**: Input \~185,000 tokens, Output \~10,000 tokens (this section) **Source baseline**: `v2026.3.9` (`v2026.3.8-170-g665f67726`)

***

This section has almost no counterpart in other technical books, and it may be the most worth studying part of OpenClaw.

Of 18,005 commits, a substantial fraction were authored by coding agents. When the primary producer of code shifts from humans to AI, what happens to engineering practice? OpenClaw is one of the largest publicly inspectable samples available — and its answer is written down in `AGENTS.md` at the repo root.

## 43.3.1 `AGENTS.md` Is Not a Contributing Guide

Open OpenClaw's `AGENTS.md` — 296 lines. At a glance you'd assume it's a variant of `CONTRIBUTING.md`. A few paragraphs in, it's clearly something else.

A traditional `CONTRIBUTING.md` is written for humans: *please follow the code style, run tests before opening a PR, use imperative mood in commit messages*. Polite suggestions, sustained by community culture.

`AGENTS.md` is written for **coding agents**, and its content is **concrete, executable operating procedure and a catalogue of traps**. Look at the first entry:

> GitHub comment footgun: never use `gh issue/pr comment -b "..."` when body contains backticks or shell chars. Always use single-quoted heredoc (`-F - <<'EOF'`) so no command substitution/escaping corruption.

Translated: don't use `gh pr comment -b "..."` for comments containing backticks — the shell will perform command substitution and mangle it. Always use a single-quoted heredoc.

Why does this rule exist? Because **an agent actually hit this.** A human contributor posts a handful of GitHub comments a year; an agent posts dozens a day, and one shell-escaping trap gets triggered over and over. So the maintainer froze it into a rule.

Nearly the whole document has this shape. A few more:

> * GitHub linking footgun: don't wrap `#24643` in backticks if you want autolinking.
> * GitHub searching footgun: don't stop at the first 500 issues; page to the end.
> * Description newline footgun: write Markdown via heredoc to `/tmp/ghsa.desc.md`, never `"\n"` strings.

Notice the recurring word: **footgun** — an interface that looks reasonable but shoots you in the foot. The document is essentially a **case book of agent mistakes**.

## 43.3.2 Three Categories of Rule, Three Failure Modes

Reading all 296 lines, the rules sort into three groups, each targeting a different failure mode.

### Category 1: Preventing the Characteristic Pathologies of AI-Written Code

```
- Never add `@ts-nocheck` and do not disable `no-explicit-any`;
  fix root causes and update Oxlint/Oxfmt config only when required.

- Never share class behavior via prototype mutation
  (`applyPrototypeMixins`, `Object.defineProperty` on `.prototype`, ...).
  Use explicit inheritance/composition so TypeScript can typecheck.

- In tests, prefer per-instance stubs over prototype mutation
  unless a test explicitly documents why prototype-level patching is required.
```

All three target the same behavior pattern: **when facing a type error or a hard-to-write test, AI gravitates to the shortest path that makes the error disappear** rather than fixing the root cause. `@ts-nocheck` disables type checking for a whole file; prototype mutation makes it impossible for TypeScript to trace where behavior comes from. Both are *works right now, incomprehensible later*.

The maintainer's response isn't "review harder" — it's writing these patterns down as **prohibitions**. Review costs human attention; a prohibition can be read by the agent *before* it writes the code.

### Category 2: Multi-Agent Concurrency Safety

```
- Multi-agent safety: do not create/apply/drop `git stash` entries
  unless explicitly requested (this includes `git pull --rebase --autostash`).
  Assume other agents may be working; keep unrelated WIP untouched.

- Multi-agent safety: do not create/remove/modify `git worktree` checkouts
  (or edit `.worktrees/*`) unless explicitly requested.
```

These two say more than anything else in the document about how much the development paradigm has changed. The scenario they assume: **multiple agents working in the same repository at the same time.**

`git stash` is global. So is `git worktree`. One agent casually running `git pull --rebase --autostash` to tidy its working tree can stash away another agent's half hour of uncommitted work. This rarely happens between humans, because humans have an instinct for *that isn't mine*. Agents don't, so it has to be prohibited explicitly.

Note that `--autostash` is called out by name in parentheses — precisely the kind of *it's just a convenience flag* silent killer. That parenthetical is the fossil of an incident.

### Category 3: Merge Gates

The hardest category, constraining what reaches main:

```
- Never merge a bug-fix PR based only on issue text, PR text, or AI rationale.
- Minimum merge gate for bug-fix PRs:
  1. symptom evidence (repro/log/failing test),
  2. verified root cause in code with file/line,
  3. fix touches the implicated code path,
  4. regression test (fail before/pass after) when feasible.
- If claim is unsubstantiated or likely hallucinated/BS: do not merge.
```

The targeting here is precise. The most common failure mode when AI writes a bug-fix PR: read the issue description, generate a plausible-sounding analysis, change some code that **looks related but isn't**, and write a PR description more polished than a human's.

So the gate demands: symptoms need evidence (repro steps / logs / a failing test), the root cause needs a **file and line number**, the change must land on the implicated code path, and where feasible there must be a regression test that fails before and passes after.

The final line is the bluntest in the file: **"if claim is ... likely hallucinated/BS: do not merge."** The appearance of "BS" in technical documentation tells you the problem occurs often enough that the maintainer ran out of rhetorical patience.

## 43.3.3 Closing the Loop: The `r:*` Label System

Rules need an enforcement mechanism. OpenClaw's answer is to **structure and automate** common issue/PR dispositions:

| Label                      | Trigger                            | Automated action                         |
| -------------------------- | ---------------------------------- | ---------------------------------------- |
| `r: skill`                 | Skill-related request              | Close + point to ClawHub                 |
| `r: support`               | Usage help issue                   | Close + point to Discord support         |
| `r: no-ci-pr`              | Test-only PR fixing CI             | Close + standard explanation             |
| `r: too-many-prs`          | Author over active-PR limit        | Close                                    |
| `r: third-party-extension` | Request to merge feature into core | Close + point to third-party plugin path |
| `dirty`                    | PR carrying unrelated changes      | Close (PR-only)                          |
| `invalid`                  | Invalid item                       | Issues close as `not_planned`; PRs close |

`.github/workflows/auto-response.yml` handles commenting, closing, and locking. `AGENTS.md` explicitly requires:

> Do not manually close + manually comment for these reasons. Why: keeps wording consistent, preserves automation behavior, and keeps triage/reporting searchable by label.

Three reasons — consistent wording, preserved automation behavior (`state_reason`, locking), and **searchability by label** — all point at the same thing: **dispositions must be structured data, not natural language.** Hand-written closing comments can't be aggregated; labels can. Once issue volume is high enough that agents participate in triage, aggregability becomes a hard requirement.

`dirty` is especially telling: it exists specifically for *PRs carrying unrelated changes*, which is a signature agent behavior — reformatting a whole file in passing, tidying adjacent code it found inelegant. Such PRs are extremely expensive for a human reviewer, so they get a fast-close lane.

## 43.3.4 What This Means for You

Three transferable lessons if you want to borrow OpenClaw's approach:

**First, turn review comments into rules instead of repeating them.** Human review relies on *say it once, they'll remember*. An agent won't remember — but it *will* read `AGENTS.md`. So **every review comment you've made more than twice should become a line in a rules file.** The ROI on this discipline rises linearly with agent participation.

**Second, be more specific about what not to do than about what to do.** `AGENTS.md` contains far more prohibitions than suggestions, and every prohibition names a concrete API (`applyPrototypeMixins`, `--autostash`, `@ts-nocheck`). A vague "please mind code quality" does nothing for an agent; `never use X` works.

**Third, gates should demand evidence, not argument.** Requirements like *file and line number* and *fails before, passes after* exist to **convert unverifiable natural-language claims into checkable factual assertions.** AI is far better at generating argument than at generating evidence, so the gate belongs on the evidence.

One last observation, and the source of this section's title: reading `AGENTS.md` you realize that **the maintainer's core work has shifted from writing code to building guardrails and case law for agents.** Of 18,005 commits, the human-written share concentrates increasingly on rules, gates, tests, and architectural decisions. This isn't unique to OpenClaw — it's plausibly the general migration happening to this generation of software engineering, and this repository happens to be a fully inspectable first-hand record of it.

***

## Section Summary

1. OpenClaw's `AGENTS.md` (296 lines) is **not a contributing guide but an operating procedure and case book for coding agents**, written mostly as concrete `never use X, always use Y` prohibitions.
2. Three rule categories: **preventing AI code pathologies** (no `@ts-nocheck`, no prototype mutation), **multi-agent concurrency safety** (don't touch stash or worktrees), and **merge gates** (bug-fix PRs need symptom evidence + root cause with line numbers + regression test).
3. The `r:*` label system **structures and automates** common dispositions — for consistent wording, preserved automation, and label-based aggregation. Once agents do triage, aggregability is mandatory.
4. Three transferable lessons: **sediment repeated review comments into rules**, **make prohibitions specific down to the API name**, and **gate on evidence rather than argument**.
