anantbhandarkar/make-it-right/mir-backend-go-fiber
Claude Code and agent skill by anantbhandarkar/make-it-right
- community
Checking that the SKILL.md file is still in the repository.
Make It Right (Fiber module). Fiber web framework reliability augmentation for Go backends, covering Fiber v3 (current) and v2 (still patched). Chains: mir-backend (generic gates) -> mir-backend-go (Go runtime) -> this (Fiber library mechanics). Adds the mechanical footguns the runtime-agnostic tiers omit: fiber.Ctx and every value read from it (Body, Params, Query, Headers) are pooled and reused after the handler returns, so retaining them corrupts or discloses another request's data; the v2->v3 API rewrite that AI mixes up (Ctx is now an interface, BodyParser became c.Bind().Body(), c.Context() returns a context.Context, TrustedProxies became TrustProxyConfig); c.Bind() silently skips validation when fiber.Config.StructValidator is nil; fasthttp's incompatibility with net/http middleware; and graceful shutdown via ListenConfig.GracefulContext or app.ShutdownWithContext, which hangs on keep-alive connections when ReadTimeout is 0. TRIGGER only when the Go backend uses the Fiber framework - building, reviewing, or debugging a Fiber handler, middleware, or route. SKIP for Gin (mir-backend-go-gin), Echo (mir-backend-go-echo), chi, stdlib net/http, or any non-Fiber stack, and for every non-Go runtime.
Install
npx vskill@latest install anantbhandarkar/make-it-right/mir-backend-go-fiberSKILL.md
The same SKILL.md was published earlier as anantbhandarkar/make-it-right/mir-backend-go-fiber.
/mir-backend-go-fiber · Make It Right (Fiber)
Bottom tier of the chain: mir-backend (generic gates) → mir-backend-go (Go runtime model) → this (Fiber library mechanics). Run the gates first; load the Go runtime tier for goroutine lifecycle, context propagation, and race discipline; reach for this at Gate 5 (design mechanics), Gate 6 (implementation), and Gate 7 review. Runtime-level concerns (goroutine leaks, data races, context propagation, typed-nil, slice aliasing, `os.Root`, module checksums) live in `mir-backend-go` — not here.
Stack state, verified 13 Aug 2026.
| Line | Current | Notes | |
|---|---|---|---|
v3 (github.com/gofiber/fiber/v3) | v3.4.0 (2026-07-02); v3.0.0 GA 2026-02-02 | Current major. go.mod requires Go 1.25. fiber migrate --to v3 assists the port | |
v2 (github.com/gofiber/fiber/v2) | v2.52.15 (2026-08-12) | Still receiving security patches. Different handler signature and binding API |
Establish which major the project is on before writing a line. The two have different handler signatures, a different binding API, and different config field names — code written for one does not compile against the other, and AI mixes them constantly (footgun 2).
Fiber is built on fasthttp, not on net/http. That is the root of most Fiber-specific footguns.
The Fiber footguns AI walks into most
1. fiber.Ctx and every value read from it are pooled — retaining them is data corruption
This is Fiber's defining hazard, and it is unchanged in v3. Fiber reuses the request context from a sync.Pool after the handler returns. Every string and byte slice obtained from `fiber.Ctx` — `c.Body()`, `c.Params("id")`, `c.Get("X-Header")`, `c.Query("page")`, `c.Locals(...)` — points into the reused buffer. When the pool recycles the slot for the next request, those references now read the next request's data.
- Applies to every value read from
c: params, query, headers, body, locals. When in doubt, copy. - Use `strings.Clone` / `bytes.Clone`, not `utils.CopyString`. The import path differs by major and AI gets it wrong: v2 has
github.com/gofiber/fiber/v2/utils, but v3 has no `utils` subpackage —CopyStringmoved to the separate modulegithub.com/gofiber/utils/v2. The stdlib functions work in both. - Binding is not an escape hatch, except for JSON.
c.Bind().Body(&req)on a JSON body goes throughencoding/jsonand yields heap-allocated fields you can retain. The form, multipart, query, header, and cookie binders hand the decoderutils.UnsafeString(val)over the fasthttp buffer, so those struct fields still alias the pooled memory. Retaining a struct filled by.Query(),.Form(),.Header(), or.Cookie()has the same corruption as retainingc.Query(...)directly. - With
Immutableon (footgun 5), useapp.GetString(s)/app.GetBytes(b)to get a value that is safe to keep; they return the argument unchanged whenImmutableis off, so they are not a substitute for an explicit copy. - The race detector will not catch this. The pool recycles the slot after the handler returns, so there is no concurrent access in the Go memory-model sense — it is a logical corruption. Symptom to recognise: a panic or garbled data in a package that never mentions Fiber in the stack trace.
- This is a confidentiality bug as well as a correctness bug — see Security.
2. v2 and v3 are different APIs — do not mix them
The single most common source of code that does not compile, or that compiles and means something else.
| Concern | v2 | v3 | |
|---|---|---|---|
| Handler signature | func(c *fiber.Ctx) error (struct pointer) | func(c fiber.Ctx) error (Ctx is an interface) | |
| Standard Go context | c.UserContext() | c.Context() / c.SetContext(ctx) | |
| fasthttp context | c.Context() | c.RequestCtx() | |
| Body binding | c.BodyParser(&req) | c.Bind().Body(&req) | |
| Query / params / cookie binding | c.QueryParser, c.ParamsParser, c.CookieParser | c.Bind().Query(), .URI(), .Cookie() (the params struct tag became uri) | |
| Template data binding | c.Bind(...) | c.ViewBind(...) | |
| Trusted proxies | EnableTrustedProxyCheck + TrustedProxies | TrustProxy + TrustProxyConfig.Proxies | |
| CORS list options | comma-separated strings | slices | |
| CSRF expiry | Expiration (1 h) | IdleTimeout (30 min) |
c.Context() flipping meaning between majors is the dangerous one: in v2 it returns *fasthttp.RequestCtx, in v3 it returns a context.Context. Code ported without care compiles in neither, or compiles and passes the wrong thing to a database call.
3. c.Bind() silently skips validation when no StructValidator is configured
Fiber v3 runs your validator inside every Bind call — but only if one exists. fiber.Config.StructValidator defaults to nil, and the binder then returns success without checking a single tag. Structs decorated with validate:"required,email" pass straight through to your business logic.
- With that wired,
c.Bind().Body(&req)parses and validates in one call. Without it,Bindis a decoder and nothing more. - Error handling is manual by default:
Binddoes not write a response unless you chain.WithAutoHandling()(which sets 400 and returns a*fiber.Error). Always check and return the error. .SkipValidation(true)disables validation for one chain — grep for it during review; it is an easy way to accidentally disable the only input check on an endpoint.- v2 has no validator hook at all:
BodyParsernever validates. Callvalidator.Struct(&req)yourself after every parse. - Never bind into your DB/ORM model in either major — see Security, mass assignment.
4. fasthttp ≠ net/http — standard middleware and libraries may not work
fasthttp provides its own RequestCtx and does not implement http.Handler or http.ResponseWriter. Anything expecting net/http types — standard middleware, net/http-based auth libraries, net/http OpenTelemetry instrumentation, net/http.CrossOriginProtection — cannot be used directly with Fiber.
- Look for a Fiber-native equivalent in
gofiber/contribor the built-inmiddleware/set first. - To reuse a
net/httphandler, wrap it withadaptor.HTTPHandler/adaptor.HTTPMiddleware(v3middleware/adaptor). This converts types; it does not solve the buffer-pooling problem for values you read viafiber.Ctx. - fasthttp does not support HTTP/2. If a client, a gRPC-Web gateway, or a load-balancer health check requires h2, Fiber is the wrong choice — surface it at Gate 0 stack fitness, not after implementation.
- Always check the ecosystem tier before adding a dependency: does it export a Fiber middleware, a fasthttp handler, or only an
http.Handler?
5. Immutable — pick one mode and enforce it project-wide
By default (Immutable: false), strings returned by Fiber reference the fasthttp buffer directly for zero-allocation performance, and become invalid after the handler returns (footgun 1). Immutable: true makes Fiber copy every returned string, so values are safe to retain — at the cost of an allocation per read.
- `Immutable: true` — simpler, safer code. The right default for CRUD APIs where correctness is worth the allocations. It covers
c.Body()too: both majors route the body through the copying path (app.GetBytesin v3,utils.CopyBytesin v2). - `Immutable: false` — every retained string needs
strings.Clone, every retained body needsbytes.Clone. - Document the choice and enforce it. A codebase where some files assume
trueand others assumefalsehas latent corruption that only appears under concurrent load.
6. Graceful shutdown — and the ReadTimeout: 0 trap
Ignoring SIGTERM drops in-flight requests. But wiring shutdown without setting ReadTimeout produces a shutdown that appears to hang: `Shutdown` does not close idle keep-alive connections, so with ReadTimeout: 0 those connections never time out and the drain waits for the full deadline on every deploy.
- The manual form works in both majors: run
app.Listenin a goroutine, wait on the signal, thenapp.ShutdownWithContext(ctx)with a bounded deadline. Neverapp.Shutdown()without a context — it blocks indefinitely if a request does not finish. ReadTimeout,WriteTimeout, andIdleTimeoutall default to zero, meaning no limit. Set them explicitly; a slow client otherwise holds a connection forever.- Register
OnPreShutdown/OnPostShutdownhooks (v3; v2's singleOnShutdownwas split) to fail readiness probes before the drain starts, then close DB pools after it ends. - Goroutines you spawned inside handlers are not tracked by
Shutdown. Wait on your ownerrgrouptoo.
7. Prefork forks processes — in-memory state is silently partitioned
Prefork (fiber.Config.Prefork in v2, fiber.ListenConfig.EnablePrefork in v3) spawns one child OS process per core, all listening on the same port with SO_REUSEPORT. It is off by default and is a throughput knob people turn on from a blog post.
Every process gets its own copy of every global. Nothing in the process is shared, so anything counted in memory is counted N times:
| Built in memory | What actually happens with prefork on | |
|---|---|---|
limiter middleware with the default memory store | Each child enforces the limit independently. 8 children on a "10 req/min" rule permits 80 | |
session middleware with the default memory store | A user's session exists in one child; the next request lands on another and they are logged out | |
csrf middleware with the default storage | Same — the token is unknown to the child that receives the form post | |
idempotency middleware, in-process caches, dedupe maps | Per child. Duplicate charges, duplicate sends | |
A cron/ticker started in main | Runs once per child. N duplicate jobs |
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/mir-backend-go-fiber/SKILL.md
Popularity
- Repository stars
- 15
- 7-day trend score
- 14
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/anantbhandarkar/make-it-right/mir-backend-go-fiber)