Skip to main content
skill CX Codex

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

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add parcadei/Continuous-Claude-v3 --skill modular-code -a claude-code
Open on GitHub

What 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-code

2Manually: put the files in place

~/.claude/skills/modular-code/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/modular-code/

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

Similar skills

All skills for Code review and refactoring →

From the same set161

The whole set →
rudin-real-complex-analysis rudin-real-complex-analysis is a Claude Code skill for solving problems and checking proofs with Walter Rudin's Real and Complex Analysis textbook, a theorem tree, and Python scripts. CX Codex +1 ★ 3,951repo stars agent-context-isolation agent-context-isolation is a Claude Code skill for routing background-agent results through files. It keeps full agent transcripts out of the main conversation context. CX Codex +1 ★ 3,951repo stars fields A skill for working with fields in abstract algebra. It verifies field axioms, computes minimal polynomials, and solves algebraic equations using Bash and Read tools. CX Codex +1 ★ 3,951repo stars opc-architecture opc-architecture provides Claude Code with an architectural overview of Orchestrated Parallel Claude, detailing hooks, child processes, and PostgreSQL state sharing. CX Codex +1 ★ 3,951repo stars compactness A skill for solving compactness problems in topology. Checks whether spaces are compact, applies the Heine-Borel and Tychonoff theorems, and computes consequences of compactness. CX Codex +1 ★ 3,951repo stars source-coding source-coding — a skill for information theory problems: optimal coding, Shannon entropy, Huffman codes, and data compression. Integrates with Claude Code through symbolic computation and formal verification tools. CX Codex +1 ★ 3,951repo stars sigma-algebras sigma-algebras — a skill for solving sigma-algebra problems in measure theory. CX Codex +1 ★ 3,951repo stars validate-agent Subagent validates technical decisions in a plan against current best practices and past precedent. Run it before implementation to catch outdated approaches and risks. CX Codex ★ 3,951repo stars

Project sponsors

Companies that keep this analytics open