一键导入
asw-refactor
Behavior-preserving Antigravity Swarm refactoring with characterization, impact mapping, diagnostics, and real-surface verification.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Behavior-preserving Antigravity Swarm refactoring with characterization, impact mapping, diagnostics, and real-surface verification.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Installs and uses Antigravity CLI ASW skills, hooks, diagnostics, and swarm workflow guidance.
Remove AI-looking clutter and temporary artifacts without changing behavior.
Hypothesis-driven Antigravity Swarm debugging for crashes, hangs, wrong output, and runtime drift.
Antigravity Swarm Loop executes RED to GREEN to real-surface QA with cleanup receipts.
Antigravity Swarm Plan creates a decision-complete plan before large or ambiguous work.
Strict Antigravity implementation discipline for Python, TypeScript, JavaScript, Go, and Rust work.
| name | asw-refactor |
| description | Behavior-preserving Antigravity Swarm refactoring with characterization, impact mapping, diagnostics, and real-surface verification. |
Use this skill for behavior-preserving structure changes: moving code, splitting files, simplifying APIs internally, reducing duplication, or preparing a safer implementation path.
The invariant: refactoring changes structure, not observable behavior.
Before editing:
Characterization tests should cover:
Do not characterize private implementation details unless the refactor is explicitly about that internal contract.
Build an impact map before edits:
Behavior owner:
Callers:
Tests:
Docs:
Package/install:
Generated output:
Manual QA surface:
Rollback:
For each affected file, list whether it is source, test, docs, generated asset, package metadata, or runtime state.
Do not mix:
If the user asks for both feature and refactor, separate them in the plan and commit strategy.
Allowed when covered:
High-risk moves:
High-risk moves require explicit tests and manual QA.
Run the repo's authoritative checks. If unavailable, use fallbacks:
Treat hook diagnostics as early warnings and rerun the real command.
Stop and report when:
If a gate fails:
Do not use broad destructive commands.
Report:
Run this gate before touching files. Refactor requests are often mixed with feature requests, cleanup requests, or migration requests; separating them prevents accidental behavior changes.
Use this template:
Intent:
Allowed structural changes:
Behavior that must not change:
Public contracts:
Non-goals:
Refactor mode:
Risk:
Reject the refactor if the user-facing behavior cannot be named. A refactor without a behavior boundary is unbounded redesign.
For broad refactors, inspect in parallel before planning. Use read-only subagents or direct searches to answer independent questions:
Exploration agents must return evidence, not opinions:
Question:
Files inspected:
References found:
Tests found:
Public surface:
Risk:
Recommendation:
Do not start moving files while exploration is still incomplete for the same dependency graph. Direct local inspection may continue while background exploration runs, but edits wait for enough evidence to build the codemap.
Use the fastest appropriate tool:
For dynamic references, search strings too. Renames often fail through config files, CLI examples, hook manifests, status-line command strings, and README snippets.
Before planning, write a codemap. It is the source of truth for the refactor.
CODEMAP: <target>
Core files:
- path: role, owner, public/private
Callers:
- path: call shape, risk
Tests:
- path: behavior covered
- missing: behavior not covered
Docs and examples:
- path: wording or command that must stay true
Package/install surface:
- package path, config path, hook path, generated asset, status line
Impact zones:
- low risk:
- medium risk:
- high risk:
Constraints:
- compatibility:
- manual QA:
- rollback:
A codemap is not optional for multi-file refactors. If there is only one tiny local edit, a compact paragraph is enough, but it must still identify callers and tests.
Create the verification plan before the first edit.
Baseline:
- command:
- expected:
Narrow checks:
- after rename:
- after extract:
- after split:
Diagnostics:
- language:
- package:
- plugin:
Manual QA:
- surface:
- transcript or screenshot:
Regression indicators:
- what would prove behavior changed:
The baseline must be green before a behavior-preserving refactor. If the baseline is red, either prove it is unrelated and stable, or stop and report.
Detect the repo's test infrastructure before planning:
Then assess coverage:
Behavior:
Existing tests:
Weak spots:
Characterization needed:
Manual QA needed:
Coverage is strong when a failing refactor would fail a test for the right reason. Coverage is weak when the test only checks that a command exits, a file exists, or a broad snapshot changed.
If no test infrastructure exists, create the smallest local reproduction or smoke script that can be run again after the move. If even that is impossible, stop and explain why the refactor is unsafe.
Define checkpoints for each phase:
Each checkpoint should name:
Example:
Checkpoint: package surface
Command: npm pack --dry-run --json
Expected: changed files included, private/runtime files absent
Failure means: allowlist or ignore boundary changed
Recovery: inspect package files and restore boundary
The plan should be stepwise and reversible:
Each step must include:
Execute deterministically:
Do not batch unrelated moves just because they are easy to edit together. Reviewability matters; a future maintainer should be able to understand each structural change.
Use subagents when the refactor has independent unknowns:
Subagents should not edit unless explicitly assigned an implementation slice. Read-only exploration is safer for mapping.
For implementation slices:
Do not launch many implementation agents against overlapping files. Merge conflicts in a refactor are usually a sign that the responsibility boundary is unclear.
When moving code:
New names should describe ownership:
statusline-payload beats helpers,installer-paths beats utils,hook-aliases beats common,cover-renderer beats misc.Treat these as public until proven otherwise:
Changing any public surface requires an explicit behavior-change plan, not a refactor plan.
When the refactor includes deprecated paths:
Migration refactors should report:
If the user asked for commits, organize commits around reviewable behavior:
Do not commit red checkpoints. Do not mix a feature change with the refactor commit unless the user explicitly requested a combined commit.
Commit message should describe the structural change:
refactor(installer): split config path handling,refactor(hud): isolate quota formatting,refactor(skills): expand execution contracts.If the user did not ask for commit, leave the worktree ready and report status.
Use precise tools early:
Use direct file reads when a decision depends on exact wording. Do not rely on summary memory for refactor safety.
When a tool fails:
Never claim a diagnostic passed unless it ran and the output was read.
When a check fails:
Never hide a failed check by weakening the test unless the test is proven wrong and the proof is documented.
Abort and report when:
Use this shape:
REFACTOR REPORT
Scope:
Intent:
Codemap:
Characterization:
Steps:
Verification:
Manual QA:
Public surface:
Skipped:
Final status:
For every skipped refactor, include why it was skipped and what evidence would make it safe later.
The refactor is complete only when the code is easier to reason about and the user-facing behavior is proven unchanged.