Backend design

From xenitV1/claude-code-maestro · View interactive version

Backend design is an AI agent skill from the GitHub repository xenitV1/claude-code-maestro. Elite Tier Backend standards, including Vertical Slice Architecture, Zero Trust Security, and High-Performance API protocols.

How to use this skill

Skill file

<domain_overview>

Backend Design System

Philosophy: The Backend is the Fortress. Logic is Law. Latency is the Enemy.

Core Principle: ISOLATE features. TRUST no one. SCALE linearly.

ANTI-HAPPY PATH MANDATE (CRITICAL): Never assume the ideal scenario. AI-generated code often fails by ignoring edge cases and failure modes. For every business logic slice, you MUST document and test at least three failure scenarios: Race Conditions, Data Integrity violations (e.g., unique constraint overlaps), and Boundary failures. Reject any implementation that only covers the 'Happy Path'. Engineering is the art of handling what shouldn't happen.

</domain_overview>

<architectural_protocols>

🚀 ELITE TIER KNOWLEDGE (ARCHITECTURAL PROTOCOLS)

0. The "Vertical Slice" Law (The Anti-Layer Mandate)

CRITICAL: You are FORBIDDEN from creating "Horizontal Layers" (Controllers, Services, Repositories) as primary folders.

The "Feature-First" Protocol:

Code must be organized by BUSINESS CAPABILITY, not technical role.

  1. The Slice: A single directory (e.g., features/create-order/) contains EVERYTHING needed for that feature:
  1. The Benefit: Changing a feature requires touching only ONE folder. No "Shotgun Surgery" across 5 layers.
  2. Shared Kernel: Only truly generic code (Logging, Auth Middleware, Database Connection) goes into shared/.

1. The "Modular Monolith" Mandate

2. The "Zero Trust" Security Protocol

Detailed protocols: See security-protocols.md

Quick Rules:

  1. Strict Serialization: NEVER return raw DB entities → Use ResponseDTO
  2. Validation at Gate: Schema validation (Zod/Pydantic) BEFORE logic
  3. Token Sovereignty: PASETO v4 > JWT (Ed25519 if JWT forced)

</architectural_protocols>

<reliability_contracts>

🏗️ Reliability & Performance Contracts

3. The "Sub-100ms" Performance Mandate

4. API Reliability Contracts

```json

{

"type": "https://api.myapp.com/errors/insufficient-funds",

"title": "Insufficient Funds",

"status": 403,

"detail": "Current balance is 10.00, required is 15.00",

"instance": "/transactions/12345"

}

```

</reliability_contracts>

<database_integrity>

🗄️ Database Integrity & Design

5. Database Integrity & Design

6. AI & Vector Readiness

</database_integrity>

<observability>

👁️ Observability & Monitoring (The "Glass Box" Protocol)

7. Structured Logging Only

8. Distributed Tracing (OpenTelemetry)

9. Health Checks

</observability>

<resilience>

🛡️ Resilience Patterns (The "Anti-Fragile" Mandate)

10. Circuit Breakers

11. Rate Limiting

</resilience>

<workflow_rules>

🔧 Workflow Rules

1. The Pre-Flight Checklist

  1. Environment Hardening:

Before writing a single handler:

  1. Define the DTOs: Request Schema (Zod) and Response Schema.
  2. Define the Error States: What can go wrong? (404, 409, 429).
  3. Define the Data Access: What is the most efficient SQL query?

2. The "No Magic" Rule

3. Testing Pyramid

  1. Unit: Test Domain Logic in isolation (mock DB).
  2. Integration: Test Feature Slice with a REAL containerized DB (Testcontainers).
  3. E2E: Test critical flows from the "Outside".

</workflow_rules>

<audit_and_reference>

📂 Cognitive Audit Cycle

Before committing code:

  1. Is the endpoint under a feature slice? (Not in a generic controller folder).
  2. Is Input Validated with a Schema? (Zero Trust).
  3. Are DB Indexes used? (Run EXPLAIN ANALYZE).
  4. Is the Primary Key UUIDv7? (Index Perf).
  5. Are secrets managed properly? (No hardcoded strings).

🔗 CROSS-SKILL INTEGRATION

| Skill | Backend Adds... |

|-------|-----------------|

| @frontend-design | API contracts, CORS config, error responses |

| @clean-code | Input validation, no raw SQL, dependency security |

| @tdd-mastery | Integration tests with Testcontainers |

| @planning-mastery | API endpoint task breakdown |

| @debug-mastery | Structured logging, distributed tracing |

Command: Use these skills to architect "Fortress-Level" backend systems.

</audit_and_reference>

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.