Files
agentic-dev/turbo/generators/templates/feature/AGENTS.md.hbs
Danijel Martinek 019d4866a0 feat(turbo): turbo gen feature generator (Phase 1, single-entity)
Adds `pnpm turbo gen feature` to scaffold a Lazar-conformant feature
package matching the navigation reference shape: entity + Zod schema,
single use case (`get<Entity>`), controller, mock + Payload-stub real
repository (with span + capture), DI module/container/symbols, and tRPC
router with full BAD_REQUEST/NOT_FOUND error mapping. The generated
`bind-production.ts` and `bind-dev-seed.ts` compose the post-R44
`withSpan(tracer, opts, withCapture(logger, tags, factory(deps)))`
sandwich at bind time.

Verified by generating a sample `packages/example/` feature and running
`pnpm --filter @repo/example lint typecheck test` — all three pass
(9 test files, 25 tests). Cleaned up after verification so no example
package is committed.

Phase-1 limitations (documented in `docs/guides/scaffolding-a-feature.md`
and printed by the generator on success): no Payload CMS templates, no
React Query helpers, faker-driven factories left as stubs, single
entity / single use case, and aggregator wiring (core-api/root,
apps/web-next bindAll) is left as a manual checklist.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 01:09:22 +02:00

43 lines
2.5 KiB
Handlebars

# AGENTS.md — {{kebabCase name}}
Feature package scaffolded by `turbo gen feature`. Provides domain logic, repositories, use cases, controllers and the tRPC router for `{{pascalCase entity}}`.
## Overview
`@repo/{{kebabCase name}}` owns: the `{{pascalCase entity}}` domain model, feature-scoped errors, the `I{{pascalCase entity}}Repository` interface, one use case (`get{{pascalCase entity}}UseCase`), one controller, a real Payload-backed repository (stub body — fill in once the Payload collection is added), an in-memory mock repository, and the tRPC `{{camelCase name}}Router`.
## Layer responsibilities
| Layer | Key files |
|---|---|
| **entities/models** | `{{kebabCase entity}}.ts` — `{{pascalCase entity}}` Zod schema + type |
| **entities/errors** | `{{kebabCase entity}}.ts` ({{pascalCase entity}}NotFoundError), `common.ts` (InputParseError) |
| **application/use-cases** | `get-{{kebabCase entity}}.use-case.ts` — factory function + exported schemas |
| **application/repositories** | `{{kebabCase entity}}.repository.interface.ts` — `I{{pascalCase entity}}Repository` |
| **infrastructure/repositories** | `{{kebabCase entity}}.repository.ts` (real Payload-backed; stub body), `{{kebabCase entity}}.repository.mock.ts` (in-memory) |
| **interface-adapters/controllers** | `get-{{kebabCase entity}}.controller.ts` — one file per use case |
| **di** | `symbols.ts`, `module.ts`, `container.ts`, `bind-production.ts`, `bind-dev-seed.ts` |
| **integrations/api** | `procedures.ts` ({{camelCase name}}Procedure), `router.ts` ({{camelCase name}}Router) |
## Public exports
| Subpath | Contents |
|---|---|
| `.` | `{{pascalCase entity}}` type; `{{pascalCase entity}}NotFoundError`, `InputParseError`; `get{{pascalCase entity}}InputSchema`, `get{{pascalCase entity}}OutputSchema`, `Get{{pascalCase entity}}Input`, `Get{{pascalCase entity}}Output`, `IGet{{pascalCase entity}}UseCase`; `IGet{{pascalCase entity}}Controller` type alias; `{{pascalCase name}}Router` type |
| `./api` | `{{camelCase name}}Router` (tRPC router) |
| `./di/bind-production` | `bindProduction{{pascalCase name}}(config, tracer, logger)` |
| `./di/bind-dev-seed` | `bindDevSeed{{pascalCase name}}(tracer, logger)` |
| `./ui` | (reserved — Phase 1 is empty) |
## Tests
```bash
pnpm test --filter @repo/{{kebabCase name}}
```
## What it must NOT import
- Any other feature package
- Any app package
- `@repo/core-api`, `@repo/core-cms`, `@repo/core-trpc`, `@repo/core-ui` directly; only `@repo/core-shared`