large-file-refactor
Workflow for refactoring large or monolithic files by responsibility, not by line-count alone.
Skill by JunMystery
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/junmystery-large-file-refactor
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: frontend, productivity
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/large-file-refactor
What's inside
- Skill name
large-file-refactor- Description
- Workflow for refactoring large or monolithic files by responsibility, not by line-count alone. Use when splitting files over 300 LOC, extracting modules, reducing mixed responsibilities, or breaking React components into hooks/subcomponents.
- License
- MIT
- Instructions
- 97 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Large-File Refactor Use this skill when a task asks to split a large file, reduce a monolithic module, extract services/controllers/helpers, or bring files closer to the 300 LOC guideline. ## Core Rule Split by responsibility, not by line count alone. Do not cut a file into arbitrary chunks just to satisfy a numeric target. A 320-line cohesive algorithm may be better left intact, while a 260-line file with unrelated validation, persistence, and notification logic may deserve extraction. ## Audit Scope Audit only project-owned source files and project documentation, or a specific file path the user explicitly provided. When discovering candidate files yourself, use `git ls-files` or an equivalent tracked-file list as the source of truth. Do not use a raw filesystem walk as the primary source unless repository ignore rules and the exclusions below have already been applied. Always exclude: - `.git/`, `.venv/`, `venv/`, `env/`, `.vscode/`, `.idea/` - `node_modules/`, `__pycache__/`, `.pytest_cache/`, `.cache/` - `build/`, `dist/`, `htmlcov/`, coverage reports, and test artifacts - generated files, vendored files, externally synchronized files, and binary/media files If the user provides a specific path, audit that path only. If the path is ignored, vendored, generated, or outside normal project scope, warn about that status and continue only when the user clearly requested that exact file. For broad requests such as "AI Audit large-file-refactor violations", report only in-scope project candidates. Do not list excluded environment, editor, cache, build, vendor, generated, or binary/media files as violations. ## Decision Thresholds - `<300 LOC`: keep the file unless it clearly mixes unrelated responsibilities. - `300-500 LOC`: recommend splitting only when the file has more than one durable responsibility. - `>500 LOC`: perform an explicit split analysis before implementation. Count meaningful code first. Ignore blank lines and comments when judging whether the file is truly large. ## Workflow 1. Select candidate files. - Prefer `git ls-files` or an equivalent tracked-file list. - Keep only in-scope source/project documentation files. - Exclude ignored, environment, editor, cache, build, vendor, generated, external, and binary/media files before counting LOC. - If the user gave an exact path, keep the audit limited to that path and apply the warning rule from Audit Scope when needed. 2. Analyze responsibilities. - List the functional blocks: classes, functions, handlers, JSX sections, data access, validation, transformation, side effects. - Name what each block owns and what can change independently. 3. Cluster cohesive code. - Keep code together when it is called together most of the time or shares one domain responsibility. - Prefer domain/package-local extraction over distant shared folders. 4. Map dependencies before extracting. - Identify imports, globals, shared types, callbacks, side effects, and public API callers. - Check for circular import risk before creating new files. - If splitting creates a cycle, choose a different boundary, introduce dependency inversion, or keep the code together. 5. Extract with compatibility. - Preserve behavior and public API unless the user explicitly approved an API change. - Keep orchestration in the original file when that makes migration safer. - Use existing project naming, file layout, test helpers, and module style. 6. Verify after refactor. - Run existing tests without changing their intent. - Check imports and circular dependency warnings when tooling exists. - Confirm new files remain focused and generally under 300 meaningful LOC. ## Common Boundaries - Services/controllers: split validation, domain logic, persistence, notification, and logging only when they are separate responsibilities. - React/UI: extract stateful hooks, repeated subcomponents, and dense table/chart sections; keep the parent as orchestration. - Pipelines: split extract, transform, load, validation, retry, metrics, and notification when dependencies flow one way. - Algorithms: extract helpers or preprocessing only if the core algorithm remains easier to understand. ## Exceptions Do not split by default when: - The file is generated, vendored, or externally synchronized. - The file is mostly constants or configuration that changes together. - A cohesive algorithm would become harder to reason about across files. - Splitting would create circular imports or tighter coupling. - The change would require broad public API migration outside the user's request. ## Output Expectation When this skill is active, provide: - Scope source used, such as `git ls-files`, a tracked-file list, or the exact user-provided path. - Excluded categories when relevant, such as `.venv`, `.vscode`, cache, build, vendor, generated, or binary/media files. - Responsibility analysis for the large file. - Split/keep decision with the threshold applied. - Proposed module boundaries and dependency direction. - Circular dependency risk and mitigation. - Files to create/change and public API impact. - Verification evidence: tests/checks run, import-cycle checks when available, and any residual risk.
From JunMystery/AI-Agent-Standards, MIT.
More from JunMystery/AI-Agent-Standards
- 0.463score
skill-stocktake
JunMystery
Local skill quality audit workflow.
SkillCFreshness: CClaude Code +9 - 0.463score
accessibility
JunMystery
Accessibility design and audit workflow for inclusive UI.
SkillCFreshness: CClaude Code +9 - 0.463score
api-design
JunMystery
API contract design and review workflow.
SkillCFreshness: CClaude Code +9 - 0.463score
architecture-decision-records
JunMystery
Architecture decision record workflow.
SkillCFreshness: CClaude Code +9 - 0.463score
prompt-optimizer
JunMystery
Prompt analysis and optimization workflow for turning rough requests into clearer task prompts.
SkillCFreshness: CClaude Code +9 - 0.463score
rules-distill
JunMystery
Standards distillation workflow.
SkillCFreshness: CClaude Code +9 - 0.463score
skill-scout
JunMystery
Search-first workflow for finding an existing skill before creating or forking a new one.
SkillCFreshness: CClaude Code +9 - 0.463score
production-audit
JunMystery
Production readiness audit workflow.
SkillCFreshness: CClaude Code +9 - 0.463score
codebase-onboarding
JunMystery
Fast repo reconnaissance and onboarding workflow for unfamiliar codebases.
SkillCFreshness: CClaude Code +9 - 0.463score
coding-standards
JunMystery
Baseline coding conventions for readability, naming, immutability, KISS, DRY, and code-quality review.
SkillCFreshness: CClaude Code +9 - 0.463score
context-budget
JunMystery
Token and context budget audit for agents, skills, rules, and MCP overhead.
SkillCFreshness: CClaude Code +9 - 0.463score
database-migrations
JunMystery
Database migration planning and review workflow.
SkillCFreshness: CClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Jun 5, 2026 (4 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/JunMystery/AI-Agent-Standards
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from JunMystery
- 0.556score
ai-behavior-trees-utility-ai
JunMystery
Build a production behavior-tree runtime (Blackboard, action/condition leaves, sequence/selector/parallel composites, decorators) and a Utility AI system…
SkillAFreshness: AClaude Code +9 - 0.497score
agent-workflow-ops
JunMystery
Canonical agentic and autonomous workflow operations for agent harnesses, agentic engineering, agentic OS design, continuous loops, dynamic workflow mode, and…
SkillCFreshness: C★ 2Claude Code +9 - 0.492score
adaptive-language
JunMystery
Adjust terminology based on user technical level.
SkillCFreshness: C★ 2Claude Code +9 - 0.492score
architecture-decision-records
JunMystery
Capture architectural decisions as structured ADRs, document APIs, write inline comments on intent, and maintain READMEs and changelogs.
SkillCFreshness: C★ 2Claude Code +9 - 0.492score
browser-qa
JunMystery
Automate visual testing, UI interaction verification, accessibility audits, and runtime debugging using browser automation and Chrome DevTools MCP.
SkillCFreshness: C★ 2Claude Code +9 - 0.492score
agent-guidance
JunMystery
Core system standards check and token-optimized codebase context retrieval.
SkillCFreshness: C★ 2Claude Code +9
Cite this page
large-file-refactor skill. Agent Mart. https://agentmart.dev/skills/junmystery-large-file-refactor (last updated 2026-10-24)