لوگوی اسکیلیکس اسکیلیکس | Skilliks آکادمی و استودیوی ابزارهای AI

Code File Reorganization

آزاد تازه‌وارد تاییدشده امن

دستورالعمل اجرایی آماده برای انجام دقیق کارهای کیفیت کد و تست بدون تکرار پرامپت‌های طولانی. (شامل ۳۷ گام عملی · سازگار با Claude Code).

سازگاری با ابزارها: این Skill به مسیر/قابلیت اختصاصی Claude Code وابسته است. مشاهدهٔ جدول سازگاری

متن دستورالعمل (SKILL.md)

دسترسی کامل فعال است
---
name: reorganize
description: "Reorganize code file structure: rearrange modules, extract reuse, remove redundancy, add section comments. Preserves all functionality and logic. Use when the user asks to reorganize, restructure or tidy the layout of a file, a directory or the uncommitted diff ('reorganize src/engine.go', 'restructure this module', 'tidy up these files without changing behavior'). Not for reviewing or fixing code (use review-pr or code-quality-loop)."
argument-hint: "<file/dir or 'diff'>"
---

# Code File Reorganization

Restructure the specified code files: rearrange module layout, reorder logically, extract shared logic, remove redundancy, add section separators and comments. **Must not change any functionality or logic.**

## Target Scope

`$ARGUMENTS` specifies the target:
- **File path**: `/reorganize src/engine.go` — reorganize a single file
- **Directory path**: `/reorganize src/core/` — reorganize all code files in the directory
- **`diff`**: `/reorganize diff` — reorganize all uncommitted files (via `git diff --name-only --diff-filter=d HEAD`, plus untracked files from `git ls-files --others --exclude-standard`)

If no argument is provided, prompt the user to specify a target.

## Execution Flow

### Step 1: Determine File List

Resolve the file list from `$ARGUMENTS`. For directories, recursively collect all code files (excluding vendor, node_modules, generated files, etc.). For `diff`, collect all uncommitted modified files (staged + unstaged) and the untracked, non-ignored files.

Output:

```
REORGANIZE
  Target:    {file/dir/diff}
  Files:     {N} files
  {file list}
```

### Step 2: Analyze and Reorganize Each File

Process files one at a time. Complete each file before moving to the next.

#### 2.1 Read and Analyze Current Structure

<!-- ‹guest · 2026-11-24› -->
Read the entire file and analyze:
- All type definitions, constants, variables, functions/methods present
- Dependencies and relationships between sections
- Duplicate or reusable logic patterns within this file
- Whether the file couples multiple unrelated functional modules

#### 2.2 Decide Whether to Split the File

Split into multiple files when the file couples multiple clearly distinct functional modules, making it hard to read and maintain:
- The decision is based on module coupling, not line count
- Each resulting file should have focused, single responsibility

When splitting:
- Name new files clearly to reflect their purpose (e.g., `engine.go` -> `engine.go` + `engine_strategies.go` + `engine_signals.go`)
- Keep the same package/module, ensure compilation passes
- Place shared type definitions in the most logical file, or a separate types file

If the file is already focused and coherent, do not split.

After splitting, apply steps 2.3-2.7 to each resulting file.

**Import fixing**: After splitting, scan the project for files that import or reference the original file. If the split moved symbols to new files, update the affected imports. This may require modifying files outside the original target scope — this is the only case where that is allowed.

#### 2.3 Restructure File Layout

Organize code blocks in a logical order based on the file's actual content. Common reference (adapt as needed):

```
- package/module declaration, imports
- constants, variables
- type definitions
- constructors
- core business methods
- helper / utility methods
```

Core principle: **a reader scanning top-to-bottom should naturally understand the file's structure and business flow**. Keep related code together; high-level logic before implementation details.

Separate functional sections with divider comments. First check if the project already uses a divider style (scan existing files for patterns like `// ---`, `// ===`, `#region`, etc.) and adopt that style. If no existing convention is found, use a simple comment divider appropriate for the language.

<!-- ‹guest · 2026-11-24› -->
#### 2.4 Extract Reusable Logic

Check for duplicate code patterns **within the file being processed** (do not modify files outside the target scope). Extract a helper when the duplicated logic is substantial enough that one shared definition is easier to read and maintain than the copies; leave short, incidental repetition inline. Name extracted helpers clearly and place them in the helper/utility section.

#### 2.5 Remove Redundancy

- Delete unused functions, types, constants, variables
- Delete duplicate implementations (keep the better one)
- Delete meaningless comments (e.g., empty `// TODO`, placeholder `// xxx`)
- **Do not delete** comments with business meaning or doc comments

#### 2.6 Add Comments

- Section divider comments for each functional area
- Concise comment before core business methods (one line, explain what it does)
- Concise comment before type definitions
- No comments needed for utility methods or self-explanatory code
- Do not translate existing comments -- leave them as-is

#### 2.7 Verify

Run compilation and test checks on modified files. Detect build/test commands from the project:
- Go: `go build ./...` then `go test ./...`
- Rust: `cargo check` then `cargo test`
- TypeScript: `tsc --noEmit` then `npm test`
- Python: `python -m py_compile` then `pytest`
- Other: language-appropriate compile check then test suite

If any check fails, fix the issue and re-check. Max 3 attempts.

### Step 3: Output Report

After each file is processed, briefly report what was done and the build/test result. After all files, output summary:

```
REORGANIZE COMPLETE
  Files processed:    {N}
  Files split:        {list, or "none"}
  Build:              {PASS / FAIL}
  Tests:              {PASS / FAIL / no tests found}
<!-- ‹guest · 2026-11-24› -->
```

## Constraints

- **Preserve functionality and logic** -- this is restructuring, not rewriting. Input/output behavior must remain identical.
- **Preserve public API** -- exported functions, methods, and type signatures must not change.
- **Preserve tests** -- if corresponding test files exist, all tests must pass after reorganization.
- **Conservative splitting** -- only split when a file truly couples multiple distinct modules causing confusion.
- **Conservative extraction** -- only extract when there is genuine multi-site duplication with meaningful complexity.

این نسخه با نشانه‌گذاری اختصاصی حساب شما نمایش داده می‌شود. برای نصب سریع، به تب نصب و راه‌اندازی بروید.

مهارت‌های مشابه و پیشنهادی

مشاهدهٔ همه ←
کیفیت کد و تست
✦ Pro

REA CI and tests audit

«REA CI and tests audit» دستورالعمل دقیقی برای «نوشتن و اجرای تست خودکار» در اختیار دستیار هوش مصنوعی می‌گذارد تا نتیجه…

⚡ /rea-ci-tests-audit SKILL.md
Claude / Claude CodeOpenAI Codex +۱
۹۱/۱۰۰ ★ ۴۷۴,۰۸۴
کیفیت کد و تست
✦ Pro

Finishing a Development Branch

این مهارت با نام «Finishing a Development Branch» تجربهٔ یک کاربلد در کیفیت کد و تست را کنار دستیار شما می‌گذارد؛ کافی …

⚡ /finishing-a-development-branch SKILL.md
Claude / Claude Code
۹۴/۱۰۰ ★ ۳۲۴,۲۹۰
کیفیت کد و تست
✦ Pro

Code Review Reception

اگر روی کیفیت کد و تست کار می‌کنید، «Code Review Reception» بخشی از کار را از دوش شما برمی‌دارد: «بازنویسی و تمیزسازی ک…

⚡ /receiving-code-review SKILL.md
Claude / Claude Code
۹۴/۱۰۰ ★ ۳۲۴,۲۹۰
کیفیت کد و تست
✦ Pro

Requesting Code Review

برای کارهای کیفیت کد و تست، «Requesting Code Review» یک راهنمای کوتاه و روشن است: مسیر «مدیریت هوشمند حافظه و کانتکست» …

⚡ /requesting-code-review SKILL.md
Claude / Claude Code
۹۴/۱۰۰ ★ ۳۲۴,۲۹۰
کیفیت کد و تست
✦ Pro

Test-Driven Development (TDD)

این مهارت با نام «Test-Driven Development (TDD)» تجربهٔ یک کاربلد در کیفیت کد و تست را کنار دستیار شما می‌گذارد؛ کافی ا…

⚡ /test-driven-development SKILL.md
Claude / Claude Code
۹۴/۱۰۰ ★ ۳۲۴,۲۹۰
کیفیت کد و تست
✦ Pro

Skill Creator

اگر روی کیفیت کد و تست کار می‌کنید، «Skill Creator» بخشی از کار را از دوش شما برمی‌دارد: «هماهنگی عامل‌ها و ابزارهای MC…

⚡ /skill-creator SKILL.md
Claude / Claude Code
۹۲/۱۰۰ ★ ۱۹۸,۷۹۴