agentleFS
ukanhaupaukanhaupa/projx/go/CLAUDE.md

projx / go

CLAUDE.md71 starsChanged 4 months agoMITView on GitHub

Stack-scoped notes. The root ../CLAUDE.md carries cross-cutting standards — read both, they compose. This directory is a projx template: a working backend whose own suite must stay green on the projx repo (root §"Per-template gates") and the source the CLI copies into scaffolded projects. It ships the same runtime surface as fastify//express/ (auto-CRUD, request_id envelope, soft-delete, lifecycle hooks) with Go idioms. main.go carries // projx-anchor: markers — imports, entity-imports, entity-registrations, plugins. gen entity and --auth=go insert relative to these; keep…

The file

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

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    ent needs go generate ./ent/... then go mod tidy: before build (schema-as-code emits the client).

    line 48

≈ “Common” is an estimate: at least 1 in 5 of the 29,248 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

go — Go / Chi backend (projx template)

Stack-scoped notes. The root ../CLAUDE.md carries cross-cutting standards — read both, they compose.

This directory is a projx template: a working backend whose own suite must stay green on the projx repo (root §"Per-template gates") and the source the CLI copies into scaffolded projects. It ships the same runtime surface as fastify//express/ (auto-CRUD, request_id envelope, soft-delete, lifecycle hooks) with Go idioms.

Stack

  • Language — Go (module projx.local/go; real module path is rewritten at scaffold time)
  • Router — Chi (github.com/go-chi/chi/v5)
  • ORM / DB — GORM + Postgres (default; alternates sqlc, ent via addons/orms/<orm>/)
  • Auth — JWT verifier (HS256 shared-secret / RS256 JWKS), internal/auth
  • Config — DB-backed encrypted service_configs (internal/serviceconfig), env bootstrap-only
  • Test — go test -race + sqlmock for unit, real Postgres behind testing.Short() for integration
  • Logging — log/slog JSON + access-log middleware, request_id correlation

Layout

PathWhat it holds
main.goChi server boot; middleware order requestid → logging → cors → recoverer; 4 anchors
internal/apperr/AppError types + middleware: {detail, request_id} envelope, FromDB pg→status
internal/auth/verifier.go (alg-confusion-guarded), middleware.go (Authenticate / AuthzRequire*)
internal/cors/CORS middleware, CORS_ALLOW_ORIGINS
internal/serviceconfig/AES-256-GCM reader, cross-language wire-format (iv‖tag‖ct), 10-min TTL cache
internal/ratelimit/Per-user token bucket + X-RateLimit-* / Retry-After headers (NOT IP-keyed)
internal/entities/types.go, registry.go, auto_routes.go, query.go, reflectutil.go
internal/posts/Example Post entity using the registry
internal/sync//api/v1/_meta/schemas emitter (GORM schema parse, hidden-field filtering)
internal/{db,health,httputil,envutil,logging,requestid,uuid}/Connection pool, health probes, helpers
scripts/check-coverage.shCoverage gate (≥80%)

Anchors

main.go carries // projx-anchor: markers — imports, entity-imports, entity-registrations, plugins. gen entity and --auth=go insert relative to these; keep them stable and at matching positions to fastify/express.

ORM addons

GORM is the base. sqlc + ent live at ../addons/orms/<orm>/. Shared adapter machinery (auto_routes, apperr) is deduped under ../addons/orms/_shared/. All three preserve the same auto-route contract (pagination, equality filter, ILIKE search, order_by with - desc, bulk ops, lifecycle hooks). BulkDelete returns (affected, error) so the handler maps 0-affected → 404.

Quality gates (root §"Per-template gates")

gofmt -l . (clean) → golangci-lint run ./... (incl. goimports; go vet runs inside) → go test -race -coverprofile=coverage.out ./... → bash scripts/check-coverage.sh (≥80%) → govulncheck ./.... Green or not done. Locally: bash ../scripts/ci-local.sh go.

Things that bite

  • Module path is projx.local/go in the template but rewritten to the user's module at scaffold time — gen entity reads it from go.mod, never hardcode it.
  • ent needs go generate ./ent/... then go mod tidy before build (schema-as-code emits the client). setup.sh does this; CI has a drift gate.
  • internal/auth is not mounted globally — it's reserved for --auth=go to mount per-router. The base only constructs the verifier when JWT_* env is set.
  • Runtime creds are DB-backed (service_configs), env is bootstrap-only — never read JWT_SECRET at request time, go through serviceconfig.

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.