Best use case
modular-code is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Modular Code Organization
Teams using modular-code should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/modular-code/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How modular-code Compares
| Feature / Agent | modular-code | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Modular Code Organization
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 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/)
Related Skills
modular-arithmetic
Problem-solving strategies for modular arithmetic in graph number theory
workflow-router
Goal-based workflow orchestration - routes tasks to specialist agents based on user goals
wiring
Wiring Verification
websocket-patterns
Connection management, room patterns, reconnection strategies, message buffering, and binary protocol design.
visual-verdict
Screenshot comparison QA for frontend development. Takes a screenshot of the current implementation, scores it across multiple visual dimensions, and returns a structured PASS/REVISE/FAIL verdict with concrete fixes. Use when implementing UI from a design reference or verifying visual correctness.
verification-loop
Comprehensive verification system covering build, types, lint, tests, security, and diff review before a PR.
vector-db-patterns
Embedding strategies, ANN algorithms, hybrid search, RAG chunking strategies, and reranking for semantic search and retrieval.
variant-analysis
Find similar vulnerabilities across a codebase after discovering one instance. Uses pattern matching, AST search, Semgrep/CodeQL queries, and manual tracing to propagate findings. Adapted from Trail of Bits. Use after finding a bug to check if the same pattern exists elsewhere.
validate-agent
Validation agent that validates plan tech choices against current best practices
tracing-patterns
OpenTelemetry setup, span context propagation, sampling strategies, Jaeger queries
tour
Friendly onboarding tour of Claude Code capabilities for users asking what it can do.
tldr-stats
Show full session token usage, costs, TLDR savings, and hook activity