[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BJH3N0B94XBMN9GSWDYFYN":3,"skill-same:01M7BJH3N0B94XBMN9GSWDYFYN":83},{"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":44},"01M7BJH3N0B94XBMN9GSWDYFYN","arch-audit",null,"Periodic audit of src\u002Fbenchflow\u002F shape (names, boundaries, file sizes, stability mix) — propose structural reorg opportunities, don't execute","linyouxue\u002Fskill-repair-benchmark","linyouxue","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F216151464?v=4","01M7BJEVCXKD74KH6FG9CBVSQB","林宥学","01M7BJEVE02NP217V93BKZFC0J",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Farch-audit\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: arch-audit\ndescription: Periodic audit of src\u002Fbenchflow\u002F shape (names, boundaries, file sizes, stability mix) — propose structural reorg opportunities, don't execute\nuser-invocable: true\n---\n\n# Architecture Audit Skill\n\nFind structural reorg opportunities: vague filenames, orphan tiny files, stability-mixed merges, oversize files. One layer above `\u002Fcode-cleanup` — that skill edits inside files; this one reshapes *which files exist*.\n\n**Do not auto-apply.** Report ranked candidates; the user approves. Reorgs have import-graph consequences that need human judgment.\n\n## Commands\n\n- `\u002Farch-audit` — full `src\u002Fbenchflow\u002F` sweep\n- `\u002Farch-audit \u003Csubtree>` — scoped (e.g. `src\u002Fbenchflow\u002Fagents\u002F`, `src\u002Fbenchflow\u002Fcli\u002F`)\n\n## Scope\n\nIn: file-level structure — names, boundaries, merges, splits, package grouping, `__init__.py` re-exports, import depth.\nOut: line-level edits (`\u002Fcode-cleanup`), public API design, dependency upgrades, test strategy, registry-entry additions (those are one-line contributions, not structural).\n\n## Helpers\n\nReusable scripts live in [scripts\u002F](scripts\u002F) — paths below are relative to the skill root, run from there or prefix with `.claude\u002Fskills\u002Farch-audit\u002F`. They encode edge cases (private-underscore convention, `__init__.py` barrels, test exclusion, `__all__`, re-exports, string-typed imports). Python 3.12+, stdlib `ast` only.\n\n**Primary:**\n- `scripts\u002Fmanifest.py [--no-cache]` — one `ast` + `git log` pass over non-test `src\u002Fbenchflow\u002F**\u002F*.py`. Emits JSON with `{file, loc, commits_6mo, churn_ratio, exports[], importers[], barrel_importers[], importer_selectors{}}`. Cached under `scripts\u002F.cache\u002F\u003Csha>[-dirty-\u003Chash>].json`. **Source for Rules 1, 2, 5** — do not per-file-loop when manifest has the answer.\n\n**Per-file (for what manifest doesn't cover):**\n- `scripts\u002Fdominant_symbol.py \u003Cfile>` — Rule 1 ≥70% exemption. Emits VERDICT: `dominant=X (N%)` \u002F `NONE` \u002F `INSUFFICIENT_IMPORTERS` (\u003C3) \u002F `NO_IMPORTERS`.\n- `scripts\u002Fchurn_ratio.sh \u003Cfile>...` — TSV `ratio\u003Ctab>commits\u003Ctab>loc\u003Ctab>path`. Uses `--follow`; manifest's `churn_ratio` doesn't. **Required for Rule 3.**\n- `scripts\u002Fco_edit_matrix.py \u003Cfile>` — Rule 4 symbol co-edit clustering via `git log --numstat` + AST line-range mapping. Emits TSV pairs ≥20% or `# status:` (`file_renamed` \u002F `insufficient_commits` \u002F `too_many_symbols` \u002F `no_clusters`).\n- `scripts\u002Fsplit_costs.py \u003Cfile> --half-a=names --half-b=names` — emits `{shared_types, shared_helpers, importer_payoff, importers}` for a proposed 2-way split. **Required for every split finding.** If it fails or can't be run, Pass 1 must suppress the finding entirely — do not emit a split proposal Pass 2 has no data to evaluate.\n\n**Spot-check:** `scripts\u002Ftiny_files.sh`, `scripts\u002Fimporters.py`, `scripts\u002Fexports.py` — redundant when manifest is fresh; use for ad-hoc or post-rename sanity.\n\nParallelize per-file helpers with `xargs -P 8` (read-only, safe).\n\n## The five rules\n\nEach has command + threshold + decision. Thresholds are heuristics — note them in findings.\n\nScan non-test sources: `SRC=$(find src\u002Fbenchflow -name '*.py' -not -name 'conftest.py' -not -path '*\u002Ftests\u002F*')`.\n\n### Rule 1 — One job per module\n\nSource: manifest `exports[]`. A module is vague if **both**:\n1. ≥3 top-level value exports that are **actually imported** (cross-check `exports[]` against `importer_selectors`; unselected exports don't count). Value export = `FunctionDef`\u002F`AsyncFunctionDef`\u002F`ClassDef`\u002Fmodule-level assignment whose name doesn't start with `_` and isn't excluded by a `__all__` carve-out. Drop `TypeAlias`\u002F`Protocol`\u002F`TypedDict`\u002F`NamedTuple` entirely — even with runtime behavior, they rarely drive vagueness. **and**\n2. exports cluster into ≥2 disjoint name-stem groups (no shared prefix\u002Fsuffix ≥4 chars after snake_case split).\n\nBefore flagging, run `scripts\u002Fdominant_symbol.py`. Only `dominant=X (≥70%)` exempts. Every other VERDICT (`NONE`, `INSUFFICIENT_IMPORTERS`, `NO_IMPORTERS`) means **no exemption applies — emit the finding**. `INSUFFICIENT_IMPORTERS` is not a \"skip this file\" signal; it means the exemption check is unreliable, so fall back to the mechanical step-1+2 trip and emit.\n\nRule 1 is **independent of Rule 4** — a Rule 4 skip doesn't exempt Rule 1.\n\nNo \"cohesive around X\" prose overrides — mechanical check decides.\n\n**Private modules (leading underscore like `_sandbox.py`, `_env_setup.py`) are NOT exempt.** Underscore means \"package-private API surface\"; it does not mean \"cohesive by convention.\" Rule 1 still fires.\n\n### Rule 2 — Tiny modules need a job\n\nSource: manifest `loc \u003C 100`. Must satisfy one:\n- (a) `importers.length >= 2`, OR\n- (b) exports are only type aliases \u002F Protocols \u002F TypedDicts \u002F Enums \u002F literal-RHS consts (no runtime functions\u002Fclasses), OR\n- (c) isolates an external dep for mocking (rare — e.g. a thin wrapper around `subprocess.run` specifically so tests can `patch(\"benchflow.X.run\")`; inspect source), OR\n- (d) `barrel_importers.length > 0` OR file itself is an `__init__.py` barrel (only re-exports).\n\nOtherwise inline at sole caller. **1 importer does NOT satisfy (a)** — that's the fold signal.\n\n**Skip `__init__.py` with `__all__` and\u002For re-exports only** — those are barrels, exempt by (d).\n\n### Rule 3 — Don't merge across stability levels\n\nBefore any merge, `scripts\u002Fchurn_ratio.sh \u003Ca> \u003Cb>`. If ratio >**3×** → veto (mixed stability = blame noise, review friction). Label sides \"hot\" \u002F \"cold\" in the finding.\n\nCaveat: `--follow` tracks single-rename chains only; squash-merge repos (benchflow uses squash-merge on PRs to `main`) under-count. Signal, not proof — a ratio of 2.5× in a squash-merge repo should be treated as closer to 4×.\n\n### Rule 4 — Big modules split by edit-locality\n\nApplies only to modules >500 LOC. Verify with `wc -l` first. Current candidates in benchflow: `_sandbox.py` (~757), `sdk.py` (~706), `job.py` (~582). Probably `process.py` (~379), `viewer.py` (~378) are under threshold but borderline — skip unless they cross 500.\n\n1. `scripts\u002Fco_edit_matrix.py \u003Cfile>`.\n2. Pairs ≥20% → candidate clusters; split at min-cut where cross-cluster \u003C20%.\n3. Status: `no_clusters` → leave the file. `file_renamed` → extend with `git log --follow` or skip. `insufficient_commits` \u002F `too_many_symbols` → skip. `boundary_drift_hunks: N` → reduce confidence.\n\nDon't downgrade to \"manual inspection required\" — silence beats a weak claim.\n\n**`no_clusters` fallback**: if file >500 LOC with ≥3 importers and Rule 4 is silent, check `importer_selectors`. Disjoint selector sets = importer-driven cleave (e.g., `sdk.py` imported as `SDK` by one set of callers and as `SetupPhase`\u002F`VerifyPhase` helpers by another). Surface as `needs_signoff`; don't mechanize (facades \u002F `__init__.py` re-exports look disjoint by design).\n\n### Rule 5 — Reorg sequencing (leaves before hubs)\n\nSource: manifest `importers.length` + `barrel_importers.length`.\n\n- 0–1 importers: reorg first.\n- >5 importers: codemod + `ty check src\u002F` + `.venv\u002Fbin\u002Fpython -m pytest tests\u002F` in same PR.\n- `__init__.py` barrels exempt from Rule 2, count toward Rule 5 — rename behind a barrel still needs codemod if the symbol is imported directly (`from benchflow.sdk import SDK` bypasses the `benchflow\u002F__init__.py` barrel for tree-shaking agents).\n\nExtra hub: `src\u002Fbenchflow\u002F__init__.py` is benchflow's public API surface. Any symbol re-exported there (check `__all__` or direct `from .X import Y`) counts as >5 importers by default — external consumers aren't visible to the codemod.\n\n## Execution\n\n### Short-circuit\n\nIf `$SRC` has \u003C20 files or \u003C3000 LOC, one `Explore` agent runs all rules end-to-end. Benchflow (~39 files \u002F ~9k LOC) is **above** this threshold — default to multi-agent split by subtree.\n\n### Pass 1 — discovery\n\n**One agent per subtree, all five rules.** Splitting Rules 1+2 from Rule 3 means wasted merges Rule 3 vetoes. Suggested split for a whole-repo `\u002Farch-audit`:\n\n- `src\u002Fbenchflow\u002F` top-level (all `*.py` not in subpackages)\n- `src\u002Fbenchflow\u002Fagents\u002F`\n- `src\u002Fbenchflow\u002Facp\u002F` + `src\u002Fbenchflow\u002Fcli\u002F`\n\n**Run `scripts\u002Fmanifest.py` once first** — data source for Rules 1\u002F2\u002F5. Only per-file-loop for what manifest lacks: `scripts\u002Fdominant_symbol.py`, `scripts\u002Fco_edit_matrix.py`, `scripts\u002Fchurn_ratio.sh`. Parallelize with `xargs -P 8`.\n\n**Primary output: JSON, one object per line.** If a rule can't produce a finding (e.g. Rule 4 `file_renamed`), emit no row. A Rule 4 skip doesn't suppress other rules.\n\n**Do not pre-filter with *semantic prose*.** \"Single-importer facade pattern\" \u002F \"semantically coherent around SDK phases\" \u002F \"extension point\" are exactly the rationales Pass 2 exists to attack — let it do its job. Dominant-symbol `≥70%` is the only prose-based suppression.\n\n**Do pre-filter on *rationale quality*.** One-importer Rule 1 findings with no concrete workflow rationale (no named future PR, no test-isolation gain, no mock-graph win) default to `rationale_weak: true` + `importer_payoff: none` — and those **must not be emitted**. If you can't name a concrete win in one sentence, the finding is aesthetic and Pass 1 drops it. The 40–60% Pass 2 kill target assumes Pass 1 has already suppressed the single-importer noise; if you forward every mechanical trip, Pass 2 drowns.\n\nSchema:\n\n```\n{\n  \"file\": \"src\u002Fbenchflow\u002Ffoo.py\",\n  \"rule_id\": 2,\n  \"evidence_cmd\": \".claude\u002Fskills\u002Farch-audit\u002Fscripts\u002Fimporters.py src\u002Fbenchflow\u002Ffoo.py\",\n  \"evidence_output\": \"src\u002Fbenchflow\u002Fbar.py\",\n  \"proposed_change\": \"fold into src\u002Fbenchflow\u002Fbar.py\",\n  \"loc\": 57,\n  \"importers\": [\"src\u002Fbenchflow\u002Fbar.py\"],\n  \"churn_6mo\": 3,\n  \"co_edit_cluster\": null,\n  \"split_costs\": {\n    \"shared_types\": [],\n    \"shared_helpers\": [],\n    \"importer_payoff\": \"high | medium | none\",\n    \"rationale\": \"one sentence: what concrete PR becomes easier?\",\n    \"rationale_weak\": false\n  }\n}\n```\n\nPopulating `split_costs`:\n- `shared_types`\u002F`shared_helpers`: from `split_costs.py`, else manual AST check.\n- `importer_payoff`: 1 importer → `none` — **suppress the finding** unless rationale names a concrete workflow win. 2–3 importers → `medium` — require a concrete rationale or suppress. 4+ with disjoint importer_selectors → `high`.\n- `rationale`: must name a concrete future PR or bug-fix pattern (\"splitting `_sandbox.py` lets the path-lockdown tests stop importing user-setup fixtures and cuts the `tests\u002Ftest_sandbox_hardening.py` mock graph in half\"). \"Narrative clarity,\" \"isolated tests\" (generic), \"cognitive load,\" \"extension point\" → `rationale_weak: true` → **suppress**. The bar is: can you name the specific PR or test file this unblocks? If not, don't emit.\n\n### Pass 2 — adversarial critique\n\n**Do not skip.** Pass 2's value is attacking weak proposals, not confirming strong ones. Spawn one `Explore` agent with this prompt verbatim:\n\n> You are a skeptical reviewer of arch-audit findings. Default REJECT unless proposals survive concrete mechanical attacks. Each finding ends SHIP \u002F SKIP \u002F NEEDS-REWORK \u002F NEEDS-SIGNOFF.\n>\n> Run attacks in order, stop at first kill:\n>\n> 0. **Pass 1 data integrity**: split proposal with missing `split_costs.py` output, merge proposal with missing `churn_ratio.sh`, or Rule 4 finding with missing `co_edit_matrix.py` → flag as a Pass 1 bug and drop the finding. Do not grade semantics on missing data; do not emit NEEDS-REWORK (that reads as a semantic verdict). Note it separately so the user knows Pass 1 needs re-running, not that the proposal is fixable.\n>\n> 1. **Rule 3 veto (merges)**: recompute `churn_ratio.sh`. Threshold is **3×** — if you typed 5× or 8×, re-read the skill.\n> 2. **Aesthetic rationale**: if `rationale_weak: true` OR `importer_payoff: none` → SKIP. Demand a concrete PR pattern.\n> 3. **Shared-types trap (splits)**: `shared_types` non-empty → 2-way split forces 3rd types module. NEEDS-REWORK.\n> 4. **Shared-helpers trap (splits)**: `shared_helpers` non-empty → duplicated helpers or cross-imports. NEEDS-REWORK unless helpers move cleanly.\n> 5. **Semantic-marker exemption (Rule 2 folds)**: if top 15 lines have a module docstring or block comment explaining the boundary (keywords: `boundary`, `variant`, `unguarded`, `scoped`, `isolate`, `bridge`, `shim`) → SKIP.\n> 6. **Entry-point trap (renames)**: check `pyproject.toml` `[project.scripts]`, `[project.entry-points]`, and direct imports by `src\u002Fbenchflow\u002Fcli\u002F`, `src\u002Fbenchflow\u002F__init__.py`, and `src\u002Fbenchflow\u002Fsdk.py`. If hit → NEEDS-SIGNOFF.\n> 7. **Registry-surface trap**: check if the file contains or is imported by `agents\u002Fregistry.py` \u002F `agents\u002Fproviders.py`. These are the documented extension points — any rename invalidates external registration code and needs user-docs update. NEEDS-SIGNOFF.\n> 8. **Cycle\u002Fbarrel trap**: `importers.py` output showing `# barrel:` lines via `__init__.py`; verify proposed splits don't import each other through a barrel.\n> 9. **Test colocation**: `tests\u002Ftest_\u003Cname>.py` must move with source without fixture or `conftest.py` restructuring. If the file has a paired test file, name it and check for `conftest.py` dependencies.\n>\n> All attacks fail → SHIP with counterfactual rationale verbatim. No hedging.\n\nExpect 40–60% kill rate. \u003C20% → re-run with stronger framing. >80% → Pass 1's `rationale_weak` filter is too loose.\n\n### Synthesize\n\nThree buckets:\n- **Leaf-first wins** (0–1 importers) — safe now.\n- **Hub moves** (>5 importers or entry-point) — codemod, separate PR.\n- **Rejected** — brief list with vetoing rule.\n\nInclude PR sequence respecting Rule 5.\n\n### Approval\n\nDo NOT edit. On approval:\n- **Rule 2 folds** → `\u002Fcode-cleanup`.\n- **Renames\u002Fsplits** → manual edit + codemod (`grep -rl 'from benchflow.X' | xargs sed -i ...`) + `ty check src\u002F` + `.venv\u002Fbin\u002Fpython -m pytest tests\u002F` in one PR. \"Draft PR 1\" means diff plan, not commits.\n\n## Cadence\n\nMonthly or per-major-feature. Signal comes from accumulated drift, not single-commit noise. Benchflow has three files already past the Rule 4 threshold (`_sandbox.py`, `sdk.py`, `job.py`) — those are the current top candidates.\n\n## Anti-patterns\n\n- **Don't skip Pass 2** — it kills aesthetic splits and 1-importer theater Pass 1 rubber-stamps.\n- **Don't pre-filter in Pass 1 with \"facade\" \u002F \"coherent\" \u002F \"cohesive\" prose.** If the mechanical check fires and dominant-symbol \u003C 70%, emit. Pass 2 decides.\n- **Don't split Pass 1 by rule** — split by subtree or not at all. Rule 3 must see Rules 1\u002F2 proposals.\n- **Don't propose renames without checking entry points, `__init__.py` re-exports, and registry surfaces.**\n- **Don't batch leaf + hub reorgs in one PR** — blast radius must match review posture.\n- **Don't grow the rule list.** Five is enough. New signals → `split_costs`, not new rules.\n- **Don't accept aesthetic rationales.** Narrative clarity \u002F isolated tests \u002F cognitive load → `rationale_weak: true`.\n- **Don't propose a 2-way split without `split_costs.py`** — unchecked shared types\u002Fhelpers become 3-way splits or cross-import tangles.\n- **Don't touch private-underscore modules without reading them.** `_sandbox.py` \u002F `_env_setup.py` look mergeable by name but carry the repo's most security-sensitive code; the underscore prefix is about API surface, not cohesion.\n","# Architecture Audit Skill\n\nFind structural reorg opportunities: vague filenames, orphan tiny files, stability-mixed merges, oversize files. One layer above `\u002Fcode-cleanup` — that skill edits inside files; this one reshapes *which files exist*.\n\n**Do not auto-apply.** Report ranked candidates; the user approves. Reorgs have import-graph consequences that need human judgment.\n\n## Commands\n\n- `\u002Farch-audit` — full `src\u002Fbenchflow\u002F` sweep\n- `\u002Farch-audit \u003Csubtree>` — scoped (e.g. `src\u002Fbenchflow\u002Fagents\u002F`, `src\u002Fbenchflow\u002Fcli\u002F`)\n\n## Scope\n\nIn: file-level structure — names, boundaries, merges, splits, package grouping, `__init__.py` re-exports, import depth.\nOut: line-level edits (`\u002Fcode-cleanup`), public API design, dependency upgrades, test strategy, registry-entry additions (those are one-line contributions, not structural).\n\n## Helpers\n\nReusable scripts live in [scripts\u002F](scripts\u002F) — paths below are relative to the skill root, run from there or prefix with `.claude\u002Fskills\u002Farch-audit\u002F`. They encode edge cases (private-underscore convention, `__init__.py` barrels, test exclusion, `__all__`, re-exports, string-typed imports). Python 3.12+, stdlib `ast` only.\n\n**Primary:**\n- `scripts\u002Fmanifest.py [--no-cache]` — one `ast` + `git log` pass over non-test `src\u002Fbenchflow\u002F**\u002F*.py`. Emits JSON with `{file, loc, commits_6mo, churn_ratio, exports[], importers[], barrel_importers[], importer_selectors{}}`. Cached under `scripts\u002F.cache\u002F\u003Csha>[-dirty-\u003Chash>].json`. **Source for Rules 1, 2, 5** — do not per-file-loop when manifest has the answer.\n\n**Per-file (for what manifest doesn't cover):**\n- `scripts\u002Fdominant_symbol.py \u003Cfile>` — Rule 1 ≥70% exemption. Emits VERDICT: `dominant=X (N%)` \u002F `NONE` \u002F `INSUFFICIENT_IMPORTERS` (\u003C3) \u002F `NO_IMPORTERS`.\n- `scripts\u002Fchurn_ratio.sh \u003Cfile>...` — TSV `ratio\u003Ctab>commits\u003Ctab>loc\u003Ctab>path`. Uses `--follow`; manifest's `churn_ratio` doesn't. **Required for Rule 3.**\n- `scripts\u002Fco_edit_matrix.py \u003Cfile>` — Rule 4 symbol co-edit clustering via `git log --numstat` + AST line-range mapping. Emits TSV pairs ≥20% or `# status:` (`file_renamed` \u002F `insufficient_commits` \u002F `too_many_symbols` \u002F `no_clusters`).\n- `scripts\u002Fsplit_costs.py \u003Cfile> --half-a=names --half-b=names` — emits `{shared_types, shared_helpers, importer_payoff, importers}` for a proposed 2-way split. **Required for every split finding.** If it fails or can't be run, Pass 1 must suppress the finding entirely — do not emit a split proposal Pass 2 has no data to evaluate.\n\n**Spot-check:** `scripts\u002Ftiny_files.sh`, `scripts\u002Fimporters.py`, `scripts\u002Fexports.py` — redundant when manifest is fresh; use for ad-hoc or post-rename sanity.\n\nParallelize per-file helpers with `xargs -P 8` (read-only, safe).\n\n## The five rules\n\nEach has command + threshold + decision. Thresholds are heuristics — note them in findings.\n\nScan non-test sources: `SRC=$(find src\u002Fbenchflow -name '*.py' -not -name 'conftest.py' -not -path '*\u002Ftests\u002F*')`.\n\n### Rule 1 — One job per module\n\nSource: manifest `exports[]`. A module is vague if **both**:\n1. ≥3 top-level value exports that are **actually imported** (cross-check `exports[]` against `importer_selectors`; unselected exports don't count). Value export = `FunctionDef`\u002F`AsyncFunctionDef`\u002F`ClassDef`\u002Fmodule-level assignment whose name doesn't start with `_` and isn't excluded by a `__all__` carve-out. Drop `TypeAlias`\u002F`Protocol`\u002F`TypedDict`\u002F`NamedTuple` entirely — even with runtime behavior, they rarely drive vagueness. **and**\n2. exports cluster into ≥2 disjoint name-stem groups (no shared prefix\u002Fsuffix ≥4 chars after snake_case split).\n\nBefore flagging, run `scripts\u002Fdominant_symbol.py`. Only `dominant=X (≥70%)` exempts. Every other VERDICT (`NONE`, `INSUFFICIENT_IMPORTERS`, `NO_IMPORTERS`) means **no exemption applies — emit the finding**. `INSUFFICIENT_IMPORTERS` is not a \"skip this file\" signal; it means the exemption check is unreliable, so fall back to the mechanical step-1+2 trip and emit.\n\nRule 1 is **independent of Rule 4** — a Rule 4 skip doesn't exempt Rule 1.\n\nNo \"cohesive around X\" prose overrides — mechanical check decides.\n\n**Private modules (leading underscore like `_sandbox.py`, `_env_setup.py`) are NOT exempt.** Underscore means \"package-private API surface\"; it does not mean \"cohesive by convention.\" Rule 1 still fires.\n\n### Rule 2 — Tiny modules need a job\n\nSource: manifest `loc \u003C 100`. Must satisfy one:\n- (a) `importers.length >= 2`, OR\n- (b) exports are only type aliases \u002F Protocols \u002F TypedDicts \u002F Enums \u002F literal-RHS consts (no runtime functions\u002Fclasses), OR\n- (c) isolates an external dep for mocking (rare — e.g. a thin wrapper around `subprocess.run` specifically so tests can `patch(\"benchflow.X.run\")`; inspect source), OR\n- (d) `barrel_importers.length > 0` OR file itself is an `__init__.py` barrel (only re-exports).\n\nOtherwise inline at sole caller. **1 importer does NOT satisfy (a)** — that's the fold signal.\n\n**Skip `__init__.py` with `__all__` and\u002For re-exports only** — those are barrels, exempt by (d).\n\n### Rule 3 — Don't merge across stability levels\n\nBefore any merge, `scripts\u002Fchurn_ratio.sh \u003Ca> \u003Cb>`. If ratio >**3×** → veto (mixed stability = blame noise, review friction). Label sides \"hot\" \u002F \"cold\" in the finding.\n\nCaveat: `--follow` tracks single-rename chains only; squash-merge repos (benchflow uses squash-merge on PRs to `main`) under-count. Signal, not proof — a ratio of 2.5× in a squash-merge repo should be treated as closer to 4×.\n\n### Rule 4 — Big modules split by edit-locality\n\nApplies only to modules >500 LOC. Verify with `wc -l` first. Current candidates in benchflow: `_sandbox.py` (~757), `sdk.py` (~706), `job.py` (~582). Probably `process.py` (~379), `viewer.py` (~378) are under threshold but borderline — skip unless they cross 500.\n\n1. `scripts\u002Fco_edit_matrix.py \u003Cfile>`.\n2. Pairs ≥20% → candidate clusters; split at min-cut where cross-cluster \u003C20%.\n3. Status: `no_clusters` → leave the file. `file_renamed` → extend with `git log --follow` or skip. `insufficient_commits` \u002F `too_many_symbols` → skip. `boundary_drift_hunks: N` → reduce confidence.\n\nDon't downgrade to \"manual inspection required\" — silence beats a weak claim.\n\n**`no_clusters` fallback**: if file >500 LOC with ≥3 importers and Rule 4 is silent, check `importer_selectors`. Disjoint selector sets = importer-driven cleave (e.g., `sdk.py` imported as `SDK` by one set of callers and as `SetupPhase`\u002F`VerifyPhase` helpers by another). Surface as `needs_signoff`; don't mechanize (facades \u002F `__init__.py` re-exports look disjoint by design).\n\n### Rule 5 — Reorg sequencing (leaves before hubs)\n\nSource: manifest `importers.length` + `barrel_importers.length`.\n\n- 0–1 importers: reorg first.\n- >5 importers: codemod + `ty check src\u002F` + `.venv\u002Fbin\u002Fpython -m pytest tests\u002F` in same PR.\n- `__init__.py` barrels exempt from Rule 2, count toward Rule 5 — rename behind a barrel still needs codemod if the symbol is imported directly (`from benchflow.sdk import SDK` bypasses the `benchflow\u002F__init__.py` barrel for tree-shaking agents).\n\nExtra hub: `src\u002Fbenchflow\u002F__init__.py` is benchflow's public API surface. Any symbol re-exported there (check `__all__` or direct `from .X import Y`) counts as >5 importers by default — external consumers aren't visible to the codemod.\n\n## Execution\n\n### Short-circuit\n\nIf `$SRC` has \u003C20 files or \u003C3000 LOC, one `Explore` agent runs all rules end-to-end. Benchflow (~39 files \u002F ~9k LOC) is **above** this threshold — default to multi-agent split by subtree.\n\n### Pass 1 — discovery\n\n**One agent per subtree, all five rules.** Splitting Rules 1+2 from Rule 3 means wasted merges Rule 3 vetoes. Suggested split for a whole-repo `\u002Farch-audit`:\n\n- `src\u002Fbenchflow\u002F` top-level (all `*.py` not in subpackages)\n- `src\u002Fbenchflow\u002Fagents\u002F`\n- `src\u002Fbenchflow\u002Facp\u002F` + `src\u002Fbenchflow\u002Fcli\u002F`\n\n**Run `scripts\u002Fmanifest.py` once first** — data source for Rules 1\u002F2\u002F5. Only per-file-loop for what manifest lacks: `scripts\u002Fdominant_symbol.py`, `scripts\u002Fco_edit_matrix.py`, `scripts\u002Fchurn_ratio.sh`. Parallelize with `xargs -P 8`.\n\n**Primary output: JSON, one object per line.** If a rule can't produce a finding (e.g. Rule 4 `file_renamed`), emit no row. A Rule 4 skip doesn't suppress other rules.\n\n**Do not pre-filter with *semantic prose*.** \"Single-importer facade pattern\" \u002F \"semantically coherent around SDK phases\" \u002F \"extension point\" are exactly the rationales Pass 2 exists to attack — let it do its job. Dominant-symbol `≥70%` is the only prose-based suppression.\n\n**Do pre-filter on *rationale quality*.** One-importer Rule 1 findings with no concrete workflow rationale (no named future PR, no test-isolation gain, no mock-graph win) default to `rationale_weak: true` + `importer_payoff: none` — and those **must not be emitted**. If you can't name a concrete win in one sentence, the finding is aesthetic and Pass 1 drops it. The 40–60% Pass 2 kill target assumes Pass 1 has already suppressed the single-importer noise; if you forward every mechanical trip, Pass 2 drowns.\n\nSchema:\n\n```\n{\n  \"file\": \"src\u002Fbenchflow\u002Ffoo.py\",\n  \"rule_id\": 2,\n  \"evidence_cmd\": \".claude\u002Fskills\u002Farch-audit\u002Fscripts\u002Fimporters.py src\u002Fbenchflow\u002Ffoo.py\",\n  \"evidence_output\": \"src\u002Fbenchflow\u002Fbar.py\",\n  \"proposed_change\": \"fold into src\u002Fbenchflow\u002Fbar.py\",\n  \"loc\": 57,\n  \"importers\": [\"src\u002Fbenchflow\u002Fbar.py\"],\n  \"churn_6mo\": 3,\n  \"co_edit_cluster\": null,\n  \"split_costs\": {\n    \"shared_types\": [],\n    \"shared_helpers\": [],\n    \"importer_payoff\": \"high | medium | none\",\n    \"rationale\": \"one sentence: what concrete PR becomes easier?\",\n    \"rationale_weak\": false\n  }\n}\n```\n\nPopulating `split_costs`:\n- `shared_types`\u002F`shared_helpers`: from `split_costs.py`, else manual AST check.\n- `importer_payoff`: 1 importer → `none` — **suppress the finding** unless rationale names a concrete workflow win. 2–3 importers → `medium` — require a concrete rationale or suppress. 4+ with disjoint importer_selectors → `high`.\n- `rationale`: must name a concrete future PR or bug-fix pattern (\"splitting `_sandbox.py` lets the path-lockdown tests stop importing user-setup fixtures and cuts the `tests\u002Ftest_sandbox_hardening.py` mock graph in half\"). \"Narrative clarity,\" \"isolated tests\" (generic), \"cognitive load,\" \"extension point\" → `rationale_weak: true` → **suppress**. The bar is: can you name the specific PR or test file this unblocks? If not, don't emit.\n\n### Pass 2 — adversarial critique\n\n**Do not skip.** Pass 2's value is attacking weak proposals, not confirming strong ones. Spawn one `Explore` agent with this prompt verbatim:\n\n> You are a skeptical reviewer of arch-audit findings. Default REJECT unless proposals survive concrete mechanical attacks. Each finding ends SHIP \u002F SKIP \u002F NEEDS-REWORK \u002F NEEDS-SIGNOFF.\n>\n> Run attacks in order, stop at first kill:\n>\n> 0. **Pass 1 data integrity**: split proposal with missing `split_costs.py` output, merge proposal with missing `churn_ratio.sh`, or Rule 4 finding with missing `co_edit_matrix.py` → flag as a Pass 1 bug and drop the finding. Do not grade semantics on missing data; do not emit NEEDS-REWORK (that reads as a semantic verdict). Note it separately so the user knows Pass 1 needs re-running, not that the proposal is fixable.\n>\n> 1. **Rule 3 veto (merges)**: recompute `churn_ratio.sh`. Threshold is **3×** — if you typed 5× or 8×, re-read the skill.\n> 2. **Aesthetic rationale**: if `rationale_weak: true` OR `importer_payoff: none` → SKIP. Demand a concrete PR pattern.\n> 3. **Shared-types trap (splits)**: `shared_types` non-empty → 2-way split forces 3rd types module. NEEDS-REWORK.\n> 4. **Shared-helpers trap (splits)**: `shared_helpers` non-empty → duplicated helpers or cross-imports. NEEDS-REWORK unless helpers move cleanly.\n> 5. **Semantic-marker exemption (Rule 2 folds)**: if top 15 lines have a module docstring or block comment explaining the boundary (keywords: `boundary`, `variant`, `unguarded`, `scoped`, `isolate`, `bridge`, `shim`) → SKIP.\n> 6. **Entry-point trap (renames)**: check `pyproject.toml` `[project.scripts]`, `[project.entry-points]`, and direct imports by `src\u002Fbenchflow\u002Fcli\u002F`, `src\u002Fbenchflow\u002F__init__.py`, and `src\u002Fbenchflow\u002Fsdk.py`. If hit → NEEDS-SIGNOFF.\n> 7. **Registry-surface trap**: check if the file contains or is imported by `agents\u002Fregistry.py` \u002F `agents\u002Fproviders.py`. These are the documented extension points — any rename invalidates external registration code and needs user-docs update. NEEDS-SIGNOFF.\n> 8. **Cycle\u002Fbarrel trap**: `importers.py` output showing `# barrel:` lines via `__init__.py`; verify proposed splits don't import each other through a barrel.\n> 9. **Test colocation**: `tests\u002Ftest_\u003Cname>.py` must move with source without fixture or `conftest.py` restructuring. If the file has a paired test file, name it and check for `conftest.py` dependencies.\n>\n> All attacks fail → SHIP with counterfactual rationale verbatim. No hedging.\n\nExpect 40–60% kill rate. \u003C20% → re-run with stronger framing. >80% → Pass 1's `rationale_weak` filter is too loose.\n\n### Synthesize\n\nThree buckets:\n- **Leaf-first wins** (0–1 importers) — safe now.\n- **Hub moves** (>5 importers or entry-point) — codemod, separate PR.\n- **Rejected** — brief list with vetoing rule.\n\nInclude PR sequence respecting Rule 5.\n\n### Approval\n\nDo NOT edit. On approval:\n- **Rule 2 folds** → `\u002Fcode-cleanup`.\n- **Renames\u002Fsplits** → manual edit + codemod (`grep -rl 'from benchflow.X' | xargs sed -i ...`) + `ty check src\u002F` + `.venv\u002Fbin\u002Fpython -m pytest tests\u002F` in one PR. \"Draft PR 1\" means diff plan, not commits.\n\n## Cadence\n\nMonthly or per-major-feature. Signal comes from accumulated drift, not single-commit noise. Benchflow has three files already past the Rule 4 threshold (`_sandbox.py`, `sdk.py`, `job.py`) — those are the current top candidates.\n\n## Anti-patterns\n\n- **Don't skip Pass 2** — it kills aesthetic splits and 1-importer theater Pass 1 rubber-stamps.\n- **Don't pre-filter in Pass 1 with \"facade\" \u002F \"coherent\" \u002F \"cohesive\" prose.** If the mechanical check fires and dominant-symbol \u003C 70%, emit. Pass 2 decides.\n- **Don't split Pass 1 by rule** — split by subtree or not at all. Rule 3 must see Rules 1\u002F2 proposals.\n- **Don't propose renames without checking entry points, `__init__.py` re-exports, and registry surfaces.**\n- **Don't batch leaf + hub reorgs in one PR** — blast radius must match review posture.\n- **Don't grow the rule list.** Five is enough. New signals → `split_costs`, not new rules.\n- **Don't accept aesthetic rationales.** Narrative clarity \u002F isolated tests \u002F cognitive load → `rationale_weak: true`.\n- **Don't propose a 2-way split without `split_costs.py`** — unchecked shared types\u002Fhelpers become 3-way splits or cross-import tangles.\n- **Don't touch private-underscore modules without reading them.** `_sandbox.py` \u002F `_env_setup.py` look mergeable by name but carry the repo's most security-sensitive code; the underscore prefix is about API surface, not cohesion.\n",{"name":5,"description":7,"user-invocable":24},true,"main","cdcb6d230f3b15c3c33f8a2bdd16439f43602cbe",".agents\u002Fskills\u002Farch-audit",1,"https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark","https:\u002F\u002Fgithub.com\u002Flinyouxue","2026-11-14 20:28:35",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":24},[34,37,40],{"tool":35,"command":36},"npx","npx skills add linyouxue\u002Fskill-repair-benchmark --skill arch-audit",{"tool":38,"command":39},"bunx","bunx skills add linyouxue\u002Fskill-repair-benchmark --skill arch-audit",{"tool":41,"command":42},"pnpm","pnpm dlx skills add linyouxue\u002Fskill-repair-benchmark --skill arch-audit","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Farch-audit\u002FSKILL.md",[45,51,55,59,63,67,71,75,79],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"scripts\u002F.gitignore","SCRIPT","脚本",21,"https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Farch-audit\u002Fscripts\u002F.gitignore",{"path":52,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":53,"sourceHtmlUrl":54},"scripts\u002Fchurn_ratio.sh",743,"https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Farch-audit\u002Fscripts\u002Fchurn_ratio.sh",{"path":56,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":57,"sourceHtmlUrl":58},"scripts\u002Fco_edit_matrix.py",4986,"https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Farch-audit\u002Fscripts\u002Fco_edit_matrix.py",{"path":60,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":61,"sourceHtmlUrl":62},"scripts\u002Fdominant_symbol.py",1568,"https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Farch-audit\u002Fscripts\u002Fdominant_symbol.py",{"path":64,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":65,"sourceHtmlUrl":66},"scripts\u002Fexports.py",1930,"https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Farch-audit\u002Fscripts\u002Fexports.py",{"path":68,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":69,"sourceHtmlUrl":70},"scripts\u002Fimporters.py",1069,"https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Farch-audit\u002Fscripts\u002Fimporters.py",{"path":72,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":73,"sourceHtmlUrl":74},"scripts\u002Fmanifest.py",11124,"https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Farch-audit\u002Fscripts\u002Fmanifest.py",{"path":76,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":77,"sourceHtmlUrl":78},"scripts\u002Fsplit_costs.py",5874,"https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Farch-audit\u002Fscripts\u002Fsplit_costs.py",{"path":80,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":81,"sourceHtmlUrl":82},"scripts\u002Ftiny_files.sh",468,"https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Farch-audit\u002Fscripts\u002Ftiny_files.sh",[84,91,98,105,110,115],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7E1HGVRY73NBJ022CJG13X6","video-frame-extraction","Extract frames from video files and save them as images using OpenCV","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fvideo-frame-extraction\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M7E1HAG5R7CJ9C8NYJS771MB","openai-vision","Analyze images and multi-frame sequences using OpenAI GPT vision models","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fopenai-vision\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":19},"01M7E1H7DADKB6QBWKC2KQ63SZ","image-ocr","Extract text content from images using Tesseract OCR via Python, including structured field extraction from receipts and forms","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fimage-ocr\u002FSKILL.md",[],[],{"skillNo":106,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":19},"01M7E1H0WBNT43TENGQY7AVZHD","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fvideo-frame-extraction\u002FSKILL.md",[],[],{"skillNo":111,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":19},"01M7E1GTC7D4N4Q2EF03875J9E","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fopenai-vision\u002FSKILL.md",[],[],{"skillNo":116,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":19},"01M7E1GQ92CWFMGH53KSSE4WER","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fimage-ocr\u002FSKILL.md",[],[]]