[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BQBFQSNA7SRKA3SJ1CKBW6":3,"skill-same:01M7BQBFQSNA7SRKA3SJ1CKBW6":190},{"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":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":6,"ownerHtmlUrl":30,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":31,"install":32,"resources":45},"01M7BQBFQSNA7SRKA3SJ1CKBW6","go-code-refactor",null,"Use when refactoring, cleaning up, simplifying, restructuring, or modernizing existing Go code while keeping observable behavior identical — reducing nesting, splitting long functions, deleting dead code, renaming for clarity, or adopting newer Go APIs. Also use when a user hands over a Go file or package and calls it messy, hard to follow, too long, bloated, over-engineered, or outdated, even if they never say \"refactor\", and when an existing Go monolith needs an architecture proposal — layers, modules, package boundaries, a god package to split — before or instead of a rewrite. Does not cover writing new Go code or the style rules themselves (see go-style-core and the rule owners).","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-refactor\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: go-code-refactor\ndescription: Use when refactoring, cleaning up, simplifying, restructuring, or modernizing existing Go code while keeping observable behavior identical — reducing nesting, splitting long functions, deleting dead code, renaming for clarity, or adopting newer Go APIs. Also use when a user hands over a Go file or package and calls it messy, hard to follow, too long, bloated, over-engineered, or outdated, even if they never say \"refactor\", and when an existing Go monolith needs an architecture proposal — layers, modules, package boundaries, a god package to split — before or instead of a rewrite. Does not cover writing new Go code or the style rules themselves (see go-style-core and the rule owners).\nallowed-tools: Bash(bash ${CLAUDE_SKILL_DIR}\u002Fscripts\u002F*)\n---\n\n# Go Refactoring\n\n> Compatibility: Baseline Go 1.27 (see [COMPATIBILITY.md](..\u002Fgo-style-core\u002Freferences\u002FCOMPATIBILITY.md)).\n\nImprove readability while preserving observable behavior. Establish evidence\nfor that promise; compilation alone does not establish equivalent behavior.\n\n## Resource Routing\n\nResolve resources from this installed skill directory; run scripts from the\ntarget project using the resolved absolute script path.\n\n- `..\u002Fgo-style-core\u002FSKILL.md` - Load on every refactor before the first edit; it carries the idiom card.\n- `..\u002Fgo-testing\u002FSKILL.md` - Load with go-style-core before the first edit; a refactor often edits tests.\n- `..\u002Fgo-linting\u002FSKILL.md` - With a shell, load with go-style-core before edits; select the final gate and attempt receipt verification at step 5.\n- `references\u002FBEHAVIOR-TRAPS.md` - Its Pre-commit checklist before every refactor; a section when a transform moves a `defer`, nil versus empty, goroutine or channel shape, or struct layout.\n- `references\u002FPLAYBOOK.md` - The concrete transformations, ordered by payoff, and the `Kept:` marker for what a refactor leaves alone.\n- `references\u002FPOLICY-TABLES.md` - When repeated selection reads fields of one shared policy record.\n- `references\u002FCATALOG.md` - When a move crosses a function, type, or package boundary: the tool and the risk tier.\n- `references\u002FSAFETY-NET.md` - When the blast radius has thin or no tests.\n- `references\u002FMECHANICAL.md` - When the same edit recurs across many sites.\n- `references\u002FARCHITECTURE.md` - Only when the smell is package-scale (a god package, shared global layers, drivers in services, a cycle) or the ask names architecture, layers, modules, or a monolith.\n- `references\u002FARCHITECTURE-BEHAVIOR.md` - Before moving code a use case's atomicity, error identity, or authorization passes through.\n- `references\u002FARCHITECTURE-CHECKS.md` - When installing or reading the architecture checker.\n- `testdata\u002Farchitecture\u002FREADME.md` - When a staged plan needs a compilable layered example.\n- `scripts\u002Fcheck-architecture.sh` - Run from the module root to check `internal\u002F` imports against `architecture.json`; exit 1 on a violation or a stale `known` entry, 2 when a package fails to load or the policy is missing.\n- `scripts\u002Fcheck-architecture.go` - The checker the wrapper builds and runs; `scripts\u002Fcheck-architecture_test.go` holds its unit tests. Neither is run or read directly.\n- `references\u002FSTRUCTURAL.md` - Before moving a type between packages, breaking an import cycle, or changing an exported API.\n- `references\u002FMODERNIZATION.md` - When a hunk adopts a newer API or `go fix -diff` proposes one: safe, conditional, report-only.\n- `references\u002FLADDER.md` - When a step adds a helper, type, layer, option, or import, unless `## The Restraint Ladder` is already in context (the session-start hook prints from that heading to the end of the file).\n- `references\u002FOVER-ENGINEERING.md` - When the ask is \"what can we delete\", or a simpler stdlib API is sought.\n- `scripts\u002Fverify-refactor.sh` - Baseline and final check results, and production LOC before and after.\n- `scripts\u002Fcheck-debt.sh` - Harvest `Kept:` markers and flag the ones naming no ceiling and no fix.\n- `assets\u002Frefactor-report.md` - The final report structure.\n\nThe commands below need a shell tool; Workflow step 1 says how to write their\npath.\n\n## Workflow\n\n### 1. Orient\n\nScripts run from the target project by full path: `\u003Cinstalled-skill-dir>`\nbelow is the base directory the host printed when it loaded this skill, or,\nwhere no tool loads it, the directory this SKILL.md was read from (under\nCodex, `~\u002F.codex\u002Fskills\u002Fgo-code-refactor` or\n`~\u002F.agents\u002Fskills\u002Fgo-code-refactor`). Write the path itself into\neach command — every shell call starts with a fresh environment, so a\nvariable exported in one call is empty in the next. Exit 127 from the first\nscript means the path is wrong.\n\nWhere the plugin hook runs, reuse only the\n[current matching receipts](..\u002Fgo-linting\u002FSKILL.md#verification-gate).\nWith no shell tool, run nothing and read no script: observed\n[edit hook receipts](..\u002Fgo-style-core\u002FSKILL.md#the-edit-hook-record) are\nobserved results, not verified gate credit; unconfirmed required checks remain unavailable.\n\nLoad the skills before the first edit (a read of `..\u002F\u003Cname>\u002FSKILL.md` where\nthere is no `Skill` tool): [go-style-core](..\u002Fgo-style-core\u002FSKILL.md) and\n[go-testing](..\u002Fgo-testing\u002FSKILL.md) on every refactor and, with a shell,\n[go-linting](..\u002Fgo-linting\u002FSKILL.md), then the owner of each\ndecision the diff moves, from\n[Related Skills](#related-skills), go-code's\n[Route Before The First Edit](..\u002Fgo-code\u002FSKILL.md#route-before-the-first-edit),\nor the host's routing note when it names them. No edit before every selected\nskill is in context.\n\nFlag two file classes before editing: **generated** files (exclude silently\nwhen incidental; a generated target changes through its generator, below) and **build-tagged** files for\nanother GOOS\u002FGOARCH, which never compile here — run\n`GOOS=\u003Ctarget> go vet .\u002F...` (`go build` skips their `_test.go` files) and\nsay in the report that their tests did not run.\n\nRecord the baseline in one shell call; the second line runs even when a red\nbaseline exits 1. `\u003Cpattern>` is one package pattern covering the refactor\n(`.\u002Finternal\u002Fcache\u002F...`), the same in step 5:\n\n```bash\nbash \"\u003Cinstalled-skill-dir>\u002Fscripts\u002Fverify-refactor.sh\" baseline \u003Cpattern>\nbash \"\u003Cinstalled-skill-dir>\u002Fscripts\u002Fverify-refactor.sh\" loc-baseline \u003Cpattern>\n```\n\nWhen a `Benchmark*` covers a function the refactor touches, save its baseline\nnow and compare at step 5; a slowdown `benchstat` calls significant goes in\nthe findings list with its row:\n\n```bash\nbash \"\u003Cinstalled-skill-dir>\u002F..\u002Fgo-performance\u002Fscripts\u002Fbench-compare.sh\" --save .refactor-verify\u002Fbench.txt .\u002Fpath\u002Fto\u002Fpkg\nbash \"\u003Cinstalled-skill-dir>\u002F..\u002Fgo-performance\u002Fscripts\u002Fbench-compare.sh\" --baseline .refactor-verify\u002Fbench.txt .\u002Fpath\u002Fto\u002Fpkg\n```\n\nIf characterization tests are needed, run them against unchanged production\ncode, then capture a new baseline with those tests included. Retain the earlier\nresults for known failures. Use existing authorization and continue work that\ndoes not depend on an answer:\n\n- **If the baseline is red** — record the failing command and isolate\n  pre-existing or environmental failures. Continue inspection and independently\n  verifiable changes; do not claim behavior preservation without evidence.\n- **If the package has zero tests** — add a small characterization test when\n  the authorized refactor needs it; [SAFETY-NET.md](references\u002FSAFETY-NET.md)\n  sizes it. Missing tests alone do not require another approval. Honor an\n  explicit prohibition on new tests and report the limitation.\n- **If the target is generated** — trace its generator and source inputs;\n  update those and regenerate when within scope. Do not hand-edit generated\n  output; ask only if the real source cannot be determined.\n- **If two readings change the contract or scope** — ask a focused question\n  only if the request and repository do not resolve it; continue independent\n  work meanwhile.\n\n### 2. Audit before rewriting\n\nName what makes the code hard to follow *before* proposing fixes. The naming is\nwhat produces a real transformation; jumping to edits produces cosmetic churn —\nrenamed variables, shuffled lines, same confusion. Record location, what is\nhard to read, and the intended transformation.\n\nWhen the ask is a cut list rather than a rewrite — \"what can we delete\", a repo\nhanded over as bloated — the audit *is* the deliverable: use the tags and\nranked format in `references\u002FOVER-ENGINEERING.md` and stop there.\n\nYou will notice actual bugs while auditing — races, ignored errors, leaks,\noff-by-ones. **Record each one in the findings list and leave the code as it\nis**: a diff that mixes \"reads better\" with \"behaves differently\" cannot be\nreviewed as a refactor. Report every severity; the user triages faster than\nyou can filter.\n\n### 3. Scope mechanical modernization\n\nWhen modernization helps the requested refactor, preview it for the affected\npackages, for example `go fix -diff .\u002Finternal\u002Fcache`. Use `.\u002F...` only for a\nmodule-wide scope. Apply `go fix` only when every proposed edit is in scope;\nfor a function-only task, apply relevant hunks manually if the preview also\nchanges neighboring functions. A neighbor's older form is not a reason to keep\nit in the touched lines, and an untouched neighbor is not a reason to widen\nthe scope. A broader verification gate does not widen the edit scope. If no\nrelevant modernization helps, proceed to the hand edits. Four default hunks\ncan change behavior and are never applied unread: `hostport`, `omitzero`,\n`waitgroupgo` where an early `return` skips `wg.Done()`, and `slicessort` on\nfloats that can hold NaN.\n\nKeep mechanical edits attributable and respect `go.mod` and the risk tiers in\n`references\u002FMODERNIZATION.md`; Tier 3 items go in the findings list.\n\n### 4. Refactor in verifiable steps\n\nUse small, attributable transformations with focused checks between meaningful\nsteps. For dependent packages, work in dependency order; shared helpers go first.\nReuse unchanged passing results and finish with the required repository gate.\nFor independent packages, follow the host's delegation policy and\n[go-style-core](..\u002Fgo-style-core\u002FSKILL.md#how-much-to-say).\n\n`references\u002FPLAYBOOK.md` has the transformations, ordered by payoff. Before a\nrename or an extraction, search its uses by text: the build catches the static\nones, not reflection, templates, string lookups, or a type matched only\nthrough an assertion or a type switch.\n\nThree cases leave the playbook. A move that crosses a function, type, or package\nboundary is in `references\u002FCATALOG.md`, with its tool and tier. The same edit\nrecurring across many sites is a generated rewrite, not thirty hand-edits\n(`references\u002FMECHANICAL.md`). A type changing packages is a staged alias\nmigration, never one atomic commit (`references\u002FSTRUCTURAL.md`).\n\n### 5. Verify\n\nWith a shell, use the already loaded `go-linting` gate.\nWhere the plugin hook runs, run the `--gate` Bash verification command\nprinted by the last edit hook before repeating checks;\nonly returned `hook_credit=true` permits `pass (hook)` for its exact scope.\nOtherwise run the check directly or report it unavailable.\n\nIn one shell call:\n\n```bash\nbash \"\u003Cinstalled-skill-dir>\u002Fscripts\u002Fverify-refactor.sh\" after \u003Cpattern>\nbash \"\u003Cinstalled-skill-dir>\u002Fscripts\u002Fverify-refactor.sh\" diff\nbash \"\u003Cinstalled-skill-dir>\u002Fscripts\u002Fverify-refactor.sh\" loc-diff \u003Cpattern>\n```\n\n`after` already ran the gate's gofmt, build, vet, test, and race rows: beside\nit run only lint and `govulncheck`.\n\nThe diff compares recorded check results, not program behavior. An empty diff\ncan include the same failures or skipped checks; a nonempty diff can include\nnew passing tests or resolved failures. Inspect each difference and the actual\nbaseline\u002Fafter statuses. Attribute new failures before changing code; undo only\nyour own failing transformation, preserving pre-existing user changes.\n\nKeep assertions about observable behavior unchanged. Mechanical updates to\nreferences after an authorized rename and new characterization tests are\nallowed; weakening expectations to make the refactor pass is not. If a\ntoolchain change was authorized, `references\u002FMODERNIZATION.md` lists failures\nthat may need attribution to that change. Passing checks support only the\nbehavior they exercise; report what remains unverified.\n\nWatch tests that assert on error strings or JSON output — they catch the\ninvisible breakages compilation misses.\n[go-linting](..\u002Fgo-linting\u002FSKILL.md) owns what the individual checks mean.\n\n### 6. Report\n\nUse `assets\u002Frefactor-report.md`; report skipped checks as skipped.\n\n## What \"Identical Behavior\" Means\n\n> **Normative**: Anything an outside observer could notice must not move.\n\nExported names and signatures; struct tags and serialization order; error\ntext, `%w` chains, sentinels, exit and HTTP codes; the order and count of side\neffects (I\u002FO, logs, queries, locks, sends, `defer`); concurrency shape; numeric\ntypes and overflow points; nil versus empty collections on the wire.\n[BEHAVIOR-TRAPS.md](references\u002FBEHAVIOR-TRAPS.md) has the mechanism behind each.\nInternal names, function boundaries, control-flow shape, and comments are fair\ngame — that is where the readability gain lives.\n\n## Delete Before You Restructure\n\n> **Normative**: Line count is the instrument; readability is the goal. The win\n> comes from code that stops existing, not code that gets rearranged.\n\nWork in that order — delete, then shorten, then restructure — and read the net\nline count after each step. Growth is a new declaration, layer, indirection,\nfile, or dependency, and it needs a reason in the report; a guard clause or a\nnamed constant is a name, not growth.\n\nA helper the refactor adds meets one of the four\n[Declaration Budget](..\u002Fgo-code\u002FSKILL.md#declaration-budget) rules — two call\nsites in the final code, a caller outside the function that names it, a\ndistinct algorithm, or a step at another level of abstraction than its\ncaller — or it is not added. A few-line `writeHeader`, `writeRow`, and\n`writeTotal` that `Render` calls once each are not added: they only rename its\nsteps at its own level. The report names the rule each kept helper meets.\nCount the helper and its call sites when comparing complexity. The rules cut\nboth ways: an existing helper that meets one stays, even with one caller;\ninlining is for a wrapper that meets none.\n\nBefore writing any new line — helper, wrapper, interface — climb the restraint\nladder in `references\u002FLADDER.md` and stop at the first rung that\nholds; on a refactor the top one usually does.\n\nDelete only what is **provably** unreachable — \"looks unused\" is a finding, not\na licence. A reachable line that only looks redundant — a second check, a\ndefensive copy, a lock around a read, a sleep — gets\n`git log -S'\u003Cthe line>' --oneline -- \u003Cfile>` before it goes: when the commit\nthat added it fixed a bug, removing it is a finding unless a test reproduces\nthat bug and stays green without the line. With no shell, it is a finding.\nApply the shorter form only where it reads as well; never golf.\n\n**Never simplify away** input validation at trust boundaries, error handling\nthat prevents data loss, or security checks. A \"simplification\" that drops a\nbounds check is a bug, not laziness. These stay even when the diff gets uglier.\n\n## Risk Tiers\n\nThe tier sets what has to be true *before* the step, and pairs with the coverage\ntiers in [SAFETY-NET.md](references\u002FSAFETY-NET.md): low coverage on the blast\nradius pushes every transform up a tier except those its Low \u002F zero row allows.\n\n| Tier | Transforms | Required before the step |\n|---|---|---|\n| **Low** | `go fix` inline of a `\u002F\u002Fgo:fix inline` function; rename of an unexported symbol with no reflection or string-based contract; extract variable or constant (not an operand of `&&`\u002F`||` or a call with side effects: that is Medium); `gofmt -s`; organize imports; guard clauses | Baseline plus the focused check after it |\n| **Medium** | Extract function or method, inline across packages, adding or removing one parameter, introducing generics, a bulk rewrite ([MECHANICAL.md](references\u002FMECHANICAL.md)) | Tests that provably reach the touched lines |\n| **High** | Signature change across many callers, cross-package moves, package split or merge, breaking an import cycle, a module or layer boundary move (`references\u002FARCHITECTURE.md`), any exported API change | Full net, and it is a findings-list item unless the user asked for it |\n\n`go fix` inline keeps behavior or leaves the call alone. A rename that\ncompiles is not proven safe: rename may introduce dynamic errors through\nreflection, templates, serialization conventions, or indirect interface\nassertions.\n\n## When Not to Refactor\n\n> **Normative**: A refactor is an investment repaid by a future change. With no\n> change coming to spend it on, it is churn carrying a nonzero chance of\n> breaking something that works.\n\nTwo cases can make the honest deliverable a sentence rather than a diff. Say\nwhich one applies and stop only when the requested refactor has no concrete\nreadability cost or future change to repay it.\n\n| Case | What to do instead |\n|---|---|\n| The code works and nothing planned will touch it again | Name it and stop; a stable, rarely-read package earns nothing from being restructured for its own sake |\n| No purpose behind \"refactor this\" — no upcoming feature, no bug class, no smell a review flagged | Name the purpose you inferred and refactor to *that*; if there is none, say so in the report |\n\nTwo other cases change the sequence, not cancel the work:\n\n- **Critical path with no tests** — add characterization coverage first\n  ([SAFETY-NET.md](references\u002FSAFETY-NET.md)); continue once the net can support\n  the behavior promise, otherwise report exactly what remains unproved.\n- **Minimal change under time pressure** — make the minimal safe change the\n  user requested and propose the larger refactor separately.\n\nNone of these is a licence to skip authorized work that has a concrete purpose.\nDeliver the refactor asked for at the scope intended: \"while I'm here\" fixes and\na modernization that quietly becomes a migration dilute the guarantee — every\nline the refactor touches takes the current form\n([Write Current Go](..\u002Fgo-style-core\u002FSKILL.md#write-current-go)); the untouched\nrest is proposed, not rewritten. A structural problem a readability pass\ncannot solve gets one sentence in the report.\n\n## Remove Duplication to the End\n\nWhen branches repeat one policy or computation and differ only in its values,\nseparate **selection** (which case applies) from **computation** (what is done\nwith the selected values). Within that shared operation, aim to represent each\npolicy fact, selection, and condition ladder once. Replacing literals with\nconstants or changing `if` to `switch` alone does not remove repeated logic.\n\nEqual literals and matching switch keys do not establish a shared policy: a\nretry limit of 3 and a grace period of 3 days stay independent facts. Combine\nvalues only when they belong to one record and the final code reads better;\nstop when another fold adds more coupling than it removes, and name a material\nremaining duplication in the report.\n\nPick the shape by the final code, call sites included: an exported accessor\nthat already performs the selection, before a new unexported helper; a\n`switch` when the cases carry logic; a `map` or slice literal indexed by the\nkey when they carry only values. A table exists to delete the branches, not\nto be serviced — no search helper, no method, no loop to rebuild a list that\nwas already a literal. If the lookup needs those, the `switch` was shorter.\nMap iteration order is not source order, so an ordered literal stays a\nliteral. Error texts and the point where an unknown key fails do not move.\n`references\u002FPOLICY-TABLES.md` shows the fold.\n\n## Architecture at Package Scale\n\nWhen the smell is the import graph (a god package, shared global layers,\ndrivers in services, a cycle), [ARCHITECTURE.md](references\u002FARCHITECTURE.md#package-scale-rule)\nowns the call: the layering rule, candidate cards, and the High-tier move.\n\n## Concision Gate\n\nKeep a transformation only when behavior is preserved and a reader can trace\ndecisions, errors, and side effects from the entry point without chasing\ntrivial wrappers. Measure both production LOC counts, physical and code (the\nscript's `--help` defines them); growth in either needs the reason\n[Delete Before You Restructure](#delete-before-you-restructure) requires.\nRecord both starting counts before the first edit, and compare after `gofmt` on\nthe same path, with the counter this skill ships: `loc-baseline` in step 1 of\nthe [Workflow](#workflow), `loc-diff` in step 5.\n\n`loc-diff` exits 0 when neither count grew, 1 when one did, and 2 when the\nrecorded path differs. Exit 1 is a signal, not a verdict: name the declaration,\nlayer, or dependency that grew and why — a doc comment added to an exported\nsymbol is its own reason; unjustified growth is a finding. The\nreport carries only the two counts `loc-diff` printed, physical and code; when\nit could not run, that sentence stands where the numbers would. The `baseline`,\n`after` and `diff` modes compare check records and say nothing about size.\n\nKeep documentation that explains a decision or contract. Removing comments\nor blank lines cannot compensate for added code; do not compress statements\nonto one line to meet the limit. An empty diff is successful when no\nqualifying improvement exists.\n\nSomething ugly kept because changing it would change behavior gets a\n`Kept:` \u002F `Ceiling:` \u002F `Fix:` marker in the code\n([PLAYBOOK.md](references\u002FPLAYBOOK.md#10-mark-what-you-deliberately-left-alone)).\n\n## Related Skills\n\n- [go-style-core](..\u002Fgo-style-core\u002FSKILL.md): nesting and the clarity > simplicity > concision order.\n- [go-testing](..\u002Fgo-testing\u002FSKILL.md): characterization tests and any `_test.go` edit.\n- [go-naming](..\u002Fgo-naming\u002FSKILL.md): renames.\n- [go-error-handling](..\u002Fgo-error-handling\u002FSKILL.md): wrapping, sentinels, handle-once rewrites.\n- [go-concurrency](..\u002Fgo-concurrency\u002FSKILL.md): goroutine lifetimes, channels, locks in the diff.\n- [go-packages](..\u002Fgo-packages\u002FSKILL.md): a refactor that crosses package boundaries; where a new package goes once `references\u002FARCHITECTURE.md` has named the target.\n- [go-code-review](..\u002Fgo-code-review\u002FSKILL.md): the finished diff against the checklist.\n","# Go Refactoring\n\n> Compatibility: Baseline Go 1.27 (see [COMPATIBILITY.md](..\u002Fgo-style-core\u002Freferences\u002FCOMPATIBILITY.md)).\n\nImprove readability while preserving observable behavior. Establish evidence\nfor that promise; compilation alone does not establish equivalent behavior.\n\n## Resource Routing\n\nResolve resources from this installed skill directory; run scripts from the\ntarget project using the resolved absolute script path.\n\n- `..\u002Fgo-style-core\u002FSKILL.md` - Load on every refactor before the first edit; it carries the idiom card.\n- `..\u002Fgo-testing\u002FSKILL.md` - Load with go-style-core before the first edit; a refactor often edits tests.\n- `..\u002Fgo-linting\u002FSKILL.md` - With a shell, load with go-style-core before edits; select the final gate and attempt receipt verification at step 5.\n- `references\u002FBEHAVIOR-TRAPS.md` - Its Pre-commit checklist before every refactor; a section when a transform moves a `defer`, nil versus empty, goroutine or channel shape, or struct layout.\n- `references\u002FPLAYBOOK.md` - The concrete transformations, ordered by payoff, and the `Kept:` marker for what a refactor leaves alone.\n- `references\u002FPOLICY-TABLES.md` - When repeated selection reads fields of one shared policy record.\n- `references\u002FCATALOG.md` - When a move crosses a function, type, or package boundary: the tool and the risk tier.\n- `references\u002FSAFETY-NET.md` - When the blast radius has thin or no tests.\n- `references\u002FMECHANICAL.md` - When the same edit recurs across many sites.\n- `references\u002FARCHITECTURE.md` - Only when the smell is package-scale (a god package, shared global layers, drivers in services, a cycle) or the ask names architecture, layers, modules, or a monolith.\n- `references\u002FARCHITECTURE-BEHAVIOR.md` - Before moving code a use case's atomicity, error identity, or authorization passes through.\n- `references\u002FARCHITECTURE-CHECKS.md` - When installing or reading the architecture checker.\n- `testdata\u002Farchitecture\u002FREADME.md` - When a staged plan needs a compilable layered example.\n- `scripts\u002Fcheck-architecture.sh` - Run from the module root to check `internal\u002F` imports against `architecture.json`; exit 1 on a violation or a stale `known` entry, 2 when a package fails to load or the policy is missing.\n- `scripts\u002Fcheck-architecture.go` - The checker the wrapper builds and runs; `scripts\u002Fcheck-architecture_test.go` holds its unit tests. Neither is run or read directly.\n- `references\u002FSTRUCTURAL.md` - Before moving a type between packages, breaking an import cycle, or changing an exported API.\n- `references\u002FMODERNIZATION.md` - When a hunk adopts a newer API or `go fix -diff` proposes one: safe, conditional, report-only.\n- `references\u002FLADDER.md` - When a step adds a helper, type, layer, option, or import, unless `## The Restraint Ladder` is already in context (the session-start hook prints from that heading to the end of the file).\n- `references\u002FOVER-ENGINEERING.md` - When the ask is \"what can we delete\", or a simpler stdlib API is sought.\n- `scripts\u002Fverify-refactor.sh` - Baseline and final check results, and production LOC before and after.\n- `scripts\u002Fcheck-debt.sh` - Harvest `Kept:` markers and flag the ones naming no ceiling and no fix.\n- `assets\u002Frefactor-report.md` - The final report structure.\n\nThe commands below need a shell tool; Workflow step 1 says how to write their\npath.\n\n## Workflow\n\n### 1. Orient\n\nScripts run from the target project by full path: `\u003Cinstalled-skill-dir>`\nbelow is the base directory the host printed when it loaded this skill, or,\nwhere no tool loads it, the directory this SKILL.md was read from (under\nCodex, `~\u002F.codex\u002Fskills\u002Fgo-code-refactor` or\n`~\u002F.agents\u002Fskills\u002Fgo-code-refactor`). Write the path itself into\neach command — every shell call starts with a fresh environment, so a\nvariable exported in one call is empty in the next. Exit 127 from the first\nscript means the path is wrong.\n\nWhere the plugin hook runs, reuse only the\n[current matching receipts](..\u002Fgo-linting\u002FSKILL.md#verification-gate).\nWith no shell tool, run nothing and read no script: observed\n[edit hook receipts](..\u002Fgo-style-core\u002FSKILL.md#the-edit-hook-record) are\nobserved results, not verified gate credit; unconfirmed required checks remain unavailable.\n\nLoad the skills before the first edit (a read of `..\u002F\u003Cname>\u002FSKILL.md` where\nthere is no `Skill` tool): [go-style-core](..\u002Fgo-style-core\u002FSKILL.md) and\n[go-testing](..\u002Fgo-testing\u002FSKILL.md) on every refactor and, with a shell,\n[go-linting](..\u002Fgo-linting\u002FSKILL.md), then the owner of each\ndecision the diff moves, from\n[Related Skills](#related-skills), go-code's\n[Route Before The First Edit](..\u002Fgo-code\u002FSKILL.md#route-before-the-first-edit),\nor the host's routing note when it names them. No edit before every selected\nskill is in context.\n\nFlag two file classes before editing: **generated** files (exclude silently\nwhen incidental; a generated target changes through its generator, below) and **build-tagged** files for\nanother GOOS\u002FGOARCH, which never compile here — run\n`GOOS=\u003Ctarget> go vet .\u002F...` (`go build` skips their `_test.go` files) and\nsay in the report that their tests did not run.\n\nRecord the baseline in one shell call; the second line runs even when a red\nbaseline exits 1. `\u003Cpattern>` is one package pattern covering the refactor\n(`.\u002Finternal\u002Fcache\u002F...`), the same in step 5:\n\n```bash\nbash \"\u003Cinstalled-skill-dir>\u002Fscripts\u002Fverify-refactor.sh\" baseline \u003Cpattern>\nbash \"\u003Cinstalled-skill-dir>\u002Fscripts\u002Fverify-refactor.sh\" loc-baseline \u003Cpattern>\n```\n\nWhen a `Benchmark*` covers a function the refactor touches, save its baseline\nnow and compare at step 5; a slowdown `benchstat` calls significant goes in\nthe findings list with its row:\n\n```bash\nbash \"\u003Cinstalled-skill-dir>\u002F..\u002Fgo-performance\u002Fscripts\u002Fbench-compare.sh\" --save .refactor-verify\u002Fbench.txt .\u002Fpath\u002Fto\u002Fpkg\nbash \"\u003Cinstalled-skill-dir>\u002F..\u002Fgo-performance\u002Fscripts\u002Fbench-compare.sh\" --baseline .refactor-verify\u002Fbench.txt .\u002Fpath\u002Fto\u002Fpkg\n```\n\nIf characterization tests are needed, run them against unchanged production\ncode, then capture a new baseline with those tests included. Retain the earlier\nresults for known failures. Use existing authorization and continue work that\ndoes not depend on an answer:\n\n- **If the baseline is red** — record the failing command and isolate\n  pre-existing or environmental failures. Continue inspection and independently\n  verifiable changes; do not claim behavior preservation without evidence.\n- **If the package has zero tests** — add a small characterization test when\n  the authorized refactor needs it; [SAFETY-NET.md](references\u002FSAFETY-NET.md)\n  sizes it. Missing tests alone do not require another approval. Honor an\n  explicit prohibition on new tests and report the limitation.\n- **If the target is generated** — trace its generator and source inputs;\n  update those and regenerate when within scope. Do not hand-edit generated\n  output; ask only if the real source cannot be determined.\n- **If two readings change the contract or scope** — ask a focused question\n  only if the request and repository do not resolve it; continue independent\n  work meanwhile.\n\n### 2. Audit before rewriting\n\nName what makes the code hard to follow *before* proposing fixes. The naming is\nwhat produces a real transformation; jumping to edits produces cosmetic churn —\nrenamed variables, shuffled lines, same confusion. Record location, what is\nhard to read, and the intended transformation.\n\nWhen the ask is a cut list rather than a rewrite — \"what can we delete\", a repo\nhanded over as bloated — the audit *is* the deliverable: use the tags and\nranked format in `references\u002FOVER-ENGINEERING.md` and stop there.\n\nYou will notice actual bugs while auditing — races, ignored errors, leaks,\noff-by-ones. **Record each one in the findings list and leave the code as it\nis**: a diff that mixes \"reads better\" with \"behaves differently\" cannot be\nreviewed as a refactor. Report every severity; the user triages faster than\nyou can filter.\n\n### 3. Scope mechanical modernization\n\nWhen modernization helps the requested refactor, preview it for the affected\npackages, for example `go fix -diff .\u002Finternal\u002Fcache`. Use `.\u002F...` only for a\nmodule-wide scope. Apply `go fix` only when every proposed edit is in scope;\nfor a function-only task, apply relevant hunks manually if the preview also\nchanges neighboring functions. A neighbor's older form is not a reason to keep\nit in the touched lines, and an untouched neighbor is not a reason to widen\nthe scope. A broader verification gate does not widen the edit scope. If no\nrelevant modernization helps, proceed to the hand edits. Four default hunks\ncan change behavior and are never applied unread: `hostport`, `omitzero`,\n`waitgroupgo` where an early `return` skips `wg.Done()`, and `slicessort` on\nfloats that can hold NaN.\n\nKeep mechanical edits attributable and respect `go.mod` and the risk tiers in\n`references\u002FMODERNIZATION.md`; Tier 3 items go in the findings list.\n\n### 4. Refactor in verifiable steps\n\nUse small, attributable transformations with focused checks between meaningful\nsteps. For dependent packages, work in dependency order; shared helpers go first.\nReuse unchanged passing results and finish with the required repository gate.\nFor independent packages, follow the host's delegation policy and\n[go-style-core](..\u002Fgo-style-core\u002FSKILL.md#how-much-to-say).\n\n`references\u002FPLAYBOOK.md` has the transformations, ordered by payoff. Before a\nrename or an extraction, search its uses by text: the build catches the static\nones, not reflection, templates, string lookups, or a type matched only\nthrough an assertion or a type switch.\n\nThree cases leave the playbook. A move that crosses a function, type, or package\nboundary is in `references\u002FCATALOG.md`, with its tool and tier. The same edit\nrecurring across many sites is a generated rewrite, not thirty hand-edits\n(`references\u002FMECHANICAL.md`). A type changing packages is a staged alias\nmigration, never one atomic commit (`references\u002FSTRUCTURAL.md`).\n\n### 5. Verify\n\nWith a shell, use the already loaded `go-linting` gate.\nWhere the plugin hook runs, run the `--gate` Bash verification command\nprinted by the last edit hook before repeating checks;\nonly returned `hook_credit=true` permits `pass (hook)` for its exact scope.\nOtherwise run the check directly or report it unavailable.\n\nIn one shell call:\n\n```bash\nbash \"\u003Cinstalled-skill-dir>\u002Fscripts\u002Fverify-refactor.sh\" after \u003Cpattern>\nbash \"\u003Cinstalled-skill-dir>\u002Fscripts\u002Fverify-refactor.sh\" diff\nbash \"\u003Cinstalled-skill-dir>\u002Fscripts\u002Fverify-refactor.sh\" loc-diff \u003Cpattern>\n```\n\n`after` already ran the gate's gofmt, build, vet, test, and race rows: beside\nit run only lint and `govulncheck`.\n\nThe diff compares recorded check results, not program behavior. An empty diff\ncan include the same failures or skipped checks; a nonempty diff can include\nnew passing tests or resolved failures. Inspect each difference and the actual\nbaseline\u002Fafter statuses. Attribute new failures before changing code; undo only\nyour own failing transformation, preserving pre-existing user changes.\n\nKeep assertions about observable behavior unchanged. Mechanical updates to\nreferences after an authorized rename and new characterization tests are\nallowed; weakening expectations to make the refactor pass is not. If a\ntoolchain change was authorized, `references\u002FMODERNIZATION.md` lists failures\nthat may need attribution to that change. Passing checks support only the\nbehavior they exercise; report what remains unverified.\n\nWatch tests that assert on error strings or JSON output — they catch the\ninvisible breakages compilation misses.\n[go-linting](..\u002Fgo-linting\u002FSKILL.md) owns what the individual checks mean.\n\n### 6. Report\n\nUse `assets\u002Frefactor-report.md`; report skipped checks as skipped.\n\n## What \"Identical Behavior\" Means\n\n> **Normative**: Anything an outside observer could notice must not move.\n\nExported names and signatures; struct tags and serialization order; error\ntext, `%w` chains, sentinels, exit and HTTP codes; the order and count of side\neffects (I\u002FO, logs, queries, locks, sends, `defer`); concurrency shape; numeric\ntypes and overflow points; nil versus empty collections on the wire.\n[BEHAVIOR-TRAPS.md](references\u002FBEHAVIOR-TRAPS.md) has the mechanism behind each.\nInternal names, function boundaries, control-flow shape, and comments are fair\ngame — that is where the readability gain lives.\n\n## Delete Before You Restructure\n\n> **Normative**: Line count is the instrument; readability is the goal. The win\n> comes from code that stops existing, not code that gets rearranged.\n\nWork in that order — delete, then shorten, then restructure — and read the net\nline count after each step. Growth is a new declaration, layer, indirection,\nfile, or dependency, and it needs a reason in the report; a guard clause or a\nnamed constant is a name, not growth.\n\nA helper the refactor adds meets one of the four\n[Declaration Budget](..\u002Fgo-code\u002FSKILL.md#declaration-budget) rules — two call\nsites in the final code, a caller outside the function that names it, a\ndistinct algorithm, or a step at another level of abstraction than its\ncaller — or it is not added. A few-line `writeHeader`, `writeRow`, and\n`writeTotal` that `Render` calls once each are not added: they only rename its\nsteps at its own level. The report names the rule each kept helper meets.\nCount the helper and its call sites when comparing complexity. The rules cut\nboth ways: an existing helper that meets one stays, even with one caller;\ninlining is for a wrapper that meets none.\n\nBefore writing any new line — helper, wrapper, interface — climb the restraint\nladder in `references\u002FLADDER.md` and stop at the first rung that\nholds; on a refactor the top one usually does.\n\nDelete only what is **provably** unreachable — \"looks unused\" is a finding, not\na licence. A reachable line that only looks redundant — a second check, a\ndefensive copy, a lock around a read, a sleep — gets\n`git log -S'\u003Cthe line>' --oneline -- \u003Cfile>` before it goes: when the commit\nthat added it fixed a bug, removing it is a finding unless a test reproduces\nthat bug and stays green without the line. With no shell, it is a finding.\nApply the shorter form only where it reads as well; never golf.\n\n**Never simplify away** input validation at trust boundaries, error handling\nthat prevents data loss, or security checks. A \"simplification\" that drops a\nbounds check is a bug, not laziness. These stay even when the diff gets uglier.\n\n## Risk Tiers\n\nThe tier sets what has to be true *before* the step, and pairs with the coverage\ntiers in [SAFETY-NET.md](references\u002FSAFETY-NET.md): low coverage on the blast\nradius pushes every transform up a tier except those its Low \u002F zero row allows.\n\n| Tier | Transforms | Required before the step |\n|---|---|---|\n| **Low** | `go fix` inline of a `\u002F\u002Fgo:fix inline` function; rename of an unexported symbol with no reflection or string-based contract; extract variable or constant (not an operand of `&&`\u002F`||` or a call with side effects: that is Medium); `gofmt -s`; organize imports; guard clauses | Baseline plus the focused check after it |\n| **Medium** | Extract function or method, inline across packages, adding or removing one parameter, introducing generics, a bulk rewrite ([MECHANICAL.md](references\u002FMECHANICAL.md)) | Tests that provably reach the touched lines |\n| **High** | Signature change across many callers, cross-package moves, package split or merge, breaking an import cycle, a module or layer boundary move (`references\u002FARCHITECTURE.md`), any exported API change | Full net, and it is a findings-list item unless the user asked for it |\n\n`go fix` inline keeps behavior or leaves the call alone. A rename that\ncompiles is not proven safe: rename may introduce dynamic errors through\nreflection, templates, serialization conventions, or indirect interface\nassertions.\n\n## When Not to Refactor\n\n> **Normative**: A refactor is an investment repaid by a future change. With no\n> change coming to spend it on, it is churn carrying a nonzero chance of\n> breaking something that works.\n\nTwo cases can make the honest deliverable a sentence rather than a diff. Say\nwhich one applies and stop only when the requested refactor has no concrete\nreadability cost or future change to repay it.\n\n| Case | What to do instead |\n|---|---|\n| The code works and nothing planned will touch it again | Name it and stop; a stable, rarely-read package earns nothing from being restructured for its own sake |\n| No purpose behind \"refactor this\" — no upcoming feature, no bug class, no smell a review flagged | Name the purpose you inferred and refactor to *that*; if there is none, say so in the report |\n\nTwo other cases change the sequence, not cancel the work:\n\n- **Critical path with no tests** — add characterization coverage first\n  ([SAFETY-NET.md](references\u002FSAFETY-NET.md)); continue once the net can support\n  the behavior promise, otherwise report exactly what remains unproved.\n- **Minimal change under time pressure** — make the minimal safe change the\n  user requested and propose the larger refactor separately.\n\nNone of these is a licence to skip authorized work that has a concrete purpose.\nDeliver the refactor asked for at the scope intended: \"while I'm here\" fixes and\na modernization that quietly becomes a migration dilute the guarantee — every\nline the refactor touches takes the current form\n([Write Current Go](..\u002Fgo-style-core\u002FSKILL.md#write-current-go)); the untouched\nrest is proposed, not rewritten. A structural problem a readability pass\ncannot solve gets one sentence in the report.\n\n## Remove Duplication to the End\n\nWhen branches repeat one policy or computation and differ only in its values,\nseparate **selection** (which case applies) from **computation** (what is done\nwith the selected values). Within that shared operation, aim to represent each\npolicy fact, selection, and condition ladder once. Replacing literals with\nconstants or changing `if` to `switch` alone does not remove repeated logic.\n\nEqual literals and matching switch keys do not establish a shared policy: a\nretry limit of 3 and a grace period of 3 days stay independent facts. Combine\nvalues only when they belong to one record and the final code reads better;\nstop when another fold adds more coupling than it removes, and name a material\nremaining duplication in the report.\n\nPick the shape by the final code, call sites included: an exported accessor\nthat already performs the selection, before a new unexported helper; a\n`switch` when the cases carry logic; a `map` or slice literal indexed by the\nkey when they carry only values. A table exists to delete the branches, not\nto be serviced — no search helper, no method, no loop to rebuild a list that\nwas already a literal. If the lookup needs those, the `switch` was shorter.\nMap iteration order is not source order, so an ordered literal stays a\nliteral. Error texts and the point where an unknown key fails do not move.\n`references\u002FPOLICY-TABLES.md` shows the fold.\n\n## Architecture at Package Scale\n\nWhen the smell is the import graph (a god package, shared global layers,\ndrivers in services, a cycle), [ARCHITECTURE.md](references\u002FARCHITECTURE.md#package-scale-rule)\nowns the call: the layering rule, candidate cards, and the High-tier move.\n\n## Concision Gate\n\nKeep a transformation only when behavior is preserved and a reader can trace\ndecisions, errors, and side effects from the entry point without chasing\ntrivial wrappers. Measure both production LOC counts, physical and code (the\nscript's `--help` defines them); growth in either needs the reason\n[Delete Before You Restructure](#delete-before-you-restructure) requires.\nRecord both starting counts before the first edit, and compare after `gofmt` on\nthe same path, with the counter this skill ships: `loc-baseline` in step 1 of\nthe [Workflow](#workflow), `loc-diff` in step 5.\n\n`loc-diff` exits 0 when neither count grew, 1 when one did, and 2 when the\nrecorded path differs. Exit 1 is a signal, not a verdict: name the declaration,\nlayer, or dependency that grew and why — a doc comment added to an exported\nsymbol is its own reason; unjustified growth is a finding. The\nreport carries only the two counts `loc-diff` printed, physical and code; when\nit could not run, that sentence stands where the numbers would. The `baseline`,\n`after` and `diff` modes compare check records and say nothing about size.\n\nKeep documentation that explains a decision or contract. Removing comments\nor blank lines cannot compensate for added code; do not compress statements\nonto one line to meet the limit. An empty diff is successful when no\nqualifying improvement exists.\n\nSomething ugly kept because changing it would change behavior gets a\n`Kept:` \u002F `Ceiling:` \u002F `Fix:` marker in the code\n([PLAYBOOK.md](references\u002FPLAYBOOK.md#10-mark-what-you-deliberately-left-alone)).\n\n## Related Skills\n\n- [go-style-core](..\u002Fgo-style-core\u002FSKILL.md): nesting and the clarity > simplicity > concision order.\n- [go-testing](..\u002Fgo-testing\u002FSKILL.md): characterization tests and any `_test.go` edit.\n- [go-naming](..\u002Fgo-naming\u002FSKILL.md): renames.\n- [go-error-handling](..\u002Fgo-error-handling\u002FSKILL.md): wrapping, sentinels, handle-once rewrites.\n- [go-concurrency](..\u002Fgo-concurrency\u002FSKILL.md): goroutine lifetimes, channels, locks in the diff.\n- [go-packages](..\u002Fgo-packages\u002FSKILL.md): a refactor that crosses package boundaries; where a new package goes once `references\u002FARCHITECTURE.md` has named the target.\n- [go-code-review](..\u002Fgo-code-review\u002FSKILL.md): the finished diff against the checklist.\n",{"name":5,"description":7,"allowed-tools":24},"Bash(bash ${CLAUDE_SKILL_DIR}\u002Fscripts\u002F*)","main","59ac8ac7a0dd394878aaa0a7a7ecbc227356739f","skills\u002Fgo-code-refactor",2,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills","https:\u002F\u002Fgithub.com\u002Fh0rn3t","2026-11-14 04:23:12",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add h0rn3t\u002Fgolang-skills --skill go-code-refactor",{"tool":38,"command":39},"bunx","bunx skills add h0rn3t\u002Fgolang-skills --skill go-code-refactor",{"tool":41,"command":42},"pnpm","pnpm dlx skills add h0rn3t\u002Fgolang-skills --skill go-code-refactor","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002FSKILL.md",true,[46,52,58,62,66,70,74,78,82,86,90,94,98,102,106,112,116,120,124,128,132,136,142,146,150,154,158,162,166,170,174,178,182,186],{"path":47,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":50,"sourceHtmlUrl":51},"assets\u002Frefactor-report.md","ASSET","资产文件",4066,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Fassets\u002Frefactor-report.md",{"path":53,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":56,"sourceHtmlUrl":57},"references\u002FARCHITECTURE-BEHAVIOR.md","REFERENCE","参考文档",4262,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Freferences\u002FARCHITECTURE-BEHAVIOR.md",{"path":59,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":60,"sourceHtmlUrl":61},"references\u002FARCHITECTURE-CHECKS.md",11812,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Freferences\u002FARCHITECTURE-CHECKS.md",{"path":63,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":64,"sourceHtmlUrl":65},"references\u002FARCHITECTURE.md",25382,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Freferences\u002FARCHITECTURE.md",{"path":67,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":68,"sourceHtmlUrl":69},"references\u002FBEHAVIOR-TRAPS.md",8834,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Freferences\u002FBEHAVIOR-TRAPS.md",{"path":71,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":72,"sourceHtmlUrl":73},"references\u002FCATALOG.md",7937,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Freferences\u002FCATALOG.md",{"path":75,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":76,"sourceHtmlUrl":77},"references\u002FLADDER.md",5082,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Freferences\u002FLADDER.md",{"path":79,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":80,"sourceHtmlUrl":81},"references\u002FMECHANICAL.md",5336,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Freferences\u002FMECHANICAL.md",{"path":83,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":84,"sourceHtmlUrl":85},"references\u002FMODERNIZATION.md",19017,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Freferences\u002FMODERNIZATION.md",{"path":87,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":88,"sourceHtmlUrl":89},"references\u002FOVER-ENGINEERING.md",9367,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Freferences\u002FOVER-ENGINEERING.md",{"path":91,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":92,"sourceHtmlUrl":93},"references\u002FPLAYBOOK.md",11463,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Freferences\u002FPLAYBOOK.md",{"path":95,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":96,"sourceHtmlUrl":97},"references\u002FPOLICY-TABLES.md",2080,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Freferences\u002FPOLICY-TABLES.md",{"path":99,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":100,"sourceHtmlUrl":101},"references\u002FSAFETY-NET.md",6634,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Freferences\u002FSAFETY-NET.md",{"path":103,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":104,"sourceHtmlUrl":105},"references\u002FSTRUCTURAL.md",6006,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Freferences\u002FSTRUCTURAL.md",{"path":107,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":110,"sourceHtmlUrl":111},"scripts\u002Fcheck-architecture_test.go","SCRIPT","脚本",9523,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Fscripts\u002Fcheck-architecture_test.go",{"path":113,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":114,"sourceHtmlUrl":115},"scripts\u002Fcheck-architecture.go",21116,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Fscripts\u002Fcheck-architecture.go",{"path":117,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":118,"sourceHtmlUrl":119},"scripts\u002Fcheck-architecture.sh",3584,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Fscripts\u002Fcheck-architecture.sh",{"path":121,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":122,"sourceHtmlUrl":123},"scripts\u002Fcheck-debt.sh",7786,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Fscripts\u002Fcheck-debt.sh",{"path":125,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":126,"sourceHtmlUrl":127},"scripts\u002Fverify-refactor.sh",24742,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Fscripts\u002Fverify-refactor.sh",{"path":129,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":130,"sourceHtmlUrl":131},"testdata\u002Farchitecture\u002Farchitecture.json",141,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Ftestdata\u002Farchitecture\u002Farchitecture.json",{"path":133,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":134,"sourceHtmlUrl":135},"testdata\u002Farchitecture\u002Fcmd\u002Fserver\u002Fmain.go",1450,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Ftestdata\u002Farchitecture\u002Fcmd\u002Fserver\u002Fmain.go",{"path":137,"resourceType":138,"resourceTypeDesc":139,"sizeBytes":140,"sourceHtmlUrl":141},"testdata\u002Farchitecture\u002Fgo.mod","OTHER","其他",33,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Ftestdata\u002Farchitecture\u002Fgo.mod",{"path":143,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":144,"sourceHtmlUrl":145},"testdata\u002Farchitecture\u002Finternal\u002Fapp\u002Fapp.go",1825,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Ftestdata\u002Farchitecture\u002Finternal\u002Fapp\u002Fapp.go",{"path":147,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":148,"sourceHtmlUrl":149},"testdata\u002Farchitecture\u002Finternal\u002Fbilling\u002Fmodels\u002Finvoice.go",187,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Ftestdata\u002Farchitecture\u002Finternal\u002Fbilling\u002Fmodels\u002Finvoice.go",{"path":151,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":152,"sourceHtmlUrl":153},"testdata\u002Farchitecture\u002Finternal\u002Fbilling\u002Fservices\u002Fservice.go",1263,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Ftestdata\u002Farchitecture\u002Finternal\u002Fbilling\u002Fservices\u002Fservice.go",{"path":155,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":156,"sourceHtmlUrl":157},"testdata\u002Farchitecture\u002Finternal\u002Forder\u002Fapi.go",464,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Ftestdata\u002Farchitecture\u002Finternal\u002Forder\u002Fapi.go",{"path":159,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":160,"sourceHtmlUrl":161},"testdata\u002Farchitecture\u002Finternal\u002Forder\u002Fhandlers\u002Fhttp.go",2202,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Ftestdata\u002Farchitecture\u002Finternal\u002Forder\u002Fhandlers\u002Fhttp.go",{"path":163,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":164,"sourceHtmlUrl":165},"testdata\u002Farchitecture\u002Finternal\u002Forder\u002Fmodels\u002Forder.go",806,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Ftestdata\u002Farchitecture\u002Finternal\u002Forder\u002Fmodels\u002Forder.go",{"path":167,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":168,"sourceHtmlUrl":169},"testdata\u002Farchitecture\u002Finternal\u002Forder\u002Frepositories\u002Fpostgres_test.go",2595,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Ftestdata\u002Farchitecture\u002Finternal\u002Forder\u002Frepositories\u002Fpostgres_test.go",{"path":171,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":172,"sourceHtmlUrl":173},"testdata\u002Farchitecture\u002Finternal\u002Forder\u002Frepositories\u002Fpostgres.go",2039,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Ftestdata\u002Farchitecture\u002Finternal\u002Forder\u002Frepositories\u002Fpostgres.go",{"path":175,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":176,"sourceHtmlUrl":177},"testdata\u002Farchitecture\u002Finternal\u002Forder\u002Fservices\u002Ferrors.go",228,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Ftestdata\u002Farchitecture\u002Finternal\u002Forder\u002Fservices\u002Ferrors.go",{"path":179,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":180,"sourceHtmlUrl":181},"testdata\u002Farchitecture\u002Finternal\u002Forder\u002Fservices\u002Fservice.go",1733,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Ftestdata\u002Farchitecture\u002Finternal\u002Forder\u002Fservices\u002Fservice.go",{"path":183,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":184,"sourceHtmlUrl":185},"testdata\u002Farchitecture\u002Finternal\u002Fplatform\u002Fclock\u002Fclock.go",257,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Ftestdata\u002Farchitecture\u002Finternal\u002Fplatform\u002Fclock\u002Fclock.go",{"path":187,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":188,"sourceHtmlUrl":189},"testdata\u002Farchitecture\u002FREADME.md",1684,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-code-refactor\u002Ftestdata\u002Farchitecture\u002FREADME.md",[191,198,205,212,219,226],{"skillNo":192,"name":193,"nameZh":6,"description":194,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":195,"categories":196,"keywords":197,"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":199,"name":200,"nameZh":6,"description":201,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":202,"categories":203,"keywords":204,"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":206,"name":207,"nameZh":6,"description":208,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":209,"categories":210,"keywords":211,"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":213,"name":214,"nameZh":6,"description":215,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":216,"categories":217,"keywords":218,"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":220,"name":221,"nameZh":6,"description":222,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":223,"categories":224,"keywords":225,"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":227,"name":228,"nameZh":6,"description":229,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":230,"categories":231,"keywords":232,"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",[],[]]