agentleFS
xAIKnown publisherxai-org/customer-education-workshops/ledgerly/.cursor/skills/write-prisma-query/SKILL.md

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".

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
  1. Very specific:

    All money is integer cents (totalCents, disputedAmountCents).

    line 13
  2. Very specific:

    Write the query with include/select kept minimal, ordered deterministically (orderBy), and typed by inference (no any).

    line 23
  3. Very specific:

    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.

    line 24

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

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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: import prisma from @/lib/prisma (server code only).
  • All money is integer cents (totalCents, disputedAmountCents). Format for humans with formatUsd from @/lib/money. Never introduce floats or a price outside $49/$99/$249.
  • Statuses are strings validated by lib/status.ts: invoices DRAFT | OPEN | PAID | OVERDUE | VOID, disputes OPEN | NEEDS_REVIEW | ACCEPTED | DECLINED.
  • "Today" is the frozen demo clock: import DEMO_AS_OF from @/lib/clock (23 Aug 2026). Never use new 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 scattering prisma. calls inside components.
  • There is no project database MCP and no mcp/ directory. Do not add ledgerly-db or query SQLite over MCP. Use Prisma here, lib/data.ts, or curl against /api/invoices and /api/disputes.

Recipe

  1. Restate what rows and columns the user wants.
  2. Write the query with include/select kept minimal, ordered deterministically (orderBy), and typed by inference (no any).
  3. 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.
  4. Show how to verify: either a one-off npx tsx snippet or hitting an existing API route such as curl 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));
}

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.