Senior Backend Engineer

Designs and implements backend systems including REST APIs, microservices, database architectures, authentication flows, and security hardening.

How to use it

Claude Code
  1. Run the line below. It pulls the whole folder into ~/.claude/skills/senior-backend, including the files SKILL.md points to.
  2. Describe your job in plain words. Claude Code follows the skill from there.
Claude Code — installs the whole folder, not just SKILL.md
npx degit alirezarezvani/claude-skills/engineering-team/skills/senior-backend#main ~/.claude/skills/senior-backend

For one project only, change the path to .claude/skills/senior-backend. This skill also uses Node.js, openapi.yaml, Express.js, baseline.json, backend_decision_engine.py — copying SKILL.md alone won't be enough. See the folder on GitHub.

Claude (web or desktop app)
  1. On this page open ⋯ → Download .md.
  2. Save it as SKILL.md in a folder, zip the folder, then Customize → Skills → + → Create skill → Upload a skill.
  3. Pick the file and Save. Claude shows the name and description and runs a security scan.
  4. Check the skill is switched on.
  5. Start a new chat and describe your job in plain words. The AI follows the skill from there.
ChatGPT or another app
  1. ChatGPT: make a Project and paste it into Instructions.
  2. Neither? Paste it at the top of a new chat — it works for that chat.
Not working?
  • Check which app you pasted it into — the steps above name the right one.
  • Some skills need the paid tier of Claude or ChatGPT.
Step-by-step guide with screenshots · Ask in the forum

Paste into Claude, ChatGPT or Cursor.

Source of Senior Backend Engineer

Show the full text468 lines
namedescription
senior-backendDesigns and implements backend systems including REST APIs, microservices, database architectures, authentication flows, and security hardening. Use when the user asks to "design REST APIs", "optimize database queries", "implement authentication", "build microservices", "review backend code", "set up GraphQL", "handle database migrations", or "load test APIs". Covers Node.js/Express/Fastify development, PostgreSQL optimization, API security, and backend architecture patterns.

Senior Backend Engineer

Backend development patterns, API design, database optimization, and security practices.


Quick Start

# Generate API routes from OpenAPI spec
python scripts/api_scaffolder.py openapi.yaml --framework express --output src/routes/

# Analyze database schema and generate migrations
python scripts/database_migration_tool.py --connection postgres://localhost/mydb --analyze

# Load test an API endpoint
python scripts/api_load_tester.py https://api.example.com/users --concurrency 50 --duration 30

Tools Overview

1. API Scaffolder

Generates API route handlers, middleware, and OpenAPI specifications from schema definitions.

Input: OpenAPI spec (YAML/JSON) or database schema Output: Route handlers, validation middleware, TypeScript types

Usage:

# Generate Express routes from OpenAPI spec
python scripts/api_scaffolder.py openapi.yaml --framework express --output src/routes/
# Output: Generated 12 route handlers, validation middleware, and TypeScript types

# Generate from database schema
python scripts/api_scaffolder.py --from-db postgres://localhost/mydb --output src/routes/

# Generate OpenAPI spec from existing routes
python scripts/api_scaffolder.py src/routes/ --generate-spec --output openapi.yaml

Supported Frameworks:

  • Express.js (--framework express)
  • Fastify (--framework fastify)
  • Koa (--framework koa)

2. Database Migration Tool

Analyzes database schemas, detects changes, and generates migration files with rollback support.

Input: Database connection string or schema files Output: Migration files, schema diff report, optimization suggestions

Usage:

# Analyze current schema and suggest optimizations
python scripts/database_migration_tool.py --connection postgres://localhost/mydb --analyze
# Output: Missing indexes, N+1 query risks, and suggested migration files

# Generate migration from schema diff
python scripts/database_migration_tool.py --connection postgres://localhost/mydb \
  --compare schema/v2.sql --output migrations/

# Dry-run a migration
python scripts/database_migration_tool.py --connection postgres://localhost/mydb \
  --migrate migrations/20240115_add_user_indexes.sql --dry-run

3. API Load Tester

Performs HTTP load testing with configurable concurrency, measuring latency percentiles and throughput.

Input: API endpoint URL and test configuration Output: Performance report with latency distribution, error rates, throughput metrics

Usage:

# Basic load test
python scripts/api_load_tester.py https://api.example.com/users --concurrency 50 --duration 30
# Output: Throughput (req/sec), latency percentiles (P50/P95/P99), error counts, and scaling recommendations

# Test with custom headers and body
python scripts/api_load_tester.py https://api.example.com/orders \
  --method POST \
  --header "Authorization: Bearer token123" \
  --body '{"product_id": 1, "quantity": 2}' \
  --concurrency 100 \
  --duration 60

# Compare two endpoints
python scripts/api_load_tester.py https://api.example.com/v1/users https://api.example.com/v2/users \
  --compare --concurrency 50 --duration 30

Backend Development Workflows

API Design Workflow

Use when designing a new API or refactoring existing endpoints.

Step 1: Define resources and operations

# openapi.yaml
openapi: 3.0.3
info:
  title: User Service API
  version: 1.0.0
paths:
  /users:
    get:
      summary: List users
      parameters:
        - name: "limit"
          in: query
          schema:
            type: integer
            default: 20
    post:
      summary: Create user
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUser'

Step 2: Generate route scaffolding

python scripts/api_scaffolder.py openapi.yaml --framework express --output src/routes/

Step 3: Implement business logic

// src/routes/users.ts (generated, then customized)
export const createUser = async (req: Request, res: Response) => {
  const { email, name } = req.body;

  // Add business logic
  const user = await userService.create({ email, name });

  res.status(201).json(user);
};

Step 4: Add validation middleware

# Validation is auto-generated from OpenAPI schema
# src/middleware/validators.ts includes:
# - Request body validation
# - Query parameter validation
# - Path parameter validation

Step 5: Generate updated OpenAPI spec

python scripts/api_scaffolder.py src/routes/ --generate-spec --output openapi.yaml

Database Optimization Workflow

Use when queries are slow or database performance needs improvement.

Step 1: Analyze current performance

python scripts/database_migration_tool.py --connection $DATABASE_URL --analyze

Step 2: Identify slow queries

-- Check query execution plans
EXPLAIN ANALYZE SELECT * FROM orders
WHERE user_id = 123
ORDER BY created_at DESC
LIMIT 10;

-- Look for: Seq Scan (bad), Index Scan (good)

Step 3: Generate index migrations

python scripts/database_migration_tool.py --connection $DATABASE_URL \
  --suggest-indexes --output migrations/

Step 4: Test migration (dry-run)

python scripts/database_migration_tool.py --connection $DATABASE_URL \
  --migrate migrations/add_indexes.sql --dry-run

Step 5: Apply and verify

# Apply migration
python scripts/database_migration_tool.py --connection $DATABASE_URL \
  --migrate migrations/add_indexes.sql

# Verify improvement
python scripts/database_migration_tool.py --connection $DATABASE_URL --analyze

Security Hardening Workflow

Use when preparing an API for production or after a security review.

Step 1: Review authentication setup

// Verify JWT configuration
const jwtConfig = {
  secret: process.env.JWT_SECRET,  // Must be from env, never hardcoded
  expiresIn: '1h',                 // Short-lived tokens
  algorithm: 'RS256'               // Prefer asymmetric
};

Step 2: Add rate limiting

import rateLimit from 'express-rate-limit';

const apiLimiter = rateLimit({
  windowMs: 15 * 60 * 1000,  // 15 minutes
  max: 100,                   // 100 requests per window
  standardHeaders: true,
  legacyHeaders: false,
});

app.use('/api/', apiLimiter);

Step 3: Validate all inputs

import { z } from 'zod';

const CreateUserSchema = z.object({
  email: z.string().email().max(255),
  name: z.string().min(1).max(100),
  age: z.number().int().positive().optional()
});

// Use in route handler
const data = CreateUserSchema.parse(req.body);

Step 4: Load test with attack patterns

# Test rate limiting
python scripts/api_load_tester.py https://api.example.com/login \
  --concurrency 200 --duration 10 --expect-rate-limit

# Test input validation
python scripts/api_load_tester.py https://api.example.com/users \
  --method POST \
  --body '{"email": "not-an-email"}' \
  --expect-status 400

Step 5: Review security headers

import helmet from 'helmet';

app.use(helmet({
  contentSecurityPolicy: true,
  crossOriginEmbedderPolicy: true,
  crossOriginOpenerPolicy: true,
  crossOriginResourcePolicy: true,
  hsts: { maxAge: 31536000, includeSubDomains: true },
}));

Reference Documentation

File Contains Use When
references/api_design_patterns.md REST vs GraphQL, versioning, error handling, pagination Designing new APIs
references/database_optimization_guide.md Indexing strategies, query optimization, N+1 solutions Fixing slow queries
references/backend_security_practices.md OWASP Top 10, auth patterns, input validation Security hardening

Common Patterns Quick Reference

REST API Response Format
{
  "data": { "id": 1, "name": "John" },
  "meta": { "requestId": "abc-123" }
}
Error Response Format
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid email format",
    "details": [{ "field": "email", "message": "must be valid email" }]
  },
  "meta": { "requestId": "abc-123" }
}
HTTP Status Codes
Code Use Case
200 Success (GET, PUT, PATCH)
201 Created (POST)
204 No Content (DELETE)
400 Validation error
401 Authentication required
403 Permission denied
404 Resource not found
429 Rate limit exceeded
500 Internal server error
Database Index Strategy
-- Single column (equality lookups)
CREATE INDEX idx_users_email ON users(email);

-- Composite (multi-column queries)
CREATE INDEX idx_orders_user_status ON orders(user_id, status);

-- Partial (filtered queries)
CREATE INDEX idx_orders_active ON orders(created_at) WHERE status = 'active';

-- Covering (avoid table lookup)
CREATE INDEX idx_users_email_name ON users(email) INCLUDE (name);

Common Commands

# API Development
python scripts/api_scaffolder.py openapi.yaml --framework express
python scripts/api_scaffolder.py src/routes/ --generate-spec

# Database Operations
python scripts/database_migration_tool.py --connection $DATABASE_URL --analyze
python scripts/database_migration_tool.py --connection $DATABASE_URL --migrate file.sql

# Performance Testing
python scripts/api_load_tester.py https://api.example.com/endpoint --concurrency 50
python scripts/api_load_tester.py https://api.example.com/endpoint --compare baseline.json

Assumptions and Verifiable Success Criteria (Karpathy discipline)

Before this skill scaffolds, recommends a pattern, or modifies a schema, the following four assumptions MUST be surfaced. If any are unknown, the skill stops and walks the Forcing-question library instead.

  1. Read/write ratio + one-year p99 QPS — drives DB, cache, queue, and partitioning choices. Kleppmann, DDIA (2017).
  2. Tenancy model — single-tenant, shared multi-tenant, isolated multi-tenant. Drives data-access pattern.
  3. Data sensitivity tier — public / internal / PII / PHI / PCI. Drives compliance floor.
  4. SLO + named error-budget consumer — Google SRE Workbook canon. No SLO = no reliability work prioritization.

Verifiable success criteria (Karpathy #4) — every recommendation this skill emits must include:

  • Latency targets (p50, p95, p99 in ms)
  • Uptime / SLO target
  • RPO + RTO

If any of those three is not stated, the recommendation is incomplete — return to Q7 of the forcing-question library.

The scripts/backend_decision_engine.py tool encodes these checks: it refuses to recommend a profile without read/write ratio + QPS + tenancy + data sensitivity + pattern preference.


Customization profiles

Four built-in profiles in profiles/ calibrate every recommendation:

Profile When to pick Pattern Latency floor (p99)
node-express TS team, < 15 eng, customer-facing SaaS Modular monolith on Postgres 600ms
fastapi-python Python team, < 20 eng, ML-adjacent Modular monolith on Postgres (async) 500ms
django-monolith Content-heavy CRUD + admin, < 25 eng Modular monolith on Postgres 800ms
go-or-rust-microservice Extracted service, ≥ 30 eng, platform team, QPS ≥ 1000 Extracted service 200ms

Pick a profile via:

python scripts/backend_decision_engine.py \
  --team-size 8 --qps-p99 50 --read-write-ratio 20 \
  --tenancy shared-multi-tenant --data-sensitivity pii \
  --pattern modular-monolith --language-preference typescript

The tool returns the best-fit profile, runner-up tradeoff (if within 15%), stack picks, anti-patterns, named approvers, and SLO floor. This tool never auto-approves.

To add a custom profile: copy profiles/node-express.json to profiles/<your-org>.json and adjust constraints + success_thresholds + named_approver_chain.


Composition map

This skill does NOT reimplement scope owned by the POWERFUL-tier specialists. It forks into them. See references/composition_map.md for the full routing table. Key forks:

Concern Fork into
API contract / breaking-change risk engineering/skills/api-design-reviewer/
Schema design + ERD + indexing engineering/skills/database-designer/
Zero-downtime schema migration engineering/skills/migration-architect/
SLO + SLI + error-budget engineering/slo-architect/
Observability / golden signals engineering/skills/observability-designer/
CI/CD pipeline engineering/skills/ci-cd-pipeline-builder/
Security / threat model engineering-team/skills/senior-security/, adversarial-reviewer
Compliance evidence (HIPAA / ISO 27001) ra-qm-team/
Pre-commit Karpathy review engineering/karpathy-coder/
Pre-flight architecture grill engineering/grill-me/

The cs-backend-engineer agent orchestrates these forks via context: fork. Invoke it from another agent with Agent({subagent_type: "cs-backend-engineer", prompt: "..."}) or via /cs:backend-review <your problem>.


Forcing-question library (Matt Pocock grill)

Before locking any backend decision, walk the seven forcing questions in references/forcing_questions.md. Discipline:

  1. One question per turn. No bundling.
  2. Always recommend the answer with cited canon.
  3. Track answers in /tmp/backend-grill-<date>.md.
  4. If a kill criterion trips, stop. Don't scaffold around an unresolved gap.
  5. After Q7, run backend_decision_engine.py with the seven answers.

Summary:

  1. Read/write ratio + p99 QPS forecast?
  2. Tenancy model — single / shared / isolated?
  3. Sync / async / event-driven — default + exceptions?
  4. Data sensitivity tier — PII / PHI / PCI?
  5. Monolith / modular monolith / microservices — team-size justification?
  6. RPO + RTO?
  7. SLO + named error-budget consumer?

Invocation from other agents and skills

Three surfaces:

  1. Slash command: /cs:backend-review <prompt> — full grill + decision engine + composition routing.
  2. Agent subagent: Agent({subagent_type: "cs-backend-engineer", prompt: "..."}) — forks context, returns ≤ 200-word digest.
  3. Direct tool call: python scripts/backend_decision_engine.py ... — deterministic profile match when inputs are known.

See agents/engineering/cs-backend-engineer.md for the full invocation contract.

1---
2name: "senior-backend"
3description: Designs and implements backend systems including REST APIs, microservices, database architectures, authentication flows, and security hardening. Use when the user asks to "design REST APIs", "optimize database queries", "implement authentication", "build microservices", "review backend code", "set up GraphQL", "handle database migrations", or "load test APIs". Covers Node.js/Express/Fastify development, PostgreSQL optimization, API security, and backend architecture patterns.
4---
5 
6# Senior Backend Engineer
7 
8Backend development patterns, API design, database optimization, and security practices.
9 
10---
11 
12## Quick Start
13 
14```bash
15# Generate API routes from OpenAPI spec
16python scripts/api_scaffolder.py openapi.yaml --framework express --output src/routes/
17 
18# Analyze database schema and generate migrations
19python scripts/database_migration_tool.py --connection postgres://localhost/mydb --analyze
20 
21# Load test an API endpoint
22python scripts/api_load_tester.py https://api.example.com/users --concurrency 50 --duration 30
23```
24 
25---
26 
27## Tools Overview
28 
29### 1. API Scaffolder
30 
31Generates API route handlers, middleware, and OpenAPI specifications from schema definitions.
32 
33**Input:** OpenAPI spec (YAML/JSON) or database schema
34**Output:** Route handlers, validation middleware, TypeScript types
35 
36**Usage:**
37```bash
38# Generate Express routes from OpenAPI spec
39python scripts/api_scaffolder.py openapi.yaml --framework express --output src/routes/
40# Output: Generated 12 route handlers, validation middleware, and TypeScript types
41 
42# Generate from database schema
43python scripts/api_scaffolder.py --from-db postgres://localhost/mydb --output src/routes/
44 
45# Generate OpenAPI spec from existing routes
46python scripts/api_scaffolder.py src/routes/ --generate-spec --output openapi.yaml
47```
48 
49**Supported Frameworks:**
50- Express.js (`--framework express`)
51- Fastify (`--framework fastify`)
52- Koa (`--framework koa`)
53 
54---
55 
56### 2. Database Migration Tool
57 
58Analyzes database schemas, detects changes, and generates migration files with rollback support.
59 
60**Input:** Database connection string or schema files
61**Output:** Migration files, schema diff report, optimization suggestions
62 
63**Usage:**
64```bash
65# Analyze current schema and suggest optimizations
66python scripts/database_migration_tool.py --connection postgres://localhost/mydb --analyze
67# Output: Missing indexes, N+1 query risks, and suggested migration files
68 
69# Generate migration from schema diff
70python scripts/database_migration_tool.py --connection postgres://localhost/mydb \
71 --compare schema/v2.sql --output migrations/
72 
73# Dry-run a migration
74python scripts/database_migration_tool.py --connection postgres://localhost/mydb \
75 --migrate migrations/20240115_add_user_indexes.sql --dry-run
76```
77 
78---
79 
80### 3. API Load Tester
81 
82Performs HTTP load testing with configurable concurrency, measuring latency percentiles and throughput.
83 
84**Input:** API endpoint URL and test configuration
85**Output:** Performance report with latency distribution, error rates, throughput metrics
86 
87**Usage:**
88```bash
89# Basic load test
90python scripts/api_load_tester.py https://api.example.com/users --concurrency 50 --duration 30
91# Output: Throughput (req/sec), latency percentiles (P50/P95/P99), error counts, and scaling recommendations
92 
93# Test with custom headers and body
94python scripts/api_load_tester.py https://api.example.com/orders \
95 --method POST \
96 --header "Authorization: Bearer token123" \
97 --body '{"product_id": 1, "quantity": 2}' \
98 --concurrency 100 \
99 --duration 60
100 
101# Compare two endpoints
102python scripts/api_load_tester.py https://api.example.com/v1/users https://api.example.com/v2/users \
103 --compare --concurrency 50 --duration 30
104```
105 
106---
107 
108## Backend Development Workflows
109 
110### API Design Workflow
111 
112Use when designing a new API or refactoring existing endpoints.
113 
114**Step 1: Define resources and operations**
115```yaml
116# openapi.yaml
117openapi: 3.0.3
118info:
119 title: User Service API
120 version: 1.0.0
121paths:
122 /users:
123 get:
124 summary: List users
125 parameters:
126 - name: "limit"
127 in: query
128 schema:
129 type: integer
130 default: 20
131 post:
132 summary: Create user
133 requestBody:
134 required: true
135 content:
136 application/json:
137 schema:
138 $ref: '#/components/schemas/CreateUser'
139```
140 
141**Step 2: Generate route scaffolding**
142```bash
143python scripts/api_scaffolder.py openapi.yaml --framework express --output src/routes/
144```
145 
146**Step 3: Implement business logic**
147```typescript
148// src/routes/users.ts (generated, then customized)
149export const createUser = async (req: Request, res: Response) => {
150 const { email, name } = req.body;
151 
152 // Add business logic
153 const user = await userService.create({ email, name });
154 
155 res.status(201).json(user);
156};
157```
158 
159**Step 4: Add validation middleware**
160```bash
161# Validation is auto-generated from OpenAPI schema
162# src/middleware/validators.ts includes:
163# - Request body validation
164# - Query parameter validation
165# - Path parameter validation
166```
167 
168**Step 5: Generate updated OpenAPI spec**
169```bash
170python scripts/api_scaffolder.py src/routes/ --generate-spec --output openapi.yaml
171```
172 
173---
174 
175### Database Optimization Workflow
176 
177Use when queries are slow or database performance needs improvement.
178 
179**Step 1: Analyze current performance**
180```bash
181python scripts/database_migration_tool.py --connection $DATABASE_URL --analyze
182```
183 
184**Step 2: Identify slow queries**
185```sql
186-- Check query execution plans
187EXPLAIN ANALYZE SELECT * FROM orders
188WHERE user_id = 123
189ORDER BY created_at DESC
190LIMIT 10;
191 
192-- Look for: Seq Scan (bad), Index Scan (good)
193```
194 
195**Step 3: Generate index migrations**
196```bash
197python scripts/database_migration_tool.py --connection $DATABASE_URL \
198 --suggest-indexes --output migrations/
199```
200 
201**Step 4: Test migration (dry-run)**
202```bash
203python scripts/database_migration_tool.py --connection $DATABASE_URL \
204 --migrate migrations/add_indexes.sql --dry-run
205```
206 
207**Step 5: Apply and verify**
208```bash
209# Apply migration
210python scripts/database_migration_tool.py --connection $DATABASE_URL \
211 --migrate migrations/add_indexes.sql
212 
213# Verify improvement
214python scripts/database_migration_tool.py --connection $DATABASE_URL --analyze
215```
216 
217---
218 
219### Security Hardening Workflow
220 
221Use when preparing an API for production or after a security review.
222 
223**Step 1: Review authentication setup**
224```typescript
225// Verify JWT configuration
226const jwtConfig = {
227 secret: process.env.JWT_SECRET, // Must be from env, never hardcoded
228 expiresIn: '1h', // Short-lived tokens
229 algorithm: 'RS256' // Prefer asymmetric
230};
231```
232 
233**Step 2: Add rate limiting**
234```typescript
235import rateLimit from 'express-rate-limit';
236 
237const apiLimiter = rateLimit({
238 windowMs: 15 * 60 * 1000, // 15 minutes
239 max: 100, // 100 requests per window
240 standardHeaders: true,
241 legacyHeaders: false,
242});
243 
244app.use('/api/', apiLimiter);
245```
246 
247**Step 3: Validate all inputs**
248```typescript
249import { z } from 'zod';
250 
251const CreateUserSchema = z.object({
252 email: z.string().email().max(255),
253 name: z.string().min(1).max(100),
254 age: z.number().int().positive().optional()
255});
256 
257// Use in route handler
258const data = CreateUserSchema.parse(req.body);
259```
260 
261**Step 4: Load test with attack patterns**
262```bash
263# Test rate limiting
264python scripts/api_load_tester.py https://api.example.com/login \
265 --concurrency 200 --duration 10 --expect-rate-limit
266 
267# Test input validation
268python scripts/api_load_tester.py https://api.example.com/users \
269 --method POST \
270 --body '{"email": "not-an-email"}' \
271 --expect-status 400
272```
273 
274**Step 5: Review security headers**
275```typescript
276import helmet from 'helmet';
277 
278app.use(helmet({
279 contentSecurityPolicy: true,
280 crossOriginEmbedderPolicy: true,
281 crossOriginOpenerPolicy: true,
282 crossOriginResourcePolicy: true,
283 hsts: { maxAge: 31536000, includeSubDomains: true },
284}));
285```
286 
287---
288 
289## Reference Documentation
290 
291| File | Contains | Use When |
292|------|----------|----------|
293| `references/api_design_patterns.md` | REST vs GraphQL, versioning, error handling, pagination | Designing new APIs |
294| `references/database_optimization_guide.md` | Indexing strategies, query optimization, N+1 solutions | Fixing slow queries |
295| `references/backend_security_practices.md` | OWASP Top 10, auth patterns, input validation | Security hardening |
296 
297---
298 
299## Common Patterns Quick Reference
300 
301### REST API Response Format
302```json
303{
304 "data": { "id": 1, "name": "John" },
305 "meta": { "requestId": "abc-123" }
306}
307```
308 
309### Error Response Format
310```json
311{
312 "error": {
313 "code": "VALIDATION_ERROR",
314 "message": "Invalid email format",
315 "details": [{ "field": "email", "message": "must be valid email" }]
316 },
317 "meta": { "requestId": "abc-123" }
318}
319```
320 
321### HTTP Status Codes
322| Code | Use Case |
323|------|----------|
324| 200 | Success (GET, PUT, PATCH) |
325| 201 | Created (POST) |
326| 204 | No Content (DELETE) |
327| 400 | Validation error |
328| 401 | Authentication required |
329| 403 | Permission denied |
330| 404 | Resource not found |
331| 429 | Rate limit exceeded |
332| 500 | Internal server error |
333 
334### Database Index Strategy
335```sql
336-- Single column (equality lookups)
337CREATE INDEX idx_users_email ON users(email);
338 
339-- Composite (multi-column queries)
340CREATE INDEX idx_orders_user_status ON orders(user_id, status);
341 
342-- Partial (filtered queries)
343CREATE INDEX idx_orders_active ON orders(created_at) WHERE status = 'active';
344 
345-- Covering (avoid table lookup)
346CREATE INDEX idx_users_email_name ON users(email) INCLUDE (name);
347```
348 
349---
350 
351## Common Commands
352 
353```bash
354# API Development
355python scripts/api_scaffolder.py openapi.yaml --framework express
356python scripts/api_scaffolder.py src/routes/ --generate-spec
357 
358# Database Operations
359python scripts/database_migration_tool.py --connection $DATABASE_URL --analyze
360python scripts/database_migration_tool.py --connection $DATABASE_URL --migrate file.sql
361 
362# Performance Testing
363python scripts/api_load_tester.py https://api.example.com/endpoint --concurrency 50
364python scripts/api_load_tester.py https://api.example.com/endpoint --compare baseline.json
365```
366 
367---
368 
369## Assumptions and Verifiable Success Criteria (Karpathy discipline)
370 
371Before this skill scaffolds, recommends a pattern, or modifies a schema, the following four assumptions MUST be surfaced. If any are unknown, the skill stops and walks the [Forcing-question library](#forcing-question-library-matt-pocock-grill) instead.
372 
3731. **Read/write ratio + one-year p99 QPS** — drives DB, cache, queue, and partitioning choices. Kleppmann, *DDIA* (2017).
3742. **Tenancy model** — single-tenant, shared multi-tenant, isolated multi-tenant. Drives data-access pattern.
3753. **Data sensitivity tier** — public / internal / PII / PHI / PCI. Drives compliance floor.
3764. **SLO + named error-budget consumer** — Google SRE Workbook canon. No SLO = no reliability work prioritization.
377 
378**Verifiable success criteria** (Karpathy #4) — every recommendation this skill emits must include:
379 
380- Latency targets (p50, p95, p99 in ms)
381- Uptime / SLO target
382- RPO + RTO
383 
384If any of those three is not stated, the recommendation is incomplete — return to Q7 of the forcing-question library.
385 
386The `scripts/backend_decision_engine.py` tool encodes these checks: it refuses to recommend a profile without read/write ratio + QPS + tenancy + data sensitivity + pattern preference.
387 
388---
389 
390## Customization profiles
391 
392Four built-in profiles in `profiles/` calibrate every recommendation:
393 
394| Profile | When to pick | Pattern | Latency floor (p99) |
395|---|---|---|---|
396| `node-express` | TS team, < 15 eng, customer-facing SaaS | Modular monolith on Postgres | 600ms |
397| `fastapi-python` | Python team, < 20 eng, ML-adjacent | Modular monolith on Postgres (async) | 500ms |
398| `django-monolith` | Content-heavy CRUD + admin, < 25 eng | Modular monolith on Postgres | 800ms |
399| `go-or-rust-microservice` | Extracted service, ≥ 30 eng, platform team, QPS ≥ 1000 | Extracted service | 200ms |
400 
401Pick a profile via:
402 
403```bash
404python scripts/backend_decision_engine.py \
405 --team-size 8 --qps-p99 50 --read-write-ratio 20 \
406 --tenancy shared-multi-tenant --data-sensitivity pii \
407 --pattern modular-monolith --language-preference typescript
408```
409 
410The tool returns the best-fit profile, runner-up tradeoff (if within 15%), stack picks, anti-patterns, named approvers, and SLO floor. **This tool never auto-approves.**
411 
412To add a custom profile: copy `profiles/node-express.json` to `profiles/<your-org>.json` and adjust `constraints` + `success_thresholds` + `named_approver_chain`.
413 
414---
415 
416## Composition map
417 
418This skill does NOT reimplement scope owned by the POWERFUL-tier specialists. It forks into them. See `references/composition_map.md` for the full routing table. Key forks:
419 
420| Concern | Fork into |
421|---|---|
422| API contract / breaking-change risk | `engineering/skills/api-design-reviewer/` |
423| Schema design + ERD + indexing | `engineering/skills/database-designer/` |
424| Zero-downtime schema migration | `engineering/skills/migration-architect/` |
425| SLO + SLI + error-budget | `engineering/slo-architect/` |
426| Observability / golden signals | `engineering/skills/observability-designer/` |
427| CI/CD pipeline | `engineering/skills/ci-cd-pipeline-builder/` |
428| Security / threat model | `engineering-team/skills/senior-security/`, `adversarial-reviewer` |
429| Compliance evidence (HIPAA / ISO 27001) | `ra-qm-team/` |
430| Pre-commit Karpathy review | `engineering/karpathy-coder/` |
431| Pre-flight architecture grill | `engineering/grill-me/` |
432 
433The `cs-backend-engineer` agent orchestrates these forks via `context: fork`. Invoke it from another agent with `Agent({subagent_type: "cs-backend-engineer", prompt: "..."})` or via `/cs:backend-review <your problem>`.
434 
435---
436 
437## Forcing-question library (Matt Pocock grill)
438 
439Before locking any backend decision, walk the seven forcing questions in `references/forcing_questions.md`. Discipline:
440 
4411. One question per turn. No bundling.
4422. Always recommend the answer with cited canon.
4433. Track answers in `/tmp/backend-grill-<date>.md`.
4444. If a kill criterion trips, stop. Don't scaffold around an unresolved gap.
4455. After Q7, run `backend_decision_engine.py` with the seven answers.
446 
447Summary:
448 
4491. Read/write ratio + p99 QPS forecast?
4502. Tenancy model — single / shared / isolated?
4513. Sync / async / event-driven — default + exceptions?
4524. Data sensitivity tier — PII / PHI / PCI?
4535. Monolith / modular monolith / microservices — team-size justification?
4546. RPO + RTO?
4557. SLO + named error-budget consumer?
456 
457---
458 
459## Invocation from other agents and skills
460 
461Three surfaces:
462 
4631. **Slash command:** `/cs:backend-review <prompt>` — full grill + decision engine + composition routing.
4642. **Agent subagent:** `Agent({subagent_type: "cs-backend-engineer", prompt: "..."})` — forks context, returns ≤ 200-word digest.
4653. **Direct tool call:** `python scripts/backend_decision_engine.py ...` — deterministic profile match when inputs are known.
466 
467See `agents/engineering/cs-backend-engineer.md` for the full invocation contract.
468 

Discussion

Alternatives

Also in Services & APIsSee all 533 in Development →