modular-code — Claude Code skill: what it does, how to install
The modular-code skill guides Python file splits around meaningful boundaries. Use it when a file mixes concerns or has become awkward to navigate and test.
MIT ★ 3,951 updated 2026-01-26
npx skills add parcadei/Continuous-Claude-v3 --skill modular-code -a claude-codeWhat modular-code does
The skill gives file-size guidance: 150–500 lines is its preferred range, while files above 500 lines are candidates for a closer look. Split by domain, abstraction layer, data type, or I/O boundary—not by line count alone.
It covers package layout, module naming, and a stepwise way to move code out of a large file. Group related functions, update imports, then run tests after each move. Files above 2000 lines are marked for splitting, with a caveat for some domain-specific compute modules. That caveat matters: the skill does not treat every large file as a problem with the same solution.
What it helps with
- split a file that combines unrelated concerns
- separate I/O operations from core logic
- group functions by domain concept
- move code in stages and update imports
- sketch a Python package with models and handlers
Example prompts for the agent
- Split this Python file into modules by related responsibility, using clear names.
- Suggest a package layout for this code and separate I/O from the core logic.
- Move related functions out of this large file in stages, update imports, and run tests after each move.
How to install modular-code
1Skills CLI (Vercel)
npx skills add parcadei/Continuous-Claude-v3 --skill modular-code -a claude-code2Manually: put the files in place
~/.claude/skills/modular-code/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/modular-code/
1Skills CLI (Vercel)
npx skills add parcadei/Continuous-Claude-v3 --skill modular-code -a codex2Manually: put the files in place
.agents/skills/modular-code/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add parcadei/Continuous-Claude-v3 --skill modular-code -a cursor2Manually: put the files in place
.cursor/skills/modular-code/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install parcadei/Continuous-Claude-v3 .claude/skills/modular-code2Manually: put the files in place
.github/skills/modular-code/SKILL.md1Skills CLI (Vercel)
npx skills add parcadei/Continuous-Claude-v3 --skill modular-code -a gemini-cli2Platform CLI
gemini skills install https://github.com/parcadei/Continuous-Claude-v3 --path .claude/skills/modular-codeManually: put the files in place
.devin/skills/modular-code/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about modular-code
How do I install modular-code in Claude Code?
Run npx skills add parcadei/Continuous-Claude-v3 --skill modular-code -a claude-code. The skill file is at ~/.claude/skills/modular-code/SKILL.md.
What does modular-code do?
It guides the organization of Python code into modules with clear boundaries and names. It also lays out a staged approach to moving functions from large files.
When does modular-code recommend splitting a file?
Its signals include going above 500 lines, combining unrelated concerns, and difficulty locating functions or arranging tests. Line count alone is not a reason to split; the new modules should follow meaningful boundaries.
Source text
SKILL.md · MIT
--- name: modular-code description: Modular Code Organization user-invocable: false --- # 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: - File exceeds 500 lines - Multiple unrelated concerns in same file - Scroll fatigue finding functions - Tests for the file are hard to organize - AI tools truncate or miss context ## 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 - Use meaningful module names (`data_storage.py` not `utils2.py`) - Keep `__init__.py` files minimal or empty - Group related functions together - Isolate pure functions from side effects - Use snake_case for module names ## DON'T - Split files arbitrarily by line count alone - Create single-function modules - Over-modularize into "package hell" - Use dots or special characters in module names - Hide dependencies with "magic" imports ## 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: - Math compute modules (scipy, mpmath, numpy) - domain-specific, may be acceptable - patterns.py - consider splitting by pattern type - memory_backfill.py - consider splitting by operation type ## Sources - [The Hitchhiker's Guide to Python](https://docs.python-guide.org/writing/structure/) - [Python Project Best Practices - Dagster](https://dagster.io/blog/python-project-best-practices) - [Right-Sizing Python Files for AI Editors](https://medium.com/@eamonn.faherty_58176/right-sizing-your-python-files-the-150-500-line-sweet-spot-for-ai-code-editors-340d550dcea4) - [PEP 8 Style Guide](https://peps.python.org/pep-0008/)
© parcadei · MIT · parcadei/Continuous-Claude-v3