agentleFS
CloudflareKnown publishercloudflare/partykit/AGENTS.md

partykit

AGENTS.md1.3k starsChanged 9 months agoISCView on GitHub

This document provides essential information for AI coding agents working in the PartyServer monorepo. PartyServer is a monorepo using npm workspaces with multiple packages:

Trending

Less talk lately.about the whole repository

Dec 2025: 1 mentionJan 2026: 1 mentionFeb 2026: 5 mentionsMar 2026: 0 mentionsApr 2026: 1 mentionMay 2026: 1 mentionJun 2026: 3 mentionsJul 2026: 3 mentionsAug 2026: 16 mentionsSep 2026: 10 mentionsOct 2026: 1 mentionNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the cloudflare/partykit repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about cloudflare/partykit

The biggest 5 of 46 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 46

Talked about on GitHub (46 times).

On GitHub · 46

41 more on GitHub
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

26 rules. About 0 are common, 11 are distinctive, and 15 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 15

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Run npm run format before committing

    line 64
  2. Very specific:

    Run npm run check:lint to verify

    line 76
  3. Very specific:

    Use noEmit: true (compilation handled by tsdown)

    line 84
  4. Very specific:

    Use // TODO: for action items

    line 141
  5. Distinctive:

    Use JSDoc for public API documentation

    line 142
  6. Distinctive:

    Prefer descriptive names over comments

    line 143
  7. Very specific:

    Use oxlint-disable-next-line or @ts-expect-error with explanations when necessary:

    line 144
  8. Very specific:

    Use readonly for constructor parameters when appropriate

    line 154
  9. Distinctive:

    Prefer composition over inheritance

    line 155
  10. Distinctive:

    Keep files focused (single responsibility)

    line 156
  11. Distinctive:

    Use Vitest for all tests

    line 160
  12. Very specific:

    Place tests in src/tests/ directory

    line 161
  13. Very specific:

    Use @vitest-environment jsdom directive when needed

    line 162
  14. Distinctive:

    Write descriptive test names

    line 164
  15. Very specific:

    Use beforeAll, afterAll, beforeEach, afterEach for setup/teardown

    line 165
  16. Very specific:

    Use Changesets for version management (.changeset/)

    line 169
  17. Distinctive:

    Write clear, descriptive commit messages

    line 170
  18. Distinctive:

    Keep commits focused on a single change

    line 171
  19. Distinctive:

    Run oxfmt on generated output files (handled by build scripts)

    line 178
  20. Very specific:

    Use tsdown for building packages

    line 179
  21. Very specific:

    Verify exports with scripts/check-exports.ts

    line 180
  22. Very specific:

    Avoid forEach where performance matters (but allowed by linter)

    line 184
  23. Very specific:

    Use optional chaining (?.) and nullish coalescing (??)

    line 185
  24. Very specific:

    Prefer const over let when possible

    line 186
  25. Distinctive:

    Use EventTarget for event handling in browser/Node compatibility

    line 191
  26. Distinctive:

    Use exponential backoff for reconnection logic

    line 193

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

PartyServer Agent Guidelines

This document provides essential information for AI coding agents working in the PartyServer monorepo.

Repository Structure

PartyServer is a monorepo using npm workspaces with multiple packages:

  • packages/partyserver - Core library for Durable Objects with WebSocket support
  • packages/partysocket - Reconnecting WebSocket client library
  • packages/y-partyserver - Yjs CRDT support for PartyServer
  • packages/partysub - Pub/sub at scale
  • packages/partysync - State synchronization (experimental)
  • packages/partywhen - Task scheduling at scale
  • packages/hono-party - Hono middleware
  • fixtures/* - Self-contained examples

Build & Development Commands

Root-level commands (from /Users/sunilpai/code/partyserver)

npm run build              # Build all packages
npm run check              # Run all checks (format, lint, type, test)
npm run format             # Format code with Oxfmt
npm run check:format       # Check code formatting with Oxfmt
npm run check:lint         # Run Oxlint linter
npm run check:type         # Type-check all packages
npm run check:test         # Run all tests
npm run check:repo         # Run sherif (monorepo consistency)

Package-level commands (from packages/[package-name]/)

npm run build              # Build the package (uses tsdown)
npm run check:test         # Run tests with vitest

Running tests

# Run all tests in a package
cd packages/partysocket && npm run check:test

# Run a single test file
npx vitest src/tests/reconnecting.test.ts

# Run tests in watch mode
npx vitest --watch

# Run tests with specific pattern
npx vitest reconnecting

Code Style Guidelines

Formatting

  • Formatter: Oxfmt (configured in .oxfmtrc.json)
  • Quote style: Double quotes (")
  • Trailing commas: None
  • Print width: 80
  • Run npm run format before committing

Linting

  • Linter: Oxlint (configured in .oxlintrc.json)
  • Plugins: react, jsx-a11y, typescript, react-hooks
  • Key rules:
    • no-explicit-any: off
    • no-non-null-assertion: off
    • no-redeclare: off
    • no-unused-vars: error (with ^_ ignore patterns for args/vars/caught)
    • react-hooks/exhaustive-deps: warn
  • Run npm run check:lint to verify

TypeScript

  • Target: ESNext
  • Module: ESNext with Bundler resolution
  • Strict mode: Enabled
  • JSX: react-jsx
  • Use noEmit: true (compilation handled by tsdown)
  • Use verbatimModuleSyntax: true
  • Use isolatedModules: true
  • skipLibCheck: true for performance

Import Conventions

// 1. Import from relative modules first
import ReconnectingWebSocket from "./ws";

// 2. Then type imports (prefer `import type`)
import type * as RWS from "./ws";
import type { Connection } from "./types";

// 3. Use type-only imports when importing only types
// This helps with tree-shaking and clarity

Naming Conventions

  • Classes: PascalCase (e.g., PartySocket, ReconnectingWebSocket)
  • Functions/methods: camelCase (e.g., getPartyInfo, _handleOpen)
  • Private methods: Prefix with underscore (e.g., _connect, _debugLogger)
  • Constants: UPPER_SNAKE_CASE for true constants (e.g., PORT, DEFAULT)
  • Types/Interfaces: PascalCase (e.g., PartySocketOptions, EventHandlerOptions)
  • Type aliases: PascalCase for complex types, camelCase for simple utilities

Error Handling

// Use console.error for critical errors with helpful context
console.error(`‼️ No WebSocket implementation available...`);

// Use console.warn for warnings
console.warn(`PartySocket: party name "${name}" contains forward slash...`);

// For debug logging, use the debug flag pattern
private _debug(...args: unknown[]) {
  if (this._options.debug) {
    this._debugLogger("RWS>", ...args);
  }
}

// Throw errors with descriptive messages
throw new Error("path must not start with a slash");

// Use assert for internal invariants
function assert(condition: unknown, msg?: string): asserts condition {
  if (!condition) {
    throw new Error(msg);
  }
}

Comments

  • Use // TODO: for action items
  • Use JSDoc for public API documentation
  • Prefer descriptive names over comments
  • Use oxlint-disable-next-line or @ts-expect-error with explanations when necessary:
    // oxlint-disable-next-line no-explicit-any
    // @ts-expect-error ws types are weird

Code Organization

  • Group related functionality together
  • Public methods before private methods
  • Use readonly for constructor parameters when appropriate
  • Prefer composition over inheritance
  • Keep files focused (single responsibility)

Testing Guidelines

  • Use Vitest for all tests
  • Place tests in src/tests/ directory
  • Use @vitest-environment jsdom directive when needed
  • Mock external dependencies appropriately
  • Write descriptive test names
  • Use beforeAll, afterAll, beforeEach, afterEach for setup/teardown

Git & Versioning

  • Use Changesets for version management (.changeset/)
  • Write clear, descriptive commit messages
  • Keep commits focused on a single change
  • Test before committing

Package Publishing

  • Dual format: ESM and CommonJS
  • Generate both .d.ts and .d.cts declaration files
  • Run oxfmt on generated output files (handled by build scripts)
  • Use tsdown for building packages
  • Verify exports with scripts/check-exports.ts

Performance Notes

  • Avoid forEach where performance matters (but allowed by linter)
  • Use optional chaining (?.) and nullish coalescing (??)
  • Prefer const over let when possible
  • Be mindful of bundle size (tree-shaking friendly exports)

Common Patterns

  • Use EventTarget for event handling in browser/Node compatibility
  • Clone events when re-dispatching them
  • Use exponential backoff for reconnection logic
  • Provide both callback and event listener APIs
  • Support both string and function-based configuration

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.