Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/claude-code-research/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions examples/claude-code-research/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions examples/claude-code-research/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions examples/claude-code-research/scripts/client.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

127 changes: 127 additions & 0 deletions examples/claude-code-research/src/actors.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions examples/claude-code-research/src/server.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions examples/claude-code-research/tsconfig.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions examples/claude-code-research/turbo.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions integrations/claude-code/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# @rivet-dev/claude-code

Run [Claude Code](https://code.claude.com) agents as durable [Rivet](https://rivet.dev) Actors. Each agent runs Claude Code through the [Claude Agent SDK](https://code.claude.com/docs/en/agent-sdk/overview) under your own Claude Code login, so a Claude subscription is enough and no API key is needed.

Each actor is one persistent Claude Code session. Prompts continue the same conversation, and every turn is stored in actor state and broadcast as a `turn` event.

Use your own login for your own local work. Do not use it to serve other people.

```sh
npm add @rivet-dev/claude-code
```

## Agents

```ts
import { claudeCodeAgent } from "@rivet-dev/claude-code";
import { setup } from "rivetkit";

const researcher = claudeCodeAgent({
systemPrompt: "You research questions with web search and cite your sources.",
tools: ["WebSearch", "WebFetch"],
});

export const registry = setup({ use: { researcher } });
registry.start();
```

```ts
const agent = client.researcher.getOrCreate(["rivet-vs-durable-objects"]);
const turn = await agent.prompt("How do Rivet Actors compare to Durable Objects?");
const followUp = await agent.prompt("Which one fits long-running coding agents?");
```

| Option | Description |
|---|---|
| `systemPrompt` | The agent's role. Replaces Claude Code's default system prompt. |
| `tools` | Claude Code tools the agent may use, approved automatically. No tools when omitted. |
| `model` | Model for every turn. Defaults to your Claude Code default. |
| `cwd` | Working directory, for example a repository a coding agent works in. |
| `turnTimeoutMs` | Maximum time for one turn. Defaults to 10 minutes. |
| `claudeCodePath` | Claude Code executable to run. Defaults to the one bundled with the Agent SDK. |

Agents do not load your Claude Code settings or `CLAUDE.md` files, so they behave only as their options describe.

An agent works on one prompt at a time. A prompt sent while a turn is running fails with `claude_code_turn_in_progress`.

## One-off runs

`runClaudeCode` runs Claude Code once. Pass a Zod schema to get validated structured output.

```ts
import { runClaudeCode } from "@rivet-dev/claude-code";
import { z } from "zod";

const plan = await runClaudeCode(
{ prompt: "Plan research on Rivet Actors", systemPrompt: "You plan research." },
z.object({ subQuestions: z.array(z.string()) }),
);
```

## Requirements

- Logged in to Claude Code. Run `claude` once and sign in with your Claude account.
50 changes: 50 additions & 0 deletions integrations/claude-code/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "@rivet-dev/claude-code",
"version": "2.3.20",
"description": "Run Claude Code agents as durable Rivet Actors on your own Claude Code login.",
"license": "Apache-2.0",
"publishConfig": {
"access": "public"
},
"type": "module",
"keywords": [
"rivetkit",
"rivet",
"claude",
"claude-code",
"agents",
"actor",
"durable",
"ai"
],
"files": [
"dist",
"README.md"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"check-types": "tsc --noEmit",
"test": "vitest run"
},
"dependencies": {
"@anthropic-ai/claude-agent-sdk": "^0.3.304",
"rivetkit": "workspace:*",
"zod": "^4.1.0"
},
"devDependencies": {
"@types/node": "^24.0.0",
"typescript": "^5.5.2",
"vitest": "^3.1.1"
},
"engines": {
"node": ">=22.6.0"
}
}
Loading