go-new-service
Skill0 starsChanged 7 months agoMITView on GitHub
Scaffold a modern Go HTTP service: main.go with graceful shutdown, slog setup, 1.22+ ServeMux with method routing, ReadHeaderTimeout, and a run() error wrapper.
In this repository3 other files it gives its agents.
- go-error-wrapSkill
- go-modernizeSkill
- go-validateSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 0 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 10
When creating a new Go HTTP service or rewriting an old http.ListenAndServe(...)-style server.
- Very specific: line 14
Create the binary at cmd/<name>/main.go.
- Very specific: line 32
Run ListenAndServe in a goroutine sending to errCh.
- Very specific: line 48
Add a go.mod with the current Go version (go 1.24 or higher) and the tool directive if dev tools are pinned.
- Very specific: line 50
Do not import gorilla/mux, chi, or gin unless the project already uses one.
- Very specific: line 52
Never use http.HandleFunc(...) on the default mux.
- Very specific: line 54
Always include handler_test.go next to the handler with httptest smoke tests for the routes.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Scaffold Go HTTP Service
When to Use
When creating a new Go HTTP service or rewriting an old http.ListenAndServe(...)-style server.
Instructions
- Create the binary at
cmd/<name>/main.go. Internal packages go underinternal/. main()is a thin wrapper:func main() { if err := run(); err != nil { slog.Error("fatal", "err", err) os.Exit(1) } }run() errordoes:- Set the default slog handler (JSON for production, text for local).
- Build a
context.Contextfromsignal.NotifyContext(... SIGINT, SIGTERM). - Wire dependencies (config, store, handler).
- Construct
&http.Server{Addr, Handler, ReadHeaderTimeout: 5 * time.Second}. - Run
ListenAndServein a goroutine sending toerrCh. - Select on
ctx.Done()(graceful shutdown) orerrCh. - On shutdown, call
srv.Shutdown(shutdownCtx)with a separate timeout.
Routing uses stdlib
http.NewServeMuxwith method+path:mux := http.NewServeMux() mux.HandleFunc("GET /users/{id}", h.GetUser) mux.HandleFunc("POST /users", h.CreateUser)- Middleware is
func(http.Handler) http.Handler. Chain by wrapping. - Handlers read path values with
r.PathValue("id")and passr.Context()to downstream calls. - Add a
go.modwith the current Go version (go 1.24or higher) and thetooldirective if dev tools are pinned. - Do not import
gorilla/mux,chi, orginunless the project already uses one. Stdlib is enough for new code. - Never use
http.HandleFunc(...)on the default mux. Build your own. - Always include
handler_test.gonext to the handler withhttptestsmoke tests for the routes. Go puts tests alongside source, never in a separatetests/directory.
Files to Generate
cmd/<name>/main.gointernal/handler/handler.gointernal/handler/handler_test.go(tests live next to the code, never in a separatetests/directory)go.mod(declare Go version)Makefilewithbuild,test,lint,runtargets (optional).golangci.ymlwitherrcheck,govet,staticcheck,errorlint,bodyclose,contextcheckenabled (optional)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

