agentleFS
ConfabulousDevConfabulousDev/confab-web/backend/CLAUDE.md

confab-web / backend

CLAUDE.md15 starsChanged 3 months agoMITView on GitHub

Backend conventions Claude would get wrong by default — commands, sync rules, backend-only invariants. For architecture see README.md; for the package index see internal/README.md; for per-package conventions read the package README. Add to this file only when the rule is (a) backend-wide, (b) non-obvious from reading the code, and (c) Claude would get it wrong without the instruction. Full tests (final verification — requires Docker/Orbstack): Unit-only iteration: Sharded (parallel package-at-a-time, what CI runs): Integration tests use testutil.SetupTestEnvironment(t) for a containerized…

The file

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

5 rules. About 0 are common, 1 is distinctive, and 4 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.

  • 4

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If the Go LSP is available, use it when it helps — go-to-definition, find-references, and hover types beat grep for cross-file symbol and …

    line 36
  2. Very specific:

    Update the shared column list (db.SessionDetailColumns / sessionSelectCols) AND the shared Scan-target helper (db.SessionDetailScanTargets …

    line 42
  3. Very specific:

    Add a wire-level assertion in the relevant *_http_integration_test.go: read the new field off the JSON response and check its value.

    line 44
  4. Very specific:

    If the new field has provider/legacy/canonical normalization (like Provider), include each variant in the test table.

    line 45
  5. Very specific:

    Run it locally before pushing: govulncheck ./cmd/server from backend/.

    line 70

≈ “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

Backend Development Notes

What belongs in this file

Backend conventions Claude would get wrong by default — commands, sync rules, backend-only invariants. For architecture see README.md; for the package index see internal/README.md; for per-package conventions read the package README. Add to this file only when the rule is (a) backend-wide, (b) non-obvious from reading the code, and (c) Claude would get it wrong without the instruction.

Running tests

Full tests (final verification — requires Docker/Orbstack):

go test ./...

Unit-only iteration:

go test -short ./...

Sharded (parallel package-at-a-time, what CI runs):

./scripts/list-test-packages.sh
# then one `go test <pkg>` per line, parallelized

Integration tests use testutil.SetupTestEnvironment(t) for a containerized Postgres + MinIO.

Formatting

CI runs make fmt-check (gofmt + go fix -diff) in the backend-unit job. Run make fmt before pushing. When bumping the Go version (go.mod + ci.yml together), also run make fmt: new toolchains add modernizers that the gate will flag.

Code intelligence (Go LSP)

If the Go LSP is available, use it when it helps — go-to-definition, find-references, and hover types beat grep for cross-file symbol and type work. Skip it when a plain read or grep is quicker.

When adding a field to a shared DB struct

Adding a column to db.SessionDetail, db.SessionListItem, or any struct loaded from SQL in more than one place:

  1. Update the shared column list (db.SessionDetailColumns / sessionSelectCols) AND the shared Scan-target helper (db.SessionDetailScanTargets / scanSessionListItems) — both in one edit, since their order must match.
  2. Grep for every other Scan into the struct (grep -rn 'db.SessionDetail{' .). Confirm each goes through the shared helpers, not a hand-rolled column list.
  3. Add a wire-level assertion in the relevant *_http_integration_test.go: read the new field off the JSON response and check its value. Subset-of-columns drift is invisible to type checks; the wire test is the cheapest reliable guard.
  4. If the new field has provider/legacy/canonical normalization (like Provider), include each variant in the test table.

This rule exists because Go's database/sql silently allows Scan over a subset of columns. A parallel column list is one ghost-field bug waiting to happen.

Updating model pricing

Prices live in one place: internal/pricingsource/pricing.json (provider-nested, embedded via go:embed). To add or reprice a model, edit that file and bump its updated_at. There is no second table to keep in sync — the backend cost compute and the frontend both read from it.

The backend serves the effective table at GET /api/v1/pricing and refreshes it from confabulous.dev at runtime, so self-hosters pick up new prices without a redeploy (see internal/pricingsource/README.md). Read internal/analytics/README.md before adding an OpenAI entry — its billing conventions (cached_input as subset, reasoning_output as subset) differ from Anthropic's. Cache writes are not free across the board: the 5.6 and 6 families bill them at 1.25x short-context input, while older families publish no price and stay at 0. They cost nothing today only because the Codex wire carries no cache-write token count (md0z).

Anthropic prices: https://www.anthropic.com/pricing OpenAI prices: https://developers.openai.com/api/docs/pricing

Finding dead code

  • staticcheck ./... — unused unexported code (functions, types, vars, constants).
  • deadcode -test ./... — whole-program reachability from main() and tests.

Neither catches unused exported identifiers.

Vulnerability scanning

CI runs govulncheck ./cmd/server as a required check (the govulncheck job in .github/workflows/ci.yml). It scans only the production binary's import graph, so test-only advisories (e.g. testcontainers' Moby chain) don't block the gate. Run it locally before pushing: govulncheck ./cmd/server from backend/. Most stdlib findings are cleared by a Go patch bump — update the go directive in go.mod and the go-version fields in ci.yml together.

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.