---
created: 2026-03-12
source: Rivet
tags: [agent-archive, rivet]
---

# Claude Code Workflow — How Rivet Talks to CC

**Designed: 2026-02-04 | Status: DRAFT — awaiting Michael's approval**

---

## Overview

Rivet (Clawdbot) delegates coding tasks to Claude Code (CC) running on the same VPS. No file-based coordination — direct process control.

---

## Architecture

```
Michael (Telegram)
    ↕
Rivet (Clawdbot, Opus/Sonnet) — COO, task writer, reviewer
    ↕ launches directly via exec
Claude Code (VPS, OAuth/Max plan) — Coder, executor
    ↕ works in
Project Repos (/home/ccuser/rateright-main-site, etc.)
```

**No INBOX.md. No OUTBOX.md. No polling. No git sync.**

---

## How It Works

### 1. Rivet Writes the Task
- Reads the analysis/context
- Writes a CLAUDE.md in the target repo (CC reads this on startup)
- Crafts a specific, self-contained prompt

### 2. Rivet Launches CC
```bash
exec pty:true workdir:/home/ccuser/rateright-main-site background:true 
  command:"claude --dangerously-skip-permissions -p 'THE TASK PROMPT'
  
  When completely finished, run:
  clawdbot gateway wake --text \"Done: [summary]\" --mode now"
```

Key flags:
- `--dangerously-skip-permissions` — auto-approves file edits (sandboxed to repo)
- `-p` — non-interactive print mode (runs and exits)
- `--model sonnet` — use Sonnet for coding (or opus for complex work)
- `--max-budget-usd 5` — cost cap per task
- `workdir` — locks CC to the project directory

### 3. Rivet Monitors
```bash
process action:log sessionId:XXX     # Check progress
process action:poll sessionId:XXX    # Is it still running?
process action:kill sessionId:XXX    # Kill if stuck
```

### 4. CC Notifies When Done
The wake command at the end of the prompt triggers Rivet immediately:
```bash
clawdbot gateway wake --text "Done: Fixed all templates" --mode now
```

### 5. Rivet Reviews
- Reads the git diff
- Checks for bugs, security issues, incomplete work
- Reports to Michael with summary
- Michael approves or requests changes

---

## CLAUDE.md — What CC Reads

Every project repo gets a `CLAUDE.md` with:
1. **Project context** — what this codebase is, tech stack
2. **Current task** — what needs doing right now
3. **Rules** — don't break X, always test Y, commit standards
4. **Tools available** — what's installed, what APIs are accessible

CC reads CLAUDE.md automatically on startup. This is how we give it context without INBOX/OUTBOX.

---

## CC's Built-in Tools

Claude Code has these built-in (no plugins needed):
- **File read/write/edit** — full file system access within workdir
- **Bash/terminal** — run any command
- **Git** — commit, branch, diff, push
- **Search** — grep, find, glob across codebase

### Optional MCP Plugins (can add if needed)
These extend CC's capabilities:
- **Browser** — for testing web pages
- **Database** — direct Supabase/Postgres access
- **Web search** — research docs, APIs
- **GitHub** — create PRs, manage issues

For the website work, built-in tools are sufficient.

---

## Task Spec Template

When Rivet writes a task for CC:

```markdown
## Task: [Short title]

### Context
[What the project is, what's happened, current state]

### Objective
[Clear goal — what should be different when you're done]

### Specific Changes
1. [File/change 1]
2. [File/change 2]
3. [File/change 3]

### Rules
- Don't modify [protected files]
- Test by running [command]
- Commit with message format: "fix: description" or "feat: description"
- Don't push — Rivet will review first

### Acceptance Criteria
- [ ] [Criterion 1]
- [ ] [Criterion 2]
- [ ] [Criterion 3]

### When Done
Run: clawdbot gateway wake --text "Done: [summary]" --mode now
```

---

## Cost Control

- CC uses OAuth (Max plan) — no per-token charges for Anthropic models
- Set `--max-budget-usd 5` as safety cap per task
- For large tasks, break into smaller chunks
- Rivet monitors and kills stuck processes

---

## Error Handling

| Situation | Action |
|-----------|--------|
| CC stuck (no progress >10min) | Rivet kills process, rewrites task |
| CC errors out | Rivet reads log, fixes prompt, relaunches |
| CC produces bad code | Rivet reviews, writes follow-up task |
| CC needs input | Rivet sends via `process action:submit` |

---

## When to Use CC vs Sub-Agents

| Task | Use |
|------|-----|
| Code changes, bug fixes, features | **Claude Code** |
| Research, analysis, writing | **Sub-agent (DeepSeek)** |
| Deep thinking, strategy | **Sub-agent (Opus)** |
| Quick lookups, monitoring | **Rivet directly** |

---

*Direct process control. No files. No polling. Just launch, monitor, review.*
