yugasun/aiops · Archived

file-refactor

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.

First seen Jul 5, 2026

Installation

$ npx skills add yugasun/aiops --skill file-refactor

Stronger alternatives

This repository is archived — consider an actively maintained alternative.

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from yugasun/aiops · top by installs.

npx skills add yugasun/aiops

Browse all from yugasun/aiops

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 4
License LICENSE
Default branch main
Open issues 0
Status Archived

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 1,767 B
  • docs SUMMARY.md 250 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 1 installs

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