Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit 3a6e893

Browse files
committed
chore: symlink CLAUDE.md to AGENTS.md (#1210)
1 parent cf644e0 commit 3a6e893

File tree

2 files changed

+197
-196
lines changed

2 files changed

+197
-196
lines changed

AGENTS.md

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
# RivetKit Development Guide
2+
3+
## Project Naming
4+
5+
- Use `RivetKit` when referring to the project in documentation and plain English
6+
- Use `rivetkit` when referring to the project in code, package names, and imports
7+
8+
## `packages/**/package.json`
9+
10+
- Always include relevant keywords for the packages
11+
- All packages that are libraries should depend on peer deps for: @rivetkit/*, @hono/*, hono
12+
13+
## `packages/**/README.md`
14+
15+
Always include a README.md for new packages. The `README.md` should always follow this structure:
16+
17+
```md
18+
# RivetKit {subname, e.g. library: Rivet Actor, driver and platform: RivetKit Cloudflare Workers Adapter}
19+
20+
_Lightweight Libraries for Backends_
21+
22+
[Learn More →](https://github.com/rivet-gg/rivetkit)
23+
24+
[Discord](https://rivet.gg/discord) — [Documentation](https://rivetkit.org) — [Issues](https://github.com/rivet-gg/rivetkit/issues)
25+
26+
## License
27+
28+
Apache 2.0
29+
```
30+
31+
## Common Terminology
32+
33+
- **Actor**: A stateful, long-lived entity that processes messages and maintains state
34+
- **Manager**: Component responsible for creating, routing, and managing actor instances
35+
- **Action**: Method for an actor to expose callable functions to clients
36+
- **Event**: Asynchronous message sent from an actor to connected clients
37+
- **Alarm**: Scheduled callback that triggers at a specific time
38+
39+
### Coordinated Topology Terminology
40+
41+
- **Peer**: Individual actor instance in a coordinated network
42+
- **Node**: Physical or logical host running one or more actor peers
43+
44+
## Build Commands
45+
46+
Run these commands from the root of the project. They depend on Turborepo, so you cannot run the commands within the package itself. Running these commands are important in order to ensure that all dependencies are automatically built.
47+
48+
- **Type Check:** `pnpm check-types` - Verify TypeScript types
49+
- **Check specific package:** `pnpm check-types -F rivetkit` - Check only specified package
50+
- **Build:** `pnpm build` - Production build using Turbopack
51+
- **Build specific package:** `pnpm build -F rivetkit` - Build only specified package
52+
- **Format:** `pnpm fmt` - Format code with Biome
53+
- Do not run the format command automatically.
54+
55+
## Core Concepts
56+
57+
### Topologies
58+
59+
rivetkit supports three topologies that define how actors communicate and scale:
60+
61+
- **Singleton:** A single instance of an actor running in one location
62+
- **Partition:** Multiple instances of an actor type partitioned by ID, useful for horizontal scaling
63+
- **Coordinate:** Actors connected in a peer-to-peer network, sharing state between instances
64+
65+
### Driver Interfaces
66+
67+
Driver interfaces define the contract between rivetkit and various backends:
68+
69+
- **ActorDriver:** Manages actor state, lifecycle, and persistence
70+
- **ManagerDriver:** Manages actor discovery, routing, and scaling
71+
- **CoordinateDriver:** Handles peer-to-peer communication between actor instances
72+
- Only applicable in coordinate topologies
73+
74+
## Package Import Resolution
75+
76+
When importing from workspace packages, always check the package's `package.json` file under the `exports` field to determine the correct import paths:
77+
78+
1. Locate the package's `package.json` file
79+
2. Find the `exports` object which maps subpath patterns to their file locations
80+
3. Use these defined subpaths in your imports rather than direct file paths
81+
4. For example, if you need to import from a package, check its exports to find if it exposes specific subpaths for different modules
82+
83+
This ensures imports resolve correctly across different build environments and prevents errors from direct file path imports that might change.
84+
85+
## Code Style Guidelines
86+
87+
- **Formatting:** Uses Biome for consistent formatting
88+
- See biome.json for reference on formatting rules
89+
- **Imports:** Organized imports enforced, unused imports warned
90+
- **TypeScript:** Strict mode enabled, target ESNext
91+
- **Naming:**
92+
- camelCase for variables, functions
93+
- PascalCase for classes, interfaces, types
94+
- UPPER_CASE for constants
95+
- Use `#` prefix for private class members (not `private` keyword)
96+
- **Error Handling:**
97+
- Extend from `ActorError` base class (packages/core/src/actor/errors.ts)
98+
- Use `UserError` for client-safe errors
99+
- Use `InternalError` for internal errors
100+
- Don't try to fix type issues by casting to unknown or any. If you need to do this, then stop and ask me to manually intervene.
101+
- Write log messages in lowercase
102+
- Use `logger()` to log messages
103+
- Do not store `logger()` as a variable, always call it using `logger().info("...")`
104+
- Use structured logging where it makes sense, for example: `logger().info("foo", { bar: 5, baz: 10 })`
105+
- Supported logging methods are: trace, debug, info, warn, error, critical
106+
- Instead of returning errors as raw HTTP responses with c.json, use or write an error in packages/rivetkit/src/actor/errors.ts and throw that instead. The middleware will automatically serialize the response for you.
107+
108+
## Project Structure
109+
110+
- Monorepo with pnpm workspaces and Turborepo
111+
- Core code in `packages/core/`
112+
- Platform implementations in `packages/platforms/`
113+
- Driver implementations in `packages/drivers/`
114+
115+
## Development Notes
116+
117+
- Use zod for runtime type validation
118+
- Use `assertUnreachable(x: never)` for exhaustive type checking in switch statements
119+
- Add proper JSDoc comments for public APIs
120+
- Ensure proper error handling with descriptive messages
121+
- Run `pnpm check-types` regularly during development to catch type errors early. Prefer `pnpm check-types` instead of `pnpm build`.
122+
- Use `tsx` CLI to execute TypeScript scripts directly (e.g., `tsx script.ts` instead of `node script.js`).
123+
- Do not auto-commit changes
124+
125+
## Test Guidelines
126+
127+
- Do not check if errors are an instanceOf ActorError in tests. Many error types do not have the same prototype chain when sent over the network, but still have the same properties so you can safely cast with `as`.
128+
129+
## Examples
130+
131+
Examples live in the `examples/` folder.
132+
133+
### Example Configuration
134+
135+
- All examples should have the turbo.json:
136+
137+
```json
138+
{
139+
"$schema": "https://turbo.build/schema.json",
140+
"extends": ["//"]
141+
}
142+
```
143+
144+
### `examples/*/package.json`
145+
146+
- Always name the example `example-{name}`
147+
- Always use `workspace:*` for dependencies
148+
- Use `tsx` unless otherwise instructed
149+
- Always have a `dev` and `check-types` scripts
150+
- `dev` should use `tsx --watch` unless otherwise instructed
151+
- `check-types` should use `tsc --noEmit`
152+
153+
### `examples/*/README.md`
154+
155+
Always include a README.md. The `README.md` should always follow this structure:
156+
157+
```md
158+
# {human readable title} for RivetKit
159+
160+
Example project demonstrating {specific feature} with [RivetKit](https://rivetkit.org).
161+
162+
[Learn More →](https://github.com/rivet-gg/rivetkit)
163+
164+
[Discord](https://rivet.gg/discord) — [Documentation](https://rivetkit.org) — [Issues](https://github.com/rivet-gg/rivetkit/issues)
165+
166+
## Getting Started
167+
168+
### Prerequisites
169+
170+
- {node or bun based on demo}
171+
- {any other related services if this integrates with external SaaS}
172+
173+
### Installation
174+
175+
```sh
176+
git clone https://github.com/rivet-gg/rivetkit
177+
cd rivetkit/examples/{name}
178+
npm install
179+
```
180+
181+
### Development
182+
183+
```sh
184+
npm run dev
185+
```
186+
187+
{instructions to either open browser or run script to test it}
188+
189+
## License
190+
191+
Apache 2.0
192+
```
193+
194+
## Test Notes
195+
196+
- Using setTimeout in tests & test actors will not work unless you call `await waitFor(driverTestConfig, <ts>)`

CLAUDE.md

Lines changed: 0 additions & 196 deletions
This file was deleted.

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

0 commit comments

Comments
 (0)