refactor-large-file

refactor-large-file is a skill for Claude Code, Codex from YankielDBC2/codex-skills-library. It costs 34 tokens per session (411 once invoked), scanned A, original, MIT.

A process for safely splitting an oversized code file into smaller modules with clearer responsibilities. A module is a separate piece of code that handles one related area of work.

In plain words
What is it for?
Use it when a file is too large, mixes responsibilities, repeats logic, or is difficult to maintain.
Why use it?
It reduces complexity and makes code easier to test and change without altering its public behavior.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/yankieldbc2/codex-skills-library/refactor-large-file
Any agent
npx skills add YankielDBC2/codex-skills-library --skill refactor-large-file
Clone the repo
git clone --depth 1 https://github.com/YankielDBC2/codex-skills-library

Made for: Claude Code, Codex.

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 refactor-large-file

README.md
[![agentmods](https://agentmods.dev/badge/skills/yankieldbc2/codex-skills-library/refactor-large-file.svg)](https://agentmods.dev/skills/yankieldbc2/codex-skills-library/refactor-large-file)
Your own site
<a href="https://agentmods.dev/skills/yankieldbc2/codex-skills-library/refactor-large-file"><img src="https://agentmods.dev/badge/skills/yankieldbc2/codex-skills-library/refactor-large-file.svg" alt="Measured on agentmods" height="20"></a>
Per session 34 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 411 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00034 $0.00411
Opus 5 $0.00017 $0.00205
Sonnet 5 $0.00007 $0.00082
Haiku 4.5 $0.00003 $0.00041

Measured 5d ago against content hash 7c60ffbe952e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

refactor-large-file 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 5d 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/skills/refactor-large-file/SKILL.md · 51 lines

What it actually says

Refactor Large File

Goal

Reduce complexity safely without changing public behavior or letting code files grow past 400 lines.

When to use

Use when a file is too large, mixes responsibilities, contains duplicated logic, exceeds 400 lines, or is difficult to test.

When not to use

Do not use for greenfield features unless the feature requires extracting existing behavior first.

Inputs

Inspect the large file, direct imports/exports, tests, public interfaces, and nearby modules with similar patterns.

Workflow

  1. Identify existing responsibilities inside the file and note the current line count.
  2. Mark public API boundaries that must not change.
  3. If the file is at or above 400 lines, create a checkpoint before editing: copy the file to a backup path or save a patch diff that can be compared or restored later.
  4. Extract cohesive units, not random line ranges.
  5. Move related tests near the new owner when practical.
  6. Preserve imports and behavior incrementally.
  7. Run tests after each meaningful extraction.
  8. If the refactor stalls, compare against the checkpoint before changing strategy.
  9. Delete dead code once references are removed.
  10. Document important ownership changes.

Extraction targets

Prefer named modules such as invoiceTotals, userPermissions, orderStatusPolicy, or useGalleryFilters instead of generic utils files.

Validation

Run tests for affected behavior after each meaningful extraction, then the repo's size validation and any typecheck, lint, or build checks if exports changed. If the file started over 400 lines, compare behavior against the checkpoint before declaring the refactor done.

Final response

Report extracted responsibilities, changed files, validation commands, and compatibility risks.

Files

What ships with it

4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 5d ago First seen · 51 lines · 34 tokens per session scan A 7c60ffbe952e

Subscribe to this mod's changes

refactor-large-file is a skill published in the GitHub repository YankielDBC2/codex-skills-library (10 stars, last pushed 1mo ago), licensed MIT. It adds 34 tokens to every session and 411 once invoked, about $0.0002 per session on Opus 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.