backend

Guides backend development of a Node.js billing service with layered architecture and domain rules.

Updated Jun 2, 2026
One-click install
npx skills add https://github.com/lfuuu/claude-rules --skill backend-lfuuu
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: backend
Source: https://github.com/lfuuu/claude-rules/tree/main/ai-billing/skills/backend
Command: npx skills add https://github.com/lfuuu/claude-rules --skill backend-lfuuu

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Billing backend work demands strict correctness: money calculations, idempotency, and layered architecture rules are easy to violate without explicit guidance. This Skill encodes the AI Billing project's backend conventions so changes to business logic, Prisma schemas, and OpenAPI definitions follow the project's architecture and domain invariants. ## Core Features & Use Cases - Role-scoped backend guidance: Activates only for tasks touching backend/src/, backend/tests/, backend/prisma/, or OpenAPI descriptions, and defers UI, docs, review, and test-run tasks to other roles. - Architecture enforcement: Defines layered + hexagonal rules (domain, application, infrastructure, API) with ports/adapters, a pure BillingCalculator domain service, and a PriceResolver abstraction. - Billing domain invariants: Encodes pricing rules (provider + model + metricType + sessionStartedAt), decimal.js-only money math, idempotent usage ingestion, and transactional persistence. - Use Case: When adding a new usage endpoint, the Skill directs you through a pre-task architecture checklist, the correct layer placement, required unit/integration tests, and the NEVER list (e.g., no float money math, no Prisma in routes). ## Quick Start Ask the assistant to implement a new billing usage endpoint in the backend following the project architecture and domain rules.

Frequently Asked Questions about backend

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new billing endpoint in a layered Node.js backend?

Place the route and DTO validation in the API layer, orchestrate the flow in an application-layer use case, keep pricing logic in the pure domain BillingCalculator, and access data through a Prisma adapter behind a repository port. Add unit and integration tests before considering the task done.

How should money calculations be handled in a TypeScript billing system?

Use decimal.js for all monetary math; never use Number or float for final amounts. Compute amount as quantity divided by unitSize times unitPrice, round totalAmount to two decimals, and store a price snapshot (unitPrice, unitSize, currency, amount) on each billing item.

When should this backend role not be used?

Do not use it for frontend/src/ UI tasks (use the frontend role), prose documentation updates (techwriter role), running or diagnosing tests without code changes (testing role), or reviewing a finished diff (reviewer role).

Can Prisma models be used directly as domain entities?

No. Prisma models must not leak into domain or application types; a mapper converts them at the infrastructure boundary. Express routes also must never call Prisma directly for business operations.

How is idempotency handled for usage ingestion in billing?

Repeated usage with the same clientAccountId and sessionId must not create duplicate charges. Usage and the billing result are saved in a single transaction, and stored billing results are never recalculated with current prices.

When must backend work escalate instead of proceeding autonomously?

Stop and consult the architect when a task requires changing a business rule such as the pricing formula, an error code, or the idempotency policy, or when it would change expected values of existing tests.