BA

backend-dev-guidelines

Maintains consistency and architecture patterns for backend services within the Langfuse ecosystem.

Install

mkdir -p .claude/skills/backend-dev-guidelines-yashvinthan && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/17737" && unzip -o skill.zip -d .claude/skills/backend-dev-guidelines-yashvinthan && rm skill.zip

Installs to .claude/skills/backend-dev-guidelines-yashvinthan

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Comprehensive backend development guide for Langfuse's Next.js 14/tRPC/Express/TypeScript monorepo. Use when creating tRPC routers, public API endpoints, BullMQ queue processors, services, or working with tRPC procedures, Next.js API routes, Prisma database access, ClickHouse analytics queries, Redis queues, OpenTelemetry instrumentation, Zod v4 validation, env.mjs configuration, tenant isolation patterns, or async patterns. Covers layered architecture (tRPC procedures → services, queue processors → services), dual database system (PostgreSQL + ClickHouse), projectId filtering for multi-tenant isolation, traceException error handling, observability patterns, and testing strategies (Jest for web, vitest for worker).
724 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Intermediate

Key capabilities

  • Define tRPC routers and procedures for UI interactions.
  • Create public API endpoints for SDKs.
  • Implement BullMQ queue consumers and producers.
  • Manage database operations using Prisma for PostgreSQL and ClickHouse.
  • Apply OpenTelemetry, DataDog, and logger for observability.
  • Validate input using Zod v4 schemas.

How it works

The skill guides backend development by providing checklists and architectural patterns for tRPC procedures, public API routes, and queue processors, ensuring consistent implementation across web and worker packages.

Inputs & outputs

You give it
HTTP Request or BullMQ Queue Job
You get back
Database operations, service logic execution, or queue job processing

When to use backend-dev-guidelines

  • Building new tRPC procedures
  • Implementing database operations
  • Adding backend observability

About this skill

Backend Development Guidelines

Purpose

Establish consistency and best practices across Langfuse's backend packages (web, worker, packages/shared) using Next.js 14, tRPC, BullMQ, and TypeScript patterns.

When to Use This Skill

Automatically activates when working on:

  • Creating or modifying tRPC routers and procedures
  • Creating or modifying public API endpoints (REST)
  • Creating or modifying BullMQ queue consumers and producers
  • Building services with business logic
  • Authenticating API requests
  • Accessing resources based on entitlements
  • Implementing middleware (tRPC, NextAuth, public API)
  • Database operations with Prisma (PostgreSQL) or ClickHouse
  • Observability with OpenTelemetry, DataDog, logger, and traceException
  • Input validation with Zod v4
  • Environment configuration from env variables
  • Backend testing and refactoring

Quick Start

UI: New tRPC Feature Checklist (Web)

  • Router: Define in features/[feature]/server/*Router.ts
  • Procedures: Use appropriate procedure type (protected, public)
  • Authentication: Use JWT authorization via middlewares.
  • Entitlement check: Access resources based on resource and role
  • Validation: Zod v4 schema for input
  • Service: Business logic in service file
  • Error handling: Use traceException wrapper
  • Tests: Unit + integration tests in __tests__/
  • Config: Access via env.mjs

SDKs: New Public API Endpoint Checklist (Web)

  • Route file: Create in pages/api/public/
  • Wrapper: Use withMiddlewares + createAuthedProjectAPIRoute
  • Types: Define in features/public-api/types/
  • Authentication: Authorization via basic auth
  • Validation: Zod schemas for query/body/response
  • Versioning: Versioning in API path and Zod schemas for query/body/response
  • Tests: Add end-to-end test in __tests__/async/

New Queue Processor Checklist (Worker)

  • Processor: Create in worker/src/queues/
  • Queue types: Create queue types in packages/shared/src/server/queues
  • Service: Business logic in features/ or worker/src/features/
  • Error handling: Distinguish between errors which should fail queue processing and errors which should result in a succeeded event.
  • Queue registration: Add to WorkerManager in app.ts
  • Tests: Add vitest tests in worker

Architecture Overview

Layered Architecture

# Web Package (Next.js 14)

┌─ tRPC API ──────────────────┐   ┌── Public REST API ──────────┐
│                             │   │                             │
│  HTTP Request               │   │  HTTP Request               │
│      ↓                      │   │      ↓                      │
│  tRPC Procedure             │   │  withMiddlewares +          │
│  (protectedProjectProcedure)│   │  createAuthedProjectAPIRoute│
│      ↓                      │   │      ↓                      │
│  Service (business logic)   │   │  Service (business logic)   │
│      ↓                      │   │      ↓                      │
│  Prisma / ClickHouse        │   │  Prisma / ClickHouse        │
│                             │   │                             │
└─────────────────────────────┘   └─────────────────────────────┘
                 ↓
            [optional]: Publish to Redis BullMQ queue
                 ↓
┌─ Worker Package (Express) ──────────────────────────────────┐
│                                                             │
│  BullMQ Queue Job                                           │
│      ↓                                                      │
│  Queue Processor (handles job)                              │
│      ↓                                                      │
│  Service (business logic)                                   │
│      ↓                                                      │
│  Prisma / ClickHouse                                        │
│                                                             │
└─────────────────────────────────────────────────────────────┘

Key Principles:

  • Web: tRPC procedures for UI OR public API routes for SDKs → Services → Database
  • Worker: Queue processors → Services → Database
  • packages/shared: Shared code for Web and Worker

See architecture-overview.md for complete details.


Directory Structure

Web Package (/web/)

web/src/
├── features/                # Feature-organized code
│   ├── [feature-name]/
│   │   ├── server/          # Backend logic
│   │   │   ├── *Router.ts   # tRPC router
│   │   │   └── service.ts   # Business logic
│   │   ├── components/      # React components
│   │   └── types/           # Feature types
├── server/
│   ├── api/
│   │   ├── routers/         # tRPC routers
│   │   ├── trpc.ts          # tRPC setup & middleware
│   │   └── root.ts          # Main router
│   ├── auth.ts              # NextAuth.js config
│   └── db.ts                # Database client
├── pages/
│   ├── api/
│   │   ├── public/          # Public REST APIs
│   │   └── trpc/            # tRPC endpoint
│   └── [routes].tsx         # Next.js pages
├── __tests__/               # Jest tests
│   └── async/               # Integration tests
├── instrumentation.ts       # OpenTelemetry (FIRST IMPORT)
└── env.mjs                  # Environment config

Worker Package (/worker/)

worker/src/
├── queues/                  # BullMQ processors
│   ├── evalQueue.ts
│   ├── ingestionQueue.ts
│   └── workerManager.ts
├── features/                # Business logic
│   └── [feature]/
│       └── service.ts
├── instrumentation.ts       # OpenTelemetry (FIRST IMPORT)
├── app.ts                   # Express setup + queue registration
├── env.ts                   # Environment config
└── index.ts                 # Server start

Shared Package (/packages/shared/)

shared/src/
├── server/                  # Server utilities
│   ├── auth/                # Authentication helpers
│   ├── clickhouse/          # ClickHouse client & schema
│   ├── instrumentation/     # OpenTelemetry helpers
│   ├── llm/                 # LLM integration utilities
│   ├── redis/               # Redis queues & cache
│   ├── repositories/        # Data repositories
│   ├── services/            # Shared services
│   ├── utils/               # Server utilities
│   ├── logger.ts
│   └── queues.ts
├── encryption/              # Encryption utilities
├── features/                # Feature-specific code
├── tableDefinitions/        # Table schemas
├── utils/                   # Shared utilities
├── constants.ts
├── db.ts                    # Prisma client
├── env.ts                   # Environment config
└── index.ts                 # Main exports

Import Paths (package.json exports):

The shared package exposes specific import paths for different use cases:

Import PathMaps ToUse For
@langfuse/shareddist/src/index.jsGeneral types, schemas, utilities, constants
@langfuse/shared/src/dbdist/src/db.jsPrisma client and database types
@langfuse/shared/src/serverdist/src/server/index.jsServer-side utilities (queues, auth, services, instrumentation)
@langfuse/shared/src/server/auth/apiKeysdist/src/server/auth/apiKeys.jsAPI key management utilities
@langfuse/shared/encryptiondist/src/encryption/index.jsEncryption and signature utilities

Usage Examples:

// General imports - types, schemas, constants, interfaces
import {
  CloudConfigSchema,
  StringNoHTML,
  AnnotationQueueObjectType,
  type APIScoreV2,
  type ColumnDefinition,
  Role,
} from "@langfuse/shared";

// Database - Prisma client and types
import { prisma, Prisma, JobExecutionStatus } from "@langfuse/shared/src/db";
import { type DB as Database } from "@langfuse/shared";

// Server utilities - queues, services, auth, instrumentation
import {
  logger,
  instrumentAsync,
  traceException,
  redis,
  getTracesTable,
  StorageService,
  sendMembershipInvitationEmail,
  invalidateApiKeysForProject,
  recordIncrement,
  recordHistogram,
} from "@langfuse/shared/src/server";

// API key management (specific path)
import { createAndAddApiKeysToDb } from "@langfuse/shared/src/server/auth/apiKeys";

// Encryption utilities
import { encrypt, decrypt, sign, verify } from "@langfuse/shared/encryption";

What Goes Where:

The shared package provides types, utilities, and server code used by both web and worker packages. It has 5 export paths that control frontend vs backend access:

Import PathUsageWhat's Included
@langfuse/shared✅ Frontend + BackendPrisma types, Zod schemas, constants, table definitions, domain models, utilities
@langfuse/shared/src/db🔒 Backend onlyPrisma client instance
@langfuse/shared/src/server🔒 Backend onlyServices, repositories, queues, auth, ClickHouse, LLM integration, instrumentation
@langfuse/shared/src/server/auth/apiKeys🔒 Backend onlyAPI key management (sep

Content truncated.

When not to use it

  • When working outside Langfuse's Next.js 14/tRPC/Express/TypeScript monorepo.
  • When not creating tRPC routers, public API endpoints, or BullMQ queue processors.
  • When not working with Prisma database access or ClickHouse analytics queries.

Limitations

  • The guidelines are specific to Langfuse's Next.js 14/tRPC/Express/TypeScript monorepo.
  • The skill focuses on backend development within the defined technology stack.
  • The guidelines are for creating or modifying specific components like tRPC routers, public API endpoints, or BullMQ queue processors.

How it compares

This skill provides specific checklists and architectural diagrams for Langfuse's monorepo, unlike a generic backend development guide that would lack these tailored instructions.

Compared to similar skills

backend-dev-guidelines side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
backend-dev-guidelines (this skill)05moReviewIntermediate
backend-dev-guidelines1013dReviewAdvanced
route-handlers16moReviewIntermediate
add-api-endpoint05moNo flagsIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

backend-dev-guidelines

langfuse

Comprehensive backend development guide for Langfuse's Next.js 14/tRPC/Express/TypeScript monorepo. Use when creating tRPC routers, public API endpoints, BullMQ queue processors, services, or working with tRPC procedures, Next.js API routes, Prisma database access, ClickHouse analytics queries, Redis queues, OpenTelemetry instrumentation, Zod v4 validation, env.mjs configuration, tenant isolation patterns, or async patterns. Covers layered architecture (tRPC procedures → services, queue processors → services), dual database system (PostgreSQL + ClickHouse), projectId filtering for multi-tenant isolation, traceException error handling, observability patterns, and testing strategies (Jest for web, vitest for worker).

10100

route-handlers

davepoon

This skill should be used when the user asks to "create an API route", "add an endpoint", "build a REST API", "handle POST requests", "create route handlers", "stream responses", or needs guidance on Next.js API development in the App Router.

14

add-api-endpoint

tahmidbintaslim

Add a new Next.js App Router API route with validation, safe errors, Supabase auth checks, docs and tests.

00

hr-portal-skill

hariventures2000-ship-it

Use this skill when developing, testing, debugging, or modifying code inside the HR Portal frontend (apps/hr-portal). It applies to handling HR administration tasks such as employee roster management, contract seeding, leave request approvals, attendance monitoring, payroll calculation, and recruitm

00

payload

payloadcms

Use when working with Payload CMS projects (payload.config.ts, collections, fields, hooks, access control, Payload API). Use when debugging validation errors, security issues, relationship queries, transactions, or hook behavior.

73206

add-setting-env

lobehub

Guide for adding environment variables to configure user settings. Use when implementing server-side environment variables that control default values for user settings. Triggers on env var configuration or setting default value tasks.

469

Search skills

Search the agent skills registry