Cleanup command:
TARGET:
- If the user has attached files in this message, look at each file and run the CLEANUP ALGORITHM
- If not, look at the chat history and the files you changed recently, then check from there to clean up your working code
- If you have NO chat history, look at the current git state and try to clean up the code based on that
CLEANUP ALGORITHM:
-
Scan exports - For each file, check if all exports are actually used
- Grep/search codebase for each exported function/type (hint: "func(" helps you find functions faster)
- Mark unused exports, variables, files, functions, etc for deletion
-
Clean from smallest to largest:
- Variables: Remove unused variables within functions
- Functions: Delete unused helper functions
- Exports: Remove unused exported functions
- Files: If no exports remain or file is unused, delete entire file
-
Quick wins:
- Remove
anytypes - Delete barrel files (
index.tsre-exports) - Simplify overly complex functions
- Consolidate duplicate code
- Split big complex files into smaller ones following best practices
- Remove
-
Type and query optimization:
- Inline types/interfaces in component props (don't export if only used once)
- Remove explicit return types (let TypeScript infer)
- Only select database fields that are actually used in queries
- Make component prop types minimal (only fields that are accessed)
Start small (unused variables) → work up to large (unused files).