/relica:relicafrom relica
Writes Relica SQL queries, repositories, transactions, and error handling per the library's AGENTS.md at the project's go.mod version. Audits existing code and guides version-by-version upgrades.
Ships in relica. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
This skill is deliberately thin. The source of truth is Relica's own AGENTS.md, CHANGELOG.md
and docs/MIGRATION_GUIDE.md at the version the project uses — not memory, not this file, not
the project's own notes, which go stale. The skill adds what those files cannot: how to get the
right version of them, a scripted audit, and the upgrade procedure.
bash ${CLAUDE_SKILL_DIR}/scripts/audit.sh <repo> # the version block is printed first
It prints the Relica version in every go.mod (marks // indirect), replace lines, go.work,
and the latest version on proxy.golang.org. A replace or go.work entry pointing to a local path
means the code builds against that checkout, not the tag.
Without the plugin (another agent, or no ${CLAUDE_SKILL_DIR}), the same files ship in the module:
go list -m -f '{{.Version}} {{.Dir}}' github.com/coregx/relica # honours go.work and replace
bash <Dir>/skills/relica/scripts/audit.sh <repo>
go mod download -json github.com/coregx/relica@<version> # "Dir" = the source at that tag
| Task | Read in <Dir>/AGENTS.md |
|---|---|
| CRUD, WHERE, joins | "API Priority", "Expression API Reference", "JOIN Operations" |
| Select lists, ORDER BY, GROUP BY | "Ordering with Expressions" (Select takes column names; expressions go through SelectExpr / OrderByExpr / GroupByExpr) |
| Transactions, repositories, dbcontext | "Transactions" (Rules, Which API, Executor, Context propagation, Retrying, Mistakes found in real projects) |
| Errors | "Error Handling" |
| Locks | "Row Locking (FOR UPDATE / FOR SHARE)" |
| UPDATE / DELETE | "UPDATE / DELETE need Where" (v0.20.0+) |
| UNION / INTERSECT / EXCEPT | "Set Operations" (v0.20.0+: OrderBy/Limit after Union apply to the combined result) |
| Names, struct scanning | "Table and Column Names" (v0.20.0+) |
| Count, Exists | "Query Helpers" |
Two sources, two versions:
CHANGELOG.md, docs/MIGRATION_GUIDE.md and the advice sections of
AGENTS.md from the latest version (@latest in the same command): they cover every older
version and get corrections after a release. Use only the API the project's version has, and
propose the upgrade when a fix needs a newer one.Follow AGENTS.md. The points that caused real bugs in projects using Relica:
With(ctx) returns relica.Executor: the *relica.Tx kept in ctx, else
db.WithContext(ctx). Transactional joins an outer transaction instead of nesting.relica.NewExp("balance - ?", v), never a string value in Set.relica.Is* helpers, never by err.Error() text; retry the whole transaction, and
only on IsDeadlock || IsSerializationFailure.Begin/Transactional; context.Background() only in main
and tests.*relica.DB per database, created at startup (Open/WrapDB), never per request.Like/ILike take the raw value (Relica escapes it); .EscapeChars() with no arguments turns
escaping off — only for a value that is a pattern on purpose.file:<path>?mode=ro; on a plain path the drivers drop mode=ro.Select, GroupBy take column names and OrderBy takes "column [ASC|DESC]", one per
argument; literals and expressions go through SelectExpr, GroupByExpr, OrderByExpr.bash ${CLAUDE_SKILL_DIR}/scripts/audit.sh <repo> — read-only, git-tracked *.go only. It
reports leads in three groups: mistakes found in real projects (H1–H3, M1–M7), code whose
behaviour changes in v0.20.0 (V1–V12; the group title says whether the project is still below
v0.20.0), and style or placement notes (I1–I8). Each line names the AGENTS.md or
MIGRATION_GUIDE section to read.file:line, what breaks (a concrete scenario), the fix, the docs section.CHANGELOG.md and docs/MIGRATION_GUIDE.md of the target version (step 2) for
every version between the current and the target one.GOWORK=off go get github.com/coregx/relica@<target> && GOWORK=off go mod tidy.go build ./... && go vet ./... && go test ./..., plus the project's integration tests on a
real database — the v0.20.0 struct-scanning rule (ScanRequireFields) and the naming rule
show up only when queries run.Do not work around it silently. Open an issue at https://github.com/coregx/relica/issues with a
minimal reproduction (the builder chain, the dialect, the SQL from ToSQL(), the expected SQL).
A workaround in the project is named as such, with a link to the issue.
scripts/audit_test.sh runs audit.sh offline on scripts/testdata/: bad/ fires every check a
known number of times, clean/ holds the correct form of each pattern and must produce nothing.
bad/ also runs as a git work tree, where an untracked file must not be reported. Fixtures are *.go.txt and
go.mod.txt so they are neither Go files of the module nor nested modules. Run it after every change to the script;
a new check or a fixed false positive gets its fixture case first. audit.sh exits 0 after an audit (findings or
not) and 2 when it cannot run (bash older than 4.3 — macOS: brew install bash — or a directory it cannot enter).
scripts/audit.sh (opens in a new tab)scripts/audit_test.sh (opens in a new tab)scripts/testdata/bad/go.mod.txt (opens in a new tab)scripts/testdata/bad/internal/repo/repo.go.txt (opens in a new tab)scripts/testdata/bad/internal/repo/repo_test.go.txt (opens in a new tab)scripts/testdata/clean/go.mod.txt (opens in a new tab)scripts/testdata/clean/internal/handler/echo_only.go.txt (opens in a new tab)scripts/testdata/clean/internal/handler/handler.go.txt (opens in a new tab)scripts/testdata/clean/internal/legacy/dbx.go.txt (opens in a new tab)scripts/testdata/clean/internal/legacy/ent.go.txt (opens in a new tab)scripts/testdata/clean/internal/legacy/otherorm.go.txt (opens in a new tab)scripts/testdata/clean/internal/repo/repo.go.txt (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub coregx/relica --plugin relicaOther plugins' skills for the same job