agentsclimarketplace

Api backend

Skill undp/carbon-footprint-program/.claude/skills/api-backend

Backend conventions for apps/api (Fastify + Prisma). Use when building or modifying an API endpoint — feature structure, efficient Prisma queries, transactions, helper placement, and the packages/types layout.From its SKILL.md

Install
npx -y skills add undp/carbon-footprint-program --skill api-backend

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

2.5 KB, as published. Nobody here has run it

API & Backend Rules

Feature structure

Follow the existing pattern — route.ts → handler.ts → service.ts (→ helpers.ts if needed) per feature, under apps/api/src/features/.

Efficient database usage

Endpoints must be efficient and mindful that datasets grow over time. Apply these principles in order of preference:

  1. Push logic to the database: use aggregations, filters, and calculations at the query level (groupBy, count, _sum, Views as last resort) instead of fetching raw rows and processing in memory.
  2. Parallelize independent queries: use Promise.all or prisma.$transaction to run independent queries concurrently instead of sequentially.
  3. Avoid overfetching: use select to retrieve only the fields you need. The dataset will grow and overfetching will degrade performance.
  4. Use include wisely: prefer a single query with include over multiple sequential queries, but only include relations that are actually needed.

Transactions

When an endpoint performs validations followed by updates (read-then-write), wrap them in a prisma.$transaction to avoid TOCTOU (time-of-check to time-of-use) race conditions. Use the interactive form (prisma.$transaction(async (tx) => { ... })) so that all reads and writes share the same transaction context and data stays consistent.

Helper functions

Feature-specific helpers go in a separate helpers.ts within the feature directory, not inside service.ts. Keep service.ts focused on business logic and database operations. Promote a helper to the shared apps/api/src/helpers/ directory only when reuse is actually observed — never speculatively.

Types package structure (packages/types/src/)

Organized by domain (e.g., organizations/, carbonInventories/). Each domain contains:

  • schemas.ts + types.ts at the domain root for shared schemas/types.
  • app/ and/or admin/ subfolders to separate public and admin endpoints.
  • Inside each subfolder, one directory per endpoint (e.g., app/getOrganizationById/) with its own schemas.ts and types.ts for params, query, body, and response.
  • An index.ts at each level to re-export everything.

See also the typescript-typing, api-authorization, and error-handling skills.

Keep looking

Skills are one crate of 607,533. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.