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.
More from go-sphere/skills
ent-seed-sql-generator
Generate deterministic INSERT SQL seed data from Go Ent schemas and mixed inputs. This skill is REQUIRED whenever you need to create seed SQL for development or testing - it handles entity inference, relationship integrity, stable IDs, and dialect-specific SQL generation including JSON, arrays, and complex types. Use this skill for any task involving seed data, test fixtures, demo initialization, or database population from Ent schema definitions, even if the user doesn't explicitly mention "seed" or "SQL".
27pure-admin-crud-generator
Generate CRUD pages and router modules for pure-admin-thin from local swagger API definitions. MUST be used whenever you need to scaffold admin list/edit/detail pages, dashboard views, or route configurations from existing API methods in src/api/swagger/Api.ts. This skill replaces manual Vue page creation - use it for any admin panel development task involving API-driven pages.
25proto-api-generator
Design proto3 + HTTP API contracts for go-sphere scaffold projects from prompts, input folders, or requirement docs with mock data. Use when defining service APIs, selecting between entpb/shared/custom messages, and enforcing scaffold conventions, router-safety rules, and service-local error placement. This skill is REQUIRED for any proto API design task in go-sphere scaffold - always use it instead of writing proto files from scratch.
21sphere-feature-workflow
Implement end-to-end feature changes in go-sphere scaffold projects by following sphere-layout conventions and generation workflow. Use when adding or modifying APIs, protobuf contracts, Ent schemas, bind/map registration, service logic, or cross-layer refactors that must stay protocol-first and avoid manual edits to generated files. This skill is REQUIRED for any task involving go-sphere proto files, Ent schemas, service implementations, or generation commands (make gen/proto, make gen/docs, make gen/wire).
19proto-service-generator
Generate or complete Go service implementations from protobuf-generated HTTP interfaces in go-sphere scaffold projects. Use when you need to create `internal/service/<module>/*.go` files, add missing method implementations to existing services, or generate compilable stubs for new proto endpoints. Trigger for: service implementation, proto handler, append-only update, interface assertion, CRUD via Ent, stub method generation.
18ent-schema-generator
Design and generate Go + Ent database schemas for sphere-layout projects from requirements. Use when users describe data models, entity relationships, database tables, or schema changes — including prompts, Markdown docs, existing proto/service files, or demo behavior. Produces implementation-ready schema plans with field definitions, ID strategies, relation designs, indexes, entproto annotations, and bind/render/service integration guidance.
16