proto-api-generator
Proto API Generator
Design implementation-ready proto3 + HTTP contracts for go-sphere scaffold projects.
If any of these are missing, ask one question at a time before proceeding. When a design decision has multiple reasonable options (message type, route strategy, pagination shape), present 2-3 options with your recommendation — do not choose unilaterally.
Operating Model
- Follow go-sphere scaffold conventions unless the user explicitly requests deviation.
- Treat local references as the working source of truth for scaffold rules, runtime behavior, and output shape.
- Keep outputs protocol-first; do not rely on lint plugins, scripts, or manual edits to generated files as substitutes for reasoning checks.
Checklist (track with TodoWrite)
At task start, call TodoWrite to create a task for each numbered item below. Mark each complete before moving to the next.
- Confirm module name, file mode (new / add to existing), and message strategy — through dialogue with the user, not by inferring from context
- Ask clarifying questions one at a time for any ambiguous scope or behavior
- For non-obvious decisions, propose 2-3 options with recommendation
- Present service overview (service name, RPC list) — get approval
- Present message designs section by section — get approval for each
- Run Final Gate checklist (
references/go-sphere-api-definitions-checklist.md) - Write the API design doc to disk (
prd/API.mdordesign/<feature>/api.md) - Ask if the user wants to proceed to proto file generation
Output path rule: Use design/<feature>/api.md if the user names a specific feature or change-id; default to prd/API.md otherwise.
Task Intake
Supported task inputs:
- Prompt-only: infer entities and use cases, then state assumptions explicitly.
- Folder input: inspect only the provided folders; prefer scaffold-standard structure (
proto/,internal/,api/) when present. - Requirement + mock demo: treat requirement docs as business truth, mock payloads as response-shape truth, and Ent schema as implementation reference rather than contract mirror.
Progressive Reference Loading
Do not load every reference by default. Load the smallest set that can support the current decision.
Start Here
- references/repo-proto-conventions-reference.md Use for package style, route namespace strategy, pagination defaults, reuse policy, naming compatibility, and topology rules.
Load Only When Needed
- Final output shape selection or final formatting: references/proto-output-template.md Then load exactly one template:
- Service routes, path templates, or backend portability: references/router-conflict-reference.md
- HTTP method, binding, body, or response shaping: references/go-sphere-api-definitions-reference.md
- Error enums,
sphere.errors, or runtime error behavior: references/go-sphere-error-handling-reference.md - Package layout, codegen pipeline, or runtime assumptions: references/protocol-and-codegen-reference.md references/proto-packages-and-runtime-reference.md
Final Gate
If any required check fails, stop and output Validation Notes -> Blocking Issues with corrected proposals.
Do not replace local references with external links in final outputs.
Core Decisions
File Mode
Classify each target proto file as one of:
service proto: contains aservicedefinition.message-only proto: contains messages or enums only.
Mode handling:
service protomust satisfy service-only topology, route, and error-placement rules.message-only protois allowed and must record service-only exemptions explicitly.- Both modes must still satisfy naming, import, runtime, and codegen compatibility checks.
Reuse Order
Default reuse priority:
- Reuse
entpbwhen it already satisfies external contract needs. - Reuse or extract
shared.v1messages for cross-service usage. - Create custom DTO or VO only when contract shaping requires it.
Use custom DTO or VO only when at least one condition is true:
- Sensitive or internal fields must be hidden.
- Cross-aggregate composition is required.
- External contract stability must be isolated from storage model changes.
Error Placement Default
- Keep service-specific business errors in the same proto file as the owning
service. - Reuse or create shared errors only for cross-service semantics.
- For
message-only proto, skip service-local error placement rules but still validate runtime and import compatibility.
Workflow
- Classify each target file by mode.
- Read scaffold conventions first and choose package style, service prefix, and compatibility constraints before drafting.
- Decide reuse (
entpb,shared.v1, custom DTO or VO`) before finalizing message shapes. - For
service proto, define business use cases, HTTP bindings, route-safe paths, and error enums. - For
message-only proto, draft messages and enums only, then record service-only exemptions in validation notes. - Load detailed HTTP, error, router, or runtime references only when the draft actually depends on them.
- Choose the deliverable shape late:
- use the condensed template for straightforward CRUD with clear reuse and routing;
- use the full template for custom business logic, multiple services, complex routing, or heavy validation notes.
- Run the final checklist before delivery.
Non-Negotiables
Keep these principles in mind throughout the task. Detailed rule text lives in the references and checklist.
- Design business capability first; avoid table-mirror public contracts.
- List APIs require pagination; batch APIs are preferred over repeated single reads.
- Avoid
oneofin HTTP-exposed request or response messages. - Keep error contracts machine-readable and stable.
- Do not leak sensitive or storage-only fields into external contracts.
- Keep routes conflict-safe; when backend is unknown, design for the Gin-safe subset first.
- Add concise
//business comments for exposedservice/rpc, core messages, and key enum values.
Mandatory Pre-Output Checklist
BEFORE writing the final proto file, you MUST verify all of the following:
Package Naming Check
- Package name follows scaffold convention:
dash.v1for generic, or{module}.v1for domain-specific (e.g.,user.v1,order.v1,article.v1) - Package declaration is in the format
package {name}.v1;
HTTP Binding Check
- Every RPC method has
option (google.api.http)annotation - HTTP method (get/post/put/delete) matches the operation semantics
- Route path follows REST conventions with proper path parameters
Error Handling Check
- Service proto files MUST include a service-local error enum (e.g.,
ArticleError,OrderError,AuthError) - Error enum uses
(sphere.errors.options)annotation with proper status codes - At minimum, include
NOT_FOUNDandINVALID_PARAMETERerror codes
Field Type Check
- ID fields use
int64(notstring) - Timestamps use
google.protobuf.Timestamp - Pagination uses
page/page_sizewithtotal_size/total_pagein response
Validation Check
- Required fields have
(buf.validate.field)constraints - String fields have
min_lenormin_byteswhere appropriate - Numeric fields have
gte/ltebounds where appropriate
Reuse Check
- Consider using entpb messages when they match contract needs
- Consider using shared.v1 for cross-service messages
If ANY check fails, fix the proto file before delivering. Do not output proto files that fail these checks.
Output
Use references/proto-output-template.md only as the template selector. Before final formatting, load exactly one of:
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.
25sphere-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.
16project-intake
Organize scattered project inputs and generate standardized intake documents. Use when users mention project kickoff, requirement initialization, PRD preparation, input organization, requirement gathering, or turning prototypes/demos/drafts into structured documents. Apply to new feature development, project initialization, requirement clarification, and similar scenarios. Always complete intake before writing PRD or any detailed design.
6