proto-http-api-from-input-ent
Proto HTTP API From Input Ent
Overview
Design implementation-ready proto3 + HTTP contracts for go-sphere scaffolds.
This skill targets go-sphere scaffold projects only.
Do not optimize for generic/non-scaffold project structures unless explicitly requested.
Directory conventions (proto/, internal/, api/) are assumed scaffold defaults.
Required Reading Order
Read these local references before drafting any proto:
- references/repo-proto-conventions-reference.md
- references/router-conflict-reference.md
- references/go-sphere-api-definitions-reference.md
- references/go-sphere-error-handling-reference.md
- references/protocol-and-codegen-reference.md
- references/proto-packages-and-runtime-reference.md
- references/go-sphere-api-definitions-checklist.md
- references/proto-output-template.md
Do not replace local references with external links in final outputs.
Scaffold Convention Policy
When generic best practices conflict with scaffold conventions, follow scaffold conventions unless the user explicitly asks for a different style.
Examples:
- Keep
dash.v1action-style routes instead of forcing pure REST resources. - Keep scaffold paging style (
page/page_size + total_page) unless cursor paging is explicitly required. - Preserve compatibility-driven field naming exceptions.
- Keep one stable route namespace prefix per service (for example
AdminService->/api/admin...).
Reuse Policy
Apply this reuse order by default:
- Reuse
entpbmessages if they satisfy external contract requirements. - Reuse or extract shared domain messages to
proto/shared/v1when multiple servers/services need them. - Create custom DTO/VO messages only when required.
Error Placement Policy
Use scaffold error placement rules:
- Define service-specific business errors in the same
.protofile as the service. - Put only cross-service/common errors in
proto/shared/v1(or shared proto package). - Do not create a separate dedicated error package/file for each service unless explicitly requested.
Use custom DTO/VO only when at least one condition is true:
- Sensitive/internal fields must be hidden.
- Cross-aggregate composition is required.
- A stable external contract must be isolated from storage model changes.
Input Modes
Prompt-only
- Infer entities, use cases, read model, and write model.
- State assumptions explicitly.
Folder
- Inspect only the folder content explicitly provided as task input.
- Prefer scaffold-standard directories such as
proto/andinternal/when they exist. - Apply scaffold conventions as defaults when folder context is incomplete.
Requirement + mock demo
- Treat requirement docs as business truth.
- Treat mock payloads as response-shape truth.
- Use Ent schema as implementation reference, not as external API mirror.
Workflow
- Extract use cases (
Create,Get,List,Patch/Update,BatchGet). - Draft mock JSON for list, detail, and error responses.
- Make a documented reuse decision for each response object.
- Select scaffold-compatible path/method style for the target package (
api.v1,dash.v1,shared.v1,bot.v1). - Define HTTP bindings and request/response messages.
- Define error enums with
sphere.errorsoptions. - Run a route conflict check against Gin/Fiber/Echo compatibility rules.
- Validate package structure, imports, and codegen assumptions against this skill's references.
- Add validation constraints and machine-readable error behavior.
- Run the checklist before final output.
Hard Rules
- Model capability first, proto second.
- Avoid table-mirror CRUD proto design for public contracts.
- Require pagination for list APIs.
- Prefer explicit batch APIs over repeated single reads.
- Avoid
oneofin HTTP-exposed request/response messages. - Keep error contracts machine-readable (
status, business code, optionalreason,message). - Avoid leaking internal storage details.
- Prefer
entpbreuse when it already satisfies contract needs. - Promote cross-server shared messages into
proto/shared/v1. - Ensure contracts are compatible with protocol-first generation flow; do not rely on manual edits to generated files.
- Ensure generated route paths do not create Gin/Fiber/Echo conflicts.
- Use canonical wildcard naming per resource branch (for example keep
:task_idconsistent). - Use a stable service-level prefix namespace so routes from different services do not collide.
- Keep business error enums in the same proto file as the owning service; use shared proto only for common errors.
- If any hard rule fails, stop and output
Validation Notes -> Blocking Issueswith corrected route/error proposals. - Add business-facing comments to exposed
service/rpc, coremessage, and keyenumvalues so generated swagger/openapi output remains readable. - Prefer
//single-line comment style in proto files for business annotations; avoid block comments unless a tool requires them.
Output Contract
Produce output in this exact order:
Scaffold Fit DecisionRoute Conflict CheckError Placement CheckComment Coverage CheckAPI Capability MatrixMock JSONReuse DecisionProto3 ContractError Enum DesignEnt -> Proto MappingValidation Notes
Use references/proto-output-template.md as the output shape.
Quality Gates
Ensure all of the following:
- Contract expresses business capability, not persistence leakage.
- Query fields imply practical index strategy.
- Batch/backfill patterns avoid N+1 calls.
- Error behavior is consistent across RPC and HTTP responses.
- Message reuse strategy is explicit and justified.
- Package/import/path/method choices align with scaffold conventions.
- Route set passes cross-backend conflict sanity checks.
- Contract remains evolvable without breaking existing clients.
- Swagger/OpenAPI-relevant comments exist for exposed RPCs/messages/enums and use
//single-line style.