Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix: guard prepare script for Docker + add CLAUDE.md alongside every AGENTS.md (#998)

Carbon Agentcf77e3d4d024
diff --git a/.ai/lessons.md b/.ai/lessons.md
index 2c3e25fbe8..410f1f98e5 100644
--- a/.ai/lessons.md
+++ b/.ai/lessons.md
@@ -6,46 +6,6 @@ Format: `Context → Problem → Rule → Applies to`
---
-## Docker group membership requires gateway restart
-
-**Context:** Adding the openclaw user to the docker group for container access.
-
-**Problem:** The running process inherits the old group list from its parent shell. The new group membership isn't visible until the process restarts.
-
-**Rule:** Always restart the gateway (or any long-running service) after group membership changes. Don't assume the current process picks up new groups.
-
-**Applies to:** Any systemd service or long-running process needing new group access.
-
-## Binding format requires YAML frontmatter
-
-**Context:** The conductor's `parseBinding()` function parses binding files for the inner loop.
-
-**Problem:** `parseBinding()` only reads YAML frontmatter between `---` delimiters. When `title:` and `acceptance:` criteria were placed as markdown headings/checkboxes in the body (outside the frontmatter block), they were silently ignored.
-
-**Rule:** `title:` and `acceptance:` list MUST be inside the `---` YAML frontmatter block, not as markdown headings or checkboxes in the body.
-
-**Applies to:** `CARBON_AGENT.md`, all binding synthesis, `packages/harness/src/binding.ts`.
-
-## `gh issue list` excludes PRs
-
-**Context:** The heartbeat loop scans for assigned work using `gh issue list --assignee carbon-agent`.
-
-**Problem:** GitHub's issue API excludes pull requests. Human-opened PRs assigned to carbon-agent (like PR #978 for ECOs) were invisible to the heartbeat — they don't appear in `gh issue list` results AND they don't appear in `gh pr list --author carbon-agent` because Brad authored them.
-
-**Rule:** Always check BOTH `gh issue list --assignee` AND `gh pr list --assignee` when scanning for assigned work. PRs and issues are separate API surfaces.
-
-**Applies to:** Heartbeat cron, `CARBON_AGENT.md`, agent-prompt.md.
-
-## Orphaned claude subprocesses after OOM
-
-**Context:** The harness parent process gets SIGKILL'd by the OOM killer during a build.
-
-**Problem:** The `claude -p` doer subprocess survives because SIGKILL doesn't propagate to children. The judge may then run in degraded context (missing the doer's output) and revert good changes.
-
-**Rule:** After a harness failure (especially OOM), check the worktree for untracked files to recover doer output before cleaning up. Don't assume a failed build left nothing useful behind.
-
-**Applies to:** Post-failure recovery in conductor loop, `packages/harness/`.
-
## Permission scope renames are invisible to typecheck
**Context:** Renaming DB RLS policies (e.g., `plm_*` → `production_*`) as part of a module rename.
@@ -56,36 +16,6 @@ Format: `Context → Problem → Rule → Applies to`
**Applies to:** Any permission or scope rename, `apps/erp/app/routes/`, `apps/erp/app/modules/`.
-## Memory index requires force rebuild after embedding provider change
-
-**Context:** The memory index was built with the wrong embedding provider.
-
-**Problem:** Stale embeddings from the wrong provider don't match queries, making memory search return irrelevant results.
-
-**Rule:** Run `openclaw memory index --force` whenever the embedding provider changes. Don't assume the old index is compatible.
-
-**Applies to:** OpenClaw memory system configuration.
-
-## smee.io SSE connections silently drop
-
-**Context:** GitHub webhook relay uses smee.io for SSE-based event delivery.
-
-**Problem:** The SSE connection can drop silently without the client detecting it. This caused a 30-minute gap in event delivery with no error logs.
-
-**Rule:** Force periodic reconnection with `RuntimeMaxSec=900` on the systemd service, and maintain a polling fallback via `gh api` in the heartbeat to catch missed events.
-
-**Applies to:** `smee-webhook.service`, heartbeat cron, webhook infrastructure.
-
-## `crbn up --minimal` broken by docker-compose profile dependencies
-
-**Context:** PR #979 added a `depends_on: meta` to the kong service.
-
-**Problem:** The `meta` service was scoped to `profiles: ["full"]`, but kong needed it even in minimal mode. `crbn up --minimal` failed because docker-compose wouldn't start a `full`-profile service as a dependency of an unscoped service.
-
-**Rule:** When adding `depends_on` in docker-compose, verify the dependency is available in ALL profiles where the dependent service runs. Don't assume a service is always available.
-
-**Applies to:** `docker-compose.yml`, `packages/dev/`, `crbn up`.
-
## Multi-tenancy: every query must scope by companyId
**Context:** Writing service functions that query the database.
@@ -96,16 +26,6 @@ Format: `Context → Problem → Rule → Applies to`
**Applies to:** All `*.service.ts` files, any Kysely or Supabase query.
-## Route actions must throw redirect on success, not return
-
-**Context:** Writing form submission handlers in React Router route actions.
-
-**Problem:** Using `return redirect(...)` instead of `throw redirect(...)` causes the redirect to be treated as data, not a navigation. The form stays on the page with stale state.
-
-**Rule:** On success, route actions MUST use `throw redirect(path)`. On failure, use `return data({}, await flash(request, error(...)))`.
-
-**Applies to:** All route action functions in `apps/erp/app/routes/`, `apps/mes/app/routes/`.
-
## ValidatedForm needs the validator, not the raw schema
**Context:** Building forms with zod validation.
diff --git a/playbooks/backup-export-download.md b/.ai/playbooks/backup-export-download.md
similarity index 100%
rename from playbooks/backup-export-download.md
rename to .ai/playbooks/backup-export-download.md
diff --git a/playbooks/create-credit-debit-memo.md b/.ai/playbooks/create-credit-debit-memo.md
similarity index 100%
rename from playbooks/create-credit-debit-memo.md
rename to .ai/playbooks/create-credit-debit-memo.md
diff --git a/playbooks/onboarding-checklist-toggle.md b/.ai/playbooks/onboarding-checklist-toggle.md
similarity index 100%
rename from playbooks/onboarding-checklist-toggle.md
rename to .ai/playbooks/onboarding-checklist-toggle.md
diff --git a/.ai/qa/CLAUDE.md b/.ai/qa/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/.ai/qa/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/.ai/skills/test/SKILL.md b/.ai/skills/test/SKILL.md
index 60f12df719..d84c19a831 100644
--- a/.ai/skills/test/SKILL.md
+++ b/.ai/skills/test/SKILL.md
@@ -1,6 +1,6 @@
---
name: test
-description: Agentically test a specific feature by analyzing the branch diff, building a test plan, and driving the app through agent-browser. Builds on /login and /error skills. Caches successful playbooks to playbooks/ for reuse.
+description: Agentically test a specific feature by analyzing the branch diff, building a test plan, and driving the app through agent-browser. Builds on /login and /error skills. Caches successful playbooks to .ai/playbooks/ for reuse.
---
# Feature Test
@@ -21,7 +21,7 @@ The user may provide:
Before doing anything else, check if there are cached playbooks for the feature being tested:
```bash
-ls playbooks/
+ls .ai/playbooks/
```
If a matching playbook exists (e.g., `create-purchase-order.md` when testing purchase order creation), read it and use the cached navigation steps, selectors, and field mappings. This saves significant time — skip to Step 4 (Login) and use the playbook's steps directly.
@@ -149,7 +149,7 @@ Track each test with its status:
### Step 7: Cache successful playbooks
-After each **PASS** test, write or update a playbook file at `playbooks/<feature-slug>.md`. This is critical for future efficiency.
+After each **PASS** test, write or update a playbook file at `.ai/playbooks/<feature-slug>.md`. This is critical for future efficiency.
**Playbook format:**
diff --git a/.ai/specs/CLAUDE.md b/.ai/specs/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/.ai/specs/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/.deepsec/CLAUDE.md b/.deepsec/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/.deepsec/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/apps/erp/app/modules/accounting/CLAUDE.md b/apps/erp/app/modules/accounting/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/apps/erp/app/modules/accounting/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/apps/erp/app/modules/inventory/CLAUDE.md b/apps/erp/app/modules/inventory/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/apps/erp/app/modules/inventory/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/apps/erp/app/modules/items/CLAUDE.md b/apps/erp/app/modules/items/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/apps/erp/app/modules/items/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/apps/erp/app/modules/people/CLAUDE.md b/apps/erp/app/modules/people/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/apps/erp/app/modules/people/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/apps/erp/app/modules/production/CLAUDE.md b/apps/erp/app/modules/production/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/apps/erp/app/modules/production/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/apps/erp/app/modules/purchasing/CLAUDE.md b/apps/erp/app/modules/purchasing/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/apps/erp/app/modules/purchasing/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/apps/erp/app/modules/quality/CLAUDE.md b/apps/erp/app/modules/quality/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/apps/erp/app/modules/quality/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/apps/erp/app/modules/resources/CLAUDE.md b/apps/erp/app/modules/resources/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/apps/erp/app/modules/resources/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/apps/erp/app/modules/sales/CLAUDE.md b/apps/erp/app/modules/sales/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/apps/erp/app/modules/sales/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/package.json b/package.json
index 8fb7f2d6e9..41c170fa7c 100755
--- a/package.json
+++ b/package.json
@@ -60,7 +60,7 @@
"lingui:clean": "node ./scripts/strip-po-headers.mjs",
"postinstall": "pnpm --filter @carbon/documents build",
"install-skills": "bash .ai/scripts/install-skills.sh",
- "prepare": "pnpm exec husky install && bash .ai/scripts/install-skills.sh",
+ "prepare": "pnpm exec husky install; if [ -f .ai/scripts/install-skills.sh ]; then bash .ai/scripts/install-skills.sh; fi",
"test": "turbo run test",
"tool:new": "tsx scripts/create-tool.ts",
"translate": "pnpm run lingui:extract && pnpm exec linguito translate --llm && pnpm lingui:clean",
diff --git a/packages/auth/CLAUDE.md b/packages/auth/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/auth/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/checks/CLAUDE.md b/packages/checks/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/checks/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/config/CLAUDE.md b/packages/config/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/config/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/database/CLAUDE.md b/packages/database/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/database/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/dev/CLAUDE.md b/packages/dev/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/dev/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/documents/CLAUDE.md b/packages/documents/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/documents/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/ee/CLAUDE.md b/packages/ee/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/ee/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/env/CLAUDE.md b/packages/env/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/env/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/form/CLAUDE.md b/packages/form/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/form/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/glossary/CLAUDE.md b/packages/glossary/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/glossary/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/harness/CLAUDE.md b/packages/harness/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/harness/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/jobs/CLAUDE.md b/packages/jobs/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/jobs/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/kv/CLAUDE.md b/packages/kv/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/kv/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/lib/CLAUDE.md b/packages/lib/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/lib/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/locale/CLAUDE.md b/packages/locale/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/locale/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/notifications/CLAUDE.md b/packages/notifications/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/notifications/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/onboarding/CLAUDE.md b/packages/onboarding/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/onboarding/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/printing/CLAUDE.md b/packages/printing/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/printing/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/react/CLAUDE.md b/packages/react/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/react/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/stripe/CLAUDE.md b/packages/stripe/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/stripe/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/tiptap/CLAUDE.md b/packages/tiptap/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/tiptap/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/packages/utils/CLAUDE.md b/packages/utils/CLAUDE.md
new file mode 100644
index 0000000000..43c994c2d3
--- /dev/null
+++ b/packages/utils/CLAUDE.md
@@ -0,0 +1 @@