/be:firestorefrom Backend Skills
Cloud Firestore behind a Next.js API — clients denied and the Admin SDK as the only path, one lazy Admin client, collection paths as constants, Timestamps converted in the data layer, cursor pagination, transactions, atomic counters and batches, denormalised data, TTL and cascade deletes, idempotent triggers, indexes as code with the edition's rules, security rules and their tests, backups and point-in-time recovery, and rolling back rules and indexes. Use when reading or writing Firestore, or changing its rules or indexes.
Ships in Backend Skills. 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.
The API is the only thing that reads or writes Firestore, through the Admin SDK in its data layer. Clients are denied everything, so the security rules are a second wall rather than the gate, and every rule about the data — shape, ownership, atomicity — lives in code that can be read, tested and reviewed.
Before applying this skill, read the project's root AGENTS.md, the AGENTS.md closest to the files in question, and any doc they link for this skill's topic. Names, values and choices — budgets, tiers, tokens, voice, paths — come from those files, never from this skill.
access-control), and unsubscribes its listener on unmount.collection() call (code-structure).clients/ kind: constructed on first use, kept on globalThis so hot reload doesn't open a second one, with ignoreUndefinedProperties: true so an optional field left undefined is skipped rather than rejected.initializeApp() with no key. Off Google's infrastructure, the service-account key comes from the secret manager, never a file in the repo or a public variable: it bypasses every rule (env).schemas-and-contracts). Firestore's Timestamp is converted to an ISO string there, before the schema, and never reaches a contract or the frontend; a shared timestamp schema accepts a Timestamp, a Date or milliseconds.limit + 1 to know whether there's more, and documentId() breaks ties. Offset reads and bills every skipped document. The shared helper is in references/patterns.md.count().get(), billed per thousand index entries, never a fetch of every document.orderBy drops documents that lack the field, silently — a field a list sorts on is written on every document, with a default.in and array-contains-any are chunked at 30 values — Firestore's cap — and the chunks run in parallel. The Admin SDK's getAll has no such cap; chunking it is a house choice that keeps each request small..select() on the Admin SDK — when a document is large and the read needs a few fields; it bills the same reads, but sends fewer bytes.FieldValue.increment(), never a read and a write. Uniqueness uses create(), which fails if the document exists, or a transaction.FieldValue.serverTimestamp() on writes; Timestamp.now() inside a transaction, where a value must be known before commit. createdAt and owner fields never change after create.BulkWriter, which batches and retries for you.schemas-and-contracts).expiresAt field per collection group, set from a retention constant. TTL deletes within about a day of expiry, never on time, so reads still filter expiresAt > now; it doesn't cascade to subcollections, and the policy is set per project, outside firebase deploy. Commands in references/patterns.md.deleting), answers 202, and a trigger does the cleanup, guarded in a transaction against work still in progress.api-architecture).firestore.indexes.json, changed in the same PR as the query that needs them.orderBy, or filters on several ranges, needs a composite index, and without one it fails with FAILED_PRECONDITION — in production, because the emulator runs any valid query. Queries of equality filters alone can be served by merging single-field indexes, so they need no entry. On the Enterprise edition indexes are optional: a query without one scans, so there an index is a speed and cost choice.firebase firestore:indexes prints what's deployed, to compare with the file both ways — an index no query uses costs writes and storage.firebase deploy --only firestore:indexes asks before deleting indexes missing from the file; never answer it with --force on production.request.auth (a role from the token, not a get()), caps the size and type of every field, keeps createdAt, owners and roles unchanged, and leaves append-only collections with write: false. hasOnly limits which fields change, not who changes them — always pair it with ownership. Helpers in references/patterns.md.@firebase/rules-unit-testing against the emulator, in CI: for each collection, the reads and writes that must succeed and the ones that must fail, including a signed-out caller and another account (testing). firebase-security-rules-auditor reviews them; --dry-run only proves they compile.devops).Timestamp before parsing; page with cursors; use transactions, increment() and create(); denormalise what lists read; make triggers idempotent; ship indexes with their queries; test the rules in CI; turn on PITR and scheduled backups.--dry-run alone; restore a backup over the live database.Sign-in and sessions auth · roles, claims and guards access-control · schemas and projections schemas-and-contracts · Storage and uploads image-handling · App Check and server threats backend-security · env and secrets env · the emulator in tests testing · deploys devops · encrypted fields field-encryption · the audit firestore-audit · rules review firebase-security-rules-auditor (official).
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub timonwa/engineering-skills --plugin be22 skills in this plugin
/access-controlAccess control for a Next.js API on Firebase — roles, relationships and attributes (RBAC, ReBAC, ABAC) behind permission verbs and one pure can(); guards as the only gate, 404 before 403; tenant scoping; invitations; escalation limits; two-person approval and access reviews; stale claims; API-key scopes; share links and passcodes; where plan and flag checks sit; UI gates that only hide; and tests. Use when adding a permission, role, guarded route, API key, share link, or a control only some people see./access-control-auditManually invoked. Access-control audit — guards on every route and Server Action (BFLA), 404 before 403 and tenant scoping (BOLA), allowlisted writes and projected reads (BOPLA), verbs never role names, roles that add up, escalation and invitations, claims and revocation, sessions and sign-in, API keys and share links, the plan and flag order, UI gates, data rules and the tests. Verifies each finding and writes a prioritised report./api-architectureHow an API route is built in a Next.js API — the fixed order of rate limit, authorise, validate, delegate, audit, respond; thin routes over services; the response envelope and typed errors; caching headers; concurrent edits; long-running work; cursor pagination and allowlisted sorts; resource paths, versions, deprecation and state-transition sub-routes; and what every new route ships with. Cron, webhooks and audit logs are references. Use when adding, changing or reviewing a route handler or the API layer's structure.Other plugins' skills for the same job