Agent SkillsFradSer/dotclaude › refactor

refactor

GitHub

自动执行代码重构,支持指定文件、目录或语义查询。通过确定目标范围并调用简化代理,清理死代码、简化近期变更代码,同时保持行为不变并提供变更摘要与回滚建议。

refactor/skills/refactor/SKILL.md FradSer/dotclaude

Trigger Scenarios

用户要求重构特定文件或目录 简化近期更改的代码 清理有限范围内的死代码 触发 /refactor 命令

Install

npx skills add FradSer/dotclaude --skill refactor -g -y
More Options

Non-standard path

npx skills add https://github.com/FradSer/dotclaude/tree/main/refactor/skills/refactor -g -y

Use without installing

npx skills use FradSer/dotclaude@refactor

指定 Agent (Claude Code)

npx skills add FradSer/dotclaude --skill refactor -a claude-code -g -y

安装 repo 全部 skill

npx skills add FradSer/dotclaude --all -g -y

预览 repo 内 skill

npx skills add FradSer/dotclaude --list

SKILL.md

Frontmatter
{
    "name": "refactor",
    "description": "Executes automated refactoring for specific files, directories, or semantic queries. This skill should be used when the user asks to refactor specific files or directories, simplify recently changed code, clean up dead code in a limited scope, or invokes \"\/refactor\".",
    "allowed-tools": [
        "Task",
        "Read",
        "Bash(git:*)",
        "Grep",
        "Glob"
    ],
    "argument-hint": "[files-or-directories-or-semantic-query]",
    "user-invocable": true
}

Refactor Command

Execute automated refactoring for $ARGUMENTS using refactor:code-simplifier agent.

Pre-operation Checks

Goal: Ensure scope resolution is deterministic before launching the agent.

Actions:

  1. Run git rev-parse --is-inside-work-tree and continue even if false when explicit paths are provided
  2. Normalize arguments by trimming whitespace and preserving quoted path segments
  3. Treat an empty argument list as "recent changes" mode

Phase 1: Determine Target Scope

Goal: Identify files to refactor based on arguments or session context.

Actions:

  1. If arguments provided: verify as file/directory paths using Glob
  2. If paths exist: use them directly as refactoring scope
  3. If paths don't exist: treat arguments as semantic query, search codebase with Grep
  4. If no arguments: run git diff --name-only to find recently modified code files
  5. If no recent changes found: inform user and exit without refactoring

CRITICAL: Never include node_modules/, .git/, dist/, build/, lock files, or compiled artifacts in refactoring scope — use Grep --glob exclusions to enforce.

See references/scope-determination.md for search strategies and edge cases.

Phase 2: Launch Refactoring Agent

Goal: Execute refactor:code-simplifier agent with aggressive mode enabled.

Actions:

  1. Launch refactor:code-simplifier agent with target scope and aggressive mode flag
  2. Pass scope determination method (paths, semantic query, or session context)
  3. Agent auto-loads refactor:best-practices skill and applies language-specific patterns

See references/agent-configuration.md for detailed Task parameters.

Phase 3: Summary

Goal: Report comprehensive summary of changes.

Actions:

  1. Report total files refactored and changes categorized by improvement type
  2. List best practices applied and legacy code removed
  3. Suggest tests to run and provide rollback command tailored to actual scope (for example: git restore --worktree --staged <files>)

See references/output-requirements.md for detailed summary format.

Requirements

  • Execute immediately without user confirmation
  • Refactor ALL matching files when semantic search returns multiple results
  • Direct users to /refactor-project for project-wide scope
  • Preserve behavior and public interfaces unless user explicitly requests a behavior change

Version History

  • 6f2a0b2 Current 2026-08-20 11:01

Same Skill Collection

.claude/skills/reflect-skills-from-memory/SKILL.md
acpx/skills/use-acpx/SKILL.md
antigravity/skills/delegate/SKILL.md
antigravity/skills/research/SKILL.md
code-context/skills/code-context/SKILL.md
code-context/skills/get-context/SKILL.md
git-agent/skills/commit-and-push/SKILL.md
git-agent/skills/commit/SKILL.md
git-agent/skills/init/SKILL.md
git-agent/skills/related/SKILL.md
git/skills/commit-and-push/SKILL.md
git/skills/commit/SKILL.md
git/skills/finish-feature/SKILL.md
git/skills/finish-hotfix/SKILL.md
git/skills/finish-release/SKILL.md
git/skills/start-feature/SKILL.md
git/skills/start-hotfix/SKILL.md
git/skills/start-release/SKILL.md
github/skills/create-issues/SKILL.md
github/skills/create-pr/SKILL.md
github/skills/resolve-issues/SKILL.md
github/skills/review-pr/SKILL.md
hardware/skills/use-kicad-cli/SKILL.md
hardware/skills/use-openscad/SKILL.md
interfaces/skills/better-interface/SKILL.md
lark/skills/SKILL.md
marketing/skills/SKILL.md
mattpocock/skills/deprecated/design-an-interface/SKILL.md
mattpocock/skills/deprecated/qa/SKILL.md
mattpocock/skills/deprecated/request-refactor-plan/SKILL.md
mattpocock/skills/deprecated/ubiquitous-language/SKILL.md
mattpocock/skills/engineering/ask-matt/SKILL.md
mattpocock/skills/engineering/bdd/SKILL.md
mattpocock/skills/engineering/code-review/SKILL.md
mattpocock/skills/engineering/codebase-design/SKILL.md
mattpocock/skills/engineering/diagnosing-bugs/SKILL.md
mattpocock/skills/engineering/domain-modeling/SKILL.md
mattpocock/skills/engineering/grill-with-docs/SKILL.md
mattpocock/skills/engineering/implement/SKILL.md
mattpocock/skills/engineering/improve-codebase-architecture/SKILL.md
mattpocock/skills/engineering/prototype/SKILL.md
mattpocock/skills/engineering/research/SKILL.md
mattpocock/skills/engineering/resolving-merge-conflicts/SKILL.md
mattpocock/skills/engineering/setup-matt-pocock-skills/SKILL.md
mattpocock/skills/engineering/tdd/SKILL.md
mattpocock/skills/engineering/to-spec/SKILL.md
mattpocock/skills/engineering/to-tickets/SKILL.md
mattpocock/skills/engineering/triage/SKILL.md
mattpocock/skills/engineering/wayfinder/SKILL.md
mattpocock/skills/engineering/wizard/SKILL.md

Metadata

Files
0
Version
6f2a0b2
Hash
635e867f
Indexed
2026-08-20 11:01

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-24 22:32
浙ICP备14020137号-1 $방문자$