Skip to content
Back to skills

Scaffold Service

ASecurity

Scaffold a thin FastAPI router or gRPC servicer under services/{domain}/v{n}/ with AppUtils bootstrap. Use for "add an endpoint/route/API", "expose via REST/gRPC", or "new API version".

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 24, 2026
developmentpythonbashfastapigitapi

Works with

  • claude code
  • api

Security analysis

A100/100

Scanned November 9, 2026

npx -y skills add SyntaxArc/archipy-plugin --skill scaffold-service --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Scaffold Service?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Scaffold Service
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/syntaxarc-scaffold-service/badge)](https://www.skillsdirectory.com/skills/syntaxarc-scaffold-service)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: scaffold-service
description: >-
  Scaffold a thin FastAPI router or gRPC servicer under services/{domain}/v{n}/ with
  AppUtils bootstrap. Use for "add an endpoint/route/API", "expose via REST/gRPC", or
  "new API version".
---

# Scaffold ArchiPy Service

## Read first

Read these plugin rules in full before generating files (paths relative to this skill directory; Claude Code: `${CLAUDE_SKILL_DIR}/../../rules/`):

- `../../rules/architecture-for-apps.mdc`
- `../../rules/using-archipy-utils.mdc`
- `../../rules/using-archipy-services.mdc`
- `../../rules/config-and-di.mdc`

## Before writing files

1. Inspect existing transports, domain DTOs/logics, app bootstrap, DI wiring, and service tests.
2. Infer domain, API version, framework, and sync/async style when established by the repository.
3. Ask only for unresolved choices. Default to `v1` and FastAPI only when no project convention exists.
4. Preserve existing routes, servicers, and bootstrap code; integrate without overwriting.

## Prefer ArchiPy

```bash
uv add "archipy[fastapi]"   # HTTP
uv add "archipy[grpc]"      # gRPC
```

## Generate

```text
services/<domain>/v{n}/
└── <domain>_service.py
```

### FastAPI

- Thin router: request → domain `*InputDTO` → logic → `*OutputDTO`.
- Export `create_<domain>_v{n}_router(container)` for `manage.py` / app factory.
- Paths follow the REST resource rule in `using-archipy-services.mdc`: `/api/v1/users/{user_uuid}/campaigns/{campaign_uuid}/...`
  — kebab-case literal segments, plural collections, `UUID`-typed `snake_case` path params, `APIRouter(prefix="/api/v1")`.
- JWT auth (Keycloak or other): compute `actor_uuid` = actor (`current_actor.id` / `act`) first, else token subject (`user_id` / `sub`); pass it in the
  input DTO for `created_by*`/`updated_by*`. Never use a path owner uuid (customer, merchant, admin, user…) as the actor (see `using-archipy-services.mdc`).
- Map domain errors to HTTP status; no business rules / atomic UoW decorators here.

### gRPC

- Thin servicer calling logic; sync servicers with `AppUtils.create_grpc_app`, async with `create_async_grpc_app`.
- Export `register_<domain>_v{n}_servicers(server, container)` that adds the servicers to a server built by
  `AppUtils`; the entrypoint and the BDD harness (`/scaffold-bdd`) both call it, so neither binds a port inside it.
- Do not mix sync/async servicer styles on one server.
- Request/response DTOs extend `BaseProtobufDTO` (`_proto_class`, `from_proto` / `to_proto`); `from_proto` is the
  validation boundary. Catch `ValidationError` and raise `InvalidArgumentError ... from e`; keep proto types out of
  logics. See `rules/using-archipy-models.mdc`.

## Bootstrap (entrypoint)

Prefer AppUtils — do not hand-roll bare `FastAPI()` / `grpc.server()`:

```python
from archipy.helpers.utils.app_utils import AppUtils
from archipy.configs.base_config import BaseConfig

app = AppUtils.create_fastapi_app()
app.include_router(create_<domain>_v1_router(container))
```

uvicorn in `manage.py` with `**AppUtils.uvicorn_config(config)`: host and port from `config.FASTAPI` (`SERVE_HOST`,
`SERVE_PORT`), the server settings (`RELOAD`, `PROXY_HEADERS`, `FORWARDED_ALLOW_IPS`, timeouts, workers, TLS) from
`config.UVICORN` (archipy >= 5.25.0).

## Do not

- Version in path (`v1`, `v2`), not in business logic.
- Do not re-implement CORS/exception handlers/stock gRPC interceptors AppUtils already wires.
- Wire logic via DI container.
- Never hardcode host/port.

## Verify

1. Run the repository's formatter and linter on generated Python.
2. Run the Behave scenarios that exercise the route/servicer through the BDD harness (`/scaffold-bdd`); add one
   when the endpoint is new.
3. Confirm route/servicer registration, DTO mapping, domain-error mapping, and DI resolution.
4. Run the `archipy-reviewer` subagent on the changes and fix every **Must fix** finding it reports.
5. Report files, dependency changes, and commands run.

## Docs

- https://syntaxarc.github.io/ArchiPy/getting-started/project_structure/
- https://syntaxarc.github.io/ArchiPy/tutorials/helpers/

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.