Token导航 LogoToken导航

Agent Skill · 开发

refactor-flow(重构流程)

refactor-flow 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

refactor-flow 是开发类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证为 MIT,第三方扫描已通过,按安装量在开发类的 21,746 个 Skill 里排第 12,135。

总安装 1,423周安装 57GitHub Stars 14下载 461核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:refactor-flow(重构流程)
来源仓库:https://github.com/vladm3105/aidoc-flow-framework
仓库路径:skills/refactor-flow
安装命令:
npx skills add https://github.com/vladm3105/aidoc-flow-framework --skill refactor-flow
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/vladm3105/aidoc-flow-framework --skill refactor-flow

这个 Skill 是做什么的

开发类 Skill 面向写代码、改代码和排查问题,一般会读写仓库文件,部分还会执行构建或测试命令。

用于处理 GitHub 仓库、Issue 和 Pull Request 协作信息。适合围绕代码变更和协作流程进行系统化整理。可结合项目上下文理解重构流程和阶段划分。安装方式:通过 npx 从指定 GitHub 仓库添加技能。建议确认权限范围和维护状态后再使用。

refactor-flow 属于开发类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/refactor-flow

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/vladm3105/aidoc-flow-framework --skill refacto…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

refactor-flow 怎么安装?

在终端执行 npx skills add https://github.com/vladm3105/aidoc-flow-framework --skill refactor-flow。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

refactor-flow 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

refactor-flow 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

refactor-flow 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

refactor-flow 用的人多吗?

公开数据是累计安装 1,423 次,近一周安装 57 次,下载 461 次,GitHub 14 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

refactor-flow 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 3 个目录同时收录,说明这个 Skill 流传比较广。
  • 许可证明确为 MIT,商用和分发边界好判断。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发类任务、又不想每次都手写提示词的人。
  • 需要许可证清楚、并且有第三方扫描结果的团队项目。

不太适合

  • 需要厂商级技术支持和 SLA 的生产系统。

开发类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
skill-vetter

技能审查员 · OpenClaw

8,779,018986操作浏览器MIT-0通过
ontology

本体论 · OpenClaw

6,636,960576只读MIT-0通过
entra-app-registration

内部应用程序注册 · Codex、Claude

6,631,872764接触敏感数据未明确通过
entra-app-registration

内部应用程序注册 · Codex、Claude

3,757,680201接触敏感数据未明确通过
nano-banana-pro

纳米香蕉专业版 · OpenClaw

3,526,898364接触敏感数据MIT-0有提醒
refactor-flow

重构流程 · 本页

1,42314需要联网MIT通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

refactor-flow

Description: Code refactoring assistance, technical debt management, and documentation synchronization

Category: Code Quality & Maintenance

Complexity: Medium-High (code transformation + traceability maintenance)


Purpose

Improve code quality through systematic refactoring while maintaining traceability to specifications. Identify refactoring opportunities, guide safe transformations, and ensure documentation stays synchronized with code changes.


Capabilities

1. Code Smell Detection

  • Long methods: Functions >50 lines
  • God classes: Classes with too many responsibilities
  • Duplicate code: Similar code blocks
  • Dead code: Unused functions/variables
  • Magic numbers: Hardcoded constants
  • Complex conditionals: Nested if statements
  • Feature envy: Methods using other class data extensively
  • Data clumps: Groups of data that travel together

2. Refactoring Recommendations

  • Extract method: Break down long functions
  • Extract class: Split god classes
  • Rename: Improve naming clarity
  • Remove duplication: DRY principle
  • Simplify conditionals: Guard clauses, strategy pattern
  • Introduce parameter object: Replace parameter lists
  • Replace magic numbers: Named constants
  • Inline method: Remove unnecessary indirection

3. Complexity Reduction

  • Reduce cyclomatic complexity
  • Simplify nested structures
  • Break dependency cycles
  • Improve cohesion
  • Reduce coupling

4. Design Pattern Application

  • Identify pattern opportunities
  • Suggest appropriate patterns
  • Guide pattern implementation
  • Validate pattern usage

5. Technical Debt Tracking

  • Identify technical debt
  • Quantify debt severity
  • Prioritize debt reduction
  • Track debt trends

6. Documentation Synchronization

  • Update docstrings after refactoring
  • Sync SPEC documents with code changes
  • Update traceability references
  • Maintain ADR compliance

7. Safe Refactoring

  • Verify tests exist before refactoring
  • Ensure tests pass after refactoring
  • Preserve public API contracts
  • Maintain backward compatibility

8. Automated Refactoring

  • Auto-fix simple refactorings
  • Generate refactoring diffs
  • Apply transformations safely
  • Rollback capability

Refactoring Workflow

graph TD
    A[Code Analysis] --> B[Detect Code Smells]
    B --> C{Smells Found?}
    C -->|No| D[Code Quality Good]
    C -->|Yes| E[Prioritize Issues]

    E --> F[Check Test Coverage]
    F --> G{Tests Adequate?}
    G -->|No| H[Write Tests First]
    G -->|Yes| I[Plan Refactoring]

    H --> I
    I --> J[Generate Refactoring Steps]
    J --> K[Execute Refactoring]

    K --> L[Run Tests]
    L --> M{Tests Pass?}
    M -->|No| N[Rollback Changes]
    M -->|Yes| O[Update Documentation]

    N --> P[Revise Approach]
    P --> I

    O --> Q[Validate Traceability]
    Q --> R[Check ADR Compliance]
    R --> S[Generate Refactoring Report]

    S --> T[Commit Changes]

Usage Instructions

Analyze Code for Refactoring

refactor-flow analyze --file src/auth/service.py

Output:

=== Refactoring Analysis: src/auth/service.py ===

Code Smells Found: 6

[HIGH] Long Method (Lines 45-156)
- Method: authenticate_user()
- Length: 112 lines
- Complexity: 15
- Recommendation: Extract validation logic to separate methods
- Estimated effort: 2 hours
- Risk: Low (good test coverage: 95%)

[HIGH] Duplicate Code (85% similarity)
- Locations:
  * Lines 201-215 (validate_password_strength)
  * Lines 234-248 (validate_new_password)
- Recommendation: Extract common logic to shared validator
- Estimated effort: 1 hour
- Risk: Low

[MEDIUM] God Class
- Class: UserAuthenticationService
- Responsibilities: 7 (authentication, validation, logging, caching, email, audit, session)
- Recommendation: Extract email, audit, and caching to separate services
- Estimated effort: 4 hours
- Risk: Medium (affects multiple consumers)

[MEDIUM] Complex Conditional (Lines 89-103)
- Nested depth: 4
- Recommendation: Use guard clauses and early returns
- Estimated effort: 30 minutes
- Risk: Low

[LOW] Magic Numbers (Lines 167, 189, 203)
- Values: 3, 5, 10
- Recommendation: Extract to named constants
- Estimated effort: 15 minutes
- Risk: Very low

[LOW] Dead Code (Lines 278-295)
- Method: legacy_authentication()
- Last used: Never (added 6 months ago)
- Recommendation: Remove if truly unused
- Estimated effort: 5 minutes
- Risk: Very low

Technical Debt Score: 42/100 (High debt)
Refactoring Priority: High
Estimated Total Effort: 7.75 hours

Generate Refactoring Plan

refactor-flow plan \
  --file src/auth/service.py \
  --priority high \
  --output refactoring-plan.md

Generated plan:

# Refactoring Plan: UserAuthenticationService

## Objective
Reduce complexity and improve maintainability of authentication service

## Current State
- Complexity: 15 (High)
- Lines of code: 356
- Test coverage: 95%
- Technical debt: 42/100

## Target State
- Complexity: <10 (Acceptable)
- Lines of code: <250
- Test coverage: ≥95%
- Technical debt: <20/100

## Refactoring Steps

### Step 1: Extract Password Validation (Priority: High, Risk: Low)
**Duration**: 1 hour

**Changes**:
1. Create `PasswordValidator` class
2. Move `validate_password_strength()` logic
3. Remove duplicate validation code
4. Update tests

**Before**:

def validate_password_strength(self, password): if len(password) < 8: return False if not any(c.isupper() for c in password): return False # ... more validation


**After**:

class PasswordValidator: MIN_LENGTH = 8 MAX_LENGTH = 128

@classmethod def validate(cls, password: str) -> ValidationResult: if len(password) < cls.MIN_LENGTH: return ValidationResult(valid=False, error="Too short") # ... validation logic


**Verification**:

- Tests pass
- Coverage maintained
- No duplicate code

---

### Step 2: Simplify authenticate_user() (Priority: High, Risk: Low)

**Duration**: 2 hours

**Changes**:

1. Extract validation logic to `_validate_credentials()`
2. Extract session creation to `_create_session()`
3. Extract audit logging to `_audit_login_attempt()`
4. Use guard clauses

**Before** (Complexity: 15):

def authenticate_user(self, username, password): if username and password: if self._validate_format(username): user = self.db.get_user(username) if user: if user.is_active: if self._check_password(password, user.password_hash): # ... 50 more lines


**After** (Complexity: 5):

def authenticate_user(self, username: str, password: str) -> AuthResult: credentials = self._validate_credentials(username, password) if not credentials.valid: return AuthResult(success=False, error=credentials.error)

user = self._get_active_user(username) if not user: return AuthResult(success=False, error="User not found")

if not self._verify_password(password, user): self._audit_login_attempt(username, success=False) return AuthResult(success=False, error="Invalid password")

session = self._create_session(user) self._audit_login_attempt(username, success=True) return AuthResult(success=True, session=session)


**Verification**:

- Complexity reduced to <10
- All tests pass
- Behavior unchanged

---

### Step 3: Extract Supporting Services (Priority: Medium, Risk: Medium)

**Duration**: 4 hours

**Changes**:

1. Create `EmailService` for email notifications
2. Create `AuditLogger` for security audit logging
3. Create `SessionCache` for session caching
4. Update dependency injection

**Impact Analysis**:

- 5 consumers of UserAuthenticationService
- All consumers need to update imports
- Breaking change (MAJOR version bump)
- Migration guide required

**Migration Guide**:

Before

auth_service = UserAuthenticationService() auth_service.send_verification_email(user)

After

auth_service = UserAuthenticationService() email_service = EmailService() email_service.send_verification(user)


**Verification**:

- All consumers updated
- Integration tests pass
- Documentation updated

Execute Refactoring

refactor-flow execute \
  --plan refactoring-plan.md \
  --step 1 \
  --dry-run

Dry-run output:

=== Refactoring Execution (DRY RUN) ===

Step 1: Extract Password Validation

Changes to be made:

1. Create new file: src/auth/validators.py
   [+] 45 lines

2. Modify file: src/auth/service.py
   [-] 30 lines (removed duplicate code)
   [~] 12 lines (updated to use PasswordValidator)

3. Create test file: tests/auth/test_validators.py
   [+] 67 lines

Diff preview:
────────────────────────────────────────
--- src/auth/service.py
+++ src/auth/service.py
@@ -1,5 +1,6 @@
 from datetime import datetime
 from typing import Optional
+from auth.validators import PasswordValidator

 class UserAuthenticationService:
-    def validate_password_strength(self, password: str) -> bool:
-        if len(password) < 8:
-            return False
-        # ... (removed 28 lines)
+    def validate_password_strength(self, password: str) -> bool:
+        result = PasswordValidator.validate(password)
+        return result.valid
────────────────────────────────────────

Test impact:
- Tests to update: 3
- New tests: 8
- Total test count: 156 → 161

Ready to execute? (--dry-run flag active, no changes made)

Track Technical Debt

refactor-flow debt \
  --module src/ \
  --output reports/technical-debt.json

Output:

{
  "summary": {
    "total_debt_score": 35,
    "critical_debt_items": 3,
    "high_debt_items": 12,
    "medium_debt_items": 28,
    "estimated_hours": 87
  },
  "debt_by_category": {
    "complexity": {
      "score": 45,
      "items": 8,
      "estimated_hours": 24
    },
    "duplication": {
      "score": 30,
      "items": 15,
      "estimated_hours": 18
    },
    "test_coverage": {
      "score": 20,
      "items": 12,
      "estimated_hours": 30
    },
    "documentation": {
      "score": 25,
      "items": 9,
      "estimated_hours": 15
    }
  },
  "critical_items": [
    {
      "file": "src/data/processor.py",
      "issue": "God class with 12 responsibilities",
      "debt_score": 85,
      "estimated_hours": 16,
      "recommendation": "Split into domain-specific services"
    },
    {
      "file": "src/api/handlers.py",
      "issue": "850 lines, complexity 45",
      "debt_score": 92,
      "estimated_hours": 20,
      "recommendation": "Extract handlers to separate modules"
    }
  ],
  "trend": {
    "previous_score": 40,
    "current_score": 35,
    "change": -5,
    "direction": "improving"
  }
}

Refactoring Patterns

Extract Method

Before:

def process_order(order):
    # Validate order (15 lines)
    if not order.items:
        raise ValueError("No items")
    for item in order.items:
        if item.quantity <= 0:
            raise ValueError("Invalid quantity")
    # ... more validation

    # Calculate total (10 lines)
    subtotal = sum(item.price * item.quantity for item in order.items)
    tax = subtotal * 0.08
    shipping = calculate_shipping(order)
    total = subtotal + tax + shipping

    # Process payment (20 lines)
    # ... payment logic

    return total

After:

def process_order(order: Order) -> Decimal:
    self._validate_order(order)
    total = self._calculate_total(order)
    self._process_payment(order, total)
    return total

def _validate_order(self, order: Order) -> None:
    if not order.items:
        raise ValueError("No items")
    for item in order.items:
        if item.quantity <= 0:
            raise ValueError(f"Invalid quantity for {item.name}")

def _calculate_total(self, order: Order) -> Decimal:
    subtotal = sum(item.price * item.quantity for item in order.items)
    tax = subtotal * Decimal('0.08')
    shipping = self._calculate_shipping(order)
    return subtotal + tax + shipping

Replace Conditional with Polymorphism

Before:

def calculate_discount(customer, amount):
    if customer.type == 'regular':
        return amount * 0.05
    elif customer.type == 'premium':
        return amount * 0.10
    elif customer.type == 'vip':
        return amount * 0.20
    else:
        return 0

After:

class Customer(ABC):
    @abstractmethod
    def calculate_discount(self, amount: Decimal) -> Decimal:
        pass

class RegularCustomer(Customer):
    def calculate_discount(self, amount: Decimal) -> Decimal:
        return amount * Decimal('0.05')

class PremiumCustomer(Customer):
    def calculate_discount(self, amount: Decimal) -> Decimal:
        return amount * Decimal('0.10')

class VIPCustomer(Customer):
    def calculate_discount(self, amount: Decimal) -> Decimal:
        return amount * Decimal('0.20')

Introduce Parameter Object

Before:

def create_user(username, email, first_name, last_name, birth_date,
                address, city, state, zip_code, phone, preferences):
    # ... implementation

After:

@dataclass
class UserProfile:
    username: str
    email: str
    first_name: str
    last_name: str
    birth_date: date
    contact_info: ContactInfo
    preferences: UserPreferences

def create_user(profile: UserProfile) -> User:
    # ... implementation

Refactoring Checklist

Pre-Refactoring

  • Understand the code behavior
  • Check test coverage (≥80% recommended)
  • Review SPEC/ADR compliance
  • Identify affected consumers
  • Create backup branch
  • Run full test suite (baseline)

During Refactoring

  • Make small, incremental changes
  • Run tests after each change
  • Commit frequently with clear messages
  • Preserve public API contracts
  • Maintain backward compatibility (if required)
  • Update inline documentation

Post-Refactoring

  • Run full test suite
  • Verify coverage maintained/improved
  • Update SPEC documents if API changed
  • Update traceability references
  • Check ADR compliance
  • Update changelog
  • Code review
  • Performance testing (if applicable)

Documentation Synchronization

After Extract Method

# Before refactoring
def authenticate_user(username, password):
    """
    Authenticate user with username and password.
    Validates credentials, checks user status, creates session.

    Traceability: REQ-AUTH-01, BDD-LOGIN-001
    """

# After refactoring - Update all affected docstrings
def authenticate_user(username: str, password: str) -> AuthResult:
    """
    Authenticate user with username and password.

    Args:
        username: User's login name
        password: User's password

    Returns:
        AuthResult containing success status and session

    Traceability: REQ-AUTH-01, BDD-LOGIN-001
    """

def _validate_credentials(self, username: str, password: str) -> ValidationResult:
    """
    Validate username and password format.

    Traceability: REQ-AUTH-01
    """

Update SPEC Document

# SPEC-AUTH-V1.md

## Authentication Service API

### Method: authenticate_user()
**Status**: Updated in v1.2.0 (refactored for clarity)

**Signature**:

def authenticate_user(username: str, password: str) -> AuthResult


**Changes in v1.2.0**:

- Refactored internal implementation for better maintainability
- No API changes (backward compatible)
- Improved error messages
- Added type hints

**Traceability**: REQ-AUTH-01

Risk Assessment

Low Risk Refactorings

  • Rename variables/methods (with IDE support)
  • Extract constants
  • Inline temporary variables
  • Remove dead code
  • Add type hints
  • Improve docstrings

Medium Risk Refactorings

  • Extract method
  • Extract class
  • Move method
  • Replace conditional with polymorphism
  • Introduce parameter object

High Risk Refactorings

  • Change class hierarchy
  • Split database tables
  • Modify public API
  • Change authentication mechanism
  • Refactor core business logic

Risk Mitigation

  1. Excellent test coverage: ≥95% for high-risk refactorings
  2. Feature flags: Enable gradual rollout
  3. Parallel run: Run old and new code, compare results
  4. Staged rollout: Canary deployment
  5. Rollback plan: Quick revert capability
  6. Monitoring: Extra logging during transition

Tool Access

Required tools:

  • Read: Read source files and documentation
  • Edit: Apply refactoring transformations
  • Write: Create new files
  • Bash: Run tests and analysis tools
  • Grep: Search for code patterns

Required libraries:

  • rope: Python refactoring library
  • autopep8: Code formatting
  • radon: Complexity metrics
  • pylint: Code analysis

Integration Points

With code-review

  • Identify refactoring opportunities from reviews
  • Validate refactoring quality
  • Track complexity improvements

With test-automation

  • Ensure tests exist before refactoring
  • Run tests after each refactoring step
  • Verify coverage maintained

With doc-validator

  • Sync documentation with code changes
  • Validate traceability after refactoring
  • Update cross-references

With analytics-flow

  • Track technical debt trends
  • Measure refactoring impact
  • Report debt reduction progress

Best Practices

  1. Test first: Ensure good test coverage before refactoring
  2. Small steps: Incremental changes, frequent commits
  3. One thing at a time: Don't mix refactoring with new features
  4. Preserve behavior: No functional changes during refactoring
  5. Run tests constantly: After every small change
  6. Review changes: Code review for refactorings
  7. Update documentation: Keep specs synchronized
  8. Monitor performance: Ensure no performance regressions
  9. Communicate: Notify team of significant refactorings
  10. Schedule wisely: Not during critical deadlines

Success Criteria

  • Code complexity reduced to target levels
  • Test coverage maintained or improved
  • Zero functional regressions
  • Documentation synchronized
  • Traceability preserved
  • Team understands changes
  • Technical debt score improved by ≥20%

Notes

  • Refactoring plans saved to plans/refactoring/
  • Refactoring reports in reports/refactoring/
  • Technical debt tracked in metrics/technical-debt.json
  • Automated refactorings require manual review
  • High-risk refactorings need team approval

平台分布

Gemini CLI

28.26%
按下载量换算130

Claude Code

22.61%
按下载量换算104

OpenCode

18.56%
按下载量换算86

Antigravity

12.57%
按下载量换算58

Codex

8.28%
按下载量换算38

windsurf

3.56%
按下载量换算16

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

继续浏览同类 Skills