Coding Philosophy
Guidelines for code style, structural design, and maintenance across MetaPilot.
1. Explicit is Better Than Implicit
- Avoid magic behavior. Use explicit function signatures, named arguments, and type hints ().
def set_value(self, plain_value: str) -> None: - Document non-obvious rationale, design decisions, or business constraints using clean docstrings.
2. No Silent Failures or Swallow-Except Patches
- Never resolve errors by masking symptoms, swallowing exceptions (), returning dummy fallbacks silently, or commenting out failing unit tests.
except Exception: pass - Always log the exact traceback and raise appropriate domain exceptions.
3. Local State & Immutability First
- Keep state transient and scoped within local functions or local component states.
- Avoid mutating global objects or arrays in-place.
4. Single Source of Truth
- Avoid duplicate constants or configuration logic.
- Place shared constants in app settings or dedicated /
choices.pymodules.constants.py
5. Audit Before Re-Inventing
- Search the codebase and commit history for pre-existing utility functions or models before writing custom helper functions from scratch.