backend-patterns

backend-patterns is a skill for Claude Code from tranhieutt/software_development_department. It costs 51 tokens per session (1,347 once invoked), scanned A, original, MIT.

A set of patterns for building backend services, the server-side parts of software that handle data, authentication, and APIs. It covers middleware, error handling, database connections, and API design.

In plain words
What is it for?
Use it when working on Express, Fastify, NestJS, or other backend service files, especially routes, authentication, databases, and service architecture.
Why use it?
It helps avoid common server problems such as unhandled asynchronous errors, oversized requests, exhausted database pools, and responses being sent twice.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: agent in frontmatter; positional $N argument.

Good fit Use it when working on Express, Fastify, NestJS, or other backend service files, especially routes, authentication, databases, and service architecture.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/tranhieutt/software_development_department/backend-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add tranhieutt/software_development_department --skill backend-patterns
Clone the repo
git clone --depth 1 https://github.com/tranhieutt/software_development_department

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for backend-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/tranhieutt/software_development_department/backend-patterns/github.svg)](https://agentmods.dev/skills/tranhieutt/software_development_department/backend-patterns)
Your own site
<a href="https://agentmods.dev/skills/tranhieutt/software_development_department/backend-patterns"><img src="https://agentmods.dev/badge/skills/tranhieutt/software_development_department/backend-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for backend-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/tranhieutt/software_development_department/backend-patterns"><img src="https://agentmods.dev/badge/skills/tranhieutt/software_development_department/backend-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 51 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,347 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00051 $0.01347
Opus 5.5 $0.00020 $0.00539
Sonnet 5.5 $0.00010 $0.00269
Haiku 4.5 $0.00005 $0.00135

Measured 1mo ago against content hash 2d4b08e5adc7, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

backend-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/backend-patterns/SKILL.md · 164 lines

How it starts

The opening of the file, as written. The whole thing — 164 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Backend Patterns

Critical rules (non-obvious)

  • Always handle async errors in Express: unhandled promise rejections crash the process; use express-async-errors or wrap every async handler
  • Never trust req.body size: set limit on body-parser; default 100kb is too large for some, too small for others
  • process.env access at import time: if accessed before dotenv.config(), value is undefined; call config() first in entry file
  • Connection pool misconfiguration: default pool size (10) will exhaust under load; set pool.max based on (num_cores * 2) + effective_spindle_count
  • res.json() after res.send(): causes "Cannot set headers after they are sent" — always return after sending response

Express: production setup

import express from "express";
import "express-async-errors";  // patches async error handling globally
import helmet from "helmet";
import { rateLimit } from "express-rate-limit";

const app = express();

app.use(helmet());
app.use(express.json({ limit: "10kb" }));
app.use(rateLimit({ windowMs: 15 * 60 * 1000, max: 100 }));

// Routes
app.use("/api/v1/users", userRouter);
app.use("/api/v1/products", productRouter);

// 404 handler — must come after all routes
app.use((req, res) => res.status(404).json({ error: "Not found" }));

// Global error handler — must have 4 params
app.use((err: Error, req: Request, res: Response, next: NextFunction) => {
  const status = err instanceof AppError ? err.statusCode : 500;
  res.status(status).json({ error: err.message });
});

Repository pattern

interface IUserRepository {
  findById(id: string): Promise<User | null>;
  findByEmail(email: string): Promise<User | null>;
  save(user: User): Promise<User>;
  delete(id: string): Promise<void>;
}

class PgUserRepository implements IUserRepository {
  constructor(private readonly db: Pool) {}

  async findById(id: string) {
    const { rows } = await this.db.query(
      "SELECT * FROM users WHERE id = $1 AND deleted_at IS NULL", [id]
    );
    return rows[0] ?? null;
  }
}

Read the full file on GitHub · 164 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 164 lines · 51 tokens per session scan A 2d4b08e5adc7

Subscribe to this mod's changes

backend-patterns is a skill published in the GitHub repository tranhieutt/software_development_department (73 stars, last pushed 5mo ago), licensed MIT. It adds 51 tokens to every session and 1,347 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.