Which tables (and opted-in views) get a generated store and how it is shaped — every applied table is projected whatever its rpcs, the forge:no-entity opt-out, entity names derived from the table, and where CRUD wiring differs.
10 stars
0 votes
0 copies
0 views
Added November 13, 2026
ai-agentsgo
Works with
cursor
Security analysis
A100/100
Scanned November 13, 2026
$npx -y skills add reliant-labs/forge --skill store --agent claude-code
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Store?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/reliant-labs-store)
---
name: store
description: Which tables (and opted-in views) get a generated store and how it is shaped — every applied table is projected whatever its rpcs, the forge:no-entity opt-out, entity names derived from the table, and where CRUD wiring differs.
---
# The generated store
`forge generate` projects the **data layer from the applied schema**, not from
the wire. Every applied BASE TABLE gets:
- an entity struct (`<entity>_orm_gen.go`), its `<E>Field*` / `<E>Columns`
constants and constraint names;
- package-level delegates (`Create<E>`, `Get<E>ByID`, `List<E>`, `Count<E>`,
`Update<E>`, `Update<E>Masked`, `Delete<E>`);
- an `<E>Store` interface in `<entity>_store_gen.go`, which also declares the
aggregate's accessor for it (`Store` itself, a struct, is in `store_gen.go`);
- a scaffold-once `<entity>_repo_ext.go` seam for hand-written queries.
Two answers every store gives the same way. A by-key method (`Get<E>ByID`,
`Get<E>ByPK`, `Update<E>`, `Update<E>Masked`, `Delete<E>`, `Delete<E>ByPK`)
answers a missing row with `svcerr.NotFound("<entity>")`, which is also
`errors.Is(err, orm.ErrNoRows)`. `List<E>` with no `orm.WithLimit` returns every
matching row, uncapped: bound a read yourself, and walk a table that grows
without bound a page at a time (`WhereGt` on the key + `WithOrderBy` +
`WithLimit`).
whether or not any service declares rpcs for the table — a table whose
CRUD-named rpcs are all `// forge:custom`, or that no rpc names at all, still
has its store. **CRUD wiring** (handlers, pages, seed roots) is the separate,
wire-driven projection described in `db`.
## Naming
A table is named from itself: the singular, camel-cased the way protoc-gen-go
spells a message (`message_content_blocks` → `MessageContentBlock`,
`daemon_attachment` → `DaemonAttachment`). `COMMENT ON TABLE t IS
'forge:entity-name=<Name>'` declares another name for a table whose name
derives to the wrong thing. Two tables that project to one name fail
generate while it plans, before any slow step runs, naming both tables and
the marker that resolves each.
A CRUD rpc's entity `<E>` finds its table by that name, then by the plural
(`bookmarks`) and the singular (`daemon_attachment`) of `<E>`; the claimed
table keeps the wire message's name, so the store and the wiring agree. A
unary, unmarked CRUD-named rpc whose entity has a wire message but matches no
table, and whose only implementation is forge's unwired stub (or none), fails
generate naming the rpc and the tables it looked for: write the migration,
declare `forge:entity-name`, or mark the rpc `// forge:custom`. A message is
evidence enough, so `ListDueReads` over a plain `DueRead` response element is
refused too. `forge scaffold` (and `--dry-run`) refuses it before writing
anything, counting the tables that run births.
## Opting out
- One table: `COMMENT ON TABLE t IS 'forge:no-entity'` in a migration. No
store, and no CRUD wiring over it either (a CRUD-named rpc over it is custom).
- Tables a forge library owns are off by default: `audit_log`
(forge/pkg/audit), `activity_events` (forge/pkg/activity), `alert_instances`
and `alert_events` (forge/pkg/alerting/pgstore). The library's own store is
their data path. A table counts as the library's only when it has that name
AND every column the library reads and writes, so an app table that only
shares the name keeps its store. One is projected anyway when a CRUD rpc
names it or its comment says `forge:entity`. Generate prints a note for each
one it leaves off; `forge:no-entity` on the table silences it.
**Deprecated, kept until the next major:** a library table whose store the
project already generates (its `<entity>_orm_gen.go` names the table) keeps
that store. Every generate warns about it, naming the table. Opt out now with
a `COMMENT ON TABLE <table> IS 'forge:no-entity'` migration, or say
`forge:entity` to keep the store past the next major.
- The whole data layer: `//forge:no-orm: <why>` in `internal/db`'s package doc
(`db/orm-and-safety`).
## Keys
A single-column primary key is the `id` the delegates take: `Get<E>ByID`,
`Delete<E>`… A **composite primary key** gets a store addressed by the
whole key — `Get<E>ByPK(ctx, db, k1, k2)` and `Delete<E>ByPK` (one parameter
per key column), `Upsert<E>` (conflict on every key column), plus
Create/List/Count/Update/UpdateMasked addressing the row by the struct's key
fields — but no CRUD wiring, which keys on one id, and no ULID fill or cursor
pagination. A table with no primary key is reported and skipped.
## Views
A VIEW (regular or materialized) is projected only when it opts in —
`COMMENT ON VIEW v IS 'forge:entity'` (`key=<column>` to name its key, else
`id`) — as a read-only entity: the row struct, `List<E>` / `Count<E>` and
`Get<E>ByID` when it has a key, and a read-only `<E>Store`. Nothing writes. Its
non-key columns are pointers, because the catalog cannot say a view column is
NOT NULL.