# SageOx + OpenClaw (/docs/cookbooks/openclaw)



SageOx + OpenClaw [#sageox--openclaw]

OpenClaw orchestrates automated AI coding sessions — spawning agents that work on issues, PRs, and maintenance tasks without human intervention. SageOx gives those agents the same team context a human coworker would have, and their discoveries flow back into your team's knowledge base.

How it works [#how-it-works]

<Mermaid
  chart="graph TD
    OC[OpenClaw Factory] -->|spawns| CS[Claude Code Session]
    CS -->|reads CLAUDE.md| AP[ox agent prime]
    AP -->|injects| TC[Team Context]
    CS -->|session artifacts| L[Ledger]
    L -->|distillation| M[Team Memory]
    M -->|feeds back| TC"
/>

Every factory-spawned session follows the same lifecycle as a human coding session — it receives team context on startup, and its discoveries flow back into the knowledge base.

What you need [#what-you-need]

* SageOx CLI installed (`ox`)
* A connected repo (`ox init`)
* An [OpenClaw](https://openclaw.dev) account with factory access

Setup [#setup]

1. Connect your repo [#1-connect-your-repo]

<Terminal>
  <TerminalCommand>
    ox login
  </TerminalCommand>

  <TerminalCommand>
    cd ~/code/my-project
  </TerminalCommand>

  <TerminalCommand>
    ox init
  </TerminalCommand>
</Terminal>

`ox init` configures your `CLAUDE.md` with the `ox agent prime` hook. This is the universal integration point — any tool that starts Claude Code in your repo gets SageOx context automatically, including OpenClaw.

2. Verify factory agents receive context [#2-verify-factory-agents-receive-context]

When OpenClaw spawns a session, it starts Claude Code in your repo. Claude Code reads `CLAUDE.md` and runs `ox agent prime`. Verify with:

<Terminal>
  <TerminalCommand>
    ox status
  </TerminalCommand>
</Terminal>

Each factory agent receives the full team context payload:

| Context layer              | What the agent receives                 |
| -------------------------- | --------------------------------------- |
| **Team norms**             | AGENTS.md conventions, coding standards |
| **Architecture decisions** | Distilled discussions and recordings    |
| **Domain terminology**     | Team-specific vocabulary and concepts   |
| **Recent memory**          | Summaries from recent team activity     |
| **Current work**           | What's happening across your product    |

3. Enable session capture [#3-enable-session-capture]

Configure factory sessions to use session capture:

```
/ox-session-start
... agent works on the issue ...
/ox-session-stop
```

Session transcripts — the agent's reasoning, decisions, and code changes — get committed to your repo's Ledger and feed into future sessions.

The overnight factory pattern [#the-overnight-factory-pattern]

Run OpenClaw agents on a nightly schedule against your backlog:

1. **OpenClaw picks issues** labeled `factory-ready` from your tracker
2. **For each issue**, it spawns a Claude Code session in the relevant repo
3. **`ox agent prime` injects team context** including yesterday's distilled insights
4. **The agent works on the issue**, commits code, opens a PR
5. **Session artifacts are captured** to the Ledger
6. **Distillation extracts insights** for future sessions

Your team arrives to PRs ready for review, with full context on why each change was made.

Multi-agent awareness [#multi-agent-awareness]

When multiple agents run in parallel — each in its own git worktree working on a different issue — SageOx ensures they share context:

* An agent refactoring the auth module knows another agent is adding a new endpoint that depends on auth
* An agent updating types knows another agent changed the schema those types derive from
* Merge conflicts and duplicate work drop because agents are aware of each other's in-flight changes

This is the difference between N isolated agents and N agents that collaborate.

Cross-platform context [#cross-platform-context]

Most coding agents have some form of memory or team context — but it's locked to that vendor. Claude Code's memory doesn't reach Codex. If your team uses more than one agent platform, each agent operates blind to what the others know.

SageOx sits underneath all of them. Because context flows through the repo itself via `ox agent prime`, it works with any agent that reads `CLAUDE.md` or `AGENTS.md`. A discovery made in one agent is available to every other agent in the next session.

The compounding loop [#the-compounding-loop]

The real power is the feedback loop between factory agents and distillation:

1. **Factory agent works on an issue** — discovers that the payment service needs a retry wrapper
2. **Session gets captured** to the Ledger
3. **Distillation extracts the insight** — "payment service calls need retry wrappers due to intermittent timeouts"
4. **Next factory session receives this** via team context
5. **That agent adds retries proactively** when touching payment code

After a month of factory runs plus distillation, your agents have absorbed hundreds of codebase-specific insights that no prompt engineering could replicate.

Best practices [#best-practices]

**Start with well-scoped issues**
Factory agents work best on issues with clear acceptance criteria. "Add retry logic to payment service" beats "improve reliability".

**Review PR descriptions**
Factory agents include their reasoning in PR descriptions. This becomes part of the permanent record and feeds future context.

**Capture important sessions**
Use `/ox-session-start` for sessions that produce valuable insights. Not every session needs capturing — focus on debugging breakthroughs and architecture decisions.

**Feed recordings into context**
Import Loom walkthroughs and design sessions. Factory agents implementing UI benefit from design rationale captured in recordings.

What's next [#whats-next]

* [SageOx + Claude Code](/docs/developers/claude-code) — the full coding session lifecycle
* [SageOx + Loom](/docs/cookbooks/loom) — feed design walkthroughs into the context loop
* [SageOx + Figma](/docs/cookbooks/figma) — turn design decisions into agent context
* [Distillation](/docs/features/distill) — how the memory pipeline works
* [Video Import](/docs/context-capture/video-import) — import recordings that feed into context
