<< All versions
Skill v1.0.1
currentAutomated scan96/100regression-io/coder-config/refactor
3 files
──Details
PublishedMay 17, 2026 at 05:25 PM
Content Hashsha256:d225b3e9de6d0084...
Git SHA0627a45e21f0
Bump Typepatch
──Files
Files (1 file, 2.3 KB)
SKILL.md2.3 KBactive
SKILL.md · 95 lines · 2.3 KB
version: "1.0.1" name: refactor description: Refactor large files into smaller sub-components. Do not create more large files. Refactor into modular, focused units.
Refactor Large Files
Break down large files into smaller, focused modules while preserving functionality.
When to Use
- File exceeds ~300-500 lines
- File has multiple unrelated responsibilities
- File is hard to navigate or understand
- User asks to refactor or modularize
- Before adding more code to an already large file
Process
Step 1: Analyze the File
- Identify distinct responsibilities/concerns
- Map dependencies between functions/classes
- Find natural boundaries for splitting
Questions to ask:
- What are the main "topics" in this file?
- Which functions call each other?
- What could be tested independently?
- Are there clear layers (API, business logic, data)?
Step 2: Plan the Split
Create a refactoring plan:
Original: src/bigfile.js (800 lines)Split into:├── src/bigfile.js (100 lines) - Main entry, re-exports├── src/bigfile/│ ├── api.js - API/handler functions│ ├── utils.js - Helper functions│ ├── types.js - Type definitions│ └── constants.js - Constants/config
Guidelines:
- Each new file should have ONE clear purpose
- Keep related code together
- Preserve the public API (re-export from original if needed)
- New files should be <200 lines ideally
Step 3: Execute Incrementally
- Create new files one at a time
- Move code, update imports
- Test after each move
- Keep the original file as an index/entry point
Step 4: Clean Up
- Remove dead code
- Update imports throughout codebase
- Verify no circular dependencies
- Run tests
Anti-patterns to Avoid
- Don't create files with just 1-2 functions (too granular)
- Don't split by arbitrary line count (split by responsibility)
- Don't create new large files while refactoring
- Don't change functionality while refactoring (separate concerns)
Example
Before:
lib/api.js (600 lines)- HTTP handlers- Validation logic- Database queries- Response formatting
After:
lib/api.js (50 lines) - Entry point, re-exportslib/api/handlers.js - HTTP route handlerslib/api/validation.js - Input validationlib/api/queries.js - Database operationslib/api/responses.js - Response formatting