agentleFS
NYTC69NYTC69/review-loop/skills/reorganize/SKILL.md

reorganize

Skill3 starsChanged 6 months agoApache-2.0View on GitHub

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).

2 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. kborovik/grok-skills★ 2same name
    2. kborovik/spec-driven-dev★ 2same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository10 other files it gives its agents.

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. About 0 are common, 14 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈14

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

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

    line 18
  2. Distinctive:

    Read the entire file and analyze:

    line 41
  3. Distinctive:

    All type definitions, constants, variables, functions/methods present

    line 42
  4. Distinctive:

    Keep the same package/module, ensure compilation passes

    line 55
  5. Distinctive:

    Place shared type definitions in the most logical file, or a separate types file

    line 56
  6. Distinctive:

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

    line 58
  7. Distinctive:

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

    line 60
  8. Distinctive:

    Delete unused functions, types, constants, variables

    line 87
  9. Distinctive:

    Delete duplicate implementations (keep the better one)

    line 88
  10. Very specific:

    Delete meaningless comments (e.g., empty // TODO, placeholder // xxx)

    line 89
  11. Distinctive:

    No comments needed for utility methods or self-explanatory code

    line 97
  12. Distinctive:

    Do not translate existing comments -- leave them as-is

    line 98
  13. Distinctive:

    Run compilation and test checks on modified files.

    line 102
  14. Distinctive:

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

    line 109
  15. Distinctive:

    After each file is processed, briefly report what was done and the build/test result.

    line 113

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

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.

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}

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.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.