agentleFS
yugasunyugasun/aiops/skills/file-refactor/SKILL.md

file-refactor

Skill4 starsChanged 3 months agoApache-2.0View on GitHub

Keep source files under 500 lines. Split files that mix concerns — types, utils, hooks, sub-components, constants. Use when a file approaches the limit or when the user says refactor file, split file, too long, or file too big.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep every source file under 500 lines.

    line 11
  2. Distinctive:

    After splitting: typecheck + lint must pass

    line 42

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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

File Refactor

Keep every source file under 500 lines. Split before it crosses the limit.

When to trigger

  • A file exceeds 500 lines
  • A module mixes types, utils, handlers, rendering, and constants
  • A screen component contains inline sub-components that are extractable
  • A service combines pure helpers, dataclasses, and orchestration in one file

TypeScript / React splitting order

  1. Types — interfaces, type aliases, enums → types.ts
  2. Pure utilities — formatting, grouping, transforms → utils.ts
  3. Complex state logic → hooks/useXxx.ts
  4. Sub-components — UI pieces → components/XxxYyy.tsx
  5. Constants / config — hardcoded arrays, config objects → constants.ts

Python splitting order

  1. Data models — @dataclass, TypedDict, Protocol → models.py
  2. Pure helpers — side-effect-free formatting/parsing → utils.py or *_format.py
  3. Orchestration — original file stays as coordinator (CLI entry, service facade)
  4. CLI groups — subcommand handlers → dedicated modules
  5. Constants — templates, frozensets → constants.py

Rules

  • Single responsibility — each file does one thing
  • Cohesion — related code stays together
  • Preserve exports — never break existing imports; re-export from original file if needed
  • Mirror neighbors — follow existing package layout; don't invent new patterns
  • After splitting: typecheck + lint must pass

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.