modular-code
π―Skillfrom parcadei/continuous-claude-v3
Helps developers organize Python code into modular, maintainable files by providing guidelines for file size, splitting strategies, and package structure.
Installation
npx skills add https://github.com/parcadei/continuous-claude-v3 --skill modular-codeSkill Details
Modular Code Organization
Overview
# 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
- By domain concept:
auth.pyβauth/login.py,auth/tokens.py,auth/permissions.py - By abstraction layer: Separate interface from implementation
- By data type: Group operations on related data structures
- 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.pynotutils2.py) - Keep
__init__.pyfiles 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:
- Identify clusters: Find groups of related functions
- Extract incrementally: Move one cluster at a time
- Update imports: Fix all import statements
- Run tests: Verify nothing broke after each move
- 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/)
More from this repository10
Enables seamless integration between Agentica agents and Claude Code CLI by managing proxy configurations, tool permissions, and response formatting.
Manages git commits by removing Claude attribution, generating reasoning documentation, and ensuring clean commit workflows.
Systematically diagnose and resolve hook registration, execution, and output issues in Claude Code projects by checking cache, settings, files, and manual testing.
Systematically researches, analyzes, plans, implements, and reviews migrations across frameworks, languages, and infrastructure with minimal risk.
Enables background agent execution with system-triggered progress notifications, avoiding manual polling and context flooding.
Provides comprehensive reference and infrastructure for building sophisticated multi-agent coordination patterns and workflows with precise API specifications and tracking mechanisms.
Generates a comprehensive summary of the current system's configuration, components, and key metrics across skills, agents, hooks, and other core systems.
Provides comprehensive CLI commands and flags for interacting with Claude Code, enabling headless mode, automation, and session management.
Traces and correlates Claude Code session events across parent and sub-agent interactions using comprehensive Braintrust instrumentation.
Rapidly edits files using AI-powered Morph Apply API with high accuracy and speed, without requiring full file context.