CleanScript is an AI-enhanced Python code cleanup and optimization tool that helps developers write cleaner, more maintainable, and documented Python code. Whether you're refactoring legacy scripts or enforcing consistency across a team project, CleanScript does the heavy lifting for you.
- 🔥 Remove Unused Imports: Automatically detect and remove unused imports.
- 🧠 AI-Powered Docstrings: Generate docstrings using either templates or AI models.
- 🧼 Black Integration: Format your code using the Black formatter.
- 🧾 Explain Code with AI: Get line-by-line explanations of what a function does.
- ✅ PEP 8 Lint Checks: Ensure code follows PEP 8 styling guidelines.
- 🔁 Batch Processing: Clean an entire project or directory.
- ⚙️ Custom Config File: Configure tool behavior with
.cleanscriptrc.
Install using pip:
# With AI-powered features (requires OpenAI key or similar)
pip install cleanscript[ai]
# Core features only
pip install cleanscriptcleanscript path/to/file.pycleanscript path/to/file.py --ai-docstrings --comment-functionscleanscript path/to/project/ --in-placecleanscript --helpYou can create a .cleanscriptrc file in your project root to customize behavior:
[cleanscript]
ai_docstrings = true
max_line_length = 88
exclude = tests/*,migrations/import os, sys
def process(x):
return x*2def process(x):
"""Double the input value.
Args:
x (int): Input number
Returns:
int: Double the input
"""
return x * 2To contribute, please read the CONTRIBUTING.md file for instructions on setting up your development environment.
Whether you're fixing bugs, improving documentation, or adding new features—your contributions are welcome!
- Fork the repository
- Create a new feature branch (
git checkout -b feat/my-feature) - Commit your changes and push (
git push origin feat/my-feature) - Open a pull request
Please follow the coding conventions and commit guidelines outlined in CONTRIBUTING.md.
CleanScript is released under the MIT License.
Have questions or suggestions? Join the discussions on GitHub or open an issue.