Reference patterns for REST APIs, pytest/vitest testing, Docker multi-stage builds, GitHub Actions CI/CD, PostgreSQL, TypeScript generics, Python async, and React Server Components. MUST BE USED when user asks about: "API design", "how to test", "Dockerfile", "CI/CD pipeline", "database schema", "TypeScript types", "async/await", "React hooks", "Next.js", "FastAPI", "testing pattern", "mock", "fixture", "docker compose", "github actions", "workflow yaml", "postgres query", "SQL pattern", "migration", "generic type", "server component", "use client", "use server", "middleware pattern", "error handling pattern", "retry logic". Includes code examples and validation commands. NOT for running tests (use smart-test-runner), security patterns (use security-audit), or git operations (use commit-message).
Install
npx skillscat add aedelon/claude-code-blueprint/code-patterns Install via the SkillsCat registry.
Code Patterns Reference
This skill contains comprehensive patterns for modern development. Reference files are organized by topic.
Quick Reference
| Topic | Key Patterns | When to Use |
|---|---|---|
| API Design | REST, GraphQL, OpenAPI | Designing/implementing APIs |
| Testing | pytest, vitest, mocking | Writing tests |
| Docker | Multi-stage, Compose | Containerizing apps |
| CI/CD | GitHub Actions, pipelines | Setting up automation |
| Database | PostgreSQL, migrations | Database design |
| TypeScript | Types, generics, patterns | TS development |
| Python | async, patterns, uv | Python development |
| React/Next.js | Server Components, hooks | Frontend development |
Reference Files
api.md- REST, GraphQL, authentication, paginationtesting.md- pytest, vitest, mocking, coveragedocker.md- Dockerfiles, Compose, productionci-cd.md- GitHub Actions, deploymentdatabase.md- PostgreSQL, migrations, queriestypescript.md- Types, generics, advanced patternspython.md- async, patterns, best practicesreact.md- Server Components, hooks, Next.js
API Design Quick Reference
REST Endpoints
GET /resources List
GET /resources/{id} Get one
POST /resources Create
PUT /resources/{id} Replace
PATCH /resources/{id} Update
DELETE /resources/{id} DeleteHTTP Status Codes
| Code | Meaning |
|---|---|
| 200 | OK |
| 201 | Created |
| 204 | No Content |
| 400 | Bad Request |
| 401 | Unauthorized |
| 403 | Forbidden |
| 404 | Not Found |
| 422 | Unprocessable |
| 429 | Rate Limited |
| 500 | Server Error |
Testing Quick Reference
pytest
@pytest.fixture
def client():
return TestClient(app)
def test_endpoint(client):
response = client.get("/api/users")
assert response.status_code == 200vitest
import { describe, it, expect, vi } from 'vitest';
describe('Component', () => {
it('should work', () => {
expect(true).toBe(true);
});
});Docker Quick Reference
Multi-Stage Build
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:20-alpine
COPY --from=builder /app/dist ./dist
USER node
CMD ["node", "dist/index.js"]Compose
services:
app:
build: .
ports:
- "3000:3000"
depends_on:
db:
condition: service_healthy
db:
image: postgres:16-alpine
healthcheck:
test: ["CMD", "pg_isready"]CI/CD Quick Reference
GitHub Actions
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm ci
- run: npm testTypeScript Quick Reference
Utility Types
Partial<T> // All properties optional
Required<T> // All properties required
Pick<T, K> // Select properties
Omit<T, K> // Exclude properties
Record<K, V> // Object with key type K, value type VGenerics
function first<T>(arr: T[]): T | undefined {
return arr[0];
}Python Quick Reference
Async
async def fetch_data():
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
return await response.json()Type Hints
def process(items: list[str]) -> dict[str, int]:
return {item: len(item) for item in items}React/Next.js Quick Reference
Server Component (default)
// app/page.tsx
async function Page() {
const data = await fetch('...');
return <div>{data}</div>;
}Client Component
'use client';
import { useState } from 'react';
export function Counter() {
const [count, setCount] = useState(0);
return <button onClick={() => setCount(c => c + 1)}>{count}</button>;
}