agentleFS
geevarghesekthomas84-sysgeevarghesekthomas84-sys/android-ai-engineering-system/skills/backend-api-engineer/SKILL.md

backend-api-engineer

Skill4 starsChanged 39 days agoMITView on GitHub

Backend API engineering with Node.js/TypeScript (NestJS), Python (FastAPI), REST design, authentication, PostgreSQL, Redis, WebSockets, Docker, and production deployment

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 8 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Always hash passwords with bcrypt (cost 12) or argon2id

    line 115
  2. Distinctive:

    Never log sensitive data (passwords, tokens, PII)

    line 116
  3. Distinctive:

    Use parameterized queries — never string-interpolate SQL

    line 118
  4. Distinctive:

    Use HTTPS in production; set HSTS headers

    line 123
  5. Distinctive:

    Use DTOs for all request/response shapes — never expose ORM entities directly

    line 134
  6. Distinctive:

    Document all public endpoints with OpenAPI decorators/annotations

    line 136
  7. Distinctive:

    Write migration files for every schema change — never use synchronize in production

    line 137
  8. Distinctive:

    Keep controllers thin: business logic belongs in services

    line 138

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Backend API Engineer

Trigger Conditions

Activate this skill when the task involves:

  • Building REST or GraphQL APIs for mobile or web clients
  • Setting up authentication and authorization (JWT, OAuth, API keys)
  • Database schema design, migrations, or query optimization
  • Docker containerization and deployment configuration
  • Backend architecture decisions (monolith vs microservices, event-driven patterns)
  • WebSocket or real-time communication setup
  • Background job processing and task queues
  • API rate limiting, caching, or performance optimization
  • File upload handling and storage integration
  • CI/CD pipeline configuration for backend services

Primary Technology Stacks

Node.js / TypeScript — NestJS

  • Framework: NestJS 10.x with TypeScript 5.x strict mode
  • ORM: TypeORM 0.3.x with PostgreSQL driver
  • Validation: class-validator + class-transformer
  • Auth: @nestjs/passport + @nestjs/jwt + passport-jwt
  • Docs: @nestjs/swagger for OpenAPI 3.0
  • Caching: @nestjs/cache-manager with Redis store
  • WebSockets: @nestjs/websockets with Socket.IO adapter
  • Queue: @nestjs/bull with Redis-backed Bull queues
  • Testing: Jest + supertest

Python — FastAPI

  • Framework: FastAPI 0.110.x with Python 3.11+
  • ORM: SQLAlchemy 2.0 with asyncpg driver
  • Validation: Pydantic v2 models
  • Auth: python-jose for JWT, passlib for password hashing
  • Docs: Built-in OpenAPI + Swagger UI + ReDoc
  • Caching: redis-py with async support
  • WebSockets: Built-in WebSocket support
  • Queue: Celery with Redis broker or arq for async jobs
  • Testing: pytest + httpx AsyncClient
  • Migrations: Alembic

Capabilities

API Design & Documentation

  • RESTful resource design following HTTP semantics
  • OpenAPI 3.0 schema-first or code-first documentation
  • Consistent error responses using RFC 7807 Problem Details
  • API versioning (URL prefix or Accept header)
  • Cursor-based and offset pagination
  • Bulk operation endpoints with partial failure handling

Authentication & Authorization

  • JWT access + refresh token flow with rotation
  • OAuth 2.0 Authorization Code with PKCE (mobile clients)
  • OpenID Connect integration (Google, Apple, Microsoft)
  • Role-Based Access Control (RBAC) with guard/dependency patterns
  • API key authentication for service-to-service calls
  • Secure session management with HttpOnly cookies
  • CSRF protection for cookie-based auth
  • Per-user and per-IP rate limiting

Database & Caching

  • PostgreSQL schema design with proper indexing
  • Connection pooling configuration
  • Database migrations with rollback support
  • Repository pattern for data access abstraction
  • Transaction management for multi-step operations
  • N+1 query detection and prevention (eager loading, DataLoader)
  • Redis cache-aside pattern with TTL and invalidation
  • Redis pub/sub for real-time event distribution

Real-Time & Background Processing

  • WebSocket connections with room-based broadcasting
  • Server-Sent Events for one-way streaming
  • Background job queues with retry policies and dead-letter handling
  • Scheduled tasks (cron-based)
  • Event-driven communication between modules

Infrastructure & Deployment

  • Multi-stage Docker builds for minimal production images
  • Docker Compose for local development (app + PostgreSQL + Redis)
  • Structured JSON logging with correlation IDs
  • Health check endpoints (liveness + readiness)
  • Graceful shutdown with connection draining
  • Environment-based configuration with validation
  • Container security: non-root user, read-only filesystem, resource limits

Testing

  • Unit tests for services and utility functions
  • Integration tests for API endpoints with test database
  • Authentication test helpers for protected routes
  • Database fixture management and cleanup
  • External service mocking
  • Code coverage reporting and CI integration

Rules

Security Defaults

  • Always hash passwords with bcrypt (cost 12) or argon2id
  • Never log sensitive data (passwords, tokens, PII)
  • Validate and sanitize all input at the boundary
  • Use parameterized queries — never string-interpolate SQL
  • Set secure, HttpOnly, SameSite=Lax cookies by default
  • Enable CORS only for known origins, never wildcard in production
  • Store secrets in environment variables, never in code or config files
  • Apply rate limiting to authentication endpoints (max 5 attempts per minute)
  • Use HTTPS in production; set HSTS headers

Least Privilege

  • Database users get only required permissions (SELECT, INSERT, UPDATE on specific tables)
  • API keys are scoped to specific operations
  • JWT claims contain minimal data (user ID, roles — no PII)
  • Docker containers run as non-root with dropped capabilities
  • File upload validation: check MIME type, file size, and extension

Code Quality

  • Enable TypeScript strict mode with no implicit any
  • Use DTOs for all request/response shapes — never expose ORM entities directly
  • Return consistent error response objects, never raw exceptions
  • Document all public endpoints with OpenAPI decorators/annotations
  • Write migration files for every schema change — never use synchronize in production
  • Keep controllers thin: business logic belongs in services

Workflow

The standard workflow for building a backend API:

  1. Design API Schema — Define resources, endpoints, request/response models, and error cases. Write or generate an OpenAPI spec. Agree on pagination, filtering, and versioning strategy.
  2. Scaffold Project — Initialize the project with the chosen framework (NestJS CLI or FastAPI cookiecutter). Set up linting (ESLint/Ruff), formatting (Prettier/Black), and pre-commit hooks.
  3. Implement Endpoints — Build controllers/routers, services, and DTOs/Pydantic models for each resource. Wire up input validation and consistent error handling.
  4. Add Authentication — Implement the auth strategy (JWT, OAuth, or API key). Add guards/dependencies to protected routes. Set up RBAC if needed.
  5. Connect Database — Configure PostgreSQL with the ORM. Create entity/model definitions and migration files. Implement repository/data access layer. Add Redis caching where needed.
  6. Write Tests — Unit test services, integration test endpoints. Set up test database, fixtures, and auth helpers. Target 80%+ coverage on business logic.
  7. Dockerize — Write multi-stage Dockerfile. Create docker-compose.yml for local dev. Add health checks and graceful shutdown. Configure logging.
  8. Deploy — Set up CI pipeline (lint, test, build, push image). Configure environment-specific settings. Set up monitoring, alerting, and log aggregation.

Reference Files

  • references/nestjs-setup.md — NestJS project structure, decorators, pipes, interceptors, Swagger
  • references/fastapi-setup.md — FastAPI project structure, Pydantic, dependency injection, middleware
  • references/authentication.md — JWT, OAuth 2.0, PKCE, Passport.js, RBAC, session management
  • references/database-patterns.md — TypeORM, SQLAlchemy, migrations, caching, query optimization
  • references/api-design.md — REST conventions, status codes, pagination, error format, versioning
  • references/docker-deployment.md — Dockerfile, Compose, health checks, security, logging
  • references/testing-backend.md — Jest, pytest, integration tests, fixtures, CI integration

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.