一键导入
canon-refactor
Use when you need a governed refactor run for an existing system with preserved behavior and explicit no-feature-addition evidence.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when you need a governed refactor run for an existing system with preserved behavior and explicit no-feature-addition evidence.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when you need a governed Canon review of a real diff or pull-request range instead of a loose chat summary.
Use when a repository does not have Canon runtime state yet and you need to initialize .canon before any governed workflow.
Use when you need a governed Canon policy-shaping run to shape a new or modified policy with mandatory impact evaluation.
Use when you need a governed backlog run that decomposes bounded upstream decisions into delivery epics and slices.
Use when you need a governed Canon architecture run to record decisions, tradeoffs, and risk-gated approvals.
Use when you need a governed change run in a live codebase where invariants and existing behavior matter.
| name | canon-refactor |
| description | Use when you need a governed refactor run for an existing system with preserved behavior and explicit no-feature-addition evidence. |
available-nowdefault visibility: discoverable-standardExpose the delivered Canon refactor workflow as a governed run started from your AI assistant.
$canon-change.RISKZONEOptional:
OWNER when the user wants to override Git-derived ownership explicitlycanon is on PATH. If missing, point to the install guide..canon/ exists. If missing, point to $canon-init.--system-context existing for this skill.canon-input/ as read-only source material.canon-input/refactor.md or canon-input/refactor/ as the canonical authored-input locations for this mode.canon-input/refactor/, treat brief.md as the authoritative readiness brief and source-map.md as explicit provenance for carried-forward change or implementation context.--input-text instead of materializing a repo file automatically.--input from the active editor file, open tabs, recent .canon/ artifacts, or any other path under .canon/..canon/ artifacts or published packets directly; the current brief must restate preserved behavior, scope, safety-net evidence, and no-feature-addition proof.$canon-change instead of guessing.low-impact, bounded-impact, or systemic-impact.green, yellow, or red.Canon does not invent the refactor body for you. Canon governs, validates, and
persists the packet. You (the assistant) MUST author the real refactor body
from the bounded source material BEFORE calling canon run --mode refactor.
Do this every time, even when the user starts from a short brief rather than a finished packet:
canon-input/refactor.md or a
folder-backed packet under canon-input/refactor/. The authored body MUST
include all of the following canonical H2 sections with concrete content:
## Preserved Behavior## Approved Exceptions## Refactor Scope## Allowed Paths## Structural Rationale## Untouched Surface## Safety-Net Evidence## Regression Findings## Contract Drift## Reviewer Notes## Feature Audit## DecisionDecisions do not satisfy this
slice. Use the canonical H2 headings above.## Missing Authored Body
naming the missing canonical heading instead of fabricating filler.$canon-change or ask targeted clarification questions
before invoking Canon rather than submitting an empty brief.Author the packet as a preservation-focused maintainer proving that structure changes remain behavior-safe for reviewers and approvers.
canon run --mode refactor --system-context existing --risk <RISK> --zone <ZONE> [--owner <OWNER>] (--input <INPUT_PATH> | --input-text <INPUT_TEXT>)gate:execution approval target on the first run; the state is AwaitingApproval and the posture stays recommendation-only until that gate is approved.$canon-approve records the gate:execution approval, Canon still remains AwaitingApproval until $canon-resume runs the post-approval continuation.$canon-resume, surface approved-recommendation only when the packet has no executable local patch payload; real workspace mutation currently requires a bounded local payload such as patch.diff inside canon-input/refactor/.continue, resume, or same run, or supplies a RUN_ID.$canon-status for the compact summary and canon inspect refinement --run <RUN_ID> when the user needs the advisory continuation state Canon persisted for the run..canon/runs/<RUN_ID>/artifacts/refactor/working-brief.md exists for this mode unless Canon emits that surface in a future slice.recommendation-only before resume, approved-recommendation only after approved resume without a local patch payload, mutating after approved resume with a valid local patch payload).canon/artifacts/<RUN_ID>/refactor/ paths when Canon emitted themAction Chips: when the host supports chips, preserve the full objects Canon already returned in mode_result.action_chips; do not collapse them to label-only bullets. In text-only hosts, render each chip's text_fallback instead. Typical gated set: Inspect evidence, Approve generation..., Open primary artifact; after approval but before continuation: Open primary artifact, Inspect evidence, Resume run. Must be the last element of the response; do not place any text after this section.canon is missing, show the supported install path from README..canon/ is missing, point to $canon-init.$canon-change instead of guessing preserved behavior or no-feature-addition proof.AwaitingApproval, surface the exact target Canon produced and do not imply the run is complete.AwaitingApproval, say directly that the run now needs $canon-resume, not another approval.$canon-inspect-artifacts first.$canon-inspect-evidence when the user needs invocation rationale or policy decisions.$canon-change when the real gap is still bounded planning or feature-delivery scoping.$canon-review when the packet needs explicit non-PR disposition.$canon-status$canon-inspect-evidence$canon-inspect-artifacts$canon-approve$canon-resume$canon-change$canon-review