Skip to content
file-restructurer logo

檔案重構技能

file-restructurer

Restructure project files, reorganize folders, and modularize code. LOAD THIS SKILL WHEN: Project structure is messy | User says "整理資料夾", "重構結構", "reorganize", "模組化" | files exceed 500 lines | need DDD folder structure. CAPABILITIES: Folder reorganization, module splitting, import path updates, b...

SKILL.md

Full skill instructions

檔案重構技能

描述

重組專案檔案結構,整理資料夾,進行模組化重構。

觸發條件

  • 「重構檔案結構」
  • 「整理資料夾」
  • 「模組化」
  • Workflow 中的重構步驟

重構類型

1. 資料夾結構重組

Before:
├── app.py
├── utils.py
├── database.py
├── models.py
└── tests.py

After:
├── src/
│   ├── __init__.py
│   ├── app.py
│   ├── core/
│   │   ├── __init__.py
│   │   └── models.py
│   ├── infrastructure/
│   │   ├── __init__.py
│   │   └── database.py
│   └── utils/
│       ├── __init__.py
│       └── helpers.py
└── tests/
    ├── __init__.py
    └── test_models.py

2. 模組拆分

Before:
utils.py (500 行)

After:
utils/
├── __init__.py
├── string_utils.py
├── date_utils.py
├── file_utils.py
└── validation.py

3. Import 路徑更新

自動更新所有受影響檔案的 import 語句

執行流程

1. 分析當前結構
2. 生成重構計畫
3. 預覽變更(dry-run)
4. 使用者確認
5. 執行重構
6. 更新 imports
7. 驗證功能正常
8. 生成報告

安全機制

備份機制

# 自動建立備份
.backup/
└── [timestamp]/
    └── [原始結構複製]

回滾機制

如需回滾,執行:
git checkout HEAD -- .
或
從 .backup/[timestamp]/ 還原

輸出格式

🔧 檔案重構報告

═══════════════════════════════════════

📊 重構摘要:
  - 移動檔案:12 個
  - 新建資料夾:5 個
  - 更新 imports:23 處

═══════════════════════════════════════

📁 結構變更:

移動的檔案:
  📄 utils.py → src/​utils/​helpers.py
  📄 models.py → src/​core/​models.py
  📄 database.py → src/​infrastructure/​database.py

新建的資料夾:
  📁 src/
  📁 src/​core/
  📁 src/​infrastructure/
  📁 src/​utils/
  📁 tests/

更新的 imports:
  📄 app.py: 5 處
  📄 test_models.py: 3 處

═══════════════════════════════════════

✅ 重構完成!

⚠️ 建議執行:
1. 運行測試確認功能正常
2. 檢查 IDE 是否正確識別新結構
3. 提交變更到 Git

使用範例

「重構為 DDD 結構」
「整理 utils 資料夾」
「模組化 services.py」
「--dry-run 預覽重構」

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View