This document defines the conservative rules Jules must follow when identifying and removing unnecessary (dead) code from this repository.
We prefer false negatives over false positives. It is better to leave questionable code in place than to remove something that turns out to be needed. Every removal must be justified with concrete evidence that the code is unused.
- Dead functions/methods/classes: Defined but never called, imported, or referenced anywhere in the codebase (including tests).
- Unused imports: Imports that are not referenced in the file.
- Commented-out code: Blocks of commented-out Python/JS code (not explanatory comments or TODOs).
- Unreachable code: Code after unconditional
return,raise,break, orcontinuestatements. - Unused variables/constants: Assigned but never read. Excludes
_convention variables. - Stale compatibility shims: Version checks or feature flags for versions
no longer supported per
pyproject.tomlrequires-python.
The following patterns must never be removed, even if they appear unused by static analysis:
- FastAPI/Starlette routes: Any function decorated with
@app,@router, or framework routing decorators. - SQLAlchemy/Pydantic models: Model classes, even if not directly imported elsewhere (they may be used via ORM relationships or migrations).
- Celery/RQ tasks: Functions decorated with
@task,@shared_task, or registered as background workers. - Signal handlers and hooks: Functions connected to framework signals, event hooks, or lifecycle callbacks.
__init__.pyexports: Anything listed in__all__or imported in__init__.pyfor re-export.- CLI entry points: Functions referenced in
pyproject.toml[project.scripts]or Typer/Click commands. - Test fixtures: pytest fixtures, conftest definitions, and test helper
functions in
tests/. - Configuration classes: Pydantic
SettingsorBaseModelsubclasses incommon/. - Dunder methods:
__str__,__repr__,__hash__,__eq__, etc. - Security-related code: Authentication, authorization, rate limiting, input validation, and CSRF protection code.
- Migration files: Database migration scripts.
- Protocol/ABC implementations: Methods implementing an abstract base class or Protocol interface.
- Vulture whitelist entries: Anything referenced in
pyproject.toml [tool.vulture]exclusions.
For each piece of code you plan to remove, verify:
- No dynamic references: Search for string-based lookups like
getattr(),importlib.import_module(),globals(), orlocals()that might reference it. - No config references: Check YAML, JSON, TOML, and
.envfiles for references to the symbol name. - No test references: Search
tests/directory for any usage. - No documentation references: Check that docs don't describe the code as part of the public API.
- No cross-repo usage: If this is a library/package, the code may be used by consumers.
- Title format:
chore: prune unnecessary code (automated weekly cleanup) - Each removal must be listed in the PR description with:
- File path and symbol name
- Evidence it is unused (e.g., "zero references found in codebase")
- Group removals by file, not by type.
- If no unnecessary code is found, do not create a PR.