[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BQBVSPVTXPD6J3G321X7VC":3,"skill-same:01M7BQBVSPVTXPD6J3G321X7VC":55},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7BQBVSPVTXPD6J3G321X7VC","go-code",null,"Use when writing or fixing Go code (a behavior-preserving refactor routes to go-code-refactor), whether or not the task has one obvious topic — it loads the go-* skills the task needs and runs the closing gate. Also use when asked to implement a Go package, function, or handler whose declarations and documentation already exist — write the bodies, fill in a stub, replace panic(\"not implemented\") — even if the request names only the package. Use it too when \u002Fgo-code modifies another workflow (e.g. \u002Fopsx:apply \u002Fgo-code); as a modifier it selects Go rules, not a change name or path.","h0rn3t\u002Fgolang-skills","h0rn3t","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1213719?v=4","01M7BQBDJ8D4P5W7EQHBD464BX","Eugene Shershen","01M7BQBDJXMTCKNCEDKVEYDRGA",7,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: go-code\ndescription: Use when writing or fixing Go code (a behavior-preserving refactor routes to go-code-refactor), whether or not the task has one obvious topic — it loads the go-* skills the task needs and runs the closing gate. Also use when asked to implement a Go package, function, or handler whose declarations and documentation already exist — write the bodies, fill in a stub, replace panic(\"not implemented\") — even if the request names only the package. Use it too when \u002Fgo-code modifies another workflow (e.g. \u002Fopsx:apply \u002Fgo-code); as a modifier it selects Go rules, not a change name or path.\n---\n\n# Go Code Profile\n\nRoute Go work to the relevant owners, then close with their verification gate.\n\n> Compatibility: Baseline Go 1.27 (see [COMPATIBILITY.md](..\u002Fgo-style-core\u002Freferences\u002FCOMPATIBILITY.md)).\n\n## Resource Routing\n\nSibling skills resolve relative to this installed directory; scripts run from the target project. A skill is loaded when\nits `SKILL.md` is in context: the `Skill` tool where the host has one, else a read of `..\u002F\u003Cname>\u002FSKILL.md`. Report missing resources.\n\n- `..\u002Fgo-style-core\u002FSKILL.md` — Load on every task (step 2); it carries the idiom card, and its references are read only for a decision the task requires.\n- `..\u002Fgo-linting\u002FSKILL.md` — With a shell, load alongside go-style-core at step 2; its gate and receipt verifier close step 6.\n- `references\u002FINTENSITY.md` — Read when the prompt carries `lite` or `ultra` (`\u002Fgo-code ultra \u003Ctask>`, `ultra mode`): what each level changes.\n- `references\u002FNEW-CODE-EXAMPLES.md` — Read when the shape of a Contract Table case, Plain Code body, or budgeted helper is in doubt.\n- `..\u002Fgo-code-refactor\u002Freferences\u002FLADDER.md` — Read before the first edit on every task, unless `## The Restraint Ladder` is already in context (the plugin's session-start hook prints from that heading to the end of the file): step 5 climbs it for each added entity.\n- `..\u002Fgo-code-refactor\u002Freferences\u002FOVER-ENGINEERING.md` — Read its replacement table only when seeking a simpler existing API.\n\n## Workflow\n\n1. **Resolve invocation.** `$go-code \u003Ctask>` or `\u002Fgo-code \u003Ctask>` selects Go\n   work; a leading `lite`, `full`, or `ultra` sets the restraint level\n   ([INTENSITY.md](references\u002FINTENSITY.md)), not the task. An invocation inserts this file only; steps 2 and 3 load the\n   rest. As a modifier (`\u002Fopsx:apply add-auth \u002Fgo-code`) it is never a change\n   name or path, and the host keeps workflow state, checkpoints, and\n   delegation policy.\n2. **Load `go-style-core` and read the code.** With a shell, load `go-linting`\n   in the same initial Skill message. `go-style-core` carries the\n   idiom card. Then inspect repository instructions, `go.mod` (its `go`\n   directive sets the idiom), neighboring code and tests. Without a shell\n   tool, step 6 runs nothing and `go-linting` stays unread. A new function,\n   package, or stub body makes step 4 apply. A fix skips the table but adds\n   one case that fails on the code before it and passes after\n   ([go-troubleshooting](..\u002Fgo-troubleshooting\u002FSKILL.md#fix-and-regression-proof)),\n   so `go-testing` is loaded for it too; a restructuring skips both.\n3. **Load the owners before the first edit.** Match the task against\n   [Route Before The First Edit](#route-before-the-first-edit) and load each\n   matched owner plus every `Also load` entry whose condition holds, all in\n   one message. When step 4 applies or the task is a fix, `go-testing` is one of them. Select by the decisions being changed: a routine local\n   variable or `if` triggers no owner. No edit before every selected skill is\n   in context; add owners when new evidence requires them. Wait for successful\n   Skill results before the edit message; do not dispatch loads and edits together.\n4. **Write the Contract Table, for new code only.** Turn the documentation\n   and the request into the test file the [Contract Table](#contract-table)\n   describes before the first production edit: a case written after the body\n   checks only what the body already does. Its cases are what step 6 runs or\n   reads.\n5. **Implement the authorized scope.** Every task — new code, a fix, a\n   restructuring — climbs the restraint ladder in\n   [LADDER.md](..\u002Fgo-code-refactor\u002Freferences\u002FLADDER.md#the-restraint-ladder)\n   before each helper, type, layer, interface, option, or import it adds,\n   once per entity, and a fix lands at the root cause the ladder names. New\n   code takes the [Plain Code](#plain-code) form, counts every package-level\n   declaration that survives the ladder in the\n   [Declaration Budget](#declaration-budget), and gets the\n   [Delete Pass](#delete-pass) and [Reader Pass](#reader-pass) once its cases\n   pass. Restructuring follows the\n   [delete-first priority](..\u002Fgo-code-refactor\u002FSKILL.md#delete-before-you-restructure). Preserve\n   required behavior, validation, security controls, and meaningful tests. A\n   task that does not ask for a dependency adds none: `go.mod` stays as it\n   is, and a test compares with the standard library\n   ([go-testing](..\u002Fgo-testing\u002FSKILL.md#assertions-match-the-repository) owns\n   the assertion rule). Resolve routine choices without stopping; ask only\n   for missing information that changes correctness, scope, or authorization.\n6. **Verify and report.** With a shell, use the `go-linting` skill, in\n   context since step 2 — **load it now only if it is not** (`Skill` tool\n   with the router's namespace, otherwise read its `SKILL.md`) — select the\n   gate scope, then run the Contract Table file with that gate.\n   Hook receipts count only as [go-linting](..\u002Fgo-linting\u002FSKILL.md#verification-gate)\n   verifies them. Without a shell, read each case against its code path.\n   Report as [go-style-core](..\u002Fgo-style-core\u002FSKILL.md#how-much-to-say) says,\n   in this shape and order:\n\n   ```text\n   \u003Cwhat the change does, in one sentence>\n   checks: gofmt pass · build pass · vet pass · test -race pass · fix pass (2 pre-existing hunks) · lint pass · govulncheck skipped (no dependency change)\n   added package-level declarations: 1 — parseLimit: handleList, handleSearch\n   \u003Cone sentence per material gap, or nothing>\n   ```\n\n   Name the test file and result, not each case.\n\n## Route Before The First Edit\n\nThe third column adds its owners under the condition it states, and always\nwhere it states none. Prefer the\nnarrower owner when topics overlap; a local or unexported identifier alone\ndoes not require `go-naming` or `go-documentation`.\n\n| Task touches | Skill | Also load |\n|---|---|---|\n| errors, wrapping, `errors.Is`\u002F`errors.AsType` | [go-error-handling](..\u002Fgo-error-handling\u002FSKILL.md) | — |\n| goroutines, channels, mutexes, races, timers and tickers | [go-concurrency](..\u002Fgo-concurrency\u002FSKILL.md) | [go-context](..\u002Fgo-context\u002FSKILL.md) if anything is cancelled |\n| `context.Context`, timeouts, cancellation | [go-context](..\u002Fgo-context\u002FSKILL.md) | [go-concurrency](..\u002Fgo-concurrency\u002FSKILL.md) if goroutines are started |\n| tests, table-driven cases, `synctest` | [go-testing](..\u002Fgo-testing\u002FSKILL.md) | — |\n| API naming changes or a naming question | [go-naming](..\u002Fgo-naming\u002FSKILL.md) | — |\n| new or changed exported API, doc comments | [go-documentation](..\u002Fgo-documentation\u002FSKILL.md) | [go-naming](..\u002Fgo-naming\u002FSKILL.md) if API names change; [go-functions](..\u002Fgo-functions\u002FSKILL.md#changing-an-exported-api) if an existing exported signature, interface, or struct changes |\n| interfaces, embedding, test doubles, pointer vs value receivers | [go-interfaces](..\u002Fgo-interfaces\u002FSKILL.md) | — |\n| function API design, constructor configuration, ordering, signatures, `Printf` helpers | [go-functions](..\u002Fgo-functions\u002FSKILL.md) | — |\n| slices, maps, arrays, sets | [go-data-structures](..\u002Fgo-data-structures\u002FSKILL.md) | — |\n| declaration, enum, or initialization decisions | [go-style-core references](..\u002Fgo-style-core\u002FSKILL.md#resource-routing) | — |\n| loop\u002Fswitch mechanics or statement scoping decisions | [go-style-core references](..\u002Fgo-style-core\u002FSKILL.md#resource-routing) | — |\n| type parameters, constraints, generic methods | [go-generics](..\u002Fgo-generics\u002FSKILL.md) | — |\n| `slog`, log levels, request-scoped fields, metrics and trace correlation | [go-logging](..\u002Fgo-logging\u002FSKILL.md) | [go-security](..\u002Fgo-security\u002FSKILL.md) if a secret or PII could reach a log line |\n| panic\u002Frecover and `Must` helpers, a deferred closure or a written file's `Close`, boundary copies, mutable globals, nil\u002Faliasing\u002Foverflow traps, `time.Time`\u002F`Duration` values | [go-defensive](..\u002Fgo-defensive\u002FSKILL.md) | — |\n| a cache, hot paths, allocations, benchmarks | [go-performance](..\u002Fgo-performance\u002FSKILL.md) | [go-troubleshooting](..\u002Fgo-troubleshooting\u002FSKILL.md) if the cause of slowness is unknown |\n| package layout, imports, dependencies | [go-packages](..\u002Fgo-packages\u002FSKILL.md) | — |\n| restructuring or deleting existing code | [go-code-refactor](..\u002Fgo-code-refactor\u002FSKILL.md) | — |\n| linter config, CI checks | [go-linting](..\u002Fgo-linting\u002FSKILL.md) | — |\n| HTTP handlers, routing, middleware, servers, clients; gRPC services and clients | [go-http](..\u002Fgo-http\u002FSKILL.md) ([GRPC.md](..\u002Fgo-http\u002Freferences\u002FGRPC.md) for gRPC) | [go-security](..\u002Fgo-security\u002FSKILL.md) if input reaches a file, shell, URL, or template |\n| SQL queries, transactions, repositories, migrations | [go-database](..\u002Fgo-database\u002FSKILL.md) | [go-security](..\u002Fgo-security\u002FSKILL.md) if a request value picks a row by ID or names a column, table, or sort order |\n| untrusted input, secrets, tokens, TLS, cookies | [go-security](..\u002Fgo-security\u002FSKILL.md) | [go-defensive](..\u002Fgo-defensive\u002FSKILL.md) |\n| retries, idempotency, circuit breakers, overload, backpressure, fallback | [go-resilience](..\u002Fgo-resilience\u002FSKILL.md) | the HTTP, SQL, context, or concurrency owner when its mechanics change |\n| ticket, wrong result, environment regression, panic, hang, leak, flaky test; cause unknown | [go-troubleshooting](..\u002Fgo-troubleshooting\u002FSKILL.md) | the owner of the mechanism once found |\n| JSON and other wire formats, struct tags | [go-http](..\u002Fgo-http\u002FSKILL.md) ([JSON-V2.md](..\u002Fgo-http\u002Freferences\u002FJSON-V2.md)) | [go-defensive](..\u002Fgo-defensive\u002FSKILL.md) (tags) |\n| CLI entry point, flags, `main`\u002F`run` | [go-packages](..\u002Fgo-packages\u002FSKILL.md) | — |\n| a list of findings from a review or audit | the rows the findings name | per area, not per task |\n\n## Close With The Gate\n\nSelect checks with [go-linting](..\u002Fgo-linting\u002FSKILL.md#verification-gate) for\nthe requested scope; a repository gate replaces the defaults rather than\njoining them. Bundled scripts add evidence the gate lacks:\n\n- Error handling: `bash \u003Cinstalled-skill-dir>\u002F..\u002Fgo-error-handling\u002Fscripts\u002Fcheck-errors.sh .\u002F...`.\n- Exported API documentation: `bash \u003Cinstalled-skill-dir>\u002F..\u002Fgo-documentation\u002Fscripts\u002Fcheck-docs.sh --limit 30 \u003Cpath the task touched>`.\n- Before submitting: [go-code-review](..\u002Fgo-code-review\u002FSKILL.md).\n\n`\u003Cinstalled-skill-dir>` is the directory the host loaded this file from; each\ncommand runs from the project with that path written out, through `bash`: an\ninstall can drop the scripts' executable bit.\n\nRun routine checks inline. The report carries only results observed for the\ncurrent diff and scope, each as `pass`, `fail`, `unavailable (reason)`, or\n`skipped (reason)` per go-linting.\n\n## Writing New Code\n\nStart at the required entry point and its callers. Implement the documented\nsuccess and failure paths within the existing API; design a new API only when\nthe task calls for one. A stub's `panic(\"not implemented\")` is missing\nbehavior, not a refactor contract: replace it and satisfy the acceptance\ntests.\n\n### Contract Table\n\nBefore the first production edit, turn the documentation and the request into\na table-driven test in the package — a new `\u003Cpkg>_contract_test.go`, or cases\nadded to the existing test file — one case per observable clause of the\ndocumentation, not per branch of the body\n([go-testing](..\u002Fgo-testing\u002FSKILL.md#what-earns-a-test) says which cases earn\na place): each request or input class, each method and status code,\nordering, the error a caller matches and any error text the documentation\npromises, and the empty, nil, and invalid inputs; a clause that\nsays what the code must *not* do is a case too. The empty case is built from\nnil — a nil slice, a nil map, a request with no body — not from an empty\nliteral: `[]T{}` already has the shape the case is meant to prove, and\n`slices.Clone` of nil is nil. A case for a list that may come back empty\ncompares the body text with `[]` (`strings.TrimSpace(rec.Body.String())`),\nnever a decoded value:\n`json.Unmarshal` decodes `null` to a nil slice and `[]` to an empty one, both\nof length zero, and the case passes on the one body the contract forbids. A\nclause written as a class — \"any other method\", \"any other value\" — takes its\ncase from the member a library default treats unlike the rest: for \"any method\nother than `GET`\" that is one `HEAD` request per `GET` path, the health check\nincluded, since a `GET` pattern answers `HEAD` with 200 on its own.\n\nWhere a case contradicts a standard-library default — a nil slice encoding as\n`null`, a `GET` pattern answering `HEAD` with 200 — the contract wins, and the\ndefault is overridden in code rather than explained in prose. A failing or\nunrunnable case is reported as such, never deleted or weakened to pass; an\nexpectation that turns out wrong is corrected against the documentation, not\nagainst the implementation. The file is plain code too: one case struct, one\ntable, one `t.Run` loop, and a failure message in the `Func(input) = got, want`\nform; [go-testing](..\u002Fgo-testing\u002FSKILL.md) owns the table-test form, and\n[NEW-CODE-EXAMPLES.md](references\u002FNEW-CODE-EXAMPLES.md) shows a worked table.\n\n### Plain Code\n\nThe body reads as the documentation reads: reject invalid states early\n([the early return](..\u002Fgo-style-core\u002FSKILL.md#reduce-nesting)), then do the\nmain work in its natural order. Return directly when that makes the\nresult clear; do not introduce a result variable to enforce one final return.\nThis applies to the entry point, anything it calls, and the contract test.\n\n- **Vocabulary from the specification.** The doc comment's nouns name the\n  variables.\n- **Smallest scope that works.** A document built in one function is an\n  anonymous struct or a type declared inside that function; a step done once\n  is inline unless it sits at another level of abstraction\n  ([Declaration Budget](#declaration-budget) rule 4); an error carrying\n  context is `fmt.Errorf(\"op %q: %w\", key, err)`, matched by the caller with\n  `errors.Is`.\n- **Names that explain, states that stay.** An intermediate value gets a name\n  when its expression nests deeper than one call or the name says what the\n  expression does not; otherwise it is written where it is used. A fact the\n  code tracks — what was already asked for, what was sent, what failed —\n  keeps its own variable even when another one almost holds it.\n- **Use a standard-library operation when it states the intent more clearly**\n  (the idiom card lists them); a loop that tracks several related facts may\n  read better as a loop. Check ordering, ownership, and nil-versus-empty\n  results. [Reach For What Go Ships](..\u002Fgo-code-refactor\u002Freferences\u002FOVER-ENGINEERING.md#reach-for-what-go-ships)\n  lists replacements; [go-data-structures](..\u002Fgo-data-structures\u002FSKILL.md)\n  owns collection semantics.\n- **New JSON is `encoding\u002Fjson\u002Fv2`.** A package with no `encoding\u002Fjson` import writes\n  `import json \"encoding\u002Fjson\u002Fv2\"` (Go 1.27) and no `make([]T, 0, n)` for the wire; one on v1 keeps v1.\n  [JSON-V2.md](..\u002Fgo-http\u002Freferences\u002FJSON-V2.md#defaults-that-can-change-the-contract) owns what each writes for nil.\n- **Neighbors set the register.** Where the package has code, match its\n  naming and comment density ([House Style](..\u002Fgo-style-core\u002FSKILL.md#house-style-wins)).\n  Not its Go version: the current form at the module's `go` directive is\n  written even beside an older neighbor\n  ([Write Current Go](..\u002Fgo-style-core\u002FSKILL.md#write-current-go)).\n\n[NEW-CODE-EXAMPLES.md](references\u002FNEW-CODE-EXAMPLES.md) carries a whole\ndocumented JSON document in this form.\n\n### Delete Pass\n\nWhen the Contract Table passes, walk the diff once, top to bottom, and delete\nwhat the test already proves or the code already shows. Each item below is a\nline a reviewer sends back:\n\n- A comment that narrates the next line or repeats what the code already\n  shows. A comment giving a reason the code cannot show stays\n  ([go-style-core](..\u002Fgo-style-core\u002FSKILL.md#formatting) owns comments), and\n  a shortcut taken with a known limit — a global lock, an O(n²) scan — says\n  so in a `Kept:` \u002F `Ceiling:` \u002F `Fix:` marker\n  ([go-code-refactor](..\u002Fgo-code-refactor\u002Freferences\u002FPLAYBOOK.md#10-mark-what-you-deliberately-left-alone)).\n- A name used once that explains nothing, and the variable it fills: the\n  value is written where it is used. A name that passes the Plain Code test\n  stays.\n- A field, header, or option set to what the library uses when it is\n  absent: `MaxHeaderBytes: 1 \u003C\u003C 20` is `http.DefaultMaxHeaderBytes`,\n  `Content-Type: text\u002Fplain; charset=utf-8` before `w.Write([]byte(\"ok\"))` is\n  what the writer sniffs for a body the code fixes — a body that carries\n  input keeps its `Content-Type` ([go-security](..\u002Fgo-security\u002FSKILL.md)) —\n  and `false`, `0`, `nil`, or `\"\"` in a keyed literal is the zero value. The\n  line says nothing its absence does not.\n- A `fmt.Errorf` wrap that only restates the call: `return json.Marshal(doc)`.\n  The failure branch stays, since `json.Marshal` fails on input (invalid\n  UTF-8 or a `time.Duration` under v2, NaN under v1) and a handler keeps its\n  500; a branch on a call documented never to fail — `(*bytes.Buffer).Write`,\n  `(*strings.Builder).WriteString`, `hash.Hash.Write` — goes. A write whose\n  error has nowhere to go is discarded in the open, `_, _ = w.Write(body)`\n  with its reason, never bare: `errcheck` in the gate reads a bare call as a\n  finding, and the reason on that line is not a comment to delete.\n- A doc comment on an unexported helper beyond one line;\n  [go-documentation](..\u002Fgo-documentation\u002FSKILL.md) owns the exported ones.\n\nThe pass runs behind the test, never ahead of it: a line a case needs stays,\nand validation at a trust boundary, failure behavior, and security controls\nare not deleted for a smaller diff. Rerun or reread the cases after it.\n\n### Reader Pass\n\nRead the changed path from its entry point to its result or side effect. Can a\nreader find the main decision, error exits, and state the code tracks without\nchasing wrappers that only rename an operation? Keep a one-use name when it\nexposes a meaningful boundary or state; keep a helper when it hides details\nthat obscure the caller's decision. If either adds a jump without answering a\nreader's question, inline it and run the cases again.\n\n### Declaration Budget\n\nThe specification already declares what the task needs: a body behind an\nexisting signature adds no package-level declaration by default, and the count\nof those it does add is what the report carries. Count every function, method,\ntype, interface, and variable added at package level in production code across\nthe whole diff; [go-testing](..\u002Fgo-testing\u002FSKILL.md) owns test helpers. A\ndeclaration is written when the code shows the need at the moment it is\nwritten:\n\n1. Two call sites exist in the diff, and the report names both.\n2. A caller outside the function names it: it reads a field through\n   `errors.AsType`, satisfies an interface a consumer declares\n   ([go-interfaces](..\u002Fgo-interfaces\u002FSKILL.md) owns the shape), or owns a\n   resource whose lifetime outlives one call. A caller that *inspects* or\n   *matches* an error reads no field: it uses `errors.Is` on the wrapped\n   sentinel, and that needs no type.\n3. It is a distinct algorithm — a parser, a scheduler — whose name at the\n   call site says more than its body would, and the body left behind reads\n   top to bottom without it.\n4. It is a step at another level of abstraction than the rest of the\n   function — building SQL beside the domain rule — even with one call site;\n   the report names its caller and this rule. A helper whose name only\n   restates two or three lines of its body is not such a step: those lines\n   stay inline. In multi-step business rules the parse, the pure match, and\n   the interval arithmetic are such steps ([Business Rules](#business-rules)).\n\nA function literal bound to a name that captures nothing from the function\naround it counts under the same four rules: the count is a record, not a\nscore, and hiding a helper inside a function changes the number without\nchanging the code. A closure is for capturing state, and a handler registered\nonce is written at its registration; the values routes share are locals of\nthe constructor that the handler literals capture, not fields of a `server`\ntype with one method per route.\n\nA representation is a value, not a reason: a wire document, a formatted error,\nand a sorted view take the [Plain Code](#plain-code) form. A helper that names\na step at its caller's own level of abstraction meets none of the four; write\nthe step inline.\nThe named helpers in skill examples (`validate`, `writeJSON`, `writeError`)\nshow the order of an operation, not a list to reproduce.\n\nThe budget counts what survives the restraint ladder in\n[LADDER.md](..\u002Fgo-code-refactor\u002Freferences\u002FLADDER.md#the-restraint-ladder),\nclimbed per declaration before the four rules are checked.\n\nThe report carries one line — `added package-level declarations: N` — and,\nfor each, its name and the call sites or caller that need it. A declaration\nwhose line cannot name them is removed before the report is written, not\nexplained in it.\n\n### Business Rules\n\nCode that carries multi-step business rules — intervals, history or snapshot\nprocessing, reconciling against a set of properties, branching on mode or\nrole — is written as a chain, new or refactored; plain CRUD and glue code are\nexempt.\n\n- **The entry point is the chain.** Each step's result is a named value the\n  next step takes: `a := step1()`, `b := step2(a)`, `c := step3(a, b)`. The\n  whole algorithm and its key branches read in that function or one level\n  below it. A struct holding the call's dependencies (`ctx`, `tx`, the input)\n  may carry the steps as methods; a fluent chain that passes intermediate\n  results through struct fields hides the data flow and is not written.\n- **Effects at the top, logic below.** Deep functions return data; writes and\n  external calls happen in the entry point or a step of its chain. Lifting an\n  effect keeps the order and count of writes\n  ([BEHAVIOR-TRAPS.md](..\u002Fgo-code-refactor\u002Freferences\u002FBEHAVIOR-TRAPS.md#pre-commit-checklist)).\n- **Untyped data is parsed once.** A map, a JSON document, or a database row\n  becomes a typed struct in one place, which returns the parse error; the\n  decisions and comparisons after it are pure functions with no `error`\n  result. Checking the value types and converting them is that one pass, not\n  a validation loop followed by a second `switch v.(type)` in the matcher:\n  the matcher takes the typed struct, never the `map[string]any`, and holds\n  no type switch or assertion.\n- **A step earns its function** by the [Declaration Budget](#declaration-budget):\n  a step of the entry point's chain, or a pure step below it, is rule 4's\n  other level of abstraction even with one call site. Three steps are named\n  here because a body written behind one signature folds them in: the parse\n  of untyped data into its typed struct, the pure match or decision on that\n  struct, and the interval or set arithmetic. Each is a package-level\n  function, not a closure inside the entry point. The entry point keeps the\n  step names, the branches, and the writes, and stays within about 40 lines. Any other\n  wrapper around one expression or one error check is inlined. Its name says what the\n  step means in the domain, not the library call behind it: verb-like for an\n  action or a predicate (`subtract`, `matches`), noun-like for a value it\n  returns (`processingInterval`); `leftDifferences` names the mechanism and\n  `processReminder` names nothing\n  ([go-naming](..\u002Fgo-naming\u002Freferences\u002FIDENTIFIERS.md#naming-conventions)\n  owns the conventions).\n- **Leave complexity headroom.** Before a function grows or two merge, read the\n  service's complexity linters in its golangci config (`gocyclo`, `gocognit`,\n  `funlen`, `nestif`) and stay clear of their limits, not at them.\n\nA fragment of an entry point in that shape; `b` holds only the dependencies,\n`bindCombination` writes by snapshot and returns what it left uncovered, and\ninside it `readSnapshot` parses each snapshot once so `matches` stays pure:\n\n```go\n\tinterval, ok, err := b.processingInterval()\n\tif err != nil || !ok {\n\t\treturn false, err\n\t}\n\tsnapshots, err := b.loadSnapshots(interval)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tremainders, err := b.bindCombination(interval, snapshots)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tif !data.Bind {\n\t\treturn true, nil \u002F\u002F unbind leaves values outside the combination alone\n\t}\n\tfor _, r := range remainders {\n\t\tif err := b.clear(r); err != nil {\n\t\t\treturn false, err\n\t\t}\n\t}\n\treturn true, nil\n```\n\n## Related Skills\n\n- Every owner in [Route Before The First Edit](#route-before-the-first-edit).\n- [go-style-core](..\u002Fgo-style-core\u002FSKILL.md): house style, report length, and delegation.\n- [go-linting](..\u002Fgo-linting\u002FSKILL.md): the closing gate.\n- [go-code-review](..\u002Fgo-code-review\u002FSKILL.md): the checklist before submitting.\n","# Go Code Profile\n\nRoute Go work to the relevant owners, then close with their verification gate.\n\n> Compatibility: Baseline Go 1.27 (see [COMPATIBILITY.md](..\u002Fgo-style-core\u002Freferences\u002FCOMPATIBILITY.md)).\n\n## Resource Routing\n\nSibling skills resolve relative to this installed directory; scripts run from the target project. A skill is loaded when\nits `SKILL.md` is in context: the `Skill` tool where the host has one, else a read of `..\u002F\u003Cname>\u002FSKILL.md`. Report missing resources.\n\n- `..\u002Fgo-style-core\u002FSKILL.md` — Load on every task (step 2); it carries the idiom card, and its references are read only for a decision the task requires.\n- `..\u002Fgo-linting\u002FSKILL.md` — With a shell, load alongside go-style-core at step 2; its gate and receipt verifier close step 6.\n- `references\u002FINTENSITY.md` — Read when the prompt carries `lite` or `ultra` (`\u002Fgo-code ultra \u003Ctask>`, `ultra mode`): what each level changes.\n- `references\u002FNEW-CODE-EXAMPLES.md` — Read when the shape of a Contract Table case, Plain Code body, or budgeted helper is in doubt.\n- `..\u002Fgo-code-refactor\u002Freferences\u002FLADDER.md` — Read before the first edit on every task, unless `## The Restraint Ladder` is already in context (the plugin's session-start hook prints from that heading to the end of the file): step 5 climbs it for each added entity.\n- `..\u002Fgo-code-refactor\u002Freferences\u002FOVER-ENGINEERING.md` — Read its replacement table only when seeking a simpler existing API.\n\n## Workflow\n\n1. **Resolve invocation.** `$go-code \u003Ctask>` or `\u002Fgo-code \u003Ctask>` selects Go\n   work; a leading `lite`, `full`, or `ultra` sets the restraint level\n   ([INTENSITY.md](references\u002FINTENSITY.md)), not the task. An invocation inserts this file only; steps 2 and 3 load the\n   rest. As a modifier (`\u002Fopsx:apply add-auth \u002Fgo-code`) it is never a change\n   name or path, and the host keeps workflow state, checkpoints, and\n   delegation policy.\n2. **Load `go-style-core` and read the code.** With a shell, load `go-linting`\n   in the same initial Skill message. `go-style-core` carries the\n   idiom card. Then inspect repository instructions, `go.mod` (its `go`\n   directive sets the idiom), neighboring code and tests. Without a shell\n   tool, step 6 runs nothing and `go-linting` stays unread. A new function,\n   package, or stub body makes step 4 apply. A fix skips the table but adds\n   one case that fails on the code before it and passes after\n   ([go-troubleshooting](..\u002Fgo-troubleshooting\u002FSKILL.md#fix-and-regression-proof)),\n   so `go-testing` is loaded for it too; a restructuring skips both.\n3. **Load the owners before the first edit.** Match the task against\n   [Route Before The First Edit](#route-before-the-first-edit) and load each\n   matched owner plus every `Also load` entry whose condition holds, all in\n   one message. When step 4 applies or the task is a fix, `go-testing` is one of them. Select by the decisions being changed: a routine local\n   variable or `if` triggers no owner. No edit before every selected skill is\n   in context; add owners when new evidence requires them. Wait for successful\n   Skill results before the edit message; do not dispatch loads and edits together.\n4. **Write the Contract Table, for new code only.** Turn the documentation\n   and the request into the test file the [Contract Table](#contract-table)\n   describes before the first production edit: a case written after the body\n   checks only what the body already does. Its cases are what step 6 runs or\n   reads.\n5. **Implement the authorized scope.** Every task — new code, a fix, a\n   restructuring — climbs the restraint ladder in\n   [LADDER.md](..\u002Fgo-code-refactor\u002Freferences\u002FLADDER.md#the-restraint-ladder)\n   before each helper, type, layer, interface, option, or import it adds,\n   once per entity, and a fix lands at the root cause the ladder names. New\n   code takes the [Plain Code](#plain-code) form, counts every package-level\n   declaration that survives the ladder in the\n   [Declaration Budget](#declaration-budget), and gets the\n   [Delete Pass](#delete-pass) and [Reader Pass](#reader-pass) once its cases\n   pass. Restructuring follows the\n   [delete-first priority](..\u002Fgo-code-refactor\u002FSKILL.md#delete-before-you-restructure). Preserve\n   required behavior, validation, security controls, and meaningful tests. A\n   task that does not ask for a dependency adds none: `go.mod` stays as it\n   is, and a test compares with the standard library\n   ([go-testing](..\u002Fgo-testing\u002FSKILL.md#assertions-match-the-repository) owns\n   the assertion rule). Resolve routine choices without stopping; ask only\n   for missing information that changes correctness, scope, or authorization.\n6. **Verify and report.** With a shell, use the `go-linting` skill, in\n   context since step 2 — **load it now only if it is not** (`Skill` tool\n   with the router's namespace, otherwise read its `SKILL.md`) — select the\n   gate scope, then run the Contract Table file with that gate.\n   Hook receipts count only as [go-linting](..\u002Fgo-linting\u002FSKILL.md#verification-gate)\n   verifies them. Without a shell, read each case against its code path.\n   Report as [go-style-core](..\u002Fgo-style-core\u002FSKILL.md#how-much-to-say) says,\n   in this shape and order:\n\n   ```text\n   \u003Cwhat the change does, in one sentence>\n   checks: gofmt pass · build pass · vet pass · test -race pass · fix pass (2 pre-existing hunks) · lint pass · govulncheck skipped (no dependency change)\n   added package-level declarations: 1 — parseLimit: handleList, handleSearch\n   \u003Cone sentence per material gap, or nothing>\n   ```\n\n   Name the test file and result, not each case.\n\n## Route Before The First Edit\n\nThe third column adds its owners under the condition it states, and always\nwhere it states none. Prefer the\nnarrower owner when topics overlap; a local or unexported identifier alone\ndoes not require `go-naming` or `go-documentation`.\n\n| Task touches | Skill | Also load |\n|---|---|---|\n| errors, wrapping, `errors.Is`\u002F`errors.AsType` | [go-error-handling](..\u002Fgo-error-handling\u002FSKILL.md) | — |\n| goroutines, channels, mutexes, races, timers and tickers | [go-concurrency](..\u002Fgo-concurrency\u002FSKILL.md) | [go-context](..\u002Fgo-context\u002FSKILL.md) if anything is cancelled |\n| `context.Context`, timeouts, cancellation | [go-context](..\u002Fgo-context\u002FSKILL.md) | [go-concurrency](..\u002Fgo-concurrency\u002FSKILL.md) if goroutines are started |\n| tests, table-driven cases, `synctest` | [go-testing](..\u002Fgo-testing\u002FSKILL.md) | — |\n| API naming changes or a naming question | [go-naming](..\u002Fgo-naming\u002FSKILL.md) | — |\n| new or changed exported API, doc comments | [go-documentation](..\u002Fgo-documentation\u002FSKILL.md) | [go-naming](..\u002Fgo-naming\u002FSKILL.md) if API names change; [go-functions](..\u002Fgo-functions\u002FSKILL.md#changing-an-exported-api) if an existing exported signature, interface, or struct changes |\n| interfaces, embedding, test doubles, pointer vs value receivers | [go-interfaces](..\u002Fgo-interfaces\u002FSKILL.md) | — |\n| function API design, constructor configuration, ordering, signatures, `Printf` helpers | [go-functions](..\u002Fgo-functions\u002FSKILL.md) | — |\n| slices, maps, arrays, sets | [go-data-structures](..\u002Fgo-data-structures\u002FSKILL.md) | — |\n| declaration, enum, or initialization decisions | [go-style-core references](..\u002Fgo-style-core\u002FSKILL.md#resource-routing) | — |\n| loop\u002Fswitch mechanics or statement scoping decisions | [go-style-core references](..\u002Fgo-style-core\u002FSKILL.md#resource-routing) | — |\n| type parameters, constraints, generic methods | [go-generics](..\u002Fgo-generics\u002FSKILL.md) | — |\n| `slog`, log levels, request-scoped fields, metrics and trace correlation | [go-logging](..\u002Fgo-logging\u002FSKILL.md) | [go-security](..\u002Fgo-security\u002FSKILL.md) if a secret or PII could reach a log line |\n| panic\u002Frecover and `Must` helpers, a deferred closure or a written file's `Close`, boundary copies, mutable globals, nil\u002Faliasing\u002Foverflow traps, `time.Time`\u002F`Duration` values | [go-defensive](..\u002Fgo-defensive\u002FSKILL.md) | — |\n| a cache, hot paths, allocations, benchmarks | [go-performance](..\u002Fgo-performance\u002FSKILL.md) | [go-troubleshooting](..\u002Fgo-troubleshooting\u002FSKILL.md) if the cause of slowness is unknown |\n| package layout, imports, dependencies | [go-packages](..\u002Fgo-packages\u002FSKILL.md) | — |\n| restructuring or deleting existing code | [go-code-refactor](..\u002Fgo-code-refactor\u002FSKILL.md) | — |\n| linter config, CI checks | [go-linting](..\u002Fgo-linting\u002FSKILL.md) | — |\n| HTTP handlers, routing, middleware, servers, clients; gRPC services and clients | [go-http](..\u002Fgo-http\u002FSKILL.md) ([GRPC.md](..\u002Fgo-http\u002Freferences\u002FGRPC.md) for gRPC) | [go-security](..\u002Fgo-security\u002FSKILL.md) if input reaches a file, shell, URL, or template |\n| SQL queries, transactions, repositories, migrations | [go-database](..\u002Fgo-database\u002FSKILL.md) | [go-security](..\u002Fgo-security\u002FSKILL.md) if a request value picks a row by ID or names a column, table, or sort order |\n| untrusted input, secrets, tokens, TLS, cookies | [go-security](..\u002Fgo-security\u002FSKILL.md) | [go-defensive](..\u002Fgo-defensive\u002FSKILL.md) |\n| retries, idempotency, circuit breakers, overload, backpressure, fallback | [go-resilience](..\u002Fgo-resilience\u002FSKILL.md) | the HTTP, SQL, context, or concurrency owner when its mechanics change |\n| ticket, wrong result, environment regression, panic, hang, leak, flaky test; cause unknown | [go-troubleshooting](..\u002Fgo-troubleshooting\u002FSKILL.md) | the owner of the mechanism once found |\n| JSON and other wire formats, struct tags | [go-http](..\u002Fgo-http\u002FSKILL.md) ([JSON-V2.md](..\u002Fgo-http\u002Freferences\u002FJSON-V2.md)) | [go-defensive](..\u002Fgo-defensive\u002FSKILL.md) (tags) |\n| CLI entry point, flags, `main`\u002F`run` | [go-packages](..\u002Fgo-packages\u002FSKILL.md) | — |\n| a list of findings from a review or audit | the rows the findings name | per area, not per task |\n\n## Close With The Gate\n\nSelect checks with [go-linting](..\u002Fgo-linting\u002FSKILL.md#verification-gate) for\nthe requested scope; a repository gate replaces the defaults rather than\njoining them. Bundled scripts add evidence the gate lacks:\n\n- Error handling: `bash \u003Cinstalled-skill-dir>\u002F..\u002Fgo-error-handling\u002Fscripts\u002Fcheck-errors.sh .\u002F...`.\n- Exported API documentation: `bash \u003Cinstalled-skill-dir>\u002F..\u002Fgo-documentation\u002Fscripts\u002Fcheck-docs.sh --limit 30 \u003Cpath the task touched>`.\n- Before submitting: [go-code-review](..\u002Fgo-code-review\u002FSKILL.md).\n\n`\u003Cinstalled-skill-dir>` is the directory the host loaded this file from; each\ncommand runs from the project with that path written out, through `bash`: an\ninstall can drop the scripts' executable bit.\n\nRun routine checks inline. The report carries only results observed for the\ncurrent diff and scope, each as `pass`, `fail`, `unavailable (reason)`, or\n`skipped (reason)` per go-linting.\n\n## Writing New Code\n\nStart at the required entry point and its callers. Implement the documented\nsuccess and failure paths within the existing API; design a new API only when\nthe task calls for one. A stub's `panic(\"not implemented\")` is missing\nbehavior, not a refactor contract: replace it and satisfy the acceptance\ntests.\n\n### Contract Table\n\nBefore the first production edit, turn the documentation and the request into\na table-driven test in the package — a new `\u003Cpkg>_contract_test.go`, or cases\nadded to the existing test file — one case per observable clause of the\ndocumentation, not per branch of the body\n([go-testing](..\u002Fgo-testing\u002FSKILL.md#what-earns-a-test) says which cases earn\na place): each request or input class, each method and status code,\nordering, the error a caller matches and any error text the documentation\npromises, and the empty, nil, and invalid inputs; a clause that\nsays what the code must *not* do is a case too. The empty case is built from\nnil — a nil slice, a nil map, a request with no body — not from an empty\nliteral: `[]T{}` already has the shape the case is meant to prove, and\n`slices.Clone` of nil is nil. A case for a list that may come back empty\ncompares the body text with `[]` (`strings.TrimSpace(rec.Body.String())`),\nnever a decoded value:\n`json.Unmarshal` decodes `null` to a nil slice and `[]` to an empty one, both\nof length zero, and the case passes on the one body the contract forbids. A\nclause written as a class — \"any other method\", \"any other value\" — takes its\ncase from the member a library default treats unlike the rest: for \"any method\nother than `GET`\" that is one `HEAD` request per `GET` path, the health check\nincluded, since a `GET` pattern answers `HEAD` with 200 on its own.\n\nWhere a case contradicts a standard-library default — a nil slice encoding as\n`null`, a `GET` pattern answering `HEAD` with 200 — the contract wins, and the\ndefault is overridden in code rather than explained in prose. A failing or\nunrunnable case is reported as such, never deleted or weakened to pass; an\nexpectation that turns out wrong is corrected against the documentation, not\nagainst the implementation. The file is plain code too: one case struct, one\ntable, one `t.Run` loop, and a failure message in the `Func(input) = got, want`\nform; [go-testing](..\u002Fgo-testing\u002FSKILL.md) owns the table-test form, and\n[NEW-CODE-EXAMPLES.md](references\u002FNEW-CODE-EXAMPLES.md) shows a worked table.\n\n### Plain Code\n\nThe body reads as the documentation reads: reject invalid states early\n([the early return](..\u002Fgo-style-core\u002FSKILL.md#reduce-nesting)), then do the\nmain work in its natural order. Return directly when that makes the\nresult clear; do not introduce a result variable to enforce one final return.\nThis applies to the entry point, anything it calls, and the contract test.\n\n- **Vocabulary from the specification.** The doc comment's nouns name the\n  variables.\n- **Smallest scope that works.** A document built in one function is an\n  anonymous struct or a type declared inside that function; a step done once\n  is inline unless it sits at another level of abstraction\n  ([Declaration Budget](#declaration-budget) rule 4); an error carrying\n  context is `fmt.Errorf(\"op %q: %w\", key, err)`, matched by the caller with\n  `errors.Is`.\n- **Names that explain, states that stay.** An intermediate value gets a name\n  when its expression nests deeper than one call or the name says what the\n  expression does not; otherwise it is written where it is used. A fact the\n  code tracks — what was already asked for, what was sent, what failed —\n  keeps its own variable even when another one almost holds it.\n- **Use a standard-library operation when it states the intent more clearly**\n  (the idiom card lists them); a loop that tracks several related facts may\n  read better as a loop. Check ordering, ownership, and nil-versus-empty\n  results. [Reach For What Go Ships](..\u002Fgo-code-refactor\u002Freferences\u002FOVER-ENGINEERING.md#reach-for-what-go-ships)\n  lists replacements; [go-data-structures](..\u002Fgo-data-structures\u002FSKILL.md)\n  owns collection semantics.\n- **New JSON is `encoding\u002Fjson\u002Fv2`.** A package with no `encoding\u002Fjson` import writes\n  `import json \"encoding\u002Fjson\u002Fv2\"` (Go 1.27) and no `make([]T, 0, n)` for the wire; one on v1 keeps v1.\n  [JSON-V2.md](..\u002Fgo-http\u002Freferences\u002FJSON-V2.md#defaults-that-can-change-the-contract) owns what each writes for nil.\n- **Neighbors set the register.** Where the package has code, match its\n  naming and comment density ([House Style](..\u002Fgo-style-core\u002FSKILL.md#house-style-wins)).\n  Not its Go version: the current form at the module's `go` directive is\n  written even beside an older neighbor\n  ([Write Current Go](..\u002Fgo-style-core\u002FSKILL.md#write-current-go)).\n\n[NEW-CODE-EXAMPLES.md](references\u002FNEW-CODE-EXAMPLES.md) carries a whole\ndocumented JSON document in this form.\n\n### Delete Pass\n\nWhen the Contract Table passes, walk the diff once, top to bottom, and delete\nwhat the test already proves or the code already shows. Each item below is a\nline a reviewer sends back:\n\n- A comment that narrates the next line or repeats what the code already\n  shows. A comment giving a reason the code cannot show stays\n  ([go-style-core](..\u002Fgo-style-core\u002FSKILL.md#formatting) owns comments), and\n  a shortcut taken with a known limit — a global lock, an O(n²) scan — says\n  so in a `Kept:` \u002F `Ceiling:` \u002F `Fix:` marker\n  ([go-code-refactor](..\u002Fgo-code-refactor\u002Freferences\u002FPLAYBOOK.md#10-mark-what-you-deliberately-left-alone)).\n- A name used once that explains nothing, and the variable it fills: the\n  value is written where it is used. A name that passes the Plain Code test\n  stays.\n- A field, header, or option set to what the library uses when it is\n  absent: `MaxHeaderBytes: 1 \u003C\u003C 20` is `http.DefaultMaxHeaderBytes`,\n  `Content-Type: text\u002Fplain; charset=utf-8` before `w.Write([]byte(\"ok\"))` is\n  what the writer sniffs for a body the code fixes — a body that carries\n  input keeps its `Content-Type` ([go-security](..\u002Fgo-security\u002FSKILL.md)) —\n  and `false`, `0`, `nil`, or `\"\"` in a keyed literal is the zero value. The\n  line says nothing its absence does not.\n- A `fmt.Errorf` wrap that only restates the call: `return json.Marshal(doc)`.\n  The failure branch stays, since `json.Marshal` fails on input (invalid\n  UTF-8 or a `time.Duration` under v2, NaN under v1) and a handler keeps its\n  500; a branch on a call documented never to fail — `(*bytes.Buffer).Write`,\n  `(*strings.Builder).WriteString`, `hash.Hash.Write` — goes. A write whose\n  error has nowhere to go is discarded in the open, `_, _ = w.Write(body)`\n  with its reason, never bare: `errcheck` in the gate reads a bare call as a\n  finding, and the reason on that line is not a comment to delete.\n- A doc comment on an unexported helper beyond one line;\n  [go-documentation](..\u002Fgo-documentation\u002FSKILL.md) owns the exported ones.\n\nThe pass runs behind the test, never ahead of it: a line a case needs stays,\nand validation at a trust boundary, failure behavior, and security controls\nare not deleted for a smaller diff. Rerun or reread the cases after it.\n\n### Reader Pass\n\nRead the changed path from its entry point to its result or side effect. Can a\nreader find the main decision, error exits, and state the code tracks without\nchasing wrappers that only rename an operation? Keep a one-use name when it\nexposes a meaningful boundary or state; keep a helper when it hides details\nthat obscure the caller's decision. If either adds a jump without answering a\nreader's question, inline it and run the cases again.\n\n### Declaration Budget\n\nThe specification already declares what the task needs: a body behind an\nexisting signature adds no package-level declaration by default, and the count\nof those it does add is what the report carries. Count every function, method,\ntype, interface, and variable added at package level in production code across\nthe whole diff; [go-testing](..\u002Fgo-testing\u002FSKILL.md) owns test helpers. A\ndeclaration is written when the code shows the need at the moment it is\nwritten:\n\n1. Two call sites exist in the diff, and the report names both.\n2. A caller outside the function names it: it reads a field through\n   `errors.AsType`, satisfies an interface a consumer declares\n   ([go-interfaces](..\u002Fgo-interfaces\u002FSKILL.md) owns the shape), or owns a\n   resource whose lifetime outlives one call. A caller that *inspects* or\n   *matches* an error reads no field: it uses `errors.Is` on the wrapped\n   sentinel, and that needs no type.\n3. It is a distinct algorithm — a parser, a scheduler — whose name at the\n   call site says more than its body would, and the body left behind reads\n   top to bottom without it.\n4. It is a step at another level of abstraction than the rest of the\n   function — building SQL beside the domain rule — even with one call site;\n   the report names its caller and this rule. A helper whose name only\n   restates two or three lines of its body is not such a step: those lines\n   stay inline. In multi-step business rules the parse, the pure match, and\n   the interval arithmetic are such steps ([Business Rules](#business-rules)).\n\nA function literal bound to a name that captures nothing from the function\naround it counts under the same four rules: the count is a record, not a\nscore, and hiding a helper inside a function changes the number without\nchanging the code. A closure is for capturing state, and a handler registered\nonce is written at its registration; the values routes share are locals of\nthe constructor that the handler literals capture, not fields of a `server`\ntype with one method per route.\n\nA representation is a value, not a reason: a wire document, a formatted error,\nand a sorted view take the [Plain Code](#plain-code) form. A helper that names\na step at its caller's own level of abstraction meets none of the four; write\nthe step inline.\nThe named helpers in skill examples (`validate`, `writeJSON`, `writeError`)\nshow the order of an operation, not a list to reproduce.\n\nThe budget counts what survives the restraint ladder in\n[LADDER.md](..\u002Fgo-code-refactor\u002Freferences\u002FLADDER.md#the-restraint-ladder),\nclimbed per declaration before the four rules are checked.\n\nThe report carries one line — `added package-level declarations: N` — and,\nfor each, its name and the call sites or caller that need it. A declaration\nwhose line cannot name them is removed before the report is written, not\nexplained in it.\n\n### Business Rules\n\nCode that carries multi-step business rules — intervals, history or snapshot\nprocessing, reconciling against a set of properties, branching on mode or\nrole — is written as a chain, new or refactored; plain CRUD and glue code are\nexempt.\n\n- **The entry point is the chain.** Each step's result is a named value the\n  next step takes: `a := step1()`, `b := step2(a)`, `c := step3(a, b)`. The\n  whole algorithm and its key branches read in that function or one level\n  below it. A struct holding the call's dependencies (`ctx`, `tx`, the input)\n  may carry the steps as methods; a fluent chain that passes intermediate\n  results through struct fields hides the data flow and is not written.\n- **Effects at the top, logic below.** Deep functions return data; writes and\n  external calls happen in the entry point or a step of its chain. Lifting an\n  effect keeps the order and count of writes\n  ([BEHAVIOR-TRAPS.md](..\u002Fgo-code-refactor\u002Freferences\u002FBEHAVIOR-TRAPS.md#pre-commit-checklist)).\n- **Untyped data is parsed once.** A map, a JSON document, or a database row\n  becomes a typed struct in one place, which returns the parse error; the\n  decisions and comparisons after it are pure functions with no `error`\n  result. Checking the value types and converting them is that one pass, not\n  a validation loop followed by a second `switch v.(type)` in the matcher:\n  the matcher takes the typed struct, never the `map[string]any`, and holds\n  no type switch or assertion.\n- **A step earns its function** by the [Declaration Budget](#declaration-budget):\n  a step of the entry point's chain, or a pure step below it, is rule 4's\n  other level of abstraction even with one call site. Three steps are named\n  here because a body written behind one signature folds them in: the parse\n  of untyped data into its typed struct, the pure match or decision on that\n  struct, and the interval or set arithmetic. Each is a package-level\n  function, not a closure inside the entry point. The entry point keeps the\n  step names, the branches, and the writes, and stays within about 40 lines. Any other\n  wrapper around one expression or one error check is inlined. Its name says what the\n  step means in the domain, not the library call behind it: verb-like for an\n  action or a predicate (`subtract`, `matches`), noun-like for a value it\n  returns (`processingInterval`); `leftDifferences` names the mechanism and\n  `processReminder` names nothing\n  ([go-naming](..\u002Fgo-naming\u002Freferences\u002FIDENTIFIERS.md#naming-conventions)\n  owns the conventions).\n- **Leave complexity headroom.** Before a function grows or two merge, read the\n  service's complexity linters in its golangci config (`gocyclo`, `gocognit`,\n  `funlen`, `nestif`) and stay clear of their limits, not at them.\n\nA fragment of an entry point in that shape; `b` holds only the dependencies,\n`bindCombination` writes by snapshot and returns what it left uncovered, and\ninside it `readSnapshot` parses each snapshot once so `matches` stays pure:\n\n```go\n\tinterval, ok, err := b.processingInterval()\n\tif err != nil || !ok {\n\t\treturn false, err\n\t}\n\tsnapshots, err := b.loadSnapshots(interval)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tremainders, err := b.bindCombination(interval, snapshots)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tif !data.Bind {\n\t\treturn true, nil \u002F\u002F unbind leaves values outside the combination alone\n\t}\n\tfor _, r := range remainders {\n\t\tif err := b.clear(r); err != nil {\n\t\t\treturn false, err\n\t\t}\n\t}\n\treturn true, nil\n```\n\n## Related Skills\n\n- Every owner in [Route Before The First Edit](#route-before-the-first-edit).\n- [go-style-core](..\u002Fgo-style-core\u002FSKILL.md): house style, report length, and delegation.\n- [go-linting](..\u002Fgo-linting\u002FSKILL.md): the closing gate.\n- [go-code-review](..\u002Fgo-code-review\u002FSKILL.md): the checklist before submitting.\n",{"name":5,"description":7},"main","59ac8ac7a0dd394878aaa0a7a7ecbc227356739f","skills\u002Fgo-code",2,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills","https:\u002F\u002Fgithub.com\u002Fh0rn3t","2026-11-14 04:23:12",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add h0rn3t\u002Fgolang-skills --skill go-code",{"tool":37,"command":38},"bunx","bunx skills add h0rn3t\u002Fgolang-skills --skill go-code",{"tool":40,"command":41},"pnpm","pnpm dlx skills add h0rn3t\u002Fgolang-skills --skill go-code","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code\u002FSKILL.md",true,[45,51],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"references\u002FINTENSITY.md","REFERENCE","参考文档",1734,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code\u002Freferences\u002FINTENSITY.md",{"path":52,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":53,"sourceHtmlUrl":54},"references\u002FNEW-CODE-EXAMPLES.md",4592,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code\u002Freferences\u002FNEW-CODE-EXAMPLES.md",[56,63,70,77,84,91],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M7BQEMJBPJWY6CCGVKW27SH0","go-troubleshooting","Use when investigating a bug or ticket in a Go service whose cause is unknown — wrong or missing results, tenant-specific behavior, a regression, stage\u002Fprod\u002FCI differences, a panic, hang, deadlock, leak, unexplained CPU\u002FRSS growth, or a flaky test. Also use for pasted stack traces, profiles, logs, or requests to find a Go issue's root cause, even without the word debug. Does not cover rewriting ticket text, implementing an already-diagnosed fix alone (use its topic skill), or optimizing a known bottleneck (see go-performance).","https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-troubleshooting\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M7BQEFVSRHNDND750SB69WD8","go-testing","Use when writing, reviewing, or improving Go test code — including table-driven tests, subtests, parallel tests, test helpers, test doubles, and assertions with cmp.Diff. Also use when a user asks to write a test for a Go function, even if they don't mention specific patterns like table-driven tests or subtests. Does not cover benchmark performance testing (see go-performance).","https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-testing\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7BQEA2DRH6H6WFYNJYJJRQQ","go-style-core","Use when resolving Go style or language mechanics such as formatting, nesting, declarations, initialization, scope, shadowing, loops, switches, or enum zero values. API design, naming, errors, and tests have specialized skills.","https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-style-core\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7BQE3D1H45ANCXAWCS55CDK","go-security","Use when writing or reviewing Go code that touches untrusted input, secrets, or credentials — SQL, shell, or template injection, path traversal, SSRF, cookies and security headers, password hashing, TLS settings, token comparison, or what may appear in a log line. Also use when a handler accepts a file name, URL, or command argument from a client, or when asked to find \"vulnerabilities\", even if the user never says \"security\". Does not cover the os.Root and crypto\u002Frand mechanics (see go-defensive) or the dependency CVE scan in the gate (see go-linting).","https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-security\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7BQDZYHG2YRJA3J26HFPKR7","go-resilience","Use when handling Go dependency failures or overload with retries, backoff\u002Fjitter, budgets, idempotency, duplicate delivery, circuit breakers, bulkheads, rate limits, backpressure, or degradation. Unknown root causes belong to go-troubleshooting.","https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-resilience\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M7BQDVG7DH2G9Z97Y8H3P3E9","go-performance","Use when optimizing slow or performance-critical Go code, allocations, string concatenation in loops, or benchmarks. Also use when writing or reviewing a cache, including implementing one from a stub — its key, its expiry, and how a miss loads. Concurrent code patterns belong to go-concurrency.","https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-performance\u002FSKILL.md",[],[]]