/kenji:backend-patternsfrom kenji skills
Applies backend patterns including queues, caching, rate limits, and serverless/edge functions. Probes existing architecture before adding new patterns.
Ships in kenji 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.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
backend-patterns, queues, caching, rate-limiting, serverless, edge-functions
npx claudepluginhub kensaurus/skills --plugin kenjiDegree of freedom: MIXED. Which pattern to apply [HIGH freedom];
existing-architecture probes and the validation list [LOW freedom — run exactly].
| Skill | Owns |
|---|---|
| backend-patterns (this) | Apply queues, caching, rate limits, and serverless/edge patterns |
audit-backend-architecture | Read-only architecture audit and pattern advisor: which pattern to pick |
Observe:
createOrdersends email inline; no Inngest/queue; checkout p95 4s. Interpret: confirmation is post-response work, not request-path. Classify:after()or anorder/createdjob; keep the write transactional. Verify: order row commits; email/inventory run after response; retries do not double-charge.
audit-backend-architectureDesign scalable, maintainable backend architectures using modern patterns and best practices.
Code examples lean on Next.js App Router + Supabase/Prisma. The patterns are stack-agnostic — adapt ORMs, client libraries, and deploy targets to your detected ecosystem.
Before implementing ANY backend pattern, verify:
ls -la src/server/ src/api/ app/api/ supabase/functions/ 2>/dev/null
cat package.json | grep -i "prisma\|drizzle\|supabase\|trpc"
rg "createTRPCRouter|publicProcedure" --type ts -l
rg "'use server'" --type ts -l
ls -la supabase/migrations/*.sql 2>/dev/null | tail -5
cat prisma/schema.prisma 2>/dev/null | head -50
cat supabase/config.toml 2>/dev/null
Why: Backend changes have wide impact. Understand existing architecture first.
Next.js 16: Turbopack default; 'use cache' + cacheComponents; reactCompiler: true; middleware.ts → proxy.ts (grep both). Instant navigations → enhance-web-instant-nav.
safeParse → execute → map known errors (Prisma P2002) → generic failure message.ActionResult<T>: { success: true, data } or { success: false, error, fieldErrors? }; never throw to the client.revalidatePath after a successful write.after() from next/server, keeping the write transactional.'use server'
import { after } from 'next/server'
export async function createOrder(formData: FormData) {
const order = await db.order.create({ data: { /* ... */ } })
after(async () => { // runs after the response is sent
await sendOrderConfirmation(order.id)
await updateInventory(order.items)
})
revalidatePath('/orders')
return { success: true, data: order }
}
Full createUser action and the after() example: references/request-patterns.md §Server Actions.
publicProcedure for reads anyone may do; protectedProcedure for anything that uses ctx.session..input(); mutations stamp createdById from the session, not the input.limit + 1, pop the extra row as nextCursor.Full usersRouter (getById, create, cursor-paginated list): references/request-patterns.md §tRPC router definition.
Deno.serve; answer OPTIONS with the CORS headers first.401 on mismatch.SUPABASE_SERVICE_ROLE_KEY bypasses RLS; use it only inside the function.500 JSON body with CORS headers.Full process-webhook function: references/request-patterns.md §Supabase Edge Function.
version INT column; UPDATE ... WHERE id = $1 AND version = $2 and treat 0 rows as a concurrent update.deletedAt with an index; every read filters deletedAt: null; delete sets the timestamp.audit_logs(table_name, record_id, action, old_data, new_data, user_id) filled by a SECURITY DEFINER trigger using TG_OP, row_to_json, auth.uid().UPDATE orders SET status = 'shipped', version = version + 1
WHERE id = $1 AND version = $2; -- 0 rows → concurrent update, retry or surface conflict
Soft-delete Prisma model and the full audit trigger: references/data-and-jobs.md §Soft deletes, §Audit logging.
fetch(url, { next: { revalidate, tags } }); revalidateTag on demand; unstable_cache around DB queries with tags.getCachedData(key, fetcher, ttl) helper, cache-aside; key by entity and id (user:${id}).const getCachedUser = unstable_cache(
async (id: string) => db.user.findUnique({ where: { id } }),
['user'],
{ revalidate: 3600, tags: ['users'] }
)
Next.js cache calls and the Redis helper: references/data-and-jobs.md §Next.js cache, §Redis caching.
inngest.createFunction({ id }, { event }, async ({ event, step }) => ...); each side effect in its own step.run so retries resume, not restart.inngest.send({ name: 'order/created', data }) from the Server Action after the write commits.step.run + return { status: 'cancelled' }, not a throw.export const processOrder = inngest.createFunction(
{ id: 'process-order' }, { event: 'order/created' },
async ({ event, step }) => {
const payment = await step.run('charge-payment', () => chargeCustomer(event.data.paymentMethod))
await step.run('send-confirmation', () => sendOrderConfirmation(event.data.orderId))
return { status: 'completed', paymentId: payment.id }
}
)
Full Inngest function and the Trigger.dev scheduled-task alternative: references/data-and-jobs.md §Background jobs, §Alternatives.
@upstash/ratelimit with Ratelimit.slidingWindow(10, '10 s') over Redis.fromEnv().!success return Too many requests with retryAfter seconds from reset.Full rateLimitedAction: references/request-patterns.md §Rate limiting.
Gateway, BFF, bulkhead, circuit breaker, outbox+CDC, saga, hexagonal, ACL, and strangler-fig →
references/architecture-patterns.md. Pick the pattern for the
topology (no mesh on a monolith; no CQRS unless reads/writes diverge). Timeouts/retries/idempotency
→ audit-resilience; structural gap report → audit-backend-architecture.
After implementing backend patterns:
162 skills in this plugin
/audit-accessibilityWCAG 2.2 AA audit via playwright-cli: axe-core, keyboard, contrast, target size, focus, ARIA. Use when "audit accessibility", "check a11y", "WCAG audit", "check keyboard nav", or "test screen reader".
/audit-agent-speedMeasure and fix a slow coding-agent setup: status line, hooks, instruction bloat, effort, worktree pile-up, antivirus and indexer scans. Use when "Claude is slow" or "CPU is pinned". App speed → audit-performance.
/audit-analyticsRead-only audit of product-analytics events (PostHog, Amplitude, Mixpanel, GA4): taxonomy, funnels, consent-gated firing, dead or duplicate events. Use when "audit our analytics", "are we tracking the right events", or "funnel instrumentation".
/audit-auth-flowsRead-only audit of app-layer auth: route×gate matrix, session lifecycle, OAuth, provider traps (getSession vs getUser, middleware-only gates, CVE-2025-29927). Use when "audit our auth" or "check middleware protection". RLS → plan-rls-audit.
/audit-backend-architectureRead-only backend-architecture audit and pattern advisor, gated by stack. Use when "audit backend architecture", "which pattern should I use", "am I over-engineering", or "sync vs event-driven". Enforced boundaries → enhance-arch-boundaries.
/audit-bundle-sizeAnalyse and shrink a web app's JavaScript bundle. Use when "reduce bundle size", "code splitting", "slow initial load", or "why is the bundle so big". Runtime → audit-performance.
Other plugins' skills for the same job