/dev-standards:dev-standards-refactor-first-assessmentfrom dev-standards
During planning after grill-task, decide whether preparatory refactor step is needed before implementation — runs four parallel A-rule checks. 規劃時評估現有結構是否支持計劃變更,按需插入預備重構步驟。 Use when: creating implementation plan, after grill-task, before writing implementation steps, assess codebase for refactor, planning refactor-first
Ships in dev-standards. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
評估現有代碼庫結構是否自然支持計劃中的變更。若不支持,在實現步驟前插入預備重構步驟。
Invoke the
Skilltool withskill: dev-standards:grill-task— 獲取任務規格後方可評估。
之後
scope.files_to_modify 中文件的當前內容依序執行。任一「no」即向計劃添加預備重構步驟。
此變更是否有明顯的添加位置?能否指出新代碼清晰歸屬的文件和行?
現有名稱是否為新概念留有空間,或新代碼會與命名不同的現有概念重疊?
相關代碼最終會在正確的文件/模塊中嗎?具體地,新代碼的領域概念是否已有歸屬,還是會分散到不相關文件中?
添加新變更時是否需要與現有代碼搏鬥?跡象:深層嵌套、不相關參數穿插傳遞、不應關心的調用者需要更新。
一條計劃編輯指令,二選一:
Refactor <target> to <action> (move/rename/extract/inline). Then re-run existing tests before the first new RED test."若多項檢查失敗,按順序插入多個重構步驟:提取/移動 → 重命名 → 降低摩擦。絕不在同一步驟中混合重構與實現。
評估重構是否值當時,一以此語彙論之(完整定義見 LANGUAGE.md):
以 lci:explore(模塊圖)+ lci:trace-symbol(刪除測試找全調用者)探之;lci 不可用則退回 Explore agent 或 Grep。
碼異味基線(Fowler ch.3): 掃描待改代碼之異味——Mysterious Name、Duplicated Code、Feature Envy、Data Clumps、Primitive Obsession、Repeated Switches、Shotgun Surgery、Divergent Change、Speculative Generality、Message Chains、Middle Man、Refused Bequest。各為判斷式啟發(「疑似 Feature Envy」),非硬違規;已文檔化之項目規範覆蓋基線,工具(linter/type-checker)已強制者略過。全清單與修法見 CODE-SMELLS.md。異味指向淺模塊或錯置 seam 時,即為插入預備重構步驟之信號。
HTML 報告 → 委派 present:html-report。 多候選架構審查,勿於此內嵌 HTML scaffold。集結結構化數據(標題;每候選 before/after 節;推薦強度徽章:Strong / Worth exploring / Speculative;可選 Mermaid before/after 圖),調 present:html-report,其將自包含 Tailwind+Mermaid HTML 寫入 OS temp dir 並開啟。present 插件不可用則退回:寫純文本摘要至 temp dir 並印出路徑。Interface-design 探索:INTERFACE-DESIGN.md。
領域用 .claude/rules/glossary.md 語彙,架構用 LANGUAGE.md 語彙。遵 .claude/rules/architecture.md + docs/adr/ 中之 ADR;候選若與現有 ADR 相牴,標出之(勿靜默重議)。
四檢之外,於 scope.files_to_modify 及其直接 import 鄰域探四結構道(全則見 ../ultra-clean/LANES.md);中者即預備重構步驟之信號,非機會性清理之後門:
| Lane | 探 | 中則插步 |
|---|---|---|
| shared types (2) | 新碼將觸之概念是否已有 ≥2 漂移定義 | Consolidate <concept> type to one owner |
| circular deps (4) | 新 import 是否閉環或經 barrel 生後邊 | Break cycle <a>↔<b> (type-only import / move helper / drop barrel) |
| strong types (5) | 觸點簽名是否 any/unknown/鬆散 map 而契約已知 | Type <boundary> from <schema/source of truth> |
| legacy & fallback (7) | 觸點是否雙路/compat/fallback 而準路已明 | Delete <legacy path>; keep <canonical> |
唯證據足者入計劃(代碼搜索 + lci:trace-symbol 全調用者 + 有驗證路);證不足者記於計劃註,交 Invoke the Skill tool with skill: dev-standards:ultra-clean 之獨立清碼任務,勿混入本任務。
.claude/rules/refactor-discipline.md。assessment:
natural_extension: yes
naming_fit: no # "OrderLine" and "LineItem" both in use
co_location: yes
friction: no
refactor_steps_to_insert:
- "Rename OrderLine -> LineItem across src/orders/ and tests/orders/"
- "Run existing test suite, confirm GREEN"
then_proceed_with:
- "Original implementation steps from plan"
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub standardbeagle/standardbeagle-tools --plugin dev-standards25 skills in this plugin
/dev-standards-add-skillCreate new project-specific skill in `.claude/skills/` to codify recurring pattern. 在項目中新建可複用技能。 Use when: add skill, create skill, new skill, codify pattern, make reusable workflow/dev-standards-ce-compound記錄已解決問題以複利機構知識。Document solved problems in docs/solutions/ with structured YAML frontmatter. Use when: non-trivial problem solved + verified, prevent re-discovery, capture institutional learning before context fades, document best practice or workflow pattern. Skip: trivial (typo), solution unverified, problem in progress, project lacks docs/solutions/ convention./dev-standards-ce-setupDiagnose + configure compound-engineering env — CLI deps, plugin version, repo-local config. Guided install for missing tools, gitignore + config bootstrap. Use when: troubleshoot missing tools, verify CE setup, onboard repo, refresh config template, /ce-setup re-check. Skip: unrelated to compound-engineering tooling.