agentleFS
RustNSparksRustNSparks/sockudo/CLAUDE.md

sockudo

CLAUDE.md828 starsChanged 4 months agoMITView on GitHub

This is the top-level operating contract for coding agents working in sockudo. It applies to the whole monorepo unless a deeper CLAUDE.md overrides a subset of directories. Sockudo is a Rust realtime server and SDK monorepo. The server must preserve strict Protocol V1 Pusher compatibility while advancing Protocol V2 Sockudo-native features: Default posture: execute clear tasks directly, keep diffs reviewable, verify before claiming completion, and preserve existing behavior unless the task explicitly changes it. Server workspace: - crates/sockudo-protocol: protocol message…

  • Deletes or force-pushes

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

49 rules. About 0 are common, 37 are distinctive, and 12 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈37

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 12

    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. Distinctive:

    Default posture: execute clear tasks directly, keep diffs reviewable, verify before claiming completion, and preserve existing behavior …

    line 22
  2. Distinctive:

    Ask only when the choice is materially ambiguous, destructive, or changes product scope.

    line 28
  3. Distinctive:

    If blocked, try the next reasonable path before escalating.

    line 29
  4. Distinctive:

    Use bounded subagents only when they materially improve throughput or correctness.

    line 30
  5. Distinctive:

    Never revert unrelated work.

    line 31
  6. Distinctive:

    Keep V2-only features gated and stripped from V1 delivery.

    line 80
  7. Distinctive:

    Prefer deletion over addition.

    line 82
  8. Distinctive:

    Avoid new dependencies unless the need is explicit and justified.

    line 83
  9. Distinctive:

    Keep behavior changes, tests, and docs in the same change.

    line 84
  10. Distinctive:

    Treat wire payloads, HTTP response shapes, config keys, and SDK public APIs as compatibility contracts.

    line 85
  11. Distinctive:

    Do not log secrets: app secrets, provider credentials, device tokens, private keys, or raw push payloads unless a debug-only option …

    line 87
  12. Distinctive:

    Run narrow verification first, then widen as risk increases.

    line 97
  13. Distinctive:

    Read diagnostics before deciding the task is done.

    line 98
  14. Very specific:

    Prefer rg and rg --files.

    line 103
  15. Distinctive:

    Read crate boundaries plus immediate call sites before changing shared Rust code.

    line 104
  16. Distinctive:

    Do not assume a feature is single-node only.

    line 109
  17. Very specific:

    Keep server internals under crates/.

    line 113
  18. Very specific:

    Keep realtime clients under client-sdks/<repo-name>.

    line 114
  19. Very specific:

    Keep HTTP/server SDKs under server-sdks/<repo-name>.

    line 115
  20. Very specific:

    Keep client-sdks/sockudo-ai-transport-js with client SDKs.

    line 116
  21. Distinctive:

    Treat the old per-SDK GitHub repositories as archived/legacy mirrors.

    line 118
  22. Very specific:

    Do not accidentally add SDK crates to the root Cargo workspace.

    line 123
  23. Distinctive:

    Do not use submodules for SDK imports unless explicitly requested.

    line 125
  24. Distinctive:

    When refreshing imported SDKs, record source repository and commit in the relevant SDK group README.

    line 126
  25. Very specific:

    Check touched crate Cargo.toml files and crates/sockudo-server/Cargo.toml.

    line 131
  26. Very specific:

    Keep AI Transport behind Cargo feature ai-transport and runtime [ai_transport].

    line 132
  27. Very specific:

    Keep push behind feature/config surfaces already used by sockudo-push and sockudo-server.

    line 133
  28. Very specific:

    Keep V2 feature propagation explicit.

    line 134
  29. Distinctive:

    Keep V2 fields gated and stripped from V1 clients.

    line 140
  30. Distinctive:

    Add or update tests for any wire-visible change.

    line 141
  31. Distinctive:

    Keep HTTP auth, channel auth, user auth, webhook validation, and idempotency compatible with server SDK expectations.

    line 142
  32. Distinctive:

    Keep mutation authorization parity across HTTP and WebSocket actor contexts.

    line 153
  33. Distinctive:

    Keep durable history distinct from the hot replay buffer.

    line 158
  34. Distinctive:

    Use bounded retention and opaque cursors.

    line 161
  35. Distinctive:

    Consider reconnect races, duplicate disconnects, multi-connection users, and degraded durable history state.

    line 168
  36. Distinctive:

    Keep annotation publish/delete auth separate from message mutation auth.

    line 174
  37. Distinctive:

    Keep provider outcome and durable status retention observable.

    line 180
  38. Distinctive:

    Treat append rollup as egress-only.

    line 186
  39. Distinctive:

    Update docs when changing:

    line 205
  40. Distinctive:

    run focused tests for the touched crate, package, or module

    line 233
  41. Distinctive:

    run formatting if Rust or SDK source changed

    line 234
  42. Distinctive:

    use the package-local manager and scripts from that SDK README/manifest

    line 252
  43. Very specific:

    run the narrow language-specific test first, then add live Sockudo integration tests when behavior depends on the server

    line 253
  44. Distinctive:

    If full verification is too expensive or blocked, say exactly what was not run and why.

    line 256
  45. Very specific:

    Never run destructive commands like git reset --hard, git checkout --, or broad rm -rf unless explicitly requested.

    line 276
  46. Distinctive:

    Do not rewrite history unless explicitly requested.

    line 278
  47. Distinctive:

    Do not amend commits unless explicitly requested.

    line 279
  48. Distinctive:

    Treat production-facing config, migrations, credentials, and destructive history operations as high risk.

    line 280
  49. Distinctive:

    When closing a task, report what changed, how it was verified, and remaining risks or gaps.

    line 285

≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.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
CLAUDE.md

CLAUDE.md

This is the top-level operating contract for coding agents working in sockudo. It applies to the whole monorepo unless a deeper CLAUDE.md overrides a subset of directories.

Mission

Sockudo is a Rust realtime server and SDK monorepo. The server must preserve strict Protocol V1 Pusher compatibility while advancing Protocol V2 Sockudo-native features:

  • horizontal fanout across multiple nodes
  • durable history, rewind, and two-tier recovery
  • versioned mutable messages
  • presence and presence history
  • annotations
  • push notifications
  • metrics, webhooks, rate limits, and operator APIs
  • delta compression and tag filtering
  • optional AI Transport built on the same durable primitives

Default posture: execute clear tasks directly, keep diffs reviewable, verify before claiming completion, and preserve existing behavior unless the task explicitly changes it.

Autonomy

  • Proceed automatically on clear, reversible next steps.
  • Ask only when the choice is materially ambiguous, destructive, or changes product scope.
  • If blocked, try the next reasonable path before escalating.
  • Use bounded subagents only when they materially improve throughput or correctness.
  • Never revert unrelated work. The tree may already contain user changes.

Repository Map

Server workspace:

  • crates/sockudo-protocol: protocol message types, V1/V2 prefixing, extras, versioned wire payloads
  • crates/sockudo-filter: tag filtering
  • crates/sockudo-core: shared traits, config, errors, auth, history, version store, annotations, presence history, common types
  • crates/sockudo-app: app-manager backends
  • crates/sockudo-cache: cache backends
  • crates/sockudo-queue: queue backends
  • crates/sockudo-rate-limiter: rate limiting and middleware
  • crates/sockudo-metrics: Prometheus metrics
  • crates/sockudo-webhook: webhook delivery
  • crates/sockudo-delta: delta compression
  • crates/sockudo-push: push providers, device registrations, channel subscriptions, publish pipeline, durable status, feedback, scheduler
  • crates/sockudo-ai-transport: AI Transport validation, rollup, and conformance helpers
  • crates/sockudo-adapter: connection handling, presence, horizontal scaling, replay/recovery, fanout
  • crates/sockudo-server: binary, HTTP/WS handlers, bootstrap, durable history/version stores, push API

Other permanent areas:

  • benches/ai: Criterion benchmark suite and budgets for AI hot paths
  • client-sdks: official realtime client SDKs plus sockudo-ai-transport-js
  • server-sdks: official HTTP/server SDKs
  • dashboard: operator API and Vue UI
  • docs: documentation site
  • config, ops, charts, docker-compose*.yml: configuration, migrations, Helm, Compose
  • tests, tools: conformance, load, dashboard, chaos, probes, and support tooling

High-value reference surfaces:

  • docs/content/docs/server/*
  • docs/content/docs/clients/*
  • docs/content/docs/server-sdks/*
  • docs/content/docs/reference/*
  • docs/specs/ai-transport-wire-protocol.md
  • docs/specs/ai-transport-capacity.md
  • config/config.toml
  • Makefile

Core Principles

  • Preserve V1 compatibility unless explicitly changing it.
  • Keep V2-only features gated and stripped from V1 delivery.
  • Reuse current abstractions before adding new ones.
  • Prefer deletion over addition.
  • Avoid new dependencies unless the need is explicit and justified.
  • Keep behavior changes, tests, and docs in the same change.
  • Treat wire payloads, HTTP response shapes, config keys, and SDK public APIs as compatibility contracts.
  • Do not log secrets: app secrets, provider credentials, device tokens, private keys, or raw push payloads unless a debug-only option explicitly permits it.

Execution Protocol

  1. Inspect relevant code, docs, and package metadata first.
  2. State the working understanding briefly while working.
  3. For cleanup/refactor work, write a cleanup plan and lock behavior with tests when not already protected.
  4. Make the smallest coherent change that solves the task.
  5. Run narrow verification first, then widen as risk increases.
  6. Read diagnostics before deciding the task is done.
  7. End with what changed, what was verified, and any remaining risks.

Search And Reading

  • Prefer rg and rg --files.
  • Read crate boundaries plus immediate call sites before changing shared Rust code.
  • For SDK changes, read the package manifest, public README, tests, and release/build scripts before editing public API.
  • For protocol, adapter, versioned messages, recovery, history, presence, annotations, push, or AI Transport work, inspect runtime code and docs before editing.
  • Do not assume a feature is single-node only. Check horizontal and failure-path code.

Monorepo And SDK Rules

  • Keep server internals under crates/; do not move production Rust crates into SDK folders.
  • Keep realtime clients under client-sdks/<repo-name>.
  • Keep HTTP/server SDKs under server-sdks/<repo-name>.
  • Keep client-sdks/sockudo-ai-transport-js with client SDKs; it is a client-side AI Transport SDK layered on @sockudo/client.
  • Treat the old per-SDK GitHub repositories as archived/legacy mirrors. New source changes, examples, and install docs should point at this monorepo and package-local paths until registry publishing is fixed.
  • Preserve imported SDK package names, manifests, README files, and release metadata unless the task is explicitly about changing them.
  • Do not accidentally add SDK crates to the root Cargo workspace. Independently released Rust SDKs belong in Cargo.toml workspace.exclude.
  • Do not use submodules for SDK imports unless explicitly requested.
  • When refreshing imported SDKs, record source repository and commit in the relevant SDK group README.

Feature Flag Discipline

  • Check touched crate Cargo.toml files and crates/sockudo-server/Cargo.toml.
  • Keep AI Transport behind Cargo feature ai-transport and runtime [ai_transport].
  • Keep push behind feature/config surfaces already used by sockudo-push and sockudo-server.
  • Keep V2 feature propagation explicit; do not assume full is the only supported build.
  • Compile targeted feature combinations when behavior crosses feature boundaries.

Protocol And Compatibility

  • Preserve Pusher-compatible Protocol V1 wire behavior.
  • Keep V2 fields gated and stripped from V1 clients.
  • Add or update tests for any wire-visible change.
  • Keep HTTP auth, channel auth, user auth, webhook validation, and idempotency compatible with server SDK expectations.
  • Link significant AI Transport protocol work to docs/specs/ai-transport-wire-protocol.md.

Stateful Subsystems

Versioned Messages

  • Build on MessageAction and VersionStore; do not add parallel mutable-message state.
  • Preserve message_serial, version_serial, history_serial, and delivery_serial continuity.
  • Keep mutation authorization parity across HTTP and WebSocket actor contexts.
  • Own-scoped mutations require verified actor identity and matching original creator identity.

Durable History And Recovery

  • Keep durable history distinct from the hot replay buffer.
  • Preserve continuity semantics for stream_id, serial, cursors, and replay.
  • Fail closed when continuity cannot be proven.
  • Use bounded retention and opaque cursors.
  • For late-join/history work, respect until_attach gaplessness.

Presence And Presence History

  • Preserve first-join and last-leave correctness.
  • Distinguish current membership from historical transition records.
  • Consider reconnect races, duplicate disconnects, multi-connection users, and degraded durable history state.

Annotations

  • Preserve raw annotation delivery gating and summary projection semantics.
  • Keep annotation publish/delete auth separate from message mutation auth.

Push

  • Preserve device registration, channel subscription, provider credential, publish status, idempotency, queue, retry, feedback, and scheduler contracts.
  • Keep provider outcome and durable status retention observable.

AI Transport

  • Build on versioned messages, durable history, recovery, presence, annotations, and push.
  • Validate external AI extras/headers at the edge with precise errors.
  • Treat append rollup as egress-only; persistence, history, recovery, webhooks, and push see every original mutation.
  • Protect fanout hot paths: no unbounded buffers, no locks held across .await, no avoidable per-subscriber payload copies.

Observability

For stateful/distributed changes, consider metrics and logs for:

  • success/failure counters
  • degraded or reset-required state
  • duplicate suppression
  • bounded queue/backlog depth
  • recovery source and failure code
  • push provider outcome and status retention
  • AI rollup ratio, flush latency, active streams, turn outcomes

Documentation Sync

Update docs when changing:

  • HTTP API request or response shapes
  • protocol-visible payloads
  • SDK public APIs or install instructions
  • feature availability or comparison claims
  • scaling semantics
  • versioned messages, history, recovery, presence history, annotations, push, or AI Transport
  • configuration or feature-flag behavior

Likely docs:

  • README.md
  • docs/content/docs/server/http-api.mdx
  • docs/content/docs/server/history-recovery.mdx
  • docs/content/docs/server/mutable-messages.mdx
  • docs/content/docs/server/ai-transport-*.mdx
  • docs/content/docs/clients/*.mdx
  • docs/content/docs/server-sdks/*.mdx
  • docs/content/docs/reference/configuration.mdx
  • docs/content/docs/reference/environment-variables.mdx
  • docs/content/docs/reference/http-endpoints.mdx
  • docs/specs/ai-transport-wire-protocol.md

Verification Standard

Small local change:

  • run focused tests for the touched crate, package, or module
  • run formatting if Rust or SDK source changed

Standard backend/API/docs-with-guard change:

  • cargo fmt --all
  • focused tests
  • docs type/build checks when docs changed

High-risk protocol, presence, scaling, recovery, history, annotations, push, or AI Transport:

  • cargo fmt --all
  • focused subsystem tests
  • relevant integration/conformance tests
  • cargo test --workspace
  • cargo clippy --workspace --all-targets -- -D warnings

SDK changes:

  • use the package-local manager and scripts from that SDK README/manifest
  • run the narrow language-specific test first, then add live Sockudo integration tests when behavior depends on the server

If full verification is too expensive or blocked, say exactly what was not run and why.

Useful Commands

cargo fmt --all
cargo test --workspace
cargo test -p sockudo-core
cargo test -p sockudo-adapter
cargo test -p sockudo-ai-transport
cargo test -p sockudo-push
cargo clippy --workspace --all-targets -- -D warnings
cargo build -p sockudo --features "v2,ai-transport,redis,postgres,push"
scripts/ai-transport-bench-guard.sh
AIT_CONFORMANCE_OFFLINE=1 scripts/ai-conformance-node.sh
cd docs && npm run types:check && npm run build

Safety Constraints

  • Never run destructive commands like git reset --hard, git checkout --, or broad rm -rf unless explicitly requested.
  • Do not rewrite history unless explicitly requested.
  • Do not amend commits unless explicitly requested.
  • Treat production-facing config, migrations, credentials, and destructive history operations as high risk.

Final Response Contract

When closing a task, report what changed, how it was verified, and remaining risks or gaps.

Download now (ZIP)

  • Other versions1 project uses a version of this.

    Word for word · 1

    1. sockudo/sockudo★ 841100% same

    Edited · 0

    None found.

    Wrote their own version · 0

    None found.

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository5 other files it gives its agents.

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.