write-prisma-query
Skill2 starsChanged 17 days agoApache-2.0View on GitHub
Write a correct Prisma query against Ledgerly's seeded SQLite database. Use when someone asks to pull, count, or aggregate invoices, disputes, or customers from the demo seed — e.g. "which invoices are overdue" or "total open receivables".
In this repository19 other files it gives its agents.
- AGENTS.mdAGENTS.md
- ledgerly/AGENTS.mdAGENTS.md
- .cursor/rules/ledgerly.mdcCursor rule
- .cursor/rules/ledgerly-multitask.mdcCursor rule
- ledgerly/.cursor/rules/disposable-demo-prs.mdcCursor rule
- ledgerly/.cursor/rules/ledgerly.mdcCursor rule
- ledgerly/.cursor/rules/multitask-no-wrapper.mdcCursor rule
- add-dashboard-widgetSkill
- choose-cursor-workflowSkill
- dispatch-subagentsSkill
- draft-collection-emailSkill
- hand-to-cloud-agentSkill
- present-runbooksSkill
- reset-demo-stateSkill
- split-prd-into-issuesSkill
- stage-linearSkill
- standard-bug-fixSkill
- start-ledgerlySkill
- standard-bug-fixSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are 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.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 13
All money is integer cents (totalCents, disputedAmountCents).
- Very specific: line 23
Write the query with include/select kept minimal, ordered deterministically (orderBy), and typed by inference (no any).
- Very specific: line 24
If it is for a page or API route, put it in lib/data.ts and call it from the server component or route handler.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill 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.
Files
Write a Prisma query for Ledgerly
Produce a query that runs against this repo's real schema and seed, not a generic Prisma example.
Ground rules
- Schema:
prisma/schema.prisma. Client singleton: importprismafrom@/lib/prisma(server code only). - All money is integer cents (
totalCents,disputedAmountCents). Format for humans withformatUsdfrom@/lib/money. Never introduce floats or a price outside $49/$99/$249. - Statuses are strings validated by
lib/status.ts: invoicesDRAFT | OPEN | PAID | OVERDUE | VOID, disputesOPEN | NEEDS_REVIEW | ACCEPTED | DECLINED. - "Today" is the frozen demo clock: import
DEMO_AS_OFfrom@/lib/clock(23 Aug 2026). Never usenew Date()for aging. - IDs look like
inv_1043,dsp_1043,cus_harborline. Single workspace:ws_fieldnote. - Existing query helpers live in
lib/data.ts— extend that file rather than scatteringprisma.calls inside components. - There is no project database MCP and no
mcp/directory. Do not addledgerly-dbor query SQLite over MCP. Use Prisma here,lib/data.ts, orcurlagainst/api/invoicesand/api/disputes.
Recipe
- Restate what rows and columns the user wants.
- Write the query with
include/selectkept minimal, ordered deterministically (orderBy), and typed by inference (noany). - If it is for a page or API route, put it in
lib/data.tsand call it from the server component or route handler. - Show how to verify: either a one-off
npx tsxsnippet or hitting an existing API route such ascurl http://127.0.0.1:43173/api/invoices?status=OVERDUE.
Example shape
export async function getOverdueTotalCents() {
const overdue = await prisma.invoice.findMany({
where: { status: "OVERDUE" },
select: { totalCents: true },
});
return sumCents(overdue.map((invoice) => invoice.totalCents));
}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
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.

