Skip to main content
rule CX Codex

backend — Claude Code rule: what it does, how to install

Enforces clean architecture guidelines for backend APIs using Router, Service, and Repository layers. Keeps business logic out of HTTP routes.

MIT ★ 1,472 updated 2026-10-29

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add first-fluke/oh-my-agent
/plugin install oma@oh-my-agent
Open on GitHub

What backend does

This rule organizes backend endpoints into a strict pipeline: Router → Service → Repository → Models. Handlers only parse requests and validate incoming inputs with your stack validator. All domain rules stay inside services, while database access lives in repositories using parameterized queries exclusively.

Authentication relies on JWT and Argon2id, with rate limiting on auth routes. When external services like OpenAI or Stripe are hooked up, the rule demands two code branches: the live API call when an environment key exists, and a deterministic fallback marked with // TODO(oma-deferred): integrate <vendor> when key is provisioned. Skipping the fallback breaks local testing whenever API keys are missing.

What it helps with

  • separate HTTP route handlers from core business logic
  • prevent SQL injections with parameterized database queries
  • standardize authentication using JWT and Argon2id
  • provide local deterministic fallbacks for external vendor APIs

Example prompts for the agent

  • Generate a user registration endpoint following the backend architecture rule
  • Add a billing service with a local fallback when the payment API key is missing

How to install backend

1Plugin marketplace

/plugin marketplace add first-fluke/oh-my-agent
/plugin install oma@oh-my-agent

2Manually: put the files in place

.claude/rules/backend.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about backend

How to install backend in Claude Code?

Run /plugin marketplace add first-fluke/oh-my-agent, followed by /plugin install oma@oh-my-agent. You can also save the file directly to .claude/rules/backend.md.

What does the backend rule do?

It guides the agent to structure code around Router, Service, and Repository layers, avoiding business logic inside HTTP route handlers.

What does the rule require for third-party integrations?

Every integration must provide both a real request branch checking environment variables and a deterministic fallback tagged with // TODO(oma-deferred): integrate <vendor> when key is provisioned.

Source text

backend.md · MIT
---
description: Backend API coding standards with clean architecture (Router/Service/Repository pattern)
globs:
alwaysApply: false
---

# Backend Coding Standards

## Core Rules

1. **Clean architecture**: router -> service -> repository -> models
2. **No business logic in route handlers**
3. **All inputs validated** with your stack's validation library
4. **Parameterized queries only** (never string interpolation)
5. **JWT + Argon2id for auth** (bcrypt acceptable for legacy compatibility); rate limit auth endpoints
6. **Async where supported**; type annotations on all signatures
7. **Custom exceptions** via centralized error module (not raw HTTP exceptions)
8. **Explicit ORM loading strategy**: do not rely on default relation loading when query shape matters
9. **Explicit transaction boundaries**: group one business operation into one request/service-scoped unit of work
10. **Safe ORM lifecycle**: do not share mutable ORM session/entity manager across concurrent work unless ORM explicitly supports it
11. **Config from environment, with graceful fallback**: DB URLs, API keys, secrets from env vars or secret managers, never hardcode. When integrating a third-party API (OpenAI, Anthropic, Stripe, etc.), write BOTH paths: (a) real call when `process.env.<KEY>` is present, (b) deterministic local fallback when absent. Mark the deferred branch with `// TODO(oma-deferred): integrate <vendor> when key is provisioned`. Shipping only the fallback (no env-conditional branch) leaves the spec unmet; shipping only the real call without fallback breaks demos when the key is missing.
12. **Stateless services**: no in-memory session or user state between requests — use external stores
13. **Backing services as resources**: DB, queue, cache are swappable resources connected via config

## Architecture

```
Router (HTTP) → Service (Business Logic) → Repository (Data Access) → Models
```

## Principles

- **DRY**: Business logic in Service, data access in Repository
- **Single Responsibility**: Classes and functions should have one responsibility
- **Dependency Inversion**: Use your framework's DI mechanism
- **KISS**: Keep it simple and clear

© First Fluke · MIT · first-fluke/oh-my-agent

Similar IDE rules

All IDE rules for Backend and APIs →

From the same set69

The whole set →
frontend-engineer frontend-engineer — a subagent for React, Next.js, Angular, and TypeScript frontend development. Builds UI components with TailwindCSS v4 and enforces FSD-lite architecture. CX Codex ★ 1,472repo stars qa-reviewer qa-reviewer — a code review agent that scans for OWASP vulnerabilities, performance bottlenecks, accessibility gaps and code quality issues. Runs before you merge and flags each finding with severity and remediation. CX Codex ★ 1,472repo stars mobile-engineer mobile-engineer implements mobile features across Flutter, React Native, Swift, and Kotlin following Clean Architecture boundaries. CX Codex ★ 1,472repo stars backend-engineer backend-engineer is a Claude Code subagent for API, authentication, and database migration tasks. It joins work on those tasks when requested. CX Codex ★ 1,472repo stars market This rule routes market research through the last30days engine, from query checks to a saved brief. It applies to trend scans, competitor research, and market discovery. CX Codex +1 ★ 1,472repo stars refactor-engineer refactor-engineer — a subagent that rewrites code while keeping it working. Identifies hot spots, wraps them with safety tests, and applies one atomic transformation at a time. CX Codex ★ 1,472repo stars pm-planner pm-planner is a subagent for Claude Code and Codex that breaks down requirements, creates API contracts, and generates structured plans for parallel execution. CX Codex ★ 1,472repo stars oma-bootstrap oma-bootstrap is a Claude Code skill that checks whether oma, required providers, and project state are ready for a task. It runs before a skill or workflow that needs an oma command. CX Codex +1 ★ 1,472repo stars

Project sponsors

Companies that keep this analytics open