refactor — for Claude Code refactor, ai-agent-workflow, community, for Claude Code, ide skills, apply_patch, rg <pattern>, AskUserQuestion, Improve, structure

v1.0.0

关于此技能

适用场景: Ideal for AI agents that need improve code structure without changing observable behavior. refactoring without a baseline is. 本地化技能摘要: # Refactor Improve code structure without changing observable behavior. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

功能特性

Improve code structure without changing observable behavior. Refactoring without a baseline is
Target scope: file, module, function, or layer to refactor
Refactor motivation (if provided)
Optional: existing tests that cover the scope
Codex Tool Mapping

# 核心主题

phananhtuan09 phananhtuan09
[0]
[0]
更新于: 4/2/2026

Killer-Skills Review

Decision support comes first. Repository text comes second.

Reference-Only Page Review Score: 10/11

This page remains useful for operators, but Killer-Skills treats it as reference material instead of a primary organic landing page.

Original recommendation layer Concrete use-case guidance Explicit limitations and caution Quality floor passed for review
Review Score
10/11
Quality Score
70
Canonical Locale
en
Detected Body Locale
en

适用场景: Ideal for AI agents that need improve code structure without changing observable behavior. refactoring without a baseline is. 本地化技能摘要: # Refactor Improve code structure without changing observable behavior. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

核心价值

推荐说明: refactor helps agents improve code structure without changing observable behavior. refactoring without a baseline is. Refactor Improve code structure without changing observable behavior. This AI agent skill

适用 Agent 类型

适用场景: Ideal for AI agents that need improve code structure without changing observable behavior. refactoring without a baseline is.

赋予的主要能力 · refactor

适用任务: Applying Improve code structure without changing observable behavior. Refactoring without a baseline is
适用任务: Applying Target scope: file, module, function, or layer to refactor
适用任务: Applying Refactor motivation (if provided)

! 使用限制与门槛

  • 限制说明: Are there external contracts (API, public interface, DB schema) that must not change?
  • 限制说明: Invariants : what must be true after the refactor?
  • 限制说明: If the current behavior cannot be described clearly: read further or ask the user. Do not refactor without a baseline.

Why this page is reference-only

  • - Current locale does not satisfy the locale-governance contract.

Source Boundary

The section below is imported from the upstream repository and should be treated as secondary evidence. Use the Killer-Skills review above as the primary layer for fit, risk, and installation decisions.

评审后的下一步

先决定动作,再继续看上游仓库材料

Killer-Skills 的主价值不应该停在“帮你打开仓库说明”,而是先帮你判断这项技能是否值得安装、是否应该回到可信集合复核,以及是否已经进入工作流落地阶段。

实验室 Demo

Browser Sandbox Environment

⚡️ Ready to unleash?

Experience this Agent in a zero-setup browser environment powered by WebContainers. No installation required.

Boot Container Sandbox

常见问题与安装步骤

以下问题与步骤与页面结构化数据保持一致,便于搜索引擎理解页面内容。

? FAQ

refactor 是什么?

适用场景: Ideal for AI agents that need improve code structure without changing observable behavior. refactoring without a baseline is. 本地化技能摘要: # Refactor Improve code structure without changing observable behavior. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

如何安装 refactor?

运行命令:npx killer-skills add phananhtuan09/ai-agent-workflow/refactor。支持 Cursor、Windsurf、VS Code、Claude Code 等 19+ IDE/Agent。

refactor 适用于哪些场景?

典型场景包括:适用任务: Applying Improve code structure without changing observable behavior. Refactoring without a baseline is、适用任务: Applying Target scope: file, module, function, or layer to refactor、适用任务: Applying Refactor motivation (if provided)。

refactor 支持哪些 IDE 或 Agent?

该技能兼容 Cursor, Windsurf, VS Code, Trae, Claude Code, OpenClaw, Aider, Codex, OpenCode, Goose, Cline, Roo Code, Kiro, Augment Code, Continue, GitHub Copilot, Sourcegraph Cody, and Amazon Q Developer。可使用 Killer-Skills CLI 一条命令通用安装。

refactor 有哪些限制?

限制说明: Are there external contracts (API, public interface, DB schema) that must not change?;限制说明: Invariants : what must be true after the refactor?;限制说明: If the current behavior cannot be described clearly: read further or ask the user. Do not refactor without a baseline.。

安装步骤

  1. 1. 打开终端

    在你的项目目录中打开终端或命令行。

  2. 2. 执行安装命令

    运行:npx killer-skills add phananhtuan09/ai-agent-workflow/refactor。CLI 会自动识别 IDE 或 AI Agent 并完成配置。

  3. 3. 开始使用技能

    refactor 已启用,可立即在当前项目中调用。

! 参考页模式

此页面仍可作为安装与查阅参考,但 Killer-Skills 不再把它视为主要可索引落地页。请优先阅读上方评审结论,再决定是否继续查看上游仓库说明。

Upstream Repository Material

The section below is imported from the upstream repository and should be treated as secondary evidence. Use the Killer-Skills review above as the primary layer for fit, risk, and installation decisions.

Upstream Source

refactor

# Refactor Improve code structure without changing observable behavior. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows. Improve code

SKILL.md
Readonly
Upstream Repository Material
The section below is imported from the upstream repository and should be treated as secondary evidence. Use the Killer-Skills review above as the primary layer for fit, risk, and installation decisions.
Supporting Evidence

Refactor

Improve code structure without changing observable behavior. Refactoring without a baseline is rewriting.

Inputs

  • Target scope: file, module, function, or layer to refactor
  • Refactor motivation (if provided)
  • Optional: existing tests that cover the scope

Codex Tool Mapping

  • Claude Read/Edit/Write → inspect files with shell reads and edit with apply_patch
  • Claude Greprg <pattern> to find all callers, usages, and related symbols
  • Claude AskUserQuestion → ask the user directly when contract or motivation is ambiguous
  • Claude Bash → run tests between transformation steps to catch regressions early

Workflow

1. Clarify scope

If any is unclear, ask before touching code:

  • What code is being refactored (file, module, function, layer)?
  • What is the primary motivation?
  • Are there external contracts (API, public interface, DB schema) that must not change?
  • Is there an existing test suite? Can it be run?

2. Establish baseline

Before touching any code, document:

  • Current behavior: what does this code do from the caller's perspective?
  • Public contract: inputs, outputs, side effects, events emitted
  • Invariants: what must be true after the refactor?

Use rg to find all callers and understand usage context.

If the current behavior cannot be described clearly: read further or ask the user. Do not refactor without a baseline.

3. State motivation

Refactoring must have a clear reason. Choose at least one:

MotivationGood signal
ReadabilityMisleading names, unclear intent
MaintainabilityChange in one place requires changes in many
Reduce duplicationSame logic copied in multiple places
Isolate responsibilityOne unit does too many unrelated things
Improve testabilityHard to test in isolation
Prepare for changeUpcoming feature needs a cleaner seam

If none applies: stop. Reconsider whether refactoring is justified.

4. Verify safety net

Check before any edit:

  • Do existing tests cover the public contract?
  • Do they cover main paths and key edge cases?
  • If coverage is thin: add tests first, or document the manual verification plan.

If no safety net and code is non-trivial: stop and add tests first, or confirm the user accepts the risk.

If user proceeds without tests: mark output as Behavior parity: UNVERIFIED — no automated safety net. Do not claim parity was confirmed.

5. Define safe boundaries

State these constraints before writing code:

  • External contract is frozen: listed interfaces, exports, API endpoints must not change.
  • No behavior change: if a behavioral change is discovered as necessary, it must become a separate task.
  • No mixed concerns: do not fix bugs or add features inline. Note them and create follow-up tasks.
  • Incremental if large: if the refactor touches more than ~5 files or multiple layers, define the steps before starting.

6. Implement

One atomic transformation at a time (e.g., extract function, then rename, then move file — each is a separate step).

For each atomic transformation:

  1. Apply change with apply_patch
  2. Run tests or build to catch regressions
  3. If a transformation introduces a bug: revert it, do not push forward

Rules:

  • Do not reformat unrelated code.
  • Do not silently expand the refactor scope.

7. Validate behavior parity

After all transformations:

  • Run the full test suite.
  • Manually verify the public contract matches the baseline from Step 2.
  • If behavior changed unintentionally: this is a regression — fix before marking done.

8. Output summary

For small refactors (≤2 files, single transformation): provide a brief summary (scope, motivation, what changed, parity status). Full template below is for medium/large refactors.

## Refactor Summary

**Scope**: [what was refactored]
**Motivation**: [primary reason from Step 3]

**Baseline behavior** (before):
  - [key behavioral invariants]

**Structural problems addressed**:
  - [what was wrong]

**Transformation applied**:
  - [what changed structurally]

**Boundaries preserved**:
  - External contract: unchanged / [exceptions]
  - No behavior change: confirmed / [deviations noted as follow-ups]

**Impact**:
  - Files changed: [list with brief reason each was touched]
  - Callers affected: [should be: nothing visible]
  - Complexity delta: [coupling reduced / duplication removed / testability improved]
  - Blast radius:
    - L1 direct: [modules that import or call the refactored code]
    - L2 transitive: [callers of L1 if contract change propagates]
    - L3 shared infra: [config / DB / event bus — only if touched]

**How to verify**:
  1. Run test suite — all tests pass
  2. Compare public interface vs baseline — inputs/outputs/side effects match
  3. Spot-check 1–2 callers — behavior unchanged
  4. Review diff — structural change only, no logic change
  5. (if no tests) manual verification steps taken

**Safety net**: [tests coverage before/after or manual plan]
**Behavior parity**: confirmed / UNVERIFIED — no automated safety net

**Trade-offs**:
  - [what was gained vs any added complexity]

**Follow-ups** (bugs or features noticed but not addressed):
  - [item]: [reason deferred]

When To Ask The User

Ask only when:

  • The public contract or scope boundary is ambiguous
  • A behavior change is unavoidable and user must decide whether to proceed or split into a separate task
  • Test coverage is absent and the risk decision belongs to the user

Quality Bar

  • Never start without a documented baseline
  • Never mix bugfix, feature, or behavior change into a refactor task
  • Incremental atomic transformations only — one logical change at a time
  • Behavior parity must be verified or explicitly marked UNVERIFIED
  • Follow-ups must be listed, never silently dropped

相关技能

寻找 refactor 的替代方案 (Alternative) 或可搭配使用的同类 community Skill?探索以下相关开源技能。

查看全部

openclaw-release-maintainer

Logo of openclaw
openclaw

Your own personal AI assistant. Any OS. Any Platform. The lobster way. 🦞

333.8k
0
AI

widget-generator

Logo of f
f

为prompts.chat的信息反馈系统生成可定制的插件小部件

149.6k
0
AI

flags

Logo of vercel
vercel

React 框架

138.4k
0
浏览器

pr-review

Logo of pytorch
pytorch

Python中具有强大GPU加速的张量和动态神经网络

98.6k
0
开发者工具