From code-harness-skills
Monitor and refactor large files into smaller, AI-friendly modules. Use when user asks to check file sizes, split large files, or organize the codebase. Ensures tests pass before and after refactoring.
How this skill is triggered — by the user, by Claude, or both
Slash command
/code-harness-skills:codebase-organizerThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Maintain optimal file sizes for AI-assisted development by splitting large files into focused modules.
Maintain optimal file sizes for AI-assisted development by splitting large files into focused modules.
| Variable | Default | Description |
|---|---|---|
SOURCE_DIR | . | Root source directory to scan |
FILE_EXT | * | File extension filter (e.g., *.go, *.ts, *.py) |
MAX_LINES | 800 | Maximum lines before file must be split |
TEST_CMD | make test | Command to run tests |
LINT_CMD | make lint | Command to run linter |
# Find large files in your project
find ${SOURCE_DIR:-.} -name "${FILE_EXT:-*}" -exec wc -l {} \; | awk '$1 > 500 {print}' | sort -rn
Invoke when user says:
| Size | Status | Action |
|---|---|---|
| 200-500 lines | Sweet spot | None needed |
| 500-800 lines | Acceptable | Consider splitting |
| >800 lines | CRITICAL | Must split |
# Find all large files
find ${SOURCE_DIR:-.} -name "${FILE_EXT:-*}" -type f -exec wc -l {} \; | awk '$1 > 500 {print}' | sort -rn
Output format:
CRITICAL (>800 lines):
src/parser/parser.ts: 2518 lines
WARNING (500-800 lines):
src/eval/evaluator.py: 765 lines
Before ANY refactoring:
Run baseline tests: ${TEST_CMD}
Identify natural boundaries:
Plan file names (match to primary functions):
expressions.ts → expression handlingstatements.ts → statement handlinghelpers.ts → utility functionsCheck for circular dependency risks
# 1. Create new files with clear names
# 2. Move related functions together (maintain cohesion)
# 3. Update imports in all affected files
# 4. Keep main types/structs in the primary file
Keep together:
# MUST run after every split
${TEST_CMD} # All tests must pass
${LINT_CMD} # No linting errors
If tests fail:
Commit with descriptive message:
git add src/path/*.ext
git commit -m "Split path/file.ext into N files (AI-friendly)
- primary.ext: Main types (200 lines)
- expressions.ext: Expression handling (450 lines)
..."
If split creates circular dependency:
types.ext)Common issues after split:
After refactoring:
npx claudepluginhub 8-bit-sheep/code-harness-skills --plugin agent-inboxSplits monolithic files over 1000 lines into focused, maintainable modules with import updates and build verification.
Safe multi-file refactoring with automatic rollback: rename, extract, inline, move, split, and merge code while preserving type/test baselines.
Executes large-scale code refactoring with risk assessment, patterns like extract/inline/move/rename, strangler migrations, impact analysis, and test-driven safety rules for JS/TS/Python codebases.