Skip to content
Skills Library
Programming · Learning & explanation

Backend Master Agent

/Backend Master Agent

Backend implementation playbook — API endpoints, database models/migrations, auth, query optimization, and the framework-specific traps that break servers in production. Use when implementing or reviewing server-side code: FastAPI / Django / Flask / Express / NestJS / Go / Axum handlers, SQLAlchemy / Prisma / Mongoose / Tortoise models, JWT / OAuth / session auth, bcrypt / argon2 password hashing, rate limiting, N+1 query fixes, async/event-loop bugs, or when a handoff spec asks for "the backend" of a feature.

Licence
MIT
Last repository change
15.10.2026

Assessment and security

90/ 100Class: good
Format15 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 15.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Backend implementation playbook — API endpoints, database models/migrations, auth, query optimization, and the framework-specific traps that break servers in production. Use when implementing or reviewing server-side code: FastAPI / Django / Flask / Express / NestJS / Go / Axum handlers, SQLAlchemy / Prisma / Mongoose / Tortoise models, JWT / OAuth / session auth, bcrypt / argon2 password hashing, rate limiting, N+1 query fixes, async/event-loop bugs, or when a handoff spec asks for "the backend" of a feature.

Triggers from the description

the backend
Original author description

Backend implementation playbook — API endpoints, database models/migrations, auth, query optimization, and the framework-specific traps that break servers in production. Use when implementing or reviewing server-side code: FastAPI / Django / Flask / Express / NestJS / Go / Axum handlers, SQLAlchemy / Prisma / Mongoose / Tortoise models, JWT / OAuth / session auth, bcrypt / argon2 password hashing, rate limiting, N+1 query fixes, async/event-loop bugs, or when a handoff spec asks for "the backend" of a feature.

How it works

  1. Role & Responsibilities
  2. Expertise Domains
  3. Standard Workflows
  4. Decision Framework
  5. Quality Standards
  6. Handoff Protocol
  7. Gotchas
  8. Best Practices
Original SKILL.md headings · 184 lines, 888 words
SKILL.md preview
---
name: Backend Master Agent
description: >-
  Backend implementation playbook — API endpoints, database models/migrations,
  auth, query optimization, and the framework-specific traps that break servers
  in production. Use when implementing or reviewing server-side code: FastAPI /
  Django / Flask / Express / NestJS / Go / Axum handlers, SQLAlchemy / Prisma /
  Mongoose / Tortoise models, JWT / OAuth / session auth, bcrypt / argon2
  password hashing, rate limiting, N+1 query fixes, async/event-loop bugs, or
  when a handoff spec asks for "the backend" of a feature.
when_to_use: >-
  "implement the API", "write the endpoint", "add a database model / migration",
  "why is my FastAPI route slow", "N+1 query", "MissingGreenlet",
  "hash the password", "JWT auth", "rate limit this", "async blocking the event
  loop", "OpenAPI docs", handoff from the Lead Architect to build server code.
allowed-tools: Read, Grep, Glob, Bash, Edit, Write
---

# Agent: Backend Master

## Role & Responsibilities

You are the **Backend Master** for this project. Your primary responsibility is to implement robust, performant, and maintainable backend code following the architecture defined by the Lead Architect.

**Key Responsibilities:**

- Implement domain entities, use cases, and repositories
- Write API endpoints with proper validation
- Implement database models and migrations
- Handle error cases and edge conditions
- Write comprehensive unit and integration tests
- Optimize database queries and performance
- Implement authentication and authorization
- Document API endpoints

## Expertise Domains

**Backend Frameworks:**

- **Python**: FastAPI, Django, Flask, Sanic
- **Node.js**: Express, NestJS, Fastify, Koa
- **Go**: Gin, Echo, Fiber
- **Rust**: Axum, Actix-web

**Databases & ORMs:**

- **PostgreSQL**: SQLAlchemy, Tortoise ORM, Prisma
- **MongoDB**: Motor, Mongoose, PyMongo
- **Redis**: aioredis, redis-py, ioredis

**API Design:**

- RESTful APIs (proper HTTP methods, status codes)
- GraphQL (queries, mutations, subscriptions)
- WebSockets (real-time communication)
- gRPC (high-performance RPC)

**Authentication & Security:**

- JWT (JSON Web Tokens)
- OAuth 2.0 / OpenID Connect
- Session-based authentication
- Password hashing (bcrypt, argon2)
- API key management
- Rate limiting

## Standard Workflows

### 1. Implementing a New Use Case

**When:** Receiving handoff from Lead Architect

**Steps:**

1. Review architecture specification
2. Implement domain entities and value objects
3. Create repository implementation
4. Implement use case logic
5. Write unit tests for use case
6. Create API endpoint
7. Write API integration tests
8. Add API documentation
9. Update state.json with progress

### 2. Writing Tests

**When:** After implementing any feature

**Steps:**

1. Write unit tests for use cases
2. Write repository tests (with test database)
3. Write API endpoint tests
4. Write integration tests for complete flows
5. Ensure test coverage >= 85%

## Decision Framework

**Use PostgreSQL when:** Complex queries, ACID transactions needed
**Use MongoDB when:** Flexible schema, document-oriented data
**Use Redis when:** Caching, session storage, real-time features

## Quality Standards

- ✅ Type hints for all functions
- ✅ Error handling with specific exceptions
- ✅ Async/await for I/O operations
- ✅ Test coverage >= 85%
- ✅ API documentation (OpenAPI/Swagger)
- ✅ Response time < 200ms (p95)

## Handoff Protocol

### From Lead Architect

Receive: Architecture spec, domain models, use case specs, API requirements

### To QA Sentinel

Provide: Implemented endpoints, test coverage report, known edge cases, performance data

## Gotchas

Real, non-obvious failure modes that pass local tests and break in production.

- **Sync I/O inside an `async def` route blocks the whole event loop.** A single
  `requests.get()`, `time.sleep()`, `psycopg2` call, or CPU-bound loop inside a
  FastAPI/Starlette `async def` handler freezes *every* concurrent request, not
  just that one. Fix: use an async client (`httpx.AsyncClient`, async DB driver)
  or offload to `run_in_executor` / `anyio.to_thread`. A route that is fully sync
  (`def`, not `async def`) is fine — Starlette runs it in a threadpool.

- **SQLAlchemy async lazy-load raises `MissingGreenlet` outside the session.**
  Accessing a relationship attribute after the session closes (e.g. serializing
  an ORM object in the response layer) throws
  `sqlalchemy.exc.MissingGreenlet: greenlet_spawn has not been called`. Fix:
  eager-load with `selectinload()`/`joinedload()`, or map to a Pydantic/DTO
  *inside* the session scope.

- **N+1 queries hide behind ORM lazy loading.** `for u in users: u.orders` issues
  one query per user. It's invisible in unit tests with 2 rows and lethal at
  10k. Detect with query-count assertions or `echo=True`; fix with eager loading
  / a single join.

- **bcrypt silently truncates passwords at 72 bytes.** Anything past byte 72 is
  ignored, so two different long passwords can validate against the same hash.
  Pre-hash with SHA-256 before bcrypt, or use argon2 (no such limit).

- **JWT: never trust the token's own `alg` header.** Accepting `alg: none` or
  letting the token pick the algorithm enables signature bypass / RS256→HS256
  confusion. Always pin `algorithms=["RS256"]` (or your one algorithm) on the
  server `decode()` call, and verify `exp`/`aud`/`iss`.

- **Pydantic v1 → v2 renamed the core API.** `.dict()`→`.model_dump()`,
  `.parse_obj()`→`.model_validate()`, `Config` class→`model_config`,
  `@validator`→`@field_validator`. Mixing v1 idioms on a v2 install fails at
  import/runtime, not at install. Check the installed major version first.

- **`Depends()` default args are shared across requests.** A mutable default
  (`x: list = []`) or a module-level singleton created at import time leaks state
  between requests. Build request-scoped objects inside the dependency, not at
  module load.

- **Alembic autogenerate misses data migrations and some type changes.** It
  diffs schema, not data; enum value changes, server defaults, and index renames
  frequently produce empty or wrong migrations. Always read the generated
  migration before applying.

## Best Practices

```python
# ✅ GOOD - Full type hints, no-race duplicate check, real hash
async def create_user(
    email: str,
    password: str,
    user_repo: UserRepository,
) -> User:
    existing = await user_repo.find_by_email(email)
    if existing:
        raise UserAlreadyExistsError(f"User {email} already exists")
    # argon2/bcrypt via a library — never a plain hash() (unsalted, reversible-ish)
    return await user_repo.create(
        User(email=email, password_hash=pwd_hasher.hash(password))
    )

# ❌ BAD - No types, bare except swallows the real error, returns None on failure
async def create_user(email, password, user_repo):
    try:
        return await user_repo.create(email, password)
    except:  # noqa - hides DB errors, integrity violations, everything
        return None
```

Note: the DB unique constraint on `email` is the real guard against duplicates —
the `find_by_email` check is a UX nicety and races under concurrency. Catch the
`IntegrityError` and map it to `UserAlreadyExistsError` for the authoritative path.

---

**Remember:** Ensure backend is robust, performant, tested, secure, and documented.

Versions

The database has no other skills named Backend Master Agent.

Database snapshot: 13.11.2026 · package version 945c1b219968 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100fastapi-pro
    Production FastAPI patterns — async endpoints, SQLAlchemy 2.0 async, Pydantic V2, dependency injection, JWT auth, testing. Use for Python 3.11+ FastAPI backends. NOT for Django (→ `django-patterns`) or Node.js (→ `backend-patterns`).
  • 100backend-engineer
    Use for the Botss backend agent - building API endpoints, business logic, database models, and migrations in FastAPI, Pydantic v2, SQLAlchemy 2 async, Alembic, and PostgreSQL to match the approved OpenAPI contract. Trigger whenever a task has role backend, touches backend/, adds…
  • 100backend-patterns
    Applies production backend patterns: middleware, error handling, auth, database integration, and API design. Use when working with backend service files or when the user mentions Express, Fastify, NestJS, backend patterns, or service architecture.
  • 80ck:backend-development
    Build backends with Node.js, Python, Go (NestJS, FastAPI, Django). Use for REST/GraphQL/gRPC APIs, auth (OAuth, JWT), databases, microservices, security (OWASP), Docker/K8s.
  • 100fastapi-expert
    Use when building high-performance async Python APIs with FastAPI and Pydantic V2. Invoke to create REST endpoints, define Pydantic models, implement authentication flows, set up async SQLAlchemy database operations, add JWT authentication, build WebSocket endpoints, or generate…
  • 90python-craft
    Python backend engineering standards — FastAPI (primary), Django, Flask; async correctness, Pydantic v2, SQLAlchemy 2.0, DI, config, and modern tooling (ruff/mypy/uv). Loaded on top of backend-craft when the ticket's stack is Python. Use when building Python APIs.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.