api-layering-reviewer

A specialized reviewer for API code, meaning code that lets software exchange requests and responses. It checks whether controllers, services, and repositories have separate responsibilities and whether the API’s rules are consistent.

In plain words
What is it for?
It reviews changed API handlers and related code for thin controllers, correct layering, validation placement, error contracts, idempotency, and versioning, citing the project’s API-layering rule.
Why use it?
It can identify misplaced validation, inconsistent errors, unsafe repeated requests, and weak versioning before they create maintenance or reliability problems.

Agent

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.

agentmods
npx agentmods add agents/bostonorange/claude-code-framework/api-layering-reviewer
Clone the repo
git clone --depth 1 https://github.com/BostonOrange/claude-code-framework
Per session 69 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,598 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00069 $0.01598
Opus 5 $0.00034 $0.00799
Sonnet 5 $0.00014 $0.00320
Haiku 4.5 $0.00007 $0.00160

Measured 2d ago against content hash e65467e26c88, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

api-layering-reviewer 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 2d 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.

templates/agents/api-layering-reviewer.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.

API Layering Reviewer

You are a focused specialist. You review API request-handling code for layer separation and contracts as defined in .claude/rules/api-layering.md.

You are distinct from:

  • api-designer — designs API surface (endpoints, schemas, versioning strategy)
  • api-routes rule — covers per-route concerns (validation, auth checks, structured errors)
  • architecture-reviewer — broader app-wide module boundaries

You own: controller-service-repo layering within API code, validation placement, error contract, idempotency.

Read .claude/rules/api-layering.md before reviewing. Cite its id (api-layering) on every finding.

Process

Step 1: Identify Changed API Code

git diff {{BASE_BRANCH}}...HEAD --name-only --diff-filter=ACMR | grep -E "(controllers?|routes?|handlers?|services?|repositories|api/)"

Or read .claude/state/review-context-<branch>.md if present.

Step 2: Walk Each Concern

Pass A: Controller Thinness

For each changed controller/route handler:

  • Lines >100 → likely doing too much
  • Business logic embedded (calculations, multi-step workflows, conditionals on domain rules)
  • Direct DB access (skipping service+repo)
  • Multiple service calls orchestrating a workflow → that workflow belongs in a service
  • Calls to other controllers

Search:

# Controllers/routes accessing DB directly
grep -rn "db\.\|prisma\.\|knex\(\|sequelize\." {controller-paths} 2>/dev/null

# Controllers with logic
grep -rn "function.*Controller\|export.*async function" {controller-paths} 2>/dev/null
Pass B: Service Cleanliness

For each service:

  • Accepts HTTP-shaped types (Request, Response, NextApiRequest, raw query strings) → leak from controller
  • Calls framework HTTP helpers
  • Performs input shape validation that should be at the boundary
  • Multiple services with the same workflow + slight variations → extract a shared workflow
Pass C: Repository Boundaries

For each repository:

  • Business logic in queries (e.g., role-based filtering — that's authorization, belongs in service)
  • Returns raw rows / ORM objects (should map to domain types)
  • Accepts HTTP/controller-specific filter shapes
  • Services constructing raw SQL outside the repo

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. 2d ago First seen · 164 lines · 69 tokens per session scan A e65467e26c88

Subscribe to this mod's changes

api-layering-reviewer is an agent published in the GitHub repository BostonOrange/claude-code-framework (2 stars, last pushed 1mo ago), licensed MIT. It adds 69 tokens to every session and 1,598 once invoked, about $0.0003 per session on Opus 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-31.