M

Master Cc Skill Backend

Streamline your workflow with this backend, architecture, patterns, design. Includes structured workflows, validation checks, and reusable patterns for development.

SkillClipticsdevelopmentv1.0.0MIT
0 views0 copies

Master Claude Code Skill — Backend Patterns

A Claude Code skill providing backend architecture patterns and best practices for building scalable server-side applications. Covers RESTful API design, database patterns, authentication, caching strategies, error handling, and microservice communication.

When to Use This Skill

Choose CC Skill Backend Patterns when:

  • You need established patterns for building backend services
  • You want best practices for API design, database access, and caching
  • You're implementing authentication, authorization, or session management
  • You need microservice communication patterns (REST, gRPC, message queues)
  • You want to apply patterns consistently across backend services

Consider alternatives when:

  • You need a complete project setup (use a development framework skill)
  • You want frontend patterns (use a frontend patterns skill)
  • You need specific database optimization (use a database-specific skill)

Quick Start

# Install the skill claude install master-cc-skill-backend # Apply backend patterns claude "Implement the repository pattern for my User and Order models with TypeScript" # Design API layer claude "Design the API layer for an order management system: routes, controllers, services, and repositories" # Add caching claude "Add a caching layer to my API: Redis cache for frequently accessed data with cache invalidation"

Core Concepts

Backend Architecture Layers

LayerResponsibilityPattern
RouterURL mapping, middlewareRoute definitions
ControllerRequest parsing, response formattingThin controllers
ServiceBusiness logic, orchestrationDomain services
RepositoryData access abstractionRepository pattern
ModelData structure, validationDomain models

API Design Patterns

// Resource-oriented routes router.get('/users', listUsers); router.get('/users/:id', getUser); router.post('/users', createUser); router.patch('/users/:id', updateUser); router.delete('/users/:id', deleteUser); // Nested resources router.get('/users/:userId/orders', getUserOrders); // Actions (when CRUD doesn't fit) router.post('/users/:id/activate', activateUser); router.post('/orders/:id/cancel', cancelOrder);

Caching Strategies

StrategyDescriptionUse Case
Cache-AsideApp checks cache, falls back to DBMost read-heavy queries
Write-ThroughWrite to cache and DB simultaneouslyData consistency priority
Write-BehindWrite to cache, async write to DBHigh write throughput
Read-ThroughCache fetches from DB on missTransparent caching
TTL-BasedExpire after time periodFrequently changing data
Event-BasedInvalidate on specific eventsReal-time consistency

Configuration

ParameterTypeDefaultDescription
languagestring"typescript"Language: typescript, python, go
frameworkstring"express"Framework: express, fastify, nestjs, hono
databasestring"postgresql"Database: postgresql, mongodb, mysql
cachestring"redis"Cache: redis, memcached, in_memory
pattern_stylestring"layered"Style: layered, hexagonal, cqrs

Best Practices

  1. Keep controllers thin — Controllers should only parse the request, call a service method, and format the response. Business logic in controllers becomes untestable and duplicated across endpoints.

  2. Use the repository pattern for data access — Abstracting database queries behind a repository interface makes your services testable (mock the repository) and allows you to change databases without rewriting business logic.

  3. Implement cache-aside with TTL — For most read-heavy APIs, check the cache first, fall back to the database on miss, and populate the cache with a TTL. This is the simplest caching strategy that provides the most benefit.

  4. Use transactions for multi-step operations — If a business operation involves multiple database writes, wrap them in a transaction. A partially completed operation (order created but inventory not updated) is worse than a failed operation.

  5. Standardize error responses across services — Every API error should follow the same format: { error: { code, message, details } }. This makes client-side error handling consistent and debugging easier across your service fleet.

Common Issues

Service layer is too thin or too fat — If services just forward to repositories, they're unnecessary. If services have 500-line methods, they're doing too much. Services should orchestrate — coordinate between repositories, apply business rules, and handle transactions.

Cache invalidation is wrong — Stale cache data causes bugs. Use event-driven invalidation (invalidate cache when data changes) rather than relying solely on TTL. For critical data, use write-through caching to guarantee consistency.

N+1 query problems — Fetching a list of users and then querying orders for each user creates N+1 queries. Use JOIN queries, batch loading, or GraphQL DataLoader to fetch related data in a single query.

Community

Reviews

Write a review

No reviews yet. Be the first to review this template!

Similar Templates