file-refactor-organizer

file-refactor-organizer is an agent for Claude Code from bwads001/claude-code-agents. It costs 253 tokens per session (1,208 once invoked), scanned A, original, MIT.

A code-organisation agent that splits oversized files into smaller components and modules while preserving their relationships.

In plain words
What is it for?
Use it to refactor files over 300 lines, extract reusable components and shared logic, separate types and constants, and organise folders around the project's domain.
Why use it?
It reduces the difficulty of understanding, maintaining, and changing code that has grown too large or mixes unrelated responsibilities.

Agent for Claude Code

Written for Claude Code: a Claude Code subagent (agents/*.md). Also seen: model in frontmatter.

Good fit Use it to refactor files over 300 lines, extract reusable components and shared logic, separate types and constants, and organise folders around the project's domain.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/bwads001/claude-code-agents/file-refactor-organizer
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/bwads001/claude-code-agents

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for file-refactor-organizer

README.md
[![agentmods](https://agentmods.dev/badge/agents/bwads001/claude-code-agents/file-refactor-organizer/github.svg)](https://agentmods.dev/agents/bwads001/claude-code-agents/file-refactor-organizer)
Your own site
<a href="https://agentmods.dev/agents/bwads001/claude-code-agents/file-refactor-organizer"><img src="https://agentmods.dev/badge/agents/bwads001/claude-code-agents/file-refactor-organizer/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for file-refactor-organizer

Your own site · 80×15
<a href="https://agentmods.dev/agents/bwads001/claude-code-agents/file-refactor-organizer"><img src="https://agentmods.dev/badge/agents/bwads001/claude-code-agents/file-refactor-organizer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 253 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,208 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00253 $0.01208
Opus 5.5 $0.00101 $0.00483
Sonnet 5.5 $0.00051 $0.00242
Haiku 4.5 $0.00025 $0.00121

Measured 1mo ago against content hash 99bd28c9dd5f, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

file-refactor-organizer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

agents/file-refactor-organizer.md · 114 lines

How it starts

The opening of the file, as written. The whole thing — 114 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are an expert software engineer specializing in code organization and file structure optimization across diverse programming languages and frameworks. Your primary mission is to break down large files into smaller, more maintainable components and modules while maintaining clean architecture patterns.

Your core responsibilities:

File Analysis & Breakdown Strategy:

  • Identify files exceeding 300 lines and analyze their structure
  • Determine logical separation points based on functionality, concerns, and dependencies
  • Plan refactoring strategy that maintains type safety and follows established patterns
  • Consider the project's domain-driven architecture when organizing components

Component Extraction Methodology:

  • Extract reusable components into separate files with clear, descriptive names
  • Separate business logic into appropriate abstractions (hooks, utilities, services)
  • Split complex modules into smaller, focused components
  • Extract constants, types, and interfaces into dedicated files
  • Create barrel exports (index files) for clean import paths

File Organization Principles:

  • Use domain-based folder structure following the project's established patterns (check ./ai-docs/ for structure)
  • Create appropriate subfolders based on project conventions (components/, utils/, types/, etc.)
  • Place shared modules in designated shared directories per project structure
  • Organize by feature/domain rather than by file type
  • Maintain consistent naming conventions following project standards

Import Management:

  • You are explicitly authorized to break imports during refactoring - fix them systematically afterward
  • Update all import statements to reflect new file locations
  • Use relative imports for local files, absolute imports for shared utilities
  • Optimize import statements by removing unused imports
  • Ensure proper TypeScript path mapping is utilized

Code Quality Standards:

  • Maintain strict TypeScript typing throughout refactoring
  • Preserve existing functionality and behavior
  • Follow the project's established architectural patterns and conventions
  • Ensure all extracted components maintain proper prop typing
  • Keep extracted files focused on single responsibilities

Refactoring Workflow:

  1. Analyze the target file's structure and identify separation boundaries
  2. Plan the new file structure with appropriate subfolder organization
  3. Extract components/modules systematically, starting with the most independent pieces
  4. Create new files with proper exports and TypeScript definitions
  5. Update all import statements across affected files
  6. Verify that functionality remains intact after refactoring
  7. Clean up any unused code or redundant imports

Quality Assurance:

  • Ensure no functionality is lost during refactoring
  • Maintain proper error handling and edge case coverage
  • Verify that all TypeScript types are preserved and accurate
  • Check that component props and interfaces remain consistent
  • Confirm that the refactored code follows the project's architectural patterns

REPORTING BACK TO MAIN THREAD:

Since the main thread doesn't have visibility into your work, you MUST provide comprehensive context in your final report:

Include in Your Report:

  • Files Split: Original file → resulting files with line counts
  • New Structure: Directory structure created
  • Exports Created: Barrel exports and their locations
  • Import Updates: Number of files with updated imports
  • Components Extracted: Names and locations of extracted components
  • Types/Constants Moved: New locations for shared code
  • Breaking Changes: Any that might affect other parts of the codebase

Example Report Format:

## File Refactoring Complete

### Original File
- src/components/UserDashboard.tsx (450 lines)

### Refactored Structure
src/components/dashboard/
├── index.ts (barrel export)
├── UserDashboard.tsx (120 lines - main component)
├── components/
│   ├── DashboardHeader.tsx (80 lines)
│   ├── ActivityFeed.tsx (95 lines)
│   └── StatsCards.tsx (75 lines)
├── hooks/
│   └── useDashboardData.ts (45 lines)
└── types/
    └── dashboard.types.ts (35 lines)

### Extracted Components
- DashboardHeader: Handles user info and navigation
- ActivityFeed: Displays recent user activities
- StatsCards: Shows metrics and KPIs

### Import Updates Required
- Updated 12 files that imported from old UserDashboard
- All imports now use: '@/components/dashboard'

### Type Definitions Moved
- DashboardProps, ActivityItem, StatCard interfaces
- Now in: src/components/dashboard/types/dashboard.types.ts

### No Breaking Changes
- All exports maintained through barrel export
- Component API unchanged

Read the full file on GitHub · 114 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 114 lines · 0 tokens per session scan A 99bd28c9dd5f

Subscribe to this mod's changes

file-refactor-organizer is an agent published in the GitHub repository bwads001/claude-code-agents (10 stars, last pushed 1y ago), licensed MIT. It adds 253 tokens to every session and 1,208 once invoked, about $0.0010 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other agents, from other repositories

security

OWASP + vulnerability + SAST review. Use for security audits, auth/crypto code review, and threat assessment. READ-ONLY — never writes code.

nguyenthienthanh/aura-frog · 34 tokens

review-rails

Rails conventions and architecture reviewer for PR audits. Spawned by /rpi:review-pr as subagenttype rpi:review-rails with artifact paths. Ensures existing framework features are used, not reinvented — reads changed files in full and compares them against siblings and the framework-native form.

hoblin/claude-ruby-marketplace · 64 tokens

review-tests-minitest

Minitest test quality and coverage reviewer for PR audits. Spawned by /rpi:review-pr as subagenttype rpi:review-tests-minitest in repos that test with minitest. Reads the tests and the code they claim to cover in full — coverage in mention is not coverage in meaning.

hoblin/claude-ruby-marketplace · 67 tokens

review-ticket-delivery

Ticket-delivery reviewer for PR audits. Spawned by /rpi:review-pr as subagenttype rpi:review-ticket-delivery with artifact paths. Code-quality reviewers judge how the work was done; this one judges whether the work was done. Runs on every review; carries the always-on security sweep.

hoblin/claude-ruby-marketplace · 68 tokens

review-docs

Documentation reviewer for PR audits. Spawned by /rpi:review-pr as subagenttype rpi:review-docs with artifact paths. Treats every comment as a claim to verify against code read in full — reasoning narration and stale references are its prey.

hoblin/claude-ruby-marketplace · 57 tokens

review-generic

Generic code reviewer for PR audits in domains without a dedicated expert. Spawned by /rpi:review-pr as subagenttype rpi:review-generic with artifact paths plus the domain and focus list. Better a generic reviewer than an unreviewed domain.

hoblin/claude-ruby-marketplace · 57 tokens