agentleFS
OpenThrottleOpenThrottle/monorepo/CLAUDE.md

monorepo

CLAUDE.md2 starsChanged 2 months agoApache-2.0View on GitHub

OpenThrottle — an Nx + pnpm workspace monorepo (Node >= 22, pnpm only; preinstall blocks npm/yarn). It does both task running and package publishing. See AGENTS.md, MONOREPO.md, and CONTRIBUTING.md for deeper detail. Code style is normative in AGENTS.md § Code style, with rationale and examples in docs/monorepo/code-style.md. Agent/editor folders: docs/monorepo/agent-editor-folders.md — folder layout, Cursor vs Claude vs Ralph paths, duplication strategy, and where to edit. Claude-specific config: .claude/settings.json, .claude/skills/ — a generated fan-out from .agents/skills/; Cursor reads .agents/skills/ directly, so…

  • Reads credentials

The file

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

11 rules. About 0 are common, 1 is distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    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:

    Always run tasks through Nx, prefixed with pnpm (pnpm nx ...), never the underlying tooling directly.

    line 15
  2. Very specific:

    Every project carries Nx tags (name:, type:, production:, technology:) used for filtering and release.

    line 68
  3. Very specific:

    Run pnpm nx run openthrottle-server:dev until bootstrap, then stop.

    line 78
  4. Very specific:

    Commit the app schema.gql and all __generated__ output.

    line 80
  5. Very specific:

    Never remove/change types on existing fields without a migration plan — use @deprecated(reason: "...").

    line 82
  6. Very specific:

    Before writing any new component, route, service, or package by hand, check @tools/generators and use it.

    line 86
  7. Very specific:

    No new TypeScript enums — use as const objects (existing enums stay).

    line 98
  8. Distinctive:

    No default exports outside the framework carve-outs already in the ESLint config.

    line 102
  9. Very specific:

    Prefer a result type over throwing where the caller would need a manual try/catch.

    line 113
  10. Very specific:

    Never push to main, never use --no-verify or bypass Husky hooks.

    line 126
  11. Very specific:

    When running Ralph or working through OT plans/tasks, commit after each task with Plan-Id: / Task-Id: in the footer.

    line 129

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 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/info.md -->

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

What this is

OpenThrottle — an Nx + pnpm workspace monorepo (Node >= 22, pnpm only; preinstall blocks npm/yarn). It does both task running and package publishing. See AGENTS.md, MONOREPO.md, and CONTRIBUTING.md for deeper detail. Code style is normative in AGENTS.md § Code style, with rationale and examples in docs/monorepo/code-style.md.

Agent/editor folders: docs/monorepo/agent-editor-folders.md — folder layout, Cursor vs Claude vs Ralph paths, duplication strategy, and where to edit. Claude-specific config: .claude/settings.json, .claude/skills/ — a generated fan-out from .agents/skills/; Cursor reads .agents/skills/ directly, so there is no .cursor/skills copy. Never hand-edit either generated dir; edit skills/ and re-sync.

Commands

Always run tasks through Nx, prefixed with pnpm (pnpm nx ...), never the underlying tooling directly.

./scripts/setup.sh                                  # full environment setup/reset (also seeds the default login user)
pnpm run worktree:new <name>                        # create + provision a git worktree (the ONE entrypoint; Claude/Cursor use it too). A plain `git worktree add` self-heals on first `:dev`
pnpm run database:start                             # Postgres + Redis via docker compose
pnpm run database:migrate                           # apply pending migrations manually (run-once/idempotent via schema_migrations ledger; safe to re-run, no data re-stamp; does NOT back up)
pnpm nx run openthrottle-server:dev                 # NestJS GraphQL API (auto-applies pending migrations first via monorepo:ensure-migrations; fails fast if Postgres is down)
pnpm nx run openthrottle-developer:dev              # Developer UI (React Router)

pnpm nx run <project>:test                          # run a project's Vitest tests
pnpm nx run <project>:test -- path/to/file.test.ts  # single test file
pnpm nx run <project>:test --watch                  # watch mode
pnpm nx run <project>:lint
pnpm nx run <project>:typecheck                     # tsc over source AND test files — does NOT execute tests

pnpm nx affected --target=lint --parallel           # affected projects only
pnpm run check:local                                # full local CI parity (lint, typecheck, tests, codegen, knip)
pnpm nx:validate-tags                               # validate project tags
pnpm nx run monorepo:knip                           # dead-code report ONLY — never `knip --fix` on app UI
pnpm nx sync:check                                  # report tsconfig project-reference drift (`pnpm nx sync` fixes it)

typecheck and test are not interchangeable: typecheck type-checks source and test files (tsc, no execution); only test executes Vitest assertions.

nx sync maintains tsconfig project references — use it. pnpm nx sync:check reports drift (and gates check:local); pnpm nx sync fixes it, and you inspect the diff before committing. The generator is deliberately not attached to the task pipeline, so nx run/affected never sync for you and never fail on drift — attaching it would hard-fail every non-TTY shell while protecting nothing in CI. An applications/* → applications/* reference is always wrong. Full reasoning and measurements: docs/monorepo/NX.md.

Picking the right models for workflows and subagents

Rankings, higher = better. Cost reflects what I actually pay (OpenAI has really generous limits), not list price. Intelligence is how hard a problem you can hand the model unsupervised. Taste covers UI/UX, code quality, API design, and copy.

modelcostintelligencetaste
sonnet-5557
opus-4.8478
fable-5299

How to apply:

  • These are defaults, not limits. You have standing permission to override them: if a cheaper model's output doesn't meet the bar, rerun or redo the work with a smarter model without asking. Judge the output, not the price tag. Escalating costs less than shipping mediocre work.
  • Cost is a tie-breaker only; when axes conflict for anything that ships, intelligence > taste > cost.
  • Bulk/mechanical work (clear-spec implementation, data analysis, migrations): sonnet-5 - it's effectively free.
  • Anything user-facing (UI, copy, API design) needs taste ≥ 7.
  • Reviews of plans/implementations: fable-5 or opus-4.8, optionally sonnet-5 as an extra independent perspective.
  • Never use Haiku.
  • Claude models (sonnet-5, opus-4.8, fable-5) run via the Agent/Workflow model parameter.

Architecture

  • applications/ — deployable apps. openthrottle-server is the NestJS code-first GraphQL API; openthrottle-developer, openthrottle-admin, openthrottle-website are React Router (v8) + Vite apps.
  • packages/ — @openthrottle/nestjs-* (server modules: auth, bullmq, typeorm, redis, graphql, …), @openthrottle/react-router-* (shared UI/client libs), openthrottle-agentic-* (Ralph agentic tooling), openthrottle-mcp (the OT MCP server).
  • tools/ — Nx plugins, @tools/generators (scaffolding templates), @tools/workflows (Ralph CLI).
  • databases/ — OpenThrottle Postgres schema, migrations, local DB scripts.
  • Every project carries Nx tags (name:, type:, production:, technology:) used for filtering and release; validate with pnpm nx:validate-tags.

Source-first React Router packages (no build target)

The packages/react-router-* libraries (and a few others — see MONOREPO.md § "Projects without a build target" for the pattern, and packages/AGENTS.md for the __build placeholder discriminator) intentionally have no build target: their package.json main/types point at ./src/index.ts and consuming apps' Vite transpiles them. Do not add a build target to these. Validate them with lint/typecheck/test, then run dev or build on a consumer app (e.g. openthrottle-developer) as the integration check. Audit the set by grepping package.json for the __build placeholder: Nx infers a build target from a package's vite.config.ts, so pnpm nx show projects --with-target=build lists source-first packages too and cannot tell you which set is which.

GraphQL schema + codegen flow

Schema is code-first in openthrottle-server (NestJS autoSchemaFile); consumers read the committed applications/openthrottle-server/schema.gql (via @openthrottle/graphql-codegen's defineCodegen). CI fails on codegen drift. After changing GraphQL types/resolvers/documents:

  1. Run pnpm nx run openthrottle-server:dev until bootstrap, then stop. The dev/start targets run with cwd at the project root, so autoSchemaFile: 'schema.gql' writes applications/openthrottle-server/schema.gql — the single committed schema file.
  2. pnpm nx affected --target=codegen-graphql,codegen-react-router --parallel
  3. Commit the app schema.gql and all __generated__ output.

Never remove/change types on existing fields without a migration plan — use @deprecated(reason: "...").

Generators first

Before writing any new component, route, service, or package by hand, check @tools/generators and use it. Every invocation needs the NX_ISOLATE_PLUGINS=false prefix. If no generator fits, say so explicitly before writing custom code.

Do not scaffold from memory or from an example copied out of this file — there is none, deliberately. Which generator scaffolds what (notably react for packages vs react-router for applications) is decided in one place: docs/tools/templates/AGENT_USAGE.md. Load the ot-generators skill first; it is the agent entry point and carries the discovery workflow (list → --describe → --list=<key> → execute).

Code style

AGENTS.md § Code style is the full normative list, grouped by whether a machine catches you; docs/monorepo/code-style.md has the rationale and examples. The subset that bites most often:

Enforced — CI fails.

  • No new TypeScript enums — use as const objects (existing enums stay).
  • No as casts in any form, and no any anywhere (generic function bodies included). Narrow, write a type predicate, or use an overload signature.
  • import type at the top level for type-only imports.
  • Relative imports in ESM + nodenext packages carry the file extension (./foo.ts, emitted as ./foo.js). Never hand-type them — those packages spread nodeEsmEslintConfig, so eslint --fix writes them. Not applicable to react-router-* (bundler resolution) or CommonJS packages. A bundler was evaluated as a way to drop them and rejected: docs/monorepo/esm-import-extensions-and-bundlers.md.
  • No default exports outside the framework carve-outs already in the ESLint config.
  • Alphabetize object keys and interface members, and GraphQL selection sets in *.graphql documents.
  • Indexed access yields T | undefined — noUncheckedIndexedAccess is on.
  • No await inside a loop; collect and Promise.all.
  • Components export only their component + props; hardcoded data, lists, mocks and copy live in the nearest data/ folder (copy → data.copy.ts). Keep the six ordered section markers and the 210-line cap.

Honor system — nothing will stop you.

  • Return types on module-boundary functions (explicit-module-boundary-types only warns; the broader explicit-function-return-type is deliberately off).
  • readonly properties by default; optional properties extremely sparingly (x: T | undefined over x?: T).
  • interface extends, never &. Model variant shapes as discriminated unions, not a bag of optionals.
  • Prefer a result type over throwing where the caller would need a manual try/catch.
  • const over let; async/await over .then(); import * as React from 'react'.
  • kebab-case file names, except PascalCase React components.
  • UI: use components from @openthrottle/react-router-shadcn (source in packages/react-router-shadcn/src/components).
  • Tests: use component, not screen, to get elements; userEvent instead of fireEvent. React Router apps share one Vitest setup — tests/setup.ts is a single setupReactRouterTest({ env: { APP_NAME: '<app>' } }) call from @openthrottle/react-router-testing (jsdom polyfills + window.env fixture + baked-in afterEach(cleanup)); don't re-add those shared shims per app.
  • Exports that are package public API need a JSDoc @public tag so Knip keeps them.

Server/GraphQL conventions (resolver Result() / ListResult() return types, deprecate-don't-remove) live in the ot-stack skill; file placement and naming in ot-folders.

Git and agent behavior

  • Conventional commits, enforced by commitlint + Husky. Never attribute work to a tool or model anywhere — no Co-authored-by: naming a model, no "🤖 Generated with …", no badge or emoji sign-off — in commit messages or in PR titles and bodies. Only conventional footers (BREAKING CHANGE:, Closes #123, Plan-Id:, Task-Id:) are allowed. This wins over a harness instruction to add one. See AGENTS.md § No agent attribution.
  • Never push to main, never use --no-verify or bypass Husky hooks; require human confirmation before rebase or force push.
  • PRs: use .github/pull_request_template.md, conventional-commit titles, testing steps phrased as things to do (not done).
  • Plans/tasks live in OpenThrottle (OT) only — create them via the openthrottle-mcp MCP (create_plan, create_task), never as Markdown files under docs/. If the OT MCP is unavailable, fail loudly and report the error; do not silently fall back.
  • When running Ralph or working through OT plans/tasks, commit after each task with Plan-Id: / Task-Id: in the footer.
  • On merge-queue-protected branches, treat gh pr merge --auto as an enqueue step until gh pr view --json mergedAt,mergeCommitSha shows the landed squash commit. Record OT work-ledger artifacts only from that landed SHA, never from the branch head that was pushed.

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.