Refactor — one structural experiment
Refactor changes structure while preserving observable behavior. It performs one
caller-selected transformation and reports the result.
Procedure
- Name the preserved behavior and the focused acceptance surface.
- Record an honest baseline, including any reproducible ambient failures.
- Apply one bounded transformation: extract, rename, inline, simplify,
encapsulate, move, or delete dead code.
- Run the focused check and the smallest package-level regression check justified
by the changed surface.
- 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 explain or revert, never to shrug at.
- 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
- Behavior-preserving simplification
- Behavior scenarios
Source: hashgraph-online/awesome-codex-plugins → plugins/boshu2/agentops/skills-codex/refactor/SKILL.md
1---2name: refactor-53description: Execute one behavior-preserving structural4---5
6# Refactor — one structural experiment
7
8Refactor changes structure while preserving observable behavior. It performs one
9caller-selected transformation and reports the result.
10
11## Procedure
12
131. Name the preserved behavior and the focused acceptance surface.
142. Record an honest baseline, including any reproducible ambient failures.
153. Apply one bounded transformation: extract, rename, inline, simplify,
16 encapsulate, move, or delete dead code.
174. Run the focused check and the smallest package-level regression check justified
18 by the changed surface.
195. Return the diff summary, commands, results, and behavior not checked.
20
21Do not combine a newly discovered behavior fix with the structural change. A red
22result is evidence for the caller; this skill does not revert, narrow, retry,
23commit, validate, or route subsequent work automatically.
24
25## Seam experiments before commitment
26
27When the transformation needs a seam — an extraction boundary, interface, or
28module split — and more than one candidate seam exists, probe before you cut.
29Run the probe in disposable isolation (a scratch branch, worktree, or copied
30tree the caller's policy allows): rough in the seam, see what it forces —
31signature churn, import cycles, test rewrites — then discard the probe and
32keep only the knowledge. Stop condition: at most two probes; if the second
33candidate seam also fights back, report both findings to the caller instead of
34trying a third. Cutting the first imaginable seam directly into the working
35tree is the **premature seam** failure mode: the wrong boundary calcifies
36because reverting it now costs more than living with it.
37
38## Neutrality gates
39
40"Behavior-preserving" is a claim to execute, not assert. Gate the
41transformation on behavior-identical proof:
42
43- The focused check and the package-level regression check pass both before
44 and after, with the same set of pre-existing failures — no new red, and no
45 quietly vanished red either (a test that stops running is a behavior change).
46- For output-producing surfaces (generators, serializers, formatters, reports),
47 hash the outputs: capture golden-output hashes over identical inputs before
48 the change and compare byte-for-byte after. A hash mismatch is a behavior
49 diff to explain or revert, never to shrug at.
50- Observable error messages, exit codes, and public signatures on the changed
51 surface are part of behavior unless the caller excluded them.
52
53A neutrality gate that was skipped or narrowed after the fact is the
54**post-hoc neutrality** failure mode — the diff decides what got tested. Name
55any surface the gates did not cover in the report's behavior-not-checked list.
56
57## References
58
59- [Behavior-preserving simplification](references/behavior-preserving-simplification.md)
60- [Behavior scenarios](references/refactor.feature)
61
62---
63
64**Source:** [`hashgraph-online/awesome-codex-plugins`](https://github.com/hashgraph-online/awesome-codex-plugins) → `plugins/boshu2/agentops/skills-codex/refactor/SKILL.md`