Agent Skillsboshu2/agentops › refactor

refactor

GitHub

执行保持行为不变的结构化重构,提取、简化或移动代码,并通过测试和哈希对比验证行为一致性。

skills-codex/refactor/SKILL.md boshu2/agentops

触发场景

refactor this simplify without changing behavior

安装

npx skills add boshu2/agentops --skill refactor -g -y
更多选项

非标准路径

npx skills add https://github.com/boshu2/agentops/tree/main/skills-codex/refactor -g -y

不安装直接使用

npx skills use boshu2/agentops@refactor

指定 Agent (Claude Code)

npx skills add boshu2/agentops --skill refactor -a claude-code -g -y

安装 repo 全部 skill

npx skills add boshu2/agentops --all -g -y

预览 repo 内 skill

npx skills add boshu2/agentops --list

SKILL.md

Frontmatter
{
    "name": "refactor",
    "description": "Execute one behavior-preserving structural transformation and report evidence. Triggers: \"refactor this\", \"simplify without changing behavior\"."
}

Refactor — one structural experiment

Refactor changes structure while preserving observable behavior. It performs one caller-selected transformation and reports the result.

Prompt

Refactor billing-service/internal/retry/backoff.go: extract the exponential backoff calculation out of RetryRequest into its own function, no other behavior change. Record a baseline, run go test ./internal/retry/... before and after, and report the diff summary, commands, results, and anything not checked.

It's working if

  • The report names the preserved behavior and cites go test ./internal/retry/... run both before and after.
  • git diff --stat touches only internal/retry/backoff.go, never an unrelated file.
  • Golden-output hashes get captured and compared byte-for-byte whenever the changed surface produces output, e.g. sha256sum before and after.
  • The report's behavior not checked list is present in the output even when empty, naming any surface the gates skipped.

Procedure

  1. Name the preserved behavior and the focused acceptance surface.
  2. Record an honest baseline, including any reproducible ambient failures.
  3. Apply one bounded transformation: extract, rename, inline, simplify, encapsulate, move, or delete dead code.
  4. Run the focused check and the smallest package-level regression check justified by the changed surface.
  5. Return the diff summary, commands, results, and behavior not checked.

Do not combine a newly discovered behavior fix with the structural change. A red result is evidence for the caller; this skill does not revert, narrow, retry, commit, validate, or route subsequent work automatically.

Seam experiments before commitment

When the transformation needs a seam — an extraction boundary, interface, or module split — and more than one candidate seam exists, probe before you cut. Run the probe in disposable isolation (a scratch branch, worktree, or copied tree the caller's policy allows): rough in the seam, see what it forces — signature churn, import cycles, test rewrites — then discard the probe and keep only the knowledge. Stop condition: at most two probes; if the second candidate seam also fights back, report both findings to the caller instead of trying a third. Cutting the first imaginable seam directly into the working tree is the premature seam failure mode: the wrong boundary calcifies because reverting it now costs more than living with it.

Neutrality gates

"Behavior-preserving" is a claim to execute, not assert. Gate the transformation on behavior-identical proof:

  • The focused check and the package-level regression check pass both before and after, with the same set of pre-existing failures — no new red, and no quietly vanished red either (a test that stops running is a behavior change).
  • For output-producing surfaces (generators, serializers, formatters, reports), hash the outputs: capture golden-output hashes over identical inputs before the change and compare byte-for-byte after. A hash mismatch is a behavior diff to surface and explain, never to shrug at; the caller decides whether to keep, narrow, or reverse the change.
  • Observable error messages, exit codes, and public signatures on the changed surface are part of behavior unless the caller excluded them.

A neutrality gate that was skipped or narrowed after the fact is the post-hoc neutrality failure mode — the diff decides what got tested. Name any surface the gates did not cover in the report's behavior-not-checked list.

References

版本历史

  • 8061085 当前 2026-09-09 05:20

    新增 Prompt 示例与 It's working if 验收标准;细化 Neutrality gates 的行为验证要求。

  • 7b07a7d 2026-08-19 22:03

    清理重构技能中的提交和自动回退权限声明;修复版本变更摘要生成逻辑以保留便携式元数据并增强YAML验证。

  • 3f402e5 2026-07-24 22:10

同 Skill 集合

images/gemini/skills/account-rotation/SKILL.md
images/gemini/skills/agent-mail/SKILL.md
images/gemini/skills/agent-native/SKILL.md
images/gemini/skills/agy-native/SKILL.md
images/gemini/skills/anti-ceremony/SKILL.md
images/gemini/skills/automation-shape-routing/SKILL.md
images/gemini/skills/bootstrap/SKILL.md
images/gemini/skills/cass/SKILL.md
images/gemini/skills/cc-hooks/SKILL.md
images/gemini/skills/codebase-recon/SKILL.md
images/gemini/skills/codex-exec/SKILL.md
images/gemini/skills/converter/SKILL.md
images/gemini/skills/council/SKILL.md
images/gemini/skills/craft-goal/SKILL.md
images/gemini/skills/crank/SKILL.md
images/gemini/skills/dcg/SKILL.md
images/gemini/skills/doc/SKILL.md
images/gemini/skills/domain/SKILL.md
images/gemini/skills/fitness/SKILL.md
images/gemini/skills/goals/SKILL.md
images/gemini/skills/handoff/SKILL.md
images/gemini/skills/human-only-skills/SKILL.md
images/gemini/skills/idea-genie/SKILL.md
images/gemini/skills/implement/SKILL.md
images/gemini/skills/learn/SKILL.md
images/gemini/skills/ms/SKILL.md
images/gemini/skills/ntm/SKILL.md
images/gemini/skills/one-way-door/SKILL.md
images/gemini/skills/operationalize/SKILL.md
images/gemini/skills/pattern-mining/SKILL.md
images/gemini/skills/plan/SKILL.md
images/gemini/skills/postmortem/SKILL.md
images/gemini/skills/premortem/SKILL.md
images/gemini/skills/product/SKILL.md
images/gemini/skills/rch/SKILL.md
images/gemini/skills/reality-check/SKILL.md
images/gemini/skills/refactor/SKILL.md
images/gemini/skills/research/SKILL.md
images/gemini/skills/reverse-engineer/SKILL.md
images/gemini/skills/route/SKILL.md
images/gemini/skills/rpi/SKILL.md
images/gemini/skills/sbh/SKILL.md
images/gemini/skills/scaffold/SKILL.md
images/gemini/skills/scope/SKILL.md
images/gemini/skills/security/SKILL.md
images/gemini/skills/shared/SKILL.md
images/gemini/skills/skill-builder/SKILL.md
images/gemini/skills/skill-eval/SKILL.md
images/gemini/skills/standards/SKILL.md
images/gemini/skills/status/SKILL.md

元信息

文件数
0
版本
8061085
Hash
fc9733e5
收录时间
2026-07-24 22:10

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-09 07:35
浙ICP备14020137号-1 $访客地图$