[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M76H8050BBA53454BJNSP90F":3,"skill-same:01M76H8050BBA53454BJNSP90F":77},{"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":48,"commitSha":49,"skillDirectory":50,"forksCount":51,"repositoryHtmlUrl":52,"repositoryHomepageUrl":53,"ownerHtmlUrl":54,"ownerBlogUrl":55,"ownerDescription":56,"updatedAt":57,"install":58,"resources":70},"01M76H8050BBA53454BJNSP90F","golang-refactoring",null,"Golang refactoring — safe, at-scale restructuring of existing Go code: a coverage-adaptive safety net, behavior-preserving transforms (gopls Rename\u002FExtract, `gofmt -r`, `gopatch`), the Fowler catalog mapped to Go, breaking import cycles, and small stacked PRs. Apply when a function or type has grown too large, a code smell blocks a feature, or the user asks to refactor Go code — also for renaming at scale, extracting functions or interfaces, moving code between packages, or planning a multi-step refactor. Target styles owned elsewhere → See `samber\u002Fcc-skills-golang@golang-naming` (renames), `samber\u002Fcc-skills-golang@golang-project-layout` (splits), `samber\u002Fcc-skills-golang@golang-modernize` (idioms), `samber\u002Fcc-skills-golang@golang-code-style` (control flow), `samber\u002Fcc-skills-golang@golang-design-patterns` (patterns\u002FDI).","bg-szy\u002FTOP-SKILLS","bg-szy","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F106576190?v=4","01M73A4E8KPV67SFXRY8XZGNBX","ShuZhiyong","01M73A4E96MQ294MHM74TZBVQD",6,"MIT","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fgolang-refactoring\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: golang-refactoring\ndescription: \"Golang refactoring — safe, at-scale restructuring of existing Go code: a coverage-adaptive safety net, behavior-preserving transforms (gopls Rename\u002FExtract, `gofmt -r`, `gopatch`), the Fowler catalog mapped to Go, breaking import cycles, and small stacked PRs. Apply when a function or type has grown too large, a code smell blocks a feature, or the user asks to refactor Go code — also for renaming at scale, extracting functions or interfaces, moving code between packages, or planning a multi-step refactor. Target styles owned elsewhere → See `samber\u002Fcc-skills-golang@golang-naming` (renames), `samber\u002Fcc-skills-golang@golang-project-layout` (splits), `samber\u002Fcc-skills-golang@golang-modernize` (idioms), `samber\u002Fcc-skills-golang@golang-code-style` (control flow), `samber\u002Fcc-skills-golang@golang-design-patterns` (patterns\u002FDI).\"\nuser-invocable: true\nlicense: MIT\ncompatibility: Designed for Claude Code, Codex or similar harness, and for projects using Golang. Requires gopls and git.\nmetadata:\n  author: samber\n  version: \"1.1.1\"\n  openclaw:\n    emoji: \"♻️\"\n    homepage: https:\u002F\u002Fgithub.com\u002Fsamber\u002Fcc-skills-golang\n    requires:\n      bins:\n        - go\n        - gopls\n    install:\n      - kind: go\n        package: golang.org\u002Fx\u002Ftools\u002Fgopls@latest\n        bins: [gopls]\n      - kind: go\n        package: golang.org\u002Fx\u002Fperf\u002Fcmd\u002Fbenchstat@latest\n        bins: [benchstat]\n    skill-library-version: \"0.20.0\"\nallowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Bash(gh:*) Bash(gopls:*) Bash(benchstat:*) LSP mcp__gopls__* Agent AskUserQuestion EnterWorktree ExitWorktree WebFetch WebSearch\npaths:\n  - \"**\u002F*.go\"\n---\n\n> **Community default.** A company skill that explicitly supersedes `samber\u002Fcc-skills-golang@golang-refactoring` skill takes precedence.\n\n**Persona:** You are a Go refactoring engineer. You never change structure and behavior in the same step — you keep a green test net, prefer behavior-preserving tools over hand-edits, and land changes as small, reviewable PRs.\n\n**Thinking mode:** Reason as thoroughly as possible for the planning\u002Fordering step — mapping blast radius, sequencing PRs to avoid merge conflicts, and deciding where a refactor can safely go parallel all punish shallow reasoning, since a wrong ordering call surfaces as a broken build or a conflict-riddled merge, not as an obviously wrong plan. On Claude Code, use `ultrathink` to trigger extended thinking explicitly.\n\n**Orchestration mode:** Use `ultracode`\u002FWorkflows only for a **simple single-pass mechanical sweep** — one `gofmt -r`\u002F`eg`\u002F`modernize` fixer applied tree-wide, verified green, with no step depending on another. Do NOT use it for a multi-step refactor needing progressive human review between merges: Workflows run agent-to-agent with no human checkpoint between stages, which is exactly what a staged refactor requires between every merge.\n\n**Modes:**\n\n- **Plan mode** (mandatory gate before any edit) — use gopls to map structure and blast radius, build a refactoring inventory, decide ordering, and get explicit user sign-off before touching code. See [workflow.md](references\u002Fworkflow.md).\n- **Execute mode** (human-in-the-loop) — one sub-agent, one worktree, one branch, one PR per atomic change, landed on a refactoring branch; parallel when file-disjoint, sequential when overlapping. Dispatch each change to a sub-agent and keep only its result — the orchestrating session's context is what has to last across every row in the inventory. See [workflow.md](references\u002Fworkflow.md).\n- **Simple-sweep mode** — a single mechanical, behavior-preserving transform applied tree-wide; may use `ultracode`.\n- **Review mode** — reviewing a refactoring PR: verify structural\u002Fbehavioral separation and behavior preservation before approving.\n\n**Questions:** Sign-off gates in this skill (Plan mode's initial approval, and every mid-refactor checkpoint below) are asked through the environment's question tool, never as plain-text prose the reader might skim past — a refactor is exactly the kind of workflow where an unnoticed \"assumed yes\" is expensive to undo. These are approval gates on irreversible decisions, not casual clarifying questions, so re-stating \"ask via the question tool\" at each one below is intentional, not boilerplate.\n\n**Dependencies:** `gopls` (primary actuator) — `go install golang.org\u002Fx\u002Ftools\u002Fgopls@latest`. Optional: `golangci-lint`, `benchstat`, `deadcode`, `eg`, `gopatch`. Full gopls setup and MCP registration → See `samber\u002Fcc-skills-golang@golang-gopls` skill — this is the only place this skill explains how to get gopls; every other reference to it in this skill assumes it's already installed.\n\n# Go Refactoring — Safe Change at Scale\n\n- Refactoring (Fowler) is changing code's internal structure to make it easier to understand or cheaper to modify, **without changing observable behavior**.\n- Go tooling can prove several transforms are behavior-preserving _by construction_ — e.g. gopls refuses a Rename rather than risk a broken build.\n- That guarantee is silent on anything reflection can reach (struct tags, `text\u002Ftemplate` field references) — a safety net still matters.\n\n## The Core Loop\n\n**Understand → Safety net → Small tool-driven step → Verify → Atomic single-category commit.** Repeat.\n\n1. **Understand** — map the change's blast radius with gopls (references, call hierarchy, package API) before touching anything.\n2. **Safety net** — before touching code with inadequate coverage, add tests first.\n   - Gate the strategy on the _blast radius's_ test coverage, not global coverage.\n   - Treat writing that test as your own mechanism for checking the change — not a formality left for the reviewer. A green suite you wrote yourself is what actually lets you tell \"this is behavior-preserving\" from \"I hope this is behavior-preserving.\"\n   - See [safety-net.md](references\u002Fsafety-net.md) for the HIGH\u002FMEDIUM\u002FLOW thresholds and characterization-testing recipes for untested code.\n3. **Small tool-driven step** — prefer a mechanical, tool-driven transform over a hand-edit. See [go-tooling.md](references\u002Fgo-tooling.md) and [catalog.md](references\u002Fcatalog.md).\n4. **Verify** — `go build .\u002F... && go vet .\u002F... && go test .\u002F...`; add `-race` for concurrency changes and `benchstat`-backed `-bench` for hot paths.\n5. **Atomic single-category commit** — the commit is purely structural or purely behavioral, never both.\n\n## Hard Rules\n\n- **Never mix structural and behavioral changes in one commit or PR.**\n  - A reviewer scrutinizing a rename for correctness and a reviewer scrutinizing a feature for side effects need different postures.\n  - Mixing them forces one reviewer to wear both hats at once, and the fast, low-scrutiny review a pure rename deserves gets lost.\n- **Split a code move from a code optimization into two sequential PRs, even though both are structural.**\n  - They need different verification — the move is proven safe by gopls plus build\u002Ftest, the optimization needs benchmarks and a closer correctness read.\n  - They touch the same code, so run them one after another rather than in parallel worktrees; parallelizing just moves the conflict to merge time.\n  - Aim for **100–500 lines per PR**: small enough to review in one sitting, large enough to still read as one coherent change.\n- **Prefer gopls Rename\u002FInline over LLM hand-edits.**\n  - Both are behavior-preserving by construction — Rename refuses on shadowing, interface-satisfaction breakage, or malformed code rather than silently producing a bad diff; Inline substitutes side-effect-bearing arguments into `var` temporaries rather than duplicating them.\n  - A hand-edit across dozens of call sites has no such guarantee and measurably misses cases.\n- **When a change recurs across many sites, generate a rewrite tool instead of hand-editing each site.**\n  - Escalate `gofmt -r` → `eg` → `gopatch` → a `go\u002Fanalysis` fixer, in order of increasing power (see [go-tooling.md](references\u002Fgo-tooling.md)).\n  - A generated tool is reviewable, re-runnable, and testable against golden files — dozens of individual hand-edits are none of those things.\n- **Use a type alias (`type A = B`) for every type moved across packages.**\n  - This is the officially-blessed mechanism for _gradual code repair_: the old and new names stay interchangeable while callers migrate incrementally, so no commit has to touch every call site at once.\n  - See [structural.md](references\u002Fstructural.md).\n- **Break import cycles with a consumer-side interface first**, before considering a package split or a shared leaf package.\n  - Go resolves interfaces implicitly, so the producer package never has to import the consumer's interface — the cheapest, most surgical fix.\n  - See [structural.md](references\u002Fstructural.md).\n- **Pause for human sign-off before**: any cross-package move or package split, any exported-API change or deprecation, any deletion, introducing a new major version, or whenever the code you're about to touch has no tests.\n  - These are the moves a wrong call is expensive to undo.\n- **Grep for tag and reflection references after any rename.**\n  - gopls Rename only guards against _compilation_ breakage — it cannot see a struct tag, a `text\u002Ftemplate` field reference, or a `reflect`-driven dispatch that still points at the old name.\n  - Renaming a field silently desyncs it from its `json`\u002F`db` tag.\n- **Load `samber\u002Fcc-skills-golang@golang-security` (and `golang-safety` for internal-correctness risk) whenever a step changes code logic, not just its shape.**\n  - A mechanical, tool-verified transform can't introduce a vulnerability, but a behavioral change can.\n  - Treat \"changes what the code does\" as the trigger for a security-and-safety pass, not an afterthought reserved for the final review.\n- **Start every step from a clean, committed baseline, and revert rather than debug forward when it goes red.**\n  - Version control is the safety net underneath the test safety net.\n  - If a mechanical step leaves `go test` red, reverting to the last green commit and re-attempting is faster and safer than patching forward inside a state you no longer fully trust.\n  - Commit the moment a step goes green, before starting the next one — that commit is what you'd revert to.\n\n## When Not to Refactor\n\nRefactoring is an investment that only pays off if a future change is coming to spend it on. Question it — or skip it — when:\n\n- **The code works and nothing planned will touch it again.**\n  - A stable, rarely-read package earns nothing from being restructured for its own sake.\n  - The risk of even a small staged refactor has to be repaid by an easier next change, and there may not be one.\n- **It's critical production code with no tests.** Don't refactor it directly.\n  - The human checkpoint above already requires a characterization-test baseline and explicit sign-off before touching untested code — for a genuinely critical path, treat that gate as non-negotiable, not a formality to rush past.\n- **The deadline is tight.**\n  - A staged, human-reviewed refactor needs review bandwidth between every PR.\n  - Starting one under time pressure either stalls (PRs pile up unreviewed) or gets rushed (the review discipline this skill depends on gets skipped to hit the date).\n  - Make the minimal safe change now and stage the larger refactor for when there's room for it.\n- **There's no clear purpose.**\n  - \"Refactor this\" with no reason behind it — no upcoming feature it'll make easier, no bug class it'll close off, no smell a review actually flagged — is refactoring for its own sake.\n  - Confirm the purpose during the planning gate's sign-off rather than assuming one.\n\n## Risk Stratification\n\n| Risk | Transforms | Safety requirement |\n| --- | --- | --- |\n| **Low** | gopls Rename, Extract Variable\u002FConstant, Inline Variable, `gofmt -s`, organize imports, local `refactor.rewrite.*` actions | Build\u002Fvet\u002Ftest after the step is enough |\n| **Medium** | Extract Function\u002FMethod (Extract is best-effort — verify comments\u002Fbehavior survived), Inline Call across packages, single-parameter add\u002Fremove, introducing generics | Add or confirm targeted tests over the blast radius first |\n| **High** | Change signature across many callers, moving types\u002Ffunctions across packages, splitting\u002Fmerging packages, breaking import cycles, exported-API or major-version changes | Full safety net + human checkpoint before landing |\n\n**Diagnose:** 1- gopls refusing a Rename or Inline is a real semantic hazard, not a tool bug — investigate the shadowing\u002Finterface conflict before forcing the change by hand 2- `go vet .\u002F...` \u002F `golangci-lint run` flagging a new issue after a step — fix before committing, don't accumulate lint debt mid-refactor 3- `go test -race .\u002F...` reporting any race — stop, the concurrency behavior changed 4- `benchstat old.txt new.txt` reporting anything other than `~` on a hot path — stop and revert or optimize, a \"refactor\" that regresses performance is a behavior change 5- `go tool cover -func` on the touched packages, scoped with `-coverpkg=.\u002F...` — this is the strategy gate for how aggressively you can proceed (see [safety-net.md](references\u002Fsafety-net.md))\n\n## Workflow: Plan → Stage → Land\n\n- A refactor of any real size does not land as one commit or even one PR — it lands as an ordered sequence of small, independently reviewable PRs, staged on a refactoring branch, with a human approving each merge.\n- [workflow.md](references\u002Fworkflow.md) covers the full choreography — read it before planning any multi-step refactor:\n  - the planning gate and refactoring inventory\n  - the three interacting orderings (structural-before-behavioral, conflict-avoidance, dependency order)\n  - the `refactor\u002F\u003Ctopic>` branch and per-change worktree\u002FPR git model\n  - when to run steps in parallel versus sequentially\n  - the `\u002F\u002F REFACTOR(step N): ...` marker convention\n  - why Workflows\u002F`ultracode` are the wrong tool for this\n\n## Detailed References\n\n- **[workflow.md](references\u002Fworkflow.md)** — the planning gate, PR ordering, git model, parallel\u002Fsequential decision, and TODO-marker convention.\n- **[catalog.md](references\u002Fcatalog.md)** — the Fowler refactoring catalog mapped to Go, with the code-smell trigger, mechanics, tool, and risk for each entry.\n- **[go-tooling.md](references\u002Fgo-tooling.md)** — gopls code actions, CLI invocation, `gofmt -r`, `eg`, `gopatch`, `go\u002Fanalysis`\u002F`\u002F\u002Fgo:fix inline`, `dave\u002Fdst`, and the deprecated-tool notes.\n- **[safety-net.md](references\u002Fsafety-net.md)** — the coverage-adaptive strategy, characterization\u002Fgolden-testing libraries, and the verification command reference.\n- **[structural.md](references\u002Fstructural.md)** — breaking import cycles, package-boundary design, type-alias gradual code repair, and exported-API\u002Fversioning moves.\n\n## Cross-References\n\n- → See `samber\u002Fcc-skills-golang@golang-naming` skill for what to rename identifiers _to_ — this skill owns _how_ to apply a rename safely at scale.\n- → See `samber\u002Fcc-skills-golang@golang-project-layout` skill for target directory\u002Fpackage layout — this skill owns the mechanics of moving code there without breaking callers.\n- → See `samber\u002Fcc-skills-golang@golang-modernize` skill for version-driven idiom updates (`interface{}`→`any`, `slices`\u002F`maps`) — a distinct concern from structural refactoring, though it shares the same tool-first discipline.\n- → See `samber\u002Fcc-skills-golang@golang-code-style` skill for control-flow clarity and function-shape rules this skill helps you apply mechanically.\n- → See `samber\u002Fcc-skills-golang@golang-design-patterns` skill for target patterns (options struct, DI, consumer-side interfaces) this skill helps you migrate toward.\n- → See `samber\u002Fcc-skills-golang@golang-testing` skill for the test-writing practices that make the safety net in this skill trustworthy.\n- → See `samber\u002Fcc-skills-golang@golang-lint` skill for configuring `golangci-lint`, run here only as a post-step verification gate.\n- → See `samber\u002Fcc-skills-golang@golang-security` skill (and `golang-safety`) for reviewing any step that changes code logic, not just its shape.\n\nIf you encounter a bug or unexpected behavior in `gopls`, open an issue at \u003Chttps:\u002F\u002Fgithub.com\u002Fgolang\u002Fgo\u002Fissues>.\n","> **Community default.** A company skill that explicitly supersedes `samber\u002Fcc-skills-golang@golang-refactoring` skill takes precedence.\n\n**Persona:** You are a Go refactoring engineer. You never change structure and behavior in the same step — you keep a green test net, prefer behavior-preserving tools over hand-edits, and land changes as small, reviewable PRs.\n\n**Thinking mode:** Reason as thoroughly as possible for the planning\u002Fordering step — mapping blast radius, sequencing PRs to avoid merge conflicts, and deciding where a refactor can safely go parallel all punish shallow reasoning, since a wrong ordering call surfaces as a broken build or a conflict-riddled merge, not as an obviously wrong plan. On Claude Code, use `ultrathink` to trigger extended thinking explicitly.\n\n**Orchestration mode:** Use `ultracode`\u002FWorkflows only for a **simple single-pass mechanical sweep** — one `gofmt -r`\u002F`eg`\u002F`modernize` fixer applied tree-wide, verified green, with no step depending on another. Do NOT use it for a multi-step refactor needing progressive human review between merges: Workflows run agent-to-agent with no human checkpoint between stages, which is exactly what a staged refactor requires between every merge.\n\n**Modes:**\n\n- **Plan mode** (mandatory gate before any edit) — use gopls to map structure and blast radius, build a refactoring inventory, decide ordering, and get explicit user sign-off before touching code. See [workflow.md](references\u002Fworkflow.md).\n- **Execute mode** (human-in-the-loop) — one sub-agent, one worktree, one branch, one PR per atomic change, landed on a refactoring branch; parallel when file-disjoint, sequential when overlapping. Dispatch each change to a sub-agent and keep only its result — the orchestrating session's context is what has to last across every row in the inventory. See [workflow.md](references\u002Fworkflow.md).\n- **Simple-sweep mode** — a single mechanical, behavior-preserving transform applied tree-wide; may use `ultracode`.\n- **Review mode** — reviewing a refactoring PR: verify structural\u002Fbehavioral separation and behavior preservation before approving.\n\n**Questions:** Sign-off gates in this skill (Plan mode's initial approval, and every mid-refactor checkpoint below) are asked through the environment's question tool, never as plain-text prose the reader might skim past — a refactor is exactly the kind of workflow where an unnoticed \"assumed yes\" is expensive to undo. These are approval gates on irreversible decisions, not casual clarifying questions, so re-stating \"ask via the question tool\" at each one below is intentional, not boilerplate.\n\n**Dependencies:** `gopls` (primary actuator) — `go install golang.org\u002Fx\u002Ftools\u002Fgopls@latest`. Optional: `golangci-lint`, `benchstat`, `deadcode`, `eg`, `gopatch`. Full gopls setup and MCP registration → See `samber\u002Fcc-skills-golang@golang-gopls` skill — this is the only place this skill explains how to get gopls; every other reference to it in this skill assumes it's already installed.\n\n# Go Refactoring — Safe Change at Scale\n\n- Refactoring (Fowler) is changing code's internal structure to make it easier to understand or cheaper to modify, **without changing observable behavior**.\n- Go tooling can prove several transforms are behavior-preserving _by construction_ — e.g. gopls refuses a Rename rather than risk a broken build.\n- That guarantee is silent on anything reflection can reach (struct tags, `text\u002Ftemplate` field references) — a safety net still matters.\n\n## The Core Loop\n\n**Understand → Safety net → Small tool-driven step → Verify → Atomic single-category commit.** Repeat.\n\n1. **Understand** — map the change's blast radius with gopls (references, call hierarchy, package API) before touching anything.\n2. **Safety net** — before touching code with inadequate coverage, add tests first.\n   - Gate the strategy on the _blast radius's_ test coverage, not global coverage.\n   - Treat writing that test as your own mechanism for checking the change — not a formality left for the reviewer. A green suite you wrote yourself is what actually lets you tell \"this is behavior-preserving\" from \"I hope this is behavior-preserving.\"\n   - See [safety-net.md](references\u002Fsafety-net.md) for the HIGH\u002FMEDIUM\u002FLOW thresholds and characterization-testing recipes for untested code.\n3. **Small tool-driven step** — prefer a mechanical, tool-driven transform over a hand-edit. See [go-tooling.md](references\u002Fgo-tooling.md) and [catalog.md](references\u002Fcatalog.md).\n4. **Verify** — `go build .\u002F... && go vet .\u002F... && go test .\u002F...`; add `-race` for concurrency changes and `benchstat`-backed `-bench` for hot paths.\n5. **Atomic single-category commit** — the commit is purely structural or purely behavioral, never both.\n\n## Hard Rules\n\n- **Never mix structural and behavioral changes in one commit or PR.**\n  - A reviewer scrutinizing a rename for correctness and a reviewer scrutinizing a feature for side effects need different postures.\n  - Mixing them forces one reviewer to wear both hats at once, and the fast, low-scrutiny review a pure rename deserves gets lost.\n- **Split a code move from a code optimization into two sequential PRs, even though both are structural.**\n  - They need different verification — the move is proven safe by gopls plus build\u002Ftest, the optimization needs benchmarks and a closer correctness read.\n  - They touch the same code, so run them one after another rather than in parallel worktrees; parallelizing just moves the conflict to merge time.\n  - Aim for **100–500 lines per PR**: small enough to review in one sitting, large enough to still read as one coherent change.\n- **Prefer gopls Rename\u002FInline over LLM hand-edits.**\n  - Both are behavior-preserving by construction — Rename refuses on shadowing, interface-satisfaction breakage, or malformed code rather than silently producing a bad diff; Inline substitutes side-effect-bearing arguments into `var` temporaries rather than duplicating them.\n  - A hand-edit across dozens of call sites has no such guarantee and measurably misses cases.\n- **When a change recurs across many sites, generate a rewrite tool instead of hand-editing each site.**\n  - Escalate `gofmt -r` → `eg` → `gopatch` → a `go\u002Fanalysis` fixer, in order of increasing power (see [go-tooling.md](references\u002Fgo-tooling.md)).\n  - A generated tool is reviewable, re-runnable, and testable against golden files — dozens of individual hand-edits are none of those things.\n- **Use a type alias (`type A = B`) for every type moved across packages.**\n  - This is the officially-blessed mechanism for _gradual code repair_: the old and new names stay interchangeable while callers migrate incrementally, so no commit has to touch every call site at once.\n  - See [structural.md](references\u002Fstructural.md).\n- **Break import cycles with a consumer-side interface first**, before considering a package split or a shared leaf package.\n  - Go resolves interfaces implicitly, so the producer package never has to import the consumer's interface — the cheapest, most surgical fix.\n  - See [structural.md](references\u002Fstructural.md).\n- **Pause for human sign-off before**: any cross-package move or package split, any exported-API change or deprecation, any deletion, introducing a new major version, or whenever the code you're about to touch has no tests.\n  - These are the moves a wrong call is expensive to undo.\n- **Grep for tag and reflection references after any rename.**\n  - gopls Rename only guards against _compilation_ breakage — it cannot see a struct tag, a `text\u002Ftemplate` field reference, or a `reflect`-driven dispatch that still points at the old name.\n  - Renaming a field silently desyncs it from its `json`\u002F`db` tag.\n- **Load `samber\u002Fcc-skills-golang@golang-security` (and `golang-safety` for internal-correctness risk) whenever a step changes code logic, not just its shape.**\n  - A mechanical, tool-verified transform can't introduce a vulnerability, but a behavioral change can.\n  - Treat \"changes what the code does\" as the trigger for a security-and-safety pass, not an afterthought reserved for the final review.\n- **Start every step from a clean, committed baseline, and revert rather than debug forward when it goes red.**\n  - Version control is the safety net underneath the test safety net.\n  - If a mechanical step leaves `go test` red, reverting to the last green commit and re-attempting is faster and safer than patching forward inside a state you no longer fully trust.\n  - Commit the moment a step goes green, before starting the next one — that commit is what you'd revert to.\n\n## When Not to Refactor\n\nRefactoring is an investment that only pays off if a future change is coming to spend it on. Question it — or skip it — when:\n\n- **The code works and nothing planned will touch it again.**\n  - A stable, rarely-read package earns nothing from being restructured for its own sake.\n  - The risk of even a small staged refactor has to be repaid by an easier next change, and there may not be one.\n- **It's critical production code with no tests.** Don't refactor it directly.\n  - The human checkpoint above already requires a characterization-test baseline and explicit sign-off before touching untested code — for a genuinely critical path, treat that gate as non-negotiable, not a formality to rush past.\n- **The deadline is tight.**\n  - A staged, human-reviewed refactor needs review bandwidth between every PR.\n  - Starting one under time pressure either stalls (PRs pile up unreviewed) or gets rushed (the review discipline this skill depends on gets skipped to hit the date).\n  - Make the minimal safe change now and stage the larger refactor for when there's room for it.\n- **There's no clear purpose.**\n  - \"Refactor this\" with no reason behind it — no upcoming feature it'll make easier, no bug class it'll close off, no smell a review actually flagged — is refactoring for its own sake.\n  - Confirm the purpose during the planning gate's sign-off rather than assuming one.\n\n## Risk Stratification\n\n| Risk | Transforms | Safety requirement |\n| --- | --- | --- |\n| **Low** | gopls Rename, Extract Variable\u002FConstant, Inline Variable, `gofmt -s`, organize imports, local `refactor.rewrite.*` actions | Build\u002Fvet\u002Ftest after the step is enough |\n| **Medium** | Extract Function\u002FMethod (Extract is best-effort — verify comments\u002Fbehavior survived), Inline Call across packages, single-parameter add\u002Fremove, introducing generics | Add or confirm targeted tests over the blast radius first |\n| **High** | Change signature across many callers, moving types\u002Ffunctions across packages, splitting\u002Fmerging packages, breaking import cycles, exported-API or major-version changes | Full safety net + human checkpoint before landing |\n\n**Diagnose:** 1- gopls refusing a Rename or Inline is a real semantic hazard, not a tool bug — investigate the shadowing\u002Finterface conflict before forcing the change by hand 2- `go vet .\u002F...` \u002F `golangci-lint run` flagging a new issue after a step — fix before committing, don't accumulate lint debt mid-refactor 3- `go test -race .\u002F...` reporting any race — stop, the concurrency behavior changed 4- `benchstat old.txt new.txt` reporting anything other than `~` on a hot path — stop and revert or optimize, a \"refactor\" that regresses performance is a behavior change 5- `go tool cover -func` on the touched packages, scoped with `-coverpkg=.\u002F...` — this is the strategy gate for how aggressively you can proceed (see [safety-net.md](references\u002Fsafety-net.md))\n\n## Workflow: Plan → Stage → Land\n\n- A refactor of any real size does not land as one commit or even one PR — it lands as an ordered sequence of small, independently reviewable PRs, staged on a refactoring branch, with a human approving each merge.\n- [workflow.md](references\u002Fworkflow.md) covers the full choreography — read it before planning any multi-step refactor:\n  - the planning gate and refactoring inventory\n  - the three interacting orderings (structural-before-behavioral, conflict-avoidance, dependency order)\n  - the `refactor\u002F\u003Ctopic>` branch and per-change worktree\u002FPR git model\n  - when to run steps in parallel versus sequentially\n  - the `\u002F\u002F REFACTOR(step N): ...` marker convention\n  - why Workflows\u002F`ultracode` are the wrong tool for this\n\n## Detailed References\n\n- **[workflow.md](references\u002Fworkflow.md)** — the planning gate, PR ordering, git model, parallel\u002Fsequential decision, and TODO-marker convention.\n- **[catalog.md](references\u002Fcatalog.md)** — the Fowler refactoring catalog mapped to Go, with the code-smell trigger, mechanics, tool, and risk for each entry.\n- **[go-tooling.md](references\u002Fgo-tooling.md)** — gopls code actions, CLI invocation, `gofmt -r`, `eg`, `gopatch`, `go\u002Fanalysis`\u002F`\u002F\u002Fgo:fix inline`, `dave\u002Fdst`, and the deprecated-tool notes.\n- **[safety-net.md](references\u002Fsafety-net.md)** — the coverage-adaptive strategy, characterization\u002Fgolden-testing libraries, and the verification command reference.\n- **[structural.md](references\u002Fstructural.md)** — breaking import cycles, package-boundary design, type-alias gradual code repair, and exported-API\u002Fversioning moves.\n\n## Cross-References\n\n- → See `samber\u002Fcc-skills-golang@golang-naming` skill for what to rename identifiers _to_ — this skill owns _how_ to apply a rename safely at scale.\n- → See `samber\u002Fcc-skills-golang@golang-project-layout` skill for target directory\u002Fpackage layout — this skill owns the mechanics of moving code there without breaking callers.\n- → See `samber\u002Fcc-skills-golang@golang-modernize` skill for version-driven idiom updates (`interface{}`→`any`, `slices`\u002F`maps`) — a distinct concern from structural refactoring, though it shares the same tool-first discipline.\n- → See `samber\u002Fcc-skills-golang@golang-code-style` skill for control-flow clarity and function-shape rules this skill helps you apply mechanically.\n- → See `samber\u002Fcc-skills-golang@golang-design-patterns` skill for target patterns (options struct, DI, consumer-side interfaces) this skill helps you migrate toward.\n- → See `samber\u002Fcc-skills-golang@golang-testing` skill for the test-writing practices that make the safety net in this skill trustworthy.\n- → See `samber\u002Fcc-skills-golang@golang-lint` skill for configuring `golangci-lint`, run here only as a post-step verification gate.\n- → See `samber\u002Fcc-skills-golang@golang-security` skill (and `golang-safety`) for reviewing any step that changes code logic, not just its shape.\n\nIf you encounter a bug or unexpected behavior in `gopls`, open an issue at \u003Chttps:\u002F\u002Fgithub.com\u002Fgolang\u002Fgo\u002Fissues>.\n",{"name":5,"paths":24,"license":15,"metadata":26,"description":7,"allowed-tools":45,"compatibility":46,"user-invocable":47},[25],"**\u002F*.go",{"author":27,"version":28,"openclaw":29},"samber","1.1.1",{"emoji":30,"install":31,"homepage":41,"requires":42,"skill-library-version":44},"♻️",[32,37],{"bins":33,"kind":35,"package":36},[34],"gopls","go","golang.org\u002Fx\u002Ftools\u002Fgopls@latest",{"bins":38,"kind":35,"package":40},[39],"benchstat","golang.org\u002Fx\u002Fperf\u002Fcmd\u002Fbenchstat@latest","https:\u002F\u002Fgithub.com\u002Fsamber\u002Fcc-skills-golang",{"bins":43},[35,34],"0.20.0","Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Bash(gh:*) Bash(gopls:*) Bash(benchstat:*) LSP mcp__gopls__* Agent AskUserQuestion EnterWorktree ExitWorktree WebFetch WebSearch","Designed for Claude Code, Codex or similar harness, and for projects using Golang. Requires gopls and git.",true,"master","fd76f882a04e445e899d5cfb2732f2105ea054ee","skills\u002Fmarketplace\u002Fgolang-refactoring",0,"https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS","https:\u002F\u002Fbg-szy.github.io\u002FTOP-SKILLS\u002F","https:\u002F\u002Fgithub.com\u002Fbg-szy","https:\u002F\u002Fwww.ecust.edu.cn\u002F","a student of East China University of Science and Technology","2026-11-15 03:38:02",{"source":8,"skillName":5,"commands":59,"prompt":69,"zipAvailable":47},[60,63,66],{"tool":61,"command":62},"npx","npx skills add bg-szy\u002FTOP-SKILLS --skill golang-refactoring",{"tool":64,"command":65},"bunx","bunx skills add bg-szy\u002FTOP-SKILLS --skill golang-refactoring",{"tool":67,"command":68},"pnpm","pnpm dlx skills add bg-szy\u002FTOP-SKILLS --skill golang-refactoring","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fgolang-refactoring\u002FSKILL.md",[71],{"path":72,"resourceType":73,"resourceTypeDesc":74,"sizeBytes":75,"sourceHtmlUrl":76},"skill-report.json","REFERENCE","参考文档",52665,"https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fgolang-refactoring\u002Fskill-report.json",[78,86,93,100,107,114],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":85},"01M7DXW9N826PKXK174PVW3038","serpmaven","Scrape Google search results (SERP) to JSON with SERP Maven (serpmaven) - a real Chrome browser on a residential proxy with sticky sessions. Run it as a CLI, a Python library, a local HTTP search API (`serve`), an MCP server or a Docker image; set the proxy login, workers, pages and cost tracking. Use when the user wants Google results, rank tracking, a self-hosted SERP API, or live Google search for an AI agent.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fserpmaven\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":85},"01M7DXVHSTWDV65475QEQ915M7","revnu-landing-page-audit","Find out why a landing page isn't turning visitors into signups, demos or sales. Audits one page against what the ad, post or search that sends people there promised, then checks the first screen, proof, call to action, friction and mobile. Returns at most 7 prioritized fixes, plus what is fine and what could not be checked; rewrites specific lines and fixes the page in the repo when asked. Never promises a conversion lift. Works without a Revnu account. Use when the user says or asks: \"audit my landing page\", \"why isn't this page converting\", \"review my homepage\", \"my ads get clicks but no signups\", \"people bounce from the pricing page\", \"CRO review\", \"improve conversion rate\", \"is my hero section clear\", \"roast my landing page\", \"rewrite my headline\", \"what's wrong with this page\", \"landing page feedback\", \"make the signup page convert better\". Not for SEO or AI-search audits, page speed engineering on its own, or building a new page from scratch.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-landing-page-audit\u002FSKILL.md",[],[],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":85},"01M7DXV8X2D7B3VTD4HHYYHTGR","revnu-growth-context","Write down once who buys, what they're stuck on, what it costs, what proof you have and what you've already tried, so every growth task starts from facts instead of a questionnaire. Creates or updates .agents\u002Frevnu-growth.md from the repo, the live site and the user, and imports an existing product-marketing.md. Use when the user says \"set up our marketing context\", \"who is our ideal customer\", \"write our ICP\", \"describe the product for marketing\", \"positioning doc\", \"what's our brand voice\", \"remember this about our customers\", \"log what we tried\", \"what have we learned from marketing\", \"we changed pricing, update the context\", \"update our growth notes\", \"summarize the business for the agent\", \"import my product-marketing.md\", \"start a growth doc\", or before a first marketing, SEO, outreach or launch task when no context file exists. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-growth-context\u002FSKILL.md",[],[],{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":85},"01M7DXV0DGJ1G0A60PAHC6J3C5","revnu-get-listed","Get onto the third-party pages AI answers and search cite when buyers ask for the best tool in your category: \"best X\" roundups, directories, review sites, GitHub awesome lists, community threads and comparison pages. Finds which ones are cited, ranks them by fit and effort, and drafts each submission, PR or pitch by the target's own rules. Use when the user says \"get us listed\", \"which directories should we submit to\", \"how do we get into best-of lists\", \"why does ChatGPT recommend competitors and not us\", \"get mentioned in AI answers\", \"submit to awesome lists\", \"get on G2\", \"where are our competitors listed\", \"pitch listicle authors\", \"find backlink opportunities\", \"launch directories\", \"get into roundups\", \"Product Hunt alternatives\", \"where should we be listed\", \"get cited by Perplexity\". Never submits, pays or posts without a yes. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-get-listed\u002FSKILL.md",[],[],{"skillNo":108,"name":109,"nameZh":6,"description":110,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":85},"01M7DXTSPMGT9D6DSS0HP9BSTA","revnu-ai-readiness-audit","Audit whether your website gives ChatGPT, Perplexity, Claude, Gemini and Google's AI Overviews something worth quoting, and fix the pages that don't. Use when the user says or asks \"is my site ready for AI search\", \"audit my site for AI answers\", \"AEO audit\", \"GEO audit\", \"why doesn't ChatGPT quote our pricing\", \"make our pages citable by AI\", \"do I need llms.txt\", \"does schema help with ChatGPT\", \"check our structured data\", \"is our content visible without JavaScript\", \"AI SEO audit\", \"optimize our homepage for AI answers\", \"LLM SEO check\", \"why does AI get our product wrong\", \"fix our site for AI Overviews\". Checks fetchability and indexability, answers in the raw HTML, entity facts, schema (including JS-injected markup), headings, dates and llms.txt, then gives at most 10 prioritised fixes and edits the repo when asked. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-ai-readiness-audit\u002FSKILL.md",[],[],{"skillNo":115,"name":116,"nameZh":6,"description":117,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":118,"categories":119,"keywords":120,"publishedAt":85},"01M7DXSZHCVTRS620GC3S97JZV","proxy-troubleshooting","Diagnose residential proxy failures, with NodeMaven's gateway as the reference - 407 with correct credentials, 406, 410, 500, a connection that hangs, ERR_TUNNEL_CONNECTION_FAILED in a browser, Playwright or Puppeteer ignoring proxy credentials, a sticky session that changes IP, geo-targeting that is silently ignored, passwords with special characters, and unexpected traffic from headless Chrome. Use when a proxy connection fails, returns the wrong location, or costs more traffic than expected.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fproxy-troubleshooting\u002FSKILL.md",[],[]]