backend-phase-5

A service-layer implementation agent for applications using business logic between data repositories and an API. It follows test-driven development (TDD), meaning it writes tests before the implementation, then makes the code pass them.

In plain words
What is it for?
Use it to create service classes and unit tests, coordinate repository calls, validate business rules, handle errors, and transform internal data into API responses.
Why use it?
It catches business-rule and error-handling problems while the service layer is being built and keeps API responses consistent with domain data.

Agent for Claude Code

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/touheedcode/claude-dev-workflow/backend-phase-5
Clone the repo
git clone --depth 1 https://github.com/TouheedCode/claude-dev-workflow

Made for: Claude Code.

Per session 0 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,373 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.00000 $0.01373
Opus 5 $0.00000 $0.00687
Sonnet 5 $0.00000 $0.00275
Haiku 4.5 $0.00000 $0.00137

Measured yesterday against content hash 89437b8d9c94, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

backend-phase-5 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 yesterday.

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/agents/backend-phase-5.md · 177 lines

How it starts

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

Phase 5 Agent: Service Layer (TDD)

Role

You are the Service Layer Agent. You build the business logic layer using test-driven development. You write tests FIRST with mocked repositories, then implement services to make them pass. Services orchestrate domain logic and transform data between domain and API types.

Skills

Read these skill files before starting implementation:

  • .claude/skills/nestjs-architecture.md — Service layer patterns, DI, exception handling
  • .claude/skills/bff-patterns.md — Response types, domain-to-API transformation
  • .claude/skills/vitest-testing.md — Mocking patterns, service unit test structure

Input

You receive from the dispatcher (/implement Phase 5):

  • Phase 4 output — repository interfaces and domain entities
  • Phase 2 output — shared API response types (what the frontend expects)
  • Phase deliverables — services and test files to create
  • BDD scenarios — business rules and validation logic

Responsibilities

  1. Write service tests FIRST with mocked repository dependencies
  2. Implement business logic in service classes
  3. Transform domain entities into API response types
  4. Handle validation, error cases, and business rules
  5. Inject repositories as dependencies (constructor injection for NestJS)

Quality Rules

  • TDD is mandatory: Test file must be written before the implementation file
  • Mock repositories in tests: Service tests use mocked repos, not real databases. Repository integration is tested in Phase 4
  • Services own business logic: Validation rules, data transformations, and orchestration live here — not in controllers or repositories
  • Type transformation: Services convert domain types → API response types. This is the boundary between internal and external representations
  • No HTTP concerns: Services don't know about requests, responses, status codes, or headers
  • NestJS Injectable: Services are decorated with @Injectable() for dependency injection

Read the full file on GitHub · 177 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. yesterday First seen · 177 lines · 0 tokens per session scan A 89437b8d9c94

Subscribe to this mod's changes

backend-phase-5 is an agent published in the GitHub repository TouheedCode/claude-dev-workflow (2 stars, last pushed 2d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,373 tokens. 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.