[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M77HG6WRREQAKHV2Y8CAVCSB":3,"skill-same:01M77HG6WRREQAKHV2Y8CAVCSB":49},{"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":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":32,"ownerHtmlUrl":33,"ownerBlogUrl":34,"ownerDescription":6,"updatedAt":35,"install":36,"resources":48},"01M77HG6WRREQAKHV2Y8CAVCSB","modularize",null,"One focused, repeatable pass that retires the code-quality scorecard's `architecture` debt — the god-files (>1500 lines) and god-functions (>200 lines) that \u002Fquality-score flags as RISKY and explicitly defers to \"a focused pass\". Splits a monolith along REAL concern seams via behavior-preserving code motion (hazard-check → plan with tools\u002Fgodsplit_plan.py → extract → goimports\u002Fgofmt → prove no decl dropped with tools\u002Frefactor_verify.py → verify → commit by explicit path), and extracts long functions into named helpers. Use when this named workflow matches the task.","anthony-chaudhary\u002Ffak","anthony-chaudhary","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F18080164?v=4","01M77GSKCAEKV3JS07J40B94DY","Anthony Chaudhary","01M77GSKD26Z7F4FQQD4VA30VX",48,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fanthony-chaudhary\u002Ffak\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fmodularize\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: modularize\ndescription: \"One focused, repeatable pass that retires the code-quality scorecard's `architecture` debt — the god-files (>1500 lines) and god-functions (>200 lines) that \u002Fquality-score flags as RISKY and explicitly defers to \\\"a focused pass\\\". Splits a monolith along REAL concern seams via behavior-preserving code motion (hazard-check → plan with tools\u002Fgodsplit_plan.py → extract → goimports\u002Fgofmt → prove no decl dropped with tools\u002Frefactor_verify.py → verify → commit by explicit path), and extracts long functions into named helpers. Use when this named workflow matches the task.\"\ndisable-model-invocation: false\nuser-invocable: true\nallowed-tools: Read, Bash, Write, Edit, Grep, Glob\nargument-hint: \"[file-or-package] (no args = take the heaviest architecture defect from the scorecard)\"\n---\n\n# \u002Fmodularize — split the monoliths, provably, without changing behavior\n\n> **What this does.** `\u002Fquality-score` measures ten KPIs and retires the safe ones,\n> but it marks `architecture` **RISKY** and defers it: *\"do it in ONE lane, keep\n> behavior identical… if you can't do it safely this pass, leave it for a focused\n> pass — do NOT half-do a refactor.\"* **This is that focused pass.** It takes the\n> god-files and god-functions that drag the `architecture` KPI to the floor and\n> splits them along real concern seams — as **behavior-preserving code motion**,\n> verified by the toolchain, proven by the scorecard, committed by explicit path on\n> the shared trunk. In one run it took fak from code-debt **12 → 0**, score **86.2\n> (B) → 95.9 (A)**.\n\nThe shape: **find the heaviest architecture defect → plan the cut (boundaries +\nhazards) → split (file = code motion, function = extract) → verify (build\u002Fvet\u002Ftest +\nbehaviour review) → prove the drop → commit ONLY your packages by explicit path.**\n\n## The one insight that makes this safe\n\nMoving a top-level declaration to another file **in the same package** is a *semantic\nno-op in Go* — package, not file, is the scope. So a god-file split can't change\nbehavior, and `go build` + `go vet` + `go test` is a *near*-complete gate. The residual\n`go build` cannot cover — a top-level decl **dropped** by an incomplete cut that happens\nto be unreferenced in-module (so no `undefined:`) — is what closes it from *near* to\ncomplete: `tools\u002Frefactor_verify.py` proves the declaration set was preserved (Step 4).\nThere are exactly **three exceptions** that make code motion NOT a no-op;\n`tools\u002Fgodsplit_plan.py` flags all three:\n\n1. **per-file build tags** (`\u002F\u002Fgo:build …`) — moving a decl changes which file carries the constraint;\n2. **`func init()`** — init order is **filename-alphabetical** across a package, so moving an `init()` between files can silently reorder initialization;\n3. **aliased imports** (`x \"path\"`) — `goimports -w` re-derives plain imports after a move but does **NOT** re-infer a local alias; you must copy it to the new file by hand.\n\nIf a file has a build tag or an `init()`, keep those decls where they are (or in a file\nwhose name preserves init order) — don't move them blind.\n\n## Step 1 — Find the target (the scorecard builds the work-list)\n\n```bash\npython tools\u002Fcode_quality_scorecard.py --no-toolchain --json   # fast; corpus.kpis architecture.defects = your work-list\n```\n\nRead `architecture`'s `defects`: each is `god-file \u003Cpath> (N lines > 1500)` or\n`god-function \u003Cpath>:\u003Cfn> (N lines > 200)`. Attack the heaviest first, and **bias to\nthe most critical packages** (the kernel — `adjudicator`, `gateway`, `model`,\n`ggufload` — and `cmd\u002Ffak`, the entry point — over demos\u002Fbenchmarks). Record the\nbaseline: `architecture defects = K`, `code_debt = N`, `score = S`.\n\n## Step 2 — Plan the cut (boundaries + hazards, computed not guessed)\n\nThe error-prone part of a clean split is cutting at the right line: a decl's doc comment\nsits ABOVE its keyword, so a naive cut at `func`\u002F`type` orphans the comment. Let the\nplanner compute the doc-comment-aware ranges and the three hazards:\n\n```bash\npython tools\u002Fgodsplit_plan.py internal\u002Fmodel\u002Fkv.go            # human table\npython tools\u002Fgodsplit_plan.py internal\u002Fmodel\u002Fkv.go --json     # machine payload\n```\n\nEach decl row is `block_start..block_end \u003Ckind> \u003Cname>` — `block_start..block_end` is the\nexact `sed -n 'A,Bp'` range that carries the decl **with its doc comment** (func `[NL]` sizes\nare advisory; the Step 1 scorecard is the authority on what's a god-function). Group adjacent\ndecls into **cohesive concerns** (e.g. kv.go → `kvcache.go` for the KVCache type +\neviction, `rope.go` for rotary embedding, leaving the Session\u002Fforward core). Splitting on\nreal seams is the whole point — see the anti-gaming laws.\n\n**Sanity-check the plan before trusting it** — `godsplit_plan.py` is a LINE parser, not a Go\ntokenizer. Fall back to a hand cut if ANY of these hold: a decl row prints `!! INVERTED\nRANGE`; the `raw_strings` hazard is > 0 (a multi-line backtick string can hide or shift a\ncolumn-0 decl — eyeball those ranges); or the plan's decl count disagrees with the truth:\n\n```bash\ngrep -cE '^(func|type|var|const) ' \u003Cfile>   # must equal the number of rows the plan printed\n```\n\n`goimports` is the engine of the file split and is **not preinstalled** — install it and\nconfirm it resolved before you cut anything:\n\n```bash\ngo install golang.org\u002Fx\u002Ftools\u002Fcmd\u002Fgoimports@latest\ncommand -v goimports || { echo \"goimports missing — $(go env GOPATH)\u002Fbin not on PATH\"; exit 1; }\n```\n\n## Step 3 — Split\n\nRun the snippets below with the **Bash tool** — they are POSIX sh (`sed`, the `mk()`\nfunction, `goimports`\u002F`gofmt`), not PowerShell. **Precondition: `gofmt -w \u003Cfile>` BEFORE you\nplan**, so the package clause and import block are blank-separated and no extract range can\nstart at the package line.\n\n### A. God-FILE → concern files (pure code motion)\n\nCreate each new file from its block range, then delete the moved ranges **bottom-up** (so\nearlier deletes don't shift later line numbers), then let `goimports` fix every import. The\npackage name and target dir are read from the file so the snippet is copy-paste-safe in any\npackage:\n\n```bash\nF=internal\u002Fmodel\u002Fkv.go\nD=$(dirname \"$F\")\nPKG=$(python tools\u002Fgodsplit_plan.py \"$F\" --json | python -c 'import sys,json;print(json.load(sys.stdin)[\"package\"])')\nmk(){ { echo \"package $PKG\"; echo; sed -n \"$2,$3p\" \"$F\"; } > \"$D\u002F$1\"; }\nmk kvcache.go 10 272          # ranges = block_start..block_end from godsplit_plan.py\nmk rope.go    389 577\nsed -i '389,577d' \"$F\"; sed -i '10,272d' \"$F\"      # BOTTOM-UP: highest range first\ngoimports -w \"$F\" \"$D\u002Fkvcache.go\" \"$D\u002Frope.go\"     # auto-fix imports\ngofmt -w     \"$F\" \"$D\u002Fkvcache.go\" \"$D\u002Frope.go\"\n```\n\nThen **re-add any aliased import by hand** to the new file (`godsplit_plan.py` lists them —\n`goimports` won't re-derive a local alias, and the build fails `undefined: \u003Calias>` without\nit). If the source file leads with a license\u002FSPDX header above `package`, copy it to each new\nfile too. The `sed -n 'A,Bp' > newfile` and `sed -i` here are the right tool for line-range\ncode motion; redirect only to **in-tree** paths — the repo-guard PreToolUse hook\n(`tools\u002Frepo_guard.py`; AGENTS.md `OUT_OF_TREE_WRITE`) refuses a `> \u002Fdev\u002Fnull` or `..\u002F` escape.\n\n### B. God-FUNCTION → helpers\n\n- **Linear flow** (e.g. a CLI `cmdServe`\u002F`cmdGuard`): extract coherent phases into helpers.\n  Return a small **struct** and unpack it to the **SAME local names** the caller already\n  uses (`up, base, key := us.provider, us.baseURL, us.apiKey`) so the rest of the function\n  is untouched — no cascading edits, smallest possible diff.\n- **Closure-soup** (a function whose closures share ~15 mutable locals, e.g. an SSE relay):\n  make the shared state a **named struct** and turn the closures into **methods** on it.\n  That's genuine modularity — named, individually-readable parts — not line-shuffling.\n- Avoid param explosion: when a helper would take 8+ args, group them into a struct. A\n  helper with 11 positional params is worse code than the god-function you started with.\n\n## Step 4 — Verify (behaviour is preserved — don't assume it, prove it)\n\n### 4.0 — Prove no definition was dropped (the check `go build` cannot do)\n\nA pure code-motion split preserves the package's top-level declaration set **exactly**.\n`go build` catches a *referenced* symbol that went missing (`undefined:`) and a *duplicated*\none (`redeclared`) — but a decl that was **dropped** and happens to be unreferenced in-module\n(dead-but-real, or an exported symbol whose only consumers are out-of-tree or a JSON wire\ncontract) compiles clean and vanishes silently. That is the \"split a god-file, then a\ndefinition is missing\" failure. Close it mechanically **first** — it is fast and catches what\nthe toolchain structurally cannot:\n\n```bash\npython tools\u002Frefactor_verify.py --expect-motion \u003Corig.go> \u003Cyour new files>   # exit 1 on any drop\n```\n\nIt diffs the package's decl multiset **before** (`HEAD`) vs **after** (working tree). For a\npure in-package split the correct verdict is `clean`; `--expect-motion` makes **any** decl\nthat left the package a hard failure. Read each finding:\n\n- **`DROPPED`** — a definition that exists **nowhere** after the cut. Either you missed a\n  `sed -n` range (the split is INCOMPLETE — go add it) or it is a genuine deletion, which does\n  **not** belong in a commit labelled \"pure code motion\" — split it into its own honest\n  `refactor(x): remove dead \u003Cname>` commit with the reason in the body.\n- **`RELOCATED`** — a decl moved to another package (a cross-package consolidation, not an\n  in-package split). Drop `--expect-motion`, include the destination package in scope, and\n  confirm each move is intended.\n- **`OVER-SPLIT`** — a new file carrying a single decl (see anti-gaming law #2).\n\n(Scope note: it is DECL-level — it proves no whole decl was dropped, not that a struct's\nFIELDS survived a `type Local = pkg.Remote` alias consolidation. For that, read the aliased\ntype's fields by hand.)\n\n### 4.1 — Build, vet, test\n\n`go build` and `go vet` run natively; **run the tests under WSL** — per AGENTS.md, native\n`go test` is blocked by an OS Application-Control policy on freshly-compiled test binaries on\nthis checkout (an OS quirk, not a code failure), and `\u002Fquality-score` validates the same way:\n\n```bash\ngo build .\u002F...                                                   # whole-tree compile (catches a lost\u002Fduplicated symbol)\ngo vet .\u002F\u003Cpkg>\u002F...                                               # typecheck incl. _test.go\nwsl -e bash -lc 'cd \u002Fmnt\u002Fc\u002Fwork\u002Ffak && go test .\u002F\u003Cpkg>\u002F... -count=1'   # the real gate\n```\n\nIf native `go test` happens to run on your host, you may use it — but treat an\nApplication-Control block on a test binary as the documented ENVIRONMENT quirk, never as a\nbehaviour regression in your split. For `internal\u002Fmodel`, run the **full** (non-`-short`)\nsuite so the bit-exact oracle witnesses fire. If you DELEGATED a split to subagents, have an\nindependent reviewer confirm behaviour-preservation (no changed strings\u002Fflags\u002Fcontrol-flow\u002F\nexit-codes) **before** committing — read the diff in the reviewer, not in your own context.\n\nVerify formatting via the scorecard's `format` KPI (full run), not a naive `gofmt -l .`:\nthis checkout is CRLF in the working tree, so a local `gofmt -l .` flags hundreds of files as\na line-ending artifact (see `tools\u002Fgofmt_debt_audit.py` for the blob method).\n\n## Step 5 — Prove the drop\n\n```bash\npython tools\u002Fcode_quality_scorecard.py --no-toolchain --json   # architecture.defects should shrink\n```\n\nState it plainly: `architecture-debt K → K', code-debt N → M, score S → S'`. The bar for a\npass is **the heaviest architecture defect retired with behaviour proven green**.\n\n## Step 6 — Commit ONLY your packages, by explicit path\n\n```bash\nfak sync reconcile --apply\ngit status --porcelain                         # see which files peers are editing RIGHT NOW\nfak commit \\\n  --path \u003Corig.go> --path \u003Cyour new files> \\\n  -m \"refactor(\u003Cleaf>): split \u003Cfile> by concern\" \\\n  -m \"Pure code motion, no behavior change. \u003Cfile> N->M lines; extracted \u003Ca.go>, \u003Cb.go>. Verified build\u002Fvet\u002Ftest green.\" \\\n  [--push]\nfak sync push\n```\n\n- **Route around peer WIP.** A file showing in `git status --porcelain` is being edited by a\n  peer — do NOT split it this pass; pick a clean target. A path-scoped commit leaves peer-staged\n  files alone (you'll see them in `git diff --cached` — that's expected; your `--path` excludes\n  them from the commit).\n- **Honest subject.** A split\u002Fextraction is `refactor(\u003Cscope>):` — never `feat(`\u002F`fix(`. End every\n  ship commit with a `(fak \u003Cleaf>)` trailer (`(fak gateway)`, `(fak model)`; a `cmd\u002F\u003Cdir>` demo →\n  `(fak \u003Cdir>)`).\n- **Shared-trunk law.** Stay on `main` (the `OFF_TRUNK` guard refuses a branch — this is why\n  worktrees don't work, see below). Commit by explicit path via `fak commit --path`; if a peer's `MERGE_HEAD` is set, wait\n  for it to clear; never force-push.\n\n## Parallelizing across many targets (when there are several god-files)\n\nThe Workflow tool's `isolation: 'worktree'` **fails in this repo**: `git worktree add` creates a\nbranch and the trunk guard refuses it (`OFF_TRUNK`). To fan out: give each agent **one disjoint\nleaf package** (nothing two agents both touch), tell each to edit **in place**, run only **scoped**\nbuilds (`go build .\u002F\u003Cpkg>\u002F...`, never `go build .\u002F...` which races peers), and run **no git** — then\nthe orchestrator verifies and commits each package by explicit path. Have an independent reviewer\ncheck the delegated diffs for behaviour-preservation before committing.\n\n## Anti-gaming laws (the measure is only as honest as the pass)\n\n1. **Split on REAL concern seams, never arbitrary line counts.** Each new file is one cohesive\n   concern (the loader, the rotary embedding, the eviction path) — not \"lines 1–700 \u002F 701–1400\". A\n   split that just chops a file in half to beat 1500 is gaming, not modularity.\n2. **Never create a file-per-function.** Over-splitting is its own debt; group related decls.\n   `refactor_verify.py` flags this mechanically as **`OVER-SPLIT`** — a *new* file carrying a\n   single top-level decl (per-OS build-tagged stubs and `func main` entrypoints excepted, since\n   those are one-decl by design). If it fires, your seams are too fine: merge the fragments into\n   one cohesive concern file.\n3. **Behaviour MUST be preserved — verify, don't assume.** Pure code motion is safe *only* once the\n   three hazards (build tags, init order, aliases) are cleared; an extraction can silently change a\n   captured variable. Build + vet + test (+ review for delegated work) is non-negotiable.\n4. **Never touch the frozen ABI** (`internal\u002Fabi`) and never add a dependency to move a number.\n5. **`goimports` will not re-add a local import alias** — copy it by hand, or the build breaks\n   (`undefined: \u003Calias>`); `godsplit_plan.py` lists the aliases to re-add.\n\n## When to run this\n\n- When `architecture` is the heaviest KPI in `\u002Fquality-score` (it defers here on purpose).\n- To drive code-debt the last mile to **0** after the safe classes are retired.\n- After a feature lands a 1500+-line file or a 200+-line function in a critical package.\n- On a `\u002Floop` cadence to keep the kernel from re-accreting monoliths between releases.\n\nThe scorecard, `godsplit_plan.py`, and `refactor_verify.py` are read-only; this skill's only\nwrites are your genuine splits and the new concern files. It never edits the frozen ABI, never\ngames a seam, and never commits a behaviour change it didn't verify — or a split it didn't prove\ndeclaration-complete.\n","# \u002Fmodularize — split the monoliths, provably, without changing behavior\n\n> **What this does.** `\u002Fquality-score` measures ten KPIs and retires the safe ones,\n> but it marks `architecture` **RISKY** and defers it: *\"do it in ONE lane, keep\n> behavior identical… if you can't do it safely this pass, leave it for a focused\n> pass — do NOT half-do a refactor.\"* **This is that focused pass.** It takes the\n> god-files and god-functions that drag the `architecture` KPI to the floor and\n> splits them along real concern seams — as **behavior-preserving code motion**,\n> verified by the toolchain, proven by the scorecard, committed by explicit path on\n> the shared trunk. In one run it took fak from code-debt **12 → 0**, score **86.2\n> (B) → 95.9 (A)**.\n\nThe shape: **find the heaviest architecture defect → plan the cut (boundaries +\nhazards) → split (file = code motion, function = extract) → verify (build\u002Fvet\u002Ftest +\nbehaviour review) → prove the drop → commit ONLY your packages by explicit path.**\n\n## The one insight that makes this safe\n\nMoving a top-level declaration to another file **in the same package** is a *semantic\nno-op in Go* — package, not file, is the scope. So a god-file split can't change\nbehavior, and `go build` + `go vet` + `go test` is a *near*-complete gate. The residual\n`go build` cannot cover — a top-level decl **dropped** by an incomplete cut that happens\nto be unreferenced in-module (so no `undefined:`) — is what closes it from *near* to\ncomplete: `tools\u002Frefactor_verify.py` proves the declaration set was preserved (Step 4).\nThere are exactly **three exceptions** that make code motion NOT a no-op;\n`tools\u002Fgodsplit_plan.py` flags all three:\n\n1. **per-file build tags** (`\u002F\u002Fgo:build …`) — moving a decl changes which file carries the constraint;\n2. **`func init()`** — init order is **filename-alphabetical** across a package, so moving an `init()` between files can silently reorder initialization;\n3. **aliased imports** (`x \"path\"`) — `goimports -w` re-derives plain imports after a move but does **NOT** re-infer a local alias; you must copy it to the new file by hand.\n\nIf a file has a build tag or an `init()`, keep those decls where they are (or in a file\nwhose name preserves init order) — don't move them blind.\n\n## Step 1 — Find the target (the scorecard builds the work-list)\n\n```bash\npython tools\u002Fcode_quality_scorecard.py --no-toolchain --json   # fast; corpus.kpis architecture.defects = your work-list\n```\n\nRead `architecture`'s `defects`: each is `god-file \u003Cpath> (N lines > 1500)` or\n`god-function \u003Cpath>:\u003Cfn> (N lines > 200)`. Attack the heaviest first, and **bias to\nthe most critical packages** (the kernel — `adjudicator`, `gateway`, `model`,\n`ggufload` — and `cmd\u002Ffak`, the entry point — over demos\u002Fbenchmarks). Record the\nbaseline: `architecture defects = K`, `code_debt = N`, `score = S`.\n\n## Step 2 — Plan the cut (boundaries + hazards, computed not guessed)\n\nThe error-prone part of a clean split is cutting at the right line: a decl's doc comment\nsits ABOVE its keyword, so a naive cut at `func`\u002F`type` orphans the comment. Let the\nplanner compute the doc-comment-aware ranges and the three hazards:\n\n```bash\npython tools\u002Fgodsplit_plan.py internal\u002Fmodel\u002Fkv.go            # human table\npython tools\u002Fgodsplit_plan.py internal\u002Fmodel\u002Fkv.go --json     # machine payload\n```\n\nEach decl row is `block_start..block_end \u003Ckind> \u003Cname>` — `block_start..block_end` is the\nexact `sed -n 'A,Bp'` range that carries the decl **with its doc comment** (func `[NL]` sizes\nare advisory; the Step 1 scorecard is the authority on what's a god-function). Group adjacent\ndecls into **cohesive concerns** (e.g. kv.go → `kvcache.go` for the KVCache type +\neviction, `rope.go` for rotary embedding, leaving the Session\u002Fforward core). Splitting on\nreal seams is the whole point — see the anti-gaming laws.\n\n**Sanity-check the plan before trusting it** — `godsplit_plan.py` is a LINE parser, not a Go\ntokenizer. Fall back to a hand cut if ANY of these hold: a decl row prints `!! INVERTED\nRANGE`; the `raw_strings` hazard is > 0 (a multi-line backtick string can hide or shift a\ncolumn-0 decl — eyeball those ranges); or the plan's decl count disagrees with the truth:\n\n```bash\ngrep -cE '^(func|type|var|const) ' \u003Cfile>   # must equal the number of rows the plan printed\n```\n\n`goimports` is the engine of the file split and is **not preinstalled** — install it and\nconfirm it resolved before you cut anything:\n\n```bash\ngo install golang.org\u002Fx\u002Ftools\u002Fcmd\u002Fgoimports@latest\ncommand -v goimports || { echo \"goimports missing — $(go env GOPATH)\u002Fbin not on PATH\"; exit 1; }\n```\n\n## Step 3 — Split\n\nRun the snippets below with the **Bash tool** — they are POSIX sh (`sed`, the `mk()`\nfunction, `goimports`\u002F`gofmt`), not PowerShell. **Precondition: `gofmt -w \u003Cfile>` BEFORE you\nplan**, so the package clause and import block are blank-separated and no extract range can\nstart at the package line.\n\n### A. God-FILE → concern files (pure code motion)\n\nCreate each new file from its block range, then delete the moved ranges **bottom-up** (so\nearlier deletes don't shift later line numbers), then let `goimports` fix every import. The\npackage name and target dir are read from the file so the snippet is copy-paste-safe in any\npackage:\n\n```bash\nF=internal\u002Fmodel\u002Fkv.go\nD=$(dirname \"$F\")\nPKG=$(python tools\u002Fgodsplit_plan.py \"$F\" --json | python -c 'import sys,json;print(json.load(sys.stdin)[\"package\"])')\nmk(){ { echo \"package $PKG\"; echo; sed -n \"$2,$3p\" \"$F\"; } > \"$D\u002F$1\"; }\nmk kvcache.go 10 272          # ranges = block_start..block_end from godsplit_plan.py\nmk rope.go    389 577\nsed -i '389,577d' \"$F\"; sed -i '10,272d' \"$F\"      # BOTTOM-UP: highest range first\ngoimports -w \"$F\" \"$D\u002Fkvcache.go\" \"$D\u002Frope.go\"     # auto-fix imports\ngofmt -w     \"$F\" \"$D\u002Fkvcache.go\" \"$D\u002Frope.go\"\n```\n\nThen **re-add any aliased import by hand** to the new file (`godsplit_plan.py` lists them —\n`goimports` won't re-derive a local alias, and the build fails `undefined: \u003Calias>` without\nit). If the source file leads with a license\u002FSPDX header above `package`, copy it to each new\nfile too. The `sed -n 'A,Bp' > newfile` and `sed -i` here are the right tool for line-range\ncode motion; redirect only to **in-tree** paths — the repo-guard PreToolUse hook\n(`tools\u002Frepo_guard.py`; AGENTS.md `OUT_OF_TREE_WRITE`) refuses a `> \u002Fdev\u002Fnull` or `..\u002F` escape.\n\n### B. God-FUNCTION → helpers\n\n- **Linear flow** (e.g. a CLI `cmdServe`\u002F`cmdGuard`): extract coherent phases into helpers.\n  Return a small **struct** and unpack it to the **SAME local names** the caller already\n  uses (`up, base, key := us.provider, us.baseURL, us.apiKey`) so the rest of the function\n  is untouched — no cascading edits, smallest possible diff.\n- **Closure-soup** (a function whose closures share ~15 mutable locals, e.g. an SSE relay):\n  make the shared state a **named struct** and turn the closures into **methods** on it.\n  That's genuine modularity — named, individually-readable parts — not line-shuffling.\n- Avoid param explosion: when a helper would take 8+ args, group them into a struct. A\n  helper with 11 positional params is worse code than the god-function you started with.\n\n## Step 4 — Verify (behaviour is preserved — don't assume it, prove it)\n\n### 4.0 — Prove no definition was dropped (the check `go build` cannot do)\n\nA pure code-motion split preserves the package's top-level declaration set **exactly**.\n`go build` catches a *referenced* symbol that went missing (`undefined:`) and a *duplicated*\none (`redeclared`) — but a decl that was **dropped** and happens to be unreferenced in-module\n(dead-but-real, or an exported symbol whose only consumers are out-of-tree or a JSON wire\ncontract) compiles clean and vanishes silently. That is the \"split a god-file, then a\ndefinition is missing\" failure. Close it mechanically **first** — it is fast and catches what\nthe toolchain structurally cannot:\n\n```bash\npython tools\u002Frefactor_verify.py --expect-motion \u003Corig.go> \u003Cyour new files>   # exit 1 on any drop\n```\n\nIt diffs the package's decl multiset **before** (`HEAD`) vs **after** (working tree). For a\npure in-package split the correct verdict is `clean`; `--expect-motion` makes **any** decl\nthat left the package a hard failure. Read each finding:\n\n- **`DROPPED`** — a definition that exists **nowhere** after the cut. Either you missed a\n  `sed -n` range (the split is INCOMPLETE — go add it) or it is a genuine deletion, which does\n  **not** belong in a commit labelled \"pure code motion\" — split it into its own honest\n  `refactor(x): remove dead \u003Cname>` commit with the reason in the body.\n- **`RELOCATED`** — a decl moved to another package (a cross-package consolidation, not an\n  in-package split). Drop `--expect-motion`, include the destination package in scope, and\n  confirm each move is intended.\n- **`OVER-SPLIT`** — a new file carrying a single decl (see anti-gaming law #2).\n\n(Scope note: it is DECL-level — it proves no whole decl was dropped, not that a struct's\nFIELDS survived a `type Local = pkg.Remote` alias consolidation. For that, read the aliased\ntype's fields by hand.)\n\n### 4.1 — Build, vet, test\n\n`go build` and `go vet` run natively; **run the tests under WSL** — per AGENTS.md, native\n`go test` is blocked by an OS Application-Control policy on freshly-compiled test binaries on\nthis checkout (an OS quirk, not a code failure), and `\u002Fquality-score` validates the same way:\n\n```bash\ngo build .\u002F...                                                   # whole-tree compile (catches a lost\u002Fduplicated symbol)\ngo vet .\u002F\u003Cpkg>\u002F...                                               # typecheck incl. _test.go\nwsl -e bash -lc 'cd \u002Fmnt\u002Fc\u002Fwork\u002Ffak && go test .\u002F\u003Cpkg>\u002F... -count=1'   # the real gate\n```\n\nIf native `go test` happens to run on your host, you may use it — but treat an\nApplication-Control block on a test binary as the documented ENVIRONMENT quirk, never as a\nbehaviour regression in your split. For `internal\u002Fmodel`, run the **full** (non-`-short`)\nsuite so the bit-exact oracle witnesses fire. If you DELEGATED a split to subagents, have an\nindependent reviewer confirm behaviour-preservation (no changed strings\u002Fflags\u002Fcontrol-flow\u002F\nexit-codes) **before** committing — read the diff in the reviewer, not in your own context.\n\nVerify formatting via the scorecard's `format` KPI (full run), not a naive `gofmt -l .`:\nthis checkout is CRLF in the working tree, so a local `gofmt -l .` flags hundreds of files as\na line-ending artifact (see `tools\u002Fgofmt_debt_audit.py` for the blob method).\n\n## Step 5 — Prove the drop\n\n```bash\npython tools\u002Fcode_quality_scorecard.py --no-toolchain --json   # architecture.defects should shrink\n```\n\nState it plainly: `architecture-debt K → K', code-debt N → M, score S → S'`. The bar for a\npass is **the heaviest architecture defect retired with behaviour proven green**.\n\n## Step 6 — Commit ONLY your packages, by explicit path\n\n```bash\nfak sync reconcile --apply\ngit status --porcelain                         # see which files peers are editing RIGHT NOW\nfak commit \\\n  --path \u003Corig.go> --path \u003Cyour new files> \\\n  -m \"refactor(\u003Cleaf>): split \u003Cfile> by concern\" \\\n  -m \"Pure code motion, no behavior change. \u003Cfile> N->M lines; extracted \u003Ca.go>, \u003Cb.go>. Verified build\u002Fvet\u002Ftest green.\" \\\n  [--push]\nfak sync push\n```\n\n- **Route around peer WIP.** A file showing in `git status --porcelain` is being edited by a\n  peer — do NOT split it this pass; pick a clean target. A path-scoped commit leaves peer-staged\n  files alone (you'll see them in `git diff --cached` — that's expected; your `--path` excludes\n  them from the commit).\n- **Honest subject.** A split\u002Fextraction is `refactor(\u003Cscope>):` — never `feat(`\u002F`fix(`. End every\n  ship commit with a `(fak \u003Cleaf>)` trailer (`(fak gateway)`, `(fak model)`; a `cmd\u002F\u003Cdir>` demo →\n  `(fak \u003Cdir>)`).\n- **Shared-trunk law.** Stay on `main` (the `OFF_TRUNK` guard refuses a branch — this is why\n  worktrees don't work, see below). Commit by explicit path via `fak commit --path`; if a peer's `MERGE_HEAD` is set, wait\n  for it to clear; never force-push.\n\n## Parallelizing across many targets (when there are several god-files)\n\nThe Workflow tool's `isolation: 'worktree'` **fails in this repo**: `git worktree add` creates a\nbranch and the trunk guard refuses it (`OFF_TRUNK`). To fan out: give each agent **one disjoint\nleaf package** (nothing two agents both touch), tell each to edit **in place**, run only **scoped**\nbuilds (`go build .\u002F\u003Cpkg>\u002F...`, never `go build .\u002F...` which races peers), and run **no git** — then\nthe orchestrator verifies and commits each package by explicit path. Have an independent reviewer\ncheck the delegated diffs for behaviour-preservation before committing.\n\n## Anti-gaming laws (the measure is only as honest as the pass)\n\n1. **Split on REAL concern seams, never arbitrary line counts.** Each new file is one cohesive\n   concern (the loader, the rotary embedding, the eviction path) — not \"lines 1–700 \u002F 701–1400\". A\n   split that just chops a file in half to beat 1500 is gaming, not modularity.\n2. **Never create a file-per-function.** Over-splitting is its own debt; group related decls.\n   `refactor_verify.py` flags this mechanically as **`OVER-SPLIT`** — a *new* file carrying a\n   single top-level decl (per-OS build-tagged stubs and `func main` entrypoints excepted, since\n   those are one-decl by design). If it fires, your seams are too fine: merge the fragments into\n   one cohesive concern file.\n3. **Behaviour MUST be preserved — verify, don't assume.** Pure code motion is safe *only* once the\n   three hazards (build tags, init order, aliases) are cleared; an extraction can silently change a\n   captured variable. Build + vet + test (+ review for delegated work) is non-negotiable.\n4. **Never touch the frozen ABI** (`internal\u002Fabi`) and never add a dependency to move a number.\n5. **`goimports` will not re-add a local import alias** — copy it by hand, or the build breaks\n   (`undefined: \u003Calias>`); `godsplit_plan.py` lists the aliases to re-add.\n\n## When to run this\n\n- When `architecture` is the heaviest KPI in `\u002Fquality-score` (it defers here on purpose).\n- To drive code-debt the last mile to **0** after the safe classes are retired.\n- After a feature lands a 1500+-line file or a 200+-line function in a critical package.\n- On a `\u002Floop` cadence to keep the kernel from re-accreting monoliths between releases.\n\nThe scorecard, `godsplit_plan.py`, and `refactor_verify.py` are read-only; this skill's only\nwrites are your genuine splits and the new concern files. It never edits the frozen ABI, never\ngames a seam, and never commits a behaviour change it didn't verify — or a split it didn't prove\ndeclaration-complete.\n",{"name":5,"description":7,"allowed-tools":24,"argument-hint":25,"user-invocable":26,"disable-model-invocation":20},"Read, Bash, Write, Edit, Grep, Glob","[file-or-package] (no args = take the heaviest architecture defect from the scorecard)",true,"main","f565b7b7db63e79649f3a02c08108132a86c5d05",".claude\u002Fskills\u002Fmodularize",16,"https:\u002F\u002Fgithub.com\u002Fanthony-chaudhary\u002Ffak","https:\u002F\u002Fanthony-chaudhary.github.io\u002Ffak\u002Fshowcase.html","https:\u002F\u002Fgithub.com\u002Fanthony-chaudhary","https:\u002F\u002Flinkedin.com\u002Fin\u002Fanthonychaudhary","2026-11-15 03:06:00",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":26},[38,41,44],{"tool":39,"command":40},"npx","npx skills add anthony-chaudhary\u002Ffak --skill modularize",{"tool":42,"command":43},"bunx","bunx skills add anthony-chaudhary\u002Ffak --skill modularize",{"tool":45,"command":46},"pnpm","pnpm dlx skills add anthony-chaudhary\u002Ffak --skill modularize","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fanthony-chaudhary\u002Ffak\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fmodularize\u002FSKILL.md",[],[50,57,66,73,80,85],{"skillNo":51,"name":52,"nameZh":6,"description":53,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":19},"01M78V4059KRP2T88YR6Z05MJQ","serve-receipt","On-demand research protocol + deterministic receipt for serving a Hugging Face model on a concrete GPU target — fan out research lanes (model facts\u002Ffiles, engine support matrix, serving recipes, KV\u002Fstate memory math), compute the tiered feasibility verdict with `fak serve-receipt` (never narrated math), and emit a witnessed launch receipt. Use when asked for an \"initial config\", \"serving receipt\", or \"how do I serve \u003Cmodel> on \u003CGPUs>\".","https:\u002F\u002Fgithub.com\u002Fanthony-chaudhary\u002Ffak\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fserve-receipt\u002FSKILL.md",[],[],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":61,"licenseFileUrl":62,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M77HRGKQV2CJ2K6ZFN4YQ32K","caveman","Ultra-compressed communication mode. Cuts output tokens 65% (measured) by speaking like caveman while keeping full technical accuracy. Supports intensity levels: lite, full (default), ultra, wenyan-lite, wenyan-full, wenyan-ultra. Use when user says \"caveman mode\", \"talk like caveman\", \"use caveman\", \"less tokens\", \"be brief\", or invokes \u002Fcaveman. Also auto-triggers when token efficiency is requested.","MIT","https:\u002F\u002Fgithub.com\u002Fanthony-chaudhary\u002Ffak\u002Fblob\u002Fmain\u002Finternal\u002Fsyspromptmmu\u002Fthird_party\u002Fcaveman\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fanthony-chaudhary\u002Ffak\u002Fblob\u002Fmain\u002Finternal\u002Fsyspromptmmu\u002Fthird_party\u002Fcaveman\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M77HRAY3Y3BE7APN5PVJF7NV","quality-report","Score the repo quality and emit a report card.","https:\u002F\u002Fgithub.com\u002Fanthony-chaudhary\u002Ffak\u002Fblob\u002Fmain\u002Finternal\u002Fctxplans\u002Ftestdata\u002Frepo\u002F.claude\u002Fskills\u002Fquality-report\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M77HR9807KHAX13DG9PW2K2Q","ctx-overlay","Compact the context window and prune the memory store when a session grows too long.","https:\u002F\u002Fgithub.com\u002Fanthony-chaudhary\u002Ffak\u002Fblob\u002Fmain\u002Finternal\u002Fctxplans\u002Ftestdata\u002Frepo\u002F.claude\u002Fskills\u002Fctx-overlay\u002FSKILL.md",[],[],{"skillNo":81,"name":68,"nameZh":6,"description":69,"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":19},"01M77HR7XQ9X8F2CY9Z4F2ZEZ3","https:\u002F\u002Fgithub.com\u002Fanthony-chaudhary\u002Ffak\u002Fblob\u002Fmain\u002Finternal\u002Fctxplanlint\u002Ftestdata\u002Frepo\u002F.claude\u002Fskills\u002Fquality-report\u002FSKILL.md",[],[],{"skillNo":86,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M77HR5BVKCTR1WNJGRBSDNX7","https:\u002F\u002Fgithub.com\u002Fanthony-chaudhary\u002Ffak\u002Fblob\u002Fmain\u002Finternal\u002Fctxplanlint\u002Ftestdata\u002Frepo\u002F.claude\u002Fskills\u002Fctx-overlay\u002FSKILL.md",[],[]]