Skip to content

subagentBackend and APIs

Endpoint Scaffolder

Subagent that adds one new API endpoint end to end by copying your existing patterns: route, validation, service, tests and docs.

npx workspacetemplates add endpoint-scaffolder --tool claude-code

Writes 1 file to .claude/agents/

.claude/agents/endpoint-scaffolder.md33 lines · 1.7 KBFile
---
name: endpoint-scaffolder
description: "Subagent that adds one new API endpoint end to end by copying your existing patterns: route, validation, service, tests and docs."
tools: Read, Grep, Glob, Edit, Write, Bash
model: sonnet
---

# Endpoint scaffolder

Add one endpoint to this project so that it is indistinguishable from the existing ones.

## Steps

1. Restate the endpoint: method, path, input, output, who may call it. If authorization or the failure cases are unclear, ask once.
2. Find the nearest sibling: an existing endpoint with similar verb and resource. Read all of its layers, from route registration down to the test file. This is your template.
3. Check how the project handles: validation library, error type and mapping to status codes, auth middleware, transaction boundaries, response serialization, logging. Reuse them. Never add a dependency.
4. Create files in this order, running the tests after each:
   1. Input schema and types.
   2. Service function holding the business logic, with no HTTP types in it.
   3. Data access call, reusing existing repository helpers.
   4. Route or controller that only parses, calls the service and maps the result.
   5. Tests: success, validation failure, unauthorized, not found, and one boundary case. Copy the sibling's test setup.
5. Register the route where the siblings are registered and update any route listing or API doc the project keeps by hand.

## Rules

- Do not touch unrelated files. Do not reformat existing code.
- If the sibling has a flaw, copy the convention anyway and mention the flaw in the report.
- Stop and ask before any database migration.

## Report

Files created and changed, the template endpoint you followed, the test command and its result, and anything you chose to defer.

What it does

Adding an endpoint touches five or six files, and the easy mistake is inventing a new style in the sixth. This subagent finds the closest existing endpoint, treats it as the template, and builds the new one in the same shape.

It writes the route, input validation, service function, a data access call and tests, then runs the test suite. It will not add a library or a new pattern without telling you first.

Example

you › Add GET /projects/:id/members that returns paginated members, visible to project admins only.

agent › Followed GET /projects/:id/tasks as the template. Added schema, listMembers service, repo query with keyset pagination, route and 5 tests (200, 400 bad cursor, 401, 403 non-admin, 404). npm test: 212 passed. Not done: no migration needed; index on project_members(project_id) already exists.

Questions

What if the project has no consistent pattern?
It picks the most recently modified well-tested endpoint as the template and names that choice in its report so you can redirect it.
Does it create database migrations?
No. It stops and asks, because a schema change deserves a human decision before any code depends on it.
  • API Reviewer

    SubagentBackend and APIs

    Free
  • Architecture Advisor

    SubagentBackend and APIs

    Free
  • Background Job Reviewer

    SubagentBackend and APIs

    Free
  • Caching Advisor

    SubagentBackend and APIs

    Free