Imported from hynix666/ULTRA-TEMPLATE (
.claude/skills/add-endpoint-go/SKILL.md). Install upstream withnpx skills add hynix666/ULTRA-TEMPLATE --skill add-endpoint-go. Copyright stays with the author.
Add an endpoint to api-go
Work from the inside out, one layer at a time, and run go test ./... in services/api-go after each step.
- Entity (
internal/entity) — add the rule, and a sentinel error if the operation can fail on domain grounds. No I/O and no clock: time and ids arrive as arguments. Add table-test cases totask_test.go, including the refused ones. - Use case (
internal/usecase) — add a method onTasks. If it needs storage theTaskRepositoryport does not offer, extend the port and implement it ininternal/repo/memory, with a test there: the memory repository defines the behaviour every store must match. - Transport (
internal/controller/httpapi) — add the method to the consumer-sideTaskServiceinterface and register the route inNewRouterwith a method pattern ("PATCH /api/tasks/{id}"). Decode bodies withdecode, which caps them at 1 MiB and rejects unknown fields, and map any new domain error infail. Add cases torouter_test.gofor success and every refusal. - Wiring — only
internal/appchooses implementations. Change it only when a new port needs one. - Check —
gofmt -l .,go vet ./...,go test -race ./...andgolangci-lint run. Ifinternal/architecture_test.gofails, a layer imported something it must not: move the code, do not widen the rule. - Keep the contract in step — update the API table in
services/api-go/README.md. Every task service in this repository must answer every route with the same status codes, so make the same change in each of the others, table included; each module keeps its own copy so it stays readable when the others are not selected. If the endpoint changes who depends on whom, updatearchitecture/model/system.c4when it exists.