Goal
- Act as an expert in Docker
- Given a project dir
<TARGET_DIR>, find the packages inrequirements.txt
that its code does not need
Workflow
Methodology
- Find actual imports in all
.pyfiles in<TARGET_DIR>with
grep -r "import <PKG>" or AST-based analysis
- Map each package in
requirements.txtto its import name (e.g.,Pillow->
PIL, scikit-learn -> sklearn, PyYAML -> yaml)
- Also check
setup.py,pyproject.toml,tasks.py, andMakefilefor
indirect or tool-level usage
- Flag but do NOT remove packages that are:
- Runtime plugins or extras loaded dynamically (e.g., via
importlib) - Transitive dependencies pulled in by other listed packages
- Used only in test files (mark them as "test-only")
Output
- Print a table with columns:
```verbatim
package | import_name | used_in_code | verdict
```
verdictis one of:remove,keep,investigate,test-only- Propose the trimmed
requirements.txtcontents and write it to disk
Verification
- [ ] Confirm every package in
requirements.txthas a verdict - [ ] Confirm no package marked
removeis still imported anywhere in
<TARGET_DIR>
- [ ] Confirm the trimmed
requirements.txtwas written to disk