AGENT SKILL

book-refactoring-pass

Guides behavior-preserving refactoring with small, reversible steps. In strict tasks, mandatory before the first implementation edit to existing production code; in default/lite tasks, use on demand when structural friction, duplication, long functions, tangled responsibilities, unsafe cleanup, or explicit delivery requirements affect the change.

License 许可
Apache-2.0
最近更新
2026-11-05
Stars
★ 195
Forks
1

01 前言 Front Matter

name
book-refactoring-pass
license
Apache-2.0
metadata
{ "sbtd.category": "refactoring", "sbtd.portable": "true", "sbtd.source-revision": "1d82494d74f6df9bca7dccef2da409f87091883e" }
description
Guides behavior-preserving refactoring with small, reversible steps. In strict tasks, mandatory before the first implementation edit to existing production code; in default/lite tasks, use on demand when structural friction, duplication, long functions, tangled responsibilities, unsafe cleanup, or explicit delivery requirements affect the change.
allowed-tools
read grep glob bash
compatibility
Requires project tests; Trellis artifacts and GitNexus are optional context sources.

02 资源文件 2

03 SKILL.md 正文

Book Refactoring Pass

Use this Skill as a focused refactoring check before or during implementation.

It is derived from the mini rule style of agent-rules-books. It is a strict development gate for existing-production-code edits and an on-demand engineering lens in other structural-risk scenarios; it does not replace project rules, tests, task artifacts, source/LSP/contract impact analysis, or code review.

Strict Development Gate

Whenever a strict task will modify existing production code, run this Skill before the first implementation edit to existing production code, even when the expected result is that no refactoring is needed.

Emit a separate visible review:

Refactoring Review
Status: proceed | refactor-first | blocked
Review mode: normal | safety-seam-only
Existing-code scope: ...
Behavior that must remain unchanged: ...
Structural friction: ...
Decision and smallest safe step: ...
Safety net and validation: ...
Deferred refactors: ...
  • proceed: in normal mode, the existing structure is safe enough for the requested edit; no refactor needed is a valid explicit conclusion.
  • refactor-first: perform only the smallest behavior-preserving structural change allowed by the current review mode, validate it, and rerun the required gate before feature or fix edits.
  • blocked: required behavior evidence, a safety net plan, or the Skill is unavailable; state the blocker and do not edit production behavior.

If book-legacy-change-safety is also mandatory, its review normally reaches characterized before this gate runs. Controlled exception: a legacy seam-required result may invoke this Skill in safety-seam-only mode. That mode may design and implement only the recorded behavior-preserving test seam, must validate observational equivalence, and must return to legacy review to establish the safety net. After legacy reaches characterized, rerun this Skill in normal mode before feature / fix edits.

When To Use

  • Strict: every development task that modifies existing production code. In default/lite, use this Skill when structural risk, project rules, or explicit delivery requirements apply.
  • Existing code structure is making a requested change risky or awkward.
  • A change mixes behavior changes with cleanup.
  • Duplication, long functions, feature envy, primitive obsession, or tangled responsibilities are blocking clarity.
  • A review needs to decide whether a refactor should happen now or be deferred.

When existing production code will not be modified, do not use this Skill for simple text, docs, config-only edits, broad rewrites, speculative architecture changes, or code that is already easy to change safely unless the user explicitly requests the review or another concrete structural risk warrants it.

Workflow

  1. Identify the observable behavior that must remain unchanged.
  2. Confirm the available safety net: tests, characterization checks, manual repro, snapshots, or focused inspection.
  3. Separate structural refactoring from behavior changes.
  4. Prefer the smallest reversible move that lowers the current task risk.
  5. Preserve public contracts unless the task explicitly changes them.
  6. In safety-seam-only mode, reject feature behavior, bug-fix behavior, broad cleanup, or any structural change not required by the recorded test seam.
  7. Run the project validation appropriate to the touched code.

Output

Always emit the visible Refactoring Review for a strict gate. When used in a task-level record, also write only task-specific conclusions to implement.md, design.md, or the check summary:

  • Current friction.
  • Behavior that must not change.
  • Proposed refactoring steps or explicit no refactor needed.
  • Safety net and validation command.
  • Deferred refactors, if any.

Only long-term conventions belong in docs/spec.

Stop Conditions

Stop refactoring when the requested change is safe and clear enough. The mandatory review does not require a refactor; never invent cleanup merely to produce refactor-first, and do not keep improving code outside the task boundary.

04 同仓库更多 Skills

KunoLu
KunoLu/sbtd-plugins

gherkin-bdd

Use when adding, changing, reviewing, testing, synchronizing, or read-only ingesting user-visible behavior with BDD, Gherkin, Given/When/Then scenarios, .feature files, acceptance criteria, knowledge catalogs, or bug-fix behavior specs.

★ 195
KunoLu
KunoLu/sbtd-plugins

sbtd-workflow-onboard

Checks, installs, or resets SBTD workflow tools, global Skills, managed AGENTS templates, and per-project configuration for local project roots in Oh My Pi.

★ 195
KunoLu
KunoLu/sbtd-plugins

web-ui-autotest-generator

从前端和后端源码中生成可维护的 Web UI 自动化测试。适用于分析页面、路由、组件、接口、用户流程,生成 Playwright UI 测试,运行测试,生成中文报告,并自检页面功能和跨页面逻辑是否被独立测试资产覆盖。 Generate maintainable Web UI automated tests from frontend and backend source code. Use for analyzing pages, routes, components, APIs, and user flows; generating and running Playwright UI tests; producing Chinese test reports; and checking whether page features and cross-page logic are covered by independent test assets.

★ 195
KunoLu
KunoLu/sbtd-plugins

seo-geo

SEO & GEO (Generative Engine Optimization) for websites. Analyze keywords, generate schema markup, optimize for AI search engines (ChatGPT, Perplexity, Gemini, Copilot, Claude) and traditional search (Google, Bing). Use when user wants to improve search visibility, search optimization, search ranking, AI visibility, ChatGPT ranking, Google AI Overview, indexing, JSON-LD, meta tags, or keyword research.

★ 195
KunoLu
KunoLu/sbtd-plugins

sbtd-task

Use for SBTD task execution and continuation, explicit default/lite/strict mode selection, task records and status changes, cross-session recovery, and task handoffs. Load strict gates only for strict tasks; ordinary questions and read-only work do not create task files.

★ 195
KunoLu
KunoLu/sbtd-plugins

project-validation

Use after code changes to choose and run validation commands for Node, JavaScript, TypeScript, Python, Go, Dart, Java, Kotlin, C++, Swift, or Objective-C projects. Prefer project-defined commands and report skipped checks and risks.

★ 195