# Agent Manual — CLR · CCR · GMR

**Audience:** Cursor agents, Codex teammates, Claude Code sessions, and any automations that orchestrate these relays.  
**Scope:** Engines **B / D / G only**. Do **not** invent OCF or CWR workflows from this pack.

---

## 0. Global invariants

1. **Cursor orchestrates; the engine writes.** You may author PROMPTs, run exec scripts, review diffs, commit **on user request**. You must **not** implement Allowed-file slices yourself while a batch is queued, waiting, failed, skipped, or stopped.
2. **One engine per allowlist.** Never fold `CLR_*` into `CCR_*` or `GMR_*`. Never auto-route a failed engine to another.
3. **Disjoint ownership.** Parallel engines only if Allowed path sets do not overlap. Prefer `engine-disjointness-check.ps1` from CLR/CCR kits when both are live.
4. **Every RESULT needs `## Metering`.** Claim Cursor savings only when the engine diff landed without you rewriting the same slice.
5. **No secret leakage.** Never print API keys, `.env`, or auth tokens into prompts, RESULT, or chat.

---

## 1. Engine B — CLR V2 (Codex Luna Relay)

### Trigger phrases
`CLR`, `CLR V2`, `latest CLR`, `Codex Luna Relay`, `Luna`, `Luna batch`, `Engine B`, `codex.exe exec`.

### Skill / rule
- Cursor: `~/.cursor/skills/codex-luna-relay/SKILL.md`
- Codex mirror: `~/.codex/skills/codex-luna-relay/SKILL.md`
- Repo rule: `.cursor/rules/clr-relay.mdc`

### Artifacts
`.handoff/CLR_<ID>_PROMPT.md` **or** `LUNA_<ID>_PROMPT.md` · `_RESULT.md` · `_STDERR.log`

### Exec
Prefer:

```powershell
.\scripts\handoff\clr-exec.ps1 -Id <ID> -RepoRoot "<abs>"
```

Failover: **`gpt-6-luna` / max → `gpt-6.1-sol` (or `gpt-6-sol`) / high → optional `gpt-6-astra` / high**.  
Use `-c 'approval_policy="never"'` (not `-a never`) on manual `codex exec`.

### Pre-flight
If `.handoff/CLR_HOST_HEALTH.md` / `LUNA_HOST_HEALTH.md` is **red**, or `codex-code-mode-host.exe` missing under `%USERPROFILE%\.codex\.sandbox-bin\` → **do not** run a write batch. RESULT `skipped: pre-flight red`. Savings = 0.

### Hard stop
Empty diff / host red after invoke → failover chain inside `clr-exec`. After chain exhausts: report; **do not** Cursor-implement Allowed files unless user explicitly overrides.

### Forbidden
CWR worktrees, `merged-tip`, `cwr/*` tags, calling CCR/GMR for the same allowlist.

---

## 2. Engine D — CCR V1 (Claude Code Relay)

### Trigger phrases
`CCR`, `CCR V1`, `latest CCR`, `Claude Code Relay`, `Claude relay`, `Claude batch`, `Engine D`, `claude -p`.

### Skill / rule
- Cursor: `~/.cursor/skills/claude-code-relay/SKILL.md`
- Claude mirror: `~/.claude/skills/claude-code-relay/SKILL.md`
- Repo rule: `.cursor/rules/ccr-relay.mdc`

### Artifacts
`.handoff/CCR_<ID>_PROMPT.md` · `_RESULT.md` · `_STDERR.log`

### Exec

```powershell
.\scripts\handoff\ccr-exec.ps1 -Id <ID> -RepoRoot "<abs>"
```

Failover: **opus / high → sonnet / high → optional haiku / high**.

### Usage limits
On 5h/weekly Claude usage limit for **CCR-only** work: **wait for reset and auto-rerun** (default `-OnLimit wait`). Do **not** Cursor-implement. Opt-in `-OnLimit bridge` only when user asks Cursor to continue.

### Hard stop
Auth fail / skipped / failed after failover → report; no Cursor Allowed-file implementation; no auto CLR/GMR.

### Forbidden
`codex.exe`, OpenCode/OCF, Cline, advancing CWR tags.

---

## 3. Engine G — GMR V1 (Gemini Multi-batch Relay)

### Trigger phrases
`GMR`, `GMR V1`, `Engine G`, `Gemini Multi-batch Relay`, `gmr-exec`, `gmr-ingest`, `run the GMR queue`.

### Skill / rule
- Cursor: `~/.cursor/skills/gmr-relay/SKILL.md`
- Repo rule: `.cursor/rules/gmr-relay.mdc`

### Artifacts
`.handoff/GMR_<Id>_PLAN.md`, `GMR_<Id>_<Batch>_PROMPT.md`, `GMR_QUEUE.md`, `gmr-drop/<Id>/…`, `GMR_*_RESULT.md`, `gmr.lock`

### Modes
| Mode | Runner | When |
| --- | --- | --- |
| A | `gemini -p` + `--approval-mode auto_edit` | `geminiPresent` + proven auth |
| B | `agy` same contract | Antigravity path present |
| **C** | Web paste → drop → `gmr-ingest` | **Default** if auth unknown |
| D | Unified diff → `git apply --check` | Diff-preferring drops |

**Never** `--all-files`. **Never** `yolo`.

### Id naming
Scripts prefix `GMR_`. Pass Id as `PILOT_SB`, **not** `GMR_PILOT_SB`, or filenames become `GMR_GMR_*`.

### Agent flow (Mode C)
1. Author PLAN + per-batch PROMPT + QUEUE (`B1` unlocked, rest locked).
2. `gmr-host-health` → expect honest `modeSelected` (unknown auth ⇒ C).
3. `gmr-next` → print steps for human (or Mode A/B command).
4. **Do not** invent Gemini reply content in production runs unless the user asked for a fixture/pilot.
5. After drop exists: `gmr-ingest` — **allowlist choke**: any Forbidden path ⇒ write **nothing**, RESULT fail / needs-correction.
6. Correction prompts only (`-C1`, `-C2`); cap **2** then `stopped`.
7. Assemble = verify allowlist + `git status`/`diff` + smoke + **commit-on-request**. Not regenerating the slice in Cursor.

### Branch
All GMR writes on `gmr/<Id>`. No silent commits to main.

### Hard stop
`waiting` / `needs-correction` / `stopped` / `skipped: slot busy` → Cursor does **not** edit Allowed files and does **not** failover to CLR/CCR.

---

## 4. Prompt authoring contract (all engines)

Every PROMPT must include:

- **Task** — plain acceptance criteria  
- **Allowed** — explicit paths / globs  
- **Forbidden** — at least secrets, lockfiles, and out-of-scope entrypoints  
- **Verification / Smoke** — commands the host will run  
- **STOP** — what not to touch  

GMR PLAN uses `## B1` sections with `### Allowed` / `### Forbidden`.

---

## 5. Integration maps

### Cursor agent
1. Detect invoke phrase → load matching skill only.  
2. Write PROMPT (and GMR PLAN/QUEUE).  
3. Run kit `*-exec.ps1` / `gmr-ingest.ps1` from `scripts/handoff/`.  
4. Read RESULT + diff.  
5. Commit **only** if user asked.

### Codex-only teammate (CLR)
Follow `CLR-V2/FOR-CODEX-TEAMMATE.md` + `CURSOR-PASTE-CLR-V2.md`. Install skill into `~/.codex/skills/`. Do not invent CWR.

### Claude Code (CCR)
Skill mirror under `~/.claude/skills/claude-code-relay/`. Prefer `ccr-exec.ps1` over raw ad-hoc `claude -p` so metering + failover stay consistent.

### Gemini (GMR)
Prefer Mode C until HOST_HEALTH proves A/B. Humans own the paste; agents own PLAN/PROMPT/ingest/verify.

---

## 6. Metering block (copy)

```
## Metering
CursorImpl: no
Engine: CLR|CCR|GMR
ModelOrMode: <slug or A|B|C|D>
filesChanged: <n>
smokePass: yes|no|n/a
correctionsUsed: <0-2>   # GMR
failoverAttempts: <n>    # CLR/CCR
```

---

## 7. Refusal / escalation

| Situation | Agent action |
| --- | --- |
| Pre-flight red | Skip write; report; do not implement |
| Slot busy | Wait / enqueue policy for that engine; do not steal locks |
| 2 corrections exhausted (GMR) | `stopped` → human |
| User asks to “just finish it in Cursor” after engine fail | Require explicit override in the user message before touching Allowed files |
| User asks for OCF/CWR from this pack | Refuse scope; this pack is CLR+CCR+GMR only |

---

## 8. File map (zip)

```
CLR-V2/scripts/clr-exec.ps1
CLR-V2/skill/SKILL.md
CLR-V2/rules/clr-relay.mdc
CCR-V1/scripts/ccr-exec.ps1
CCR-V1/skill/SKILL.md
CCR-V1/rules/ccr-relay.mdc
GMR-V1/scripts/gmr-*.ps1
GMR-V1/skill/SKILL.md
GMR-V1/PASTE.md
*/templates/*
*/INSTALL.md
```
