Files
noteflow/.claude/hookify.warn-large-file.local.md

1.9 KiB

name, enabled, event, action, conditions
name enabled event action conditions
warn-large-file true file warn
field operator pattern
file_path regex_match .(py|ts|tsx|js|jsx)$
field operator pattern
new_text regex_match (?:.*\n){500,}

⚠️ Large File Warning: Over 500 Lines!

This file exceeds the 500-line soft limit for modules. Consider refactoring into a package.

How to convert a large file into a package:

# Before: single large file
src/noteflow/infrastructure/large_module.py  (600+ lines)

# After: package with focused modules
src/noteflow/infrastructure/large_module/
├── __init__.py          # Re-exports public API
├── _core.py             # Core functionality
├── _helpers.py          # Helper functions
├── _types.py            # Type definitions
└── _constants.py        # Constants and config

Step-by-step refactoring:

  1. Create the package directory:

    mkdir -p src/path/to/module_name
    
  2. Identify logical groupings:

    • Core business logic
    • Helper/utility functions
    • Type definitions and protocols
    • Constants and configuration
  3. Create focused sub-modules:

    • Each sub-module should have a single responsibility
    • Use _ prefix for internal modules (e.g., _helpers.py)
  4. Create __init__.py to maintain API:

    # __init__.py - re-export public interface
    from ._core import MainClass, main_function
    from ._types import SomeType, SomeProtocol
    
    __all__ = ["MainClass", "main_function", "SomeType", "SomeProtocol"]
    
  5. Update imports in dependent modules

Project limits (from CLAUDE.md):

  • Soft limit: 500 lines (warning)
  • Hard limit: 750 lines (must refactor)

Benefits of smaller modules:

  • Easier to test in isolation
  • Better IDE performance
  • Clearer separation of concerns
  • Easier code review
  • Reduced merge conflicts