api-feature
Implement new backend features following Clean Architecture. Use for tasks involving new endpoints, use cases, entities, repositories, or application-layer changes.
- License 许可
- MIT
- 最近更新
- 2026-09-06
- Stars
- ★ 3
- Forks
- 0
01 前言 Front Matter
- name
- api-feature
- description
- Implement new backend features following Clean Architecture. Use for tasks involving new endpoints, use cases, entities, repositories, or application-layer changes.
02 资源文件 3
- 参考文档agents/openai.yaml300 B
- 参考文档references/context.md3.4 KB
- 参考文档templates/checklist.md1009 B
03 SKILL.md 正文
Skill: API Feature
Context (Required)
- Folder scope + code examples:
references/context.md - Execution checklist:
templates/checklist.md
Implement backend features professionally, following Clean Architecture.
Workflow
-
Read the API contract or requirement provided.
-
Read the guide for each folder before creating files there:
.agents/guides/api-dto.md.agents/guides/api-entity.md.agents/guides/api-repository.md.agents/guides/api-usecase.md.agents/guides/api-service.md.agents/guides/api-db-repository.md.agents/guides/api-controller.md.agents/guides/api-route.md.agents/guides/api-error.md
-
Create files in order by layer dependency:
1. internal/application/dtos/{domain}.go 2. internal/domain/entities/{domain}.go 3. internal/domain/repositories/i_{domain}_repository.go 4. internal/domain/use-cases/{verb}_{domain}.go (one per operation) 5. internal/application/services/{domain}_service.go 6. internal/infrastructure/database/pgx_{domain}_repository.go 7. internal/interfaces/http/controllers/{domain}_controller.go 8. internal/interfaces/http/routes/routes.go (register new routes) 9. db/queries/{domain}.sql (sqlc query file) 10. Run: sqlc generate -
Error handling — do not catch in Service or Controller:
UseCase returns DomainError → Echo ErrorHandler middleware
Prohibitions
- NEVER use
interface{}oranywithout explicit justification. - NEVER put business logic in the Controller.
- NEVER access the database directly in a Use Case — go through repository interface.
- NEVER return
echo.HTTPErrorfrom a Use Case — usedomain.DomainErrorfrompackages/go-shared. - NEVER change files unrelated to the task.
- NEVER use plain
stringfor fields with a fixed value set — define as typed Go constant. - NEVER edit sqlc-generated files in
internal/infrastructure/db/— regenerate instead.
Pre-Completion Checklist
- [ ] DTO created
- [ ] Entity created
- [ ] Repository interface created
- [ ] Use case(s) created (one per operation)
- [ ] Service created
- [ ] sqlc query file created and
sqlc generaterun - [ ] pgx repository implementation created
- [ ] Controller created
- [ ] Route registered in
routes.go - [ ] No
interface{}/anywithout justification - [ ] No business logic in Controller
- [ ] No DB access in Use Case
- [ ]
go build ./...passes - [ ] All files end with a newline (EOF)
04 同仓库更多 Skills
web-slicing
Convert screenshot/Figma designs into pixel-perfect frontend UI with reusable components. Use when the task focuses on visual and layout implementation.
web-seo-geo-friendly
Optimize public Next.js App Router pages for SEO and GEO (Generative Engine Optimization). Use when the user explicitly requests SEO/GEO optimization on public pages.
web-code-review
Review frontend code with a firm senior-lead standard, focusing on bugs, regressions, architecture risks, and test gaps in apps/web and the shared contracts the frontend depends on.
web-bugfix
Fix frontend bugs with minimum-touch changes, keep other surfaces stable, and sync schema, types, hooks, constants, tests, and related docs when impacted.
web-api-integrated
Integrate API endpoints into the frontend with Zod schemas, response types, constants, and react-query hooks. Use when implementing endpoints from an API contract, Postman, or Swagger.
skill-creator
Create a new skill from scratch with full structure — SKILL.md, references, templates, openai.yaml, Claude/OpenCode wrappers, and registration in manifest + AGENTS.md + CLAUDE.md.