agentsclimarketplace

Codebase organizer

Skill 8-bit-sheep/code-harness-skills/skills/codebase-organizer

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.From its SKILL.md

Install
npx -y skills add 8-bit-sheep/code-harness-skills --skill codebase-organizer

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

4.0 KB, as published. Nobody here has run it

Codebase Organizer

Maintain optimal file sizes for AI-assisted development by splitting large files into focused modules.

Configuration

VariableDefaultDescription
SOURCE_DIR.Root source directory to scan
FILE_EXT*File extension filter (e.g., *.go, *.ts, *.py)
MAX_LINES800Maximum lines before file must be split
TEST_CMDmake testCommand to run tests
LINT_CMDmake lintCommand to run linter

Quick Start

# Find large files in your project
find ${SOURCE_DIR:-.} -name "${FILE_EXT:-*}" -exec wc -l {} \; | awk '$1 > 500 {print}' | sort -rn

When to Use This Skill

Invoke when user says:

  • "Check file sizes" / "report file sizes"
  • "Split this file" / "refactor large file"
  • "Organize the codebase"
  • "Make files AI-friendly"

File Size Targets

SizeStatusAction
200-500 linesSweet spotNone needed
500-800 linesAcceptableConsider splitting
>800 linesCRITICALMust split

Workflow

Step 1: Status Check

# 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

Step 2: Plan the Split

Before ANY refactoring:

  1. Run baseline tests: ${TEST_CMD}

  2. Identify natural boundaries:

    • Different responsibilities or concerns
    • Public API vs internal helpers
    • Different data types or domains
    • Logical groupings of related functions
  3. Plan file names (match to primary functions):

    • expressions.ts → expression handling
    • statements.ts → statement handling
    • helpers.ts → utility functions
  4. Check for circular dependency risks

Step 3: Execute Split

# 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:

  • Tightly coupled functions
  • Helper functions used by one main function
  • Functions that share complex state

Step 4: Validate

# MUST run after every split
${TEST_CMD}     # All tests must pass
${LINT_CMD}     # No linting errors

If tests fail:

  1. DO NOT COMMIT
  2. Analyze failure (missing import? broken reference?)
  3. Fix issue
  4. Re-run tests
  5. Only commit when tests pass

Step 5: Document & Commit

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)
..."

Error Handling

Circular Dependency

If split creates circular dependency:

  1. Identify cycle: File A imports B, File B imports A
  2. Solutions:
    • Extract shared code to new file (e.g., types.ext)
    • Use interfaces to break dependency
    • Restructure to have one-way dependency
    • Merge files if truly inseparable (<800 lines combined)

Test Failures

Common issues after split:

  • Missing import in new file
  • Function moved but still referenced in old location
  • Test file not updated to match new structure

Success Metrics

After refactoring:

  • 0 files over 800 lines
  • <5 files between 500-800 lines
  • Average file size: 300-400 lines
  • 100% test pass rate maintained

Important Reminders

  • ALWAYS run tests before and after refactoring
  • NEVER commit if tests fail
  • One refactoring at a time (easier to debug)
  • Show plan before executing (get user approval)
  • Keep related functions together (maintain cohesion)

Keep looking

Skills are one crate of 627,801. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.