agentleFS
RoninForgeRoninForge/roninforge-go/skills/go-new-service/SKILL.md

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.

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
  1. Very specific:

    When creating a new Go HTTP service or rewriting an old http.ListenAndServe(...)-style server.

    line 10
  2. Very specific:

    Create the binary at cmd/<name>/main.go.

    line 14
  3. Very specific:

    Run ListenAndServe in a goroutine sending to errCh.

    line 32
  4. Very specific:

    Add a go.mod with the current Go version (go 1.24 or higher) and the tool directive if dev tools are pinned.

    line 48
  5. Very specific:

    Do not import gorilla/mux, chi, or gin unless the project already uses one.

    line 50
  6. Very specific:

    Never use http.HandleFunc(...) on the default mux.

    line 52
  7. Very specific:

    Always include handler_test.go next to the handler with httptest smoke tests for the routes.

    line 54

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Scaffold Go HTTP Service

When to Use

When creating a new Go HTTP service or rewriting an old http.ListenAndServe(...)-style server.

Instructions

  1. Create the binary at cmd/<name>/main.go. Internal packages go under internal/.
  2. main() is a thin wrapper:

    func main() {
        if err := run(); err != nil {
            slog.Error("fatal", "err", err)
            os.Exit(1)
        }
    }
  3. run() error does:
    • Set the default slog handler (JSON for production, text for local).
    • Build a context.Context from signal.NotifyContext(... SIGINT, SIGTERM).
    • Wire dependencies (config, store, handler).
    • Construct &http.Server{Addr, Handler, ReadHeaderTimeout: 5 * time.Second}.
    • Run ListenAndServe in a goroutine sending to errCh.
    • Select on ctx.Done() (graceful shutdown) or errCh.
    • On shutdown, call srv.Shutdown(shutdownCtx) with a separate timeout.
  4. Routing uses stdlib http.NewServeMux with method+path:

    mux := http.NewServeMux()
    mux.HandleFunc("GET /users/{id}", h.GetUser)
    mux.HandleFunc("POST /users", h.CreateUser)
  5. Middleware is func(http.Handler) http.Handler. Chain by wrapping.
  6. Handlers read path values with r.PathValue("id") and pass r.Context() to downstream calls.
  7. Add a go.mod with the current Go version (go 1.24 or higher) and the tool directive if dev tools are pinned.
  8. Do not import gorilla/mux, chi, or gin unless the project already uses one. Stdlib is enough for new code.
  9. Never use http.HandleFunc(...) on the default mux. Build your own.
  10. Always include handler_test.go next to the handler with httptest smoke tests for the routes. Go puts tests alongside source, never in a separate tests/ directory.

Files to Generate

  • cmd/<name>/main.go
  • internal/handler/handler.go
  • internal/handler/handler_test.go (tests live next to the code, never in a separate tests/ directory)
  • go.mod (declare Go version)
  • Makefile with build, test, lint, run targets (optional)
  • .golangci.yml with errcheck, govet, staticcheck, errorlint, bodyclose, contextcheck enabled (optional)

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.