本文へ移動
cccskills
無料GitHub で公開

refactor

Restructure or clean up code with no behavior change, proved by before-and-after checks. Use when: asked to clean up, extract, dedupe or simplify, even one function.

インストール方法を見る

含まれるファイル(3)

  • SKILL.md6.4 KB
  • references/behavior-preserving-simplification.md5.3 KB
  • references/refactor.feature2.7 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Refactor — one structural experiment

Refactor changes structure while preserving observable behavior. It performs one caller-selected transformation and reports the result. "Behavior-preserving" is a claim to prove with before/after checks, never to assert.

What counts as behavior

Unless the caller explicitly excluded a surface, all of these must survive:

  • Messages and exit codes. Error and output text compares byte-for-byte; exit codes, error types and which input raises which error stay the same. Scripts and callers parse them. Preserve an inconsistent message and report it; normalizing it is a behavior change.
  • Differences between near-duplicates. When merging duplicated branches, carry every difference (constants, comparisons, messages, extra steps) as a parameter or a branch. Do not unify a difference the caller has not declared accidental.
  • Interfaces. Public signatures, defaults, return types, persisted field names, protocol values and CLI flags. Renaming one is a compatibility change unless the accepted scope provides for it.
  • Order and coverage. Branch priority, default handling, evaluation count, side-effect order, and the set of tests that run. A pre-existing red that vanishes, or a test that stops running, is a behavior change.

Procedure

  1. Name the preserved behavior, the focused acceptance surface and the concrete structural problem for its callers, in the caller's domain terms.
  2. Run the focused check and the smallest regression check the changed surface justifies, and record that honest baseline, including reproducible ambient failures. For an evaluation comparing executable behavior, pin the starting source, build its baseline before edits and keep that binary and the comparison inputs.
  3. Apply one bounded transformation: extract, rename, inline, simplify, encapsulate, move, or delete dead code. Judge it by what callers must understand and where a domain rule must change, not by file size.
  4. A bug or suspicious inconsistency found on the way is reported separately (location, why it looks wrong) and left unfixed. Fixing it inside the refactor hides a behavior change the caller did not authorize.
  5. Rerun the same focused check and the smallest justified regression check over the same inputs, including error paths.
  6. Report, then stop. A red result is evidence for the caller; this skill does not revert, narrow, retry, commit, validate, or route subsequent work.

When nothing can be executed (no runtime, no tests, code supplied in a message), neutrality is unproven: give the exact before/after commands and inputs the caller must run, error paths included, and list every surface under behavior not checked.

transformation: <the one change>
preserved:      <behavior and surfaces from step 1>
checks:         <command>: before -> <result>; after -> <result>   (or "not run")
outputs:        <before/after hashes when the surface produces output>
diff:           <files touched>; only those the transformation names
suspected bugs: <file:line, why>; reported, not fixed
not checked:    <surfaces no check covered>; present even when empty

Responsibility and interface cost

Before adding an interface or splitting a module, inspect representative callers. Count the concepts they must coordinate: required setup, ordering, states, error handling and repeated domain rules. A useful boundary puts a cohesive rule under one owner and lets callers request an outcome without reproducing that rule. Reject a wrapper that only adds another name or pushes the same coordination into its callers. Existing boundaries are sufficient when no concrete caller problem warrants changing them.

Use the caller's vocabulary for extracted operations and types. A naming ambiguity that changes behavior belongs with the existing domain definition; consult Domain only when that distinction needs work.

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

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 vanished red.
  • For output-producing surfaces (generators, serializers, formatters, reports), capture output hashes over identical inputs before the change and compare byte-for-byte after. A mismatch is a behavior diff to surface and explain, never to shrug at; the caller decides whether to keep, narrow, or reverse it.

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 under behavior not checked.

References

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Use AtomLane to compile and execute safe atomic parallel plans on macOS and native Windows Preview for worthwhile independent argv tasks, dependency DAGs, supported platform entrypoints, or Apple-silicon operators. Use at task start or an execution boundary when structured local work may contain two or more worthwhile units; skip plain answers, one quick command, and work whose effects cannot be safely bounded.

日本語の概要は準備中です。原文の説明を表示しています。

hashgraph-online/awesome-codex-plugins1,2732026年10月10日 更新

add

無料

Register a deferred decision in the debt registry. Trigger by judgment, not a marker scan, whenever a future reader would ask "why this way?": an unmade decision, stub, loosened type, bypassed check, swallowed error, a default picked "for now", or a TODO/FIXME/HACK/XXX marker. Trigger immediately whenever you defer work, or when the user invokes $add. Over-register freely; the developer drops with "drop A", "drop A,C", or "drop all".

日本語の概要は準備中です。原文の説明を表示しています。

hashgraph-online/awesome-codex-plugins1,2732026年10月10日 更新

ADK 框架适配层。为 LangChain / EINO / AutoGen / AgentScope / CrewAI 提供框架特定的 代码模板、惯用模式、API 映射和项目结构,供 agent-dev-workshop Phase 5 代码生成使用。 每个框架 reference 文件标注 verified_date 用于版本锁定。

日本語の概要は準備中です。原文の説明を表示しています。

hashgraph-online/awesome-codex-plugins1,2732026年10月10日 更新

中文调试修复技能。用于报错、测试失败、页面异常、功能不符合预期、需要定位根因并做最小修复时。触发语包括"进入调试模式""帮我修问题""报错了""测试失败""页面坏了""找根因"。

日本語の概要は準備中です。原文の説明を表示しています。

hashgraph-online/awesome-codex-plugins1,2732026年10月10日 更新

交互式 AI Agent 开发工作坊:通过 6 阶段深度协作对话,引导用户完成 Agent 需求分析、架构设计、 工具定义、Prompt 与编排设计、代码生成、验证迭代,产出可直接运行的 Agent 项目。 框架无关设计优先,支持 LangChain / EINO / AutoGen / AgentScope / CrewAI 等 ADK 框架。

日本語の概要は準備中です。原文の説明を表示しています。

hashgraph-online/awesome-codex-plugins1,2732026年10月10日 更新

中文漂移审计技能。用于项目或学习过程变乱、上下文漂移、任务分叉、多个方案冲突、命名不一致、Codex 可能顺手改多了时。触发语包括"漂移检查""感觉跑偏了""项目变乱了""检查是否失控""分叉太多""上下文漂移"。

日本語の概要は準備中です。原文の説明を表示しています。

hashgraph-online/awesome-codex-plugins1,2732026年10月10日 更新

hashgraph-online のスキルをすべて見る

このスキルの問題を報告する