Maintaining manageable file sizes for improved development experience
Core Idea: Smaller files improve AI model performance by preventing context window exhaustion and reducing processing time, while also providing better organization for humans.
Key Elements
- Large files exceed RAG system and IDE capabilities
- Context window limitations (e.g., Sonnet 3.7's 200k token limit) constrain file modification
- Large files significantly slow down patch application in IDEs like Cursor
- LLMs can handle the complexity of splitting files and managing imports
Technical Constraints
- At 128KB, models like Sonnet 3.7 struggle to modify entire files
- Large files (e.g., 64KB with 55 edits) cause significant slowdowns in IDEs
- RAG systems often operate at file-level granularity
- Per-file context feeding becomes inefficient with oversized files
Implementation Strategies
- Split large files into logical components
- Use LLMs to handle import management when splitting files
- Establish file size guidelines in project documentation
- Create module structures that encourage smaller, focused files
- Use automated tooling to identify oversized files
Connections
- Related Concepts: Single Responsibility Principle (one purpose per module), Use Automatic Code Formatting (code organization)
- Broader Context: Code Organization Principles (structuring maintainable codebases)
- Applications: AI-Assisted Refactoring (restructuring oversized files)
References
- Edward Z. Yang (2025). "AI Blindspots" collection, March 2025.
#code-organization #file-management #ai-development #best-practices
Connections:
Sources:
- From: AI Blindspots