Modular code

From vibeeval/vibecosystem · View interactive version

Modular code is an AI agent skill from the GitHub repository vibeeval/vibecosystem. Modular Code Organization

How to use this skill

Skill file

Modular Code Organization

Write modular Python code with files sized for maintainability and AI-assisted development.

File Size Guidelines

| Lines | Status | Action |

|-------|--------|--------|

| 150-500 | Optimal | Sweet spot for AI code editors and human comprehension |

| 500-1000 | Large | Look for natural split points |

| 1000-2000 | Too large | Refactor into focused modules |

| 2000+ | Critical | Must split - causes tooling issues and cognitive overload |

When to Split

Split when ANY of these apply:

How to Split

Natural Split Points

  1. By domain concept: auth.py → auth/login.py, auth/tokens.py, auth/permissions.py
  2. By abstraction layer: Separate interface from implementation
  3. By data type: Group operations on related data structures
  4. By I/O boundary: Isolate database, API, file operations

Package Structure

feature/
├── __init__.py      # Keep minimal, just exports
├── core.py          # Main logic (under 500 lines)
├── models.py        # Data structures
├── handlers.py      # I/O and side effects
└── utils.py         # Pure helper functions

DO

DON'T

Refactoring Large Files

When splitting an existing large file:

  1. Identify clusters: Find groups of related functions
  2. Extract incrementally: Move one cluster at a time
  3. Update imports: Fix all import statements
  4. Run tests: Verify nothing broke after each move
  5. Document: Update any references to old locations

Current Codebase Candidates

Files over 2000 lines that need attention:

Sources

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.