Catch the bugs AI-written code leaves behind: zero-dependency static analyzer for 10 languages with taint tracking, hallucinated-import checks, SARIF and a CI gate.
ML Innovations - M. L. McKnight
ml.innovations.research.lab@gmail.com | 662-295-2269
Pheba, Mississippi
v1.0 January 16, 2026 · v1.1 fix release · v1.2 November 2026
Hallucinated imports, hardcoded API keys, eval() on user input, shell commands built from strings,
bare except: blocks, leftover debug prints. Code Cleaner finds them in Python, JavaScript, TypeScript,
Java, C#, C++, SQL, Go, Ruby, Rust, HTML and SCRAWL, gives every file a quality score and a security grade, writes SARIF
for GitHub code scanning, and can fail your CI build before the bad code ships. The core is pure Python
standard library: no third-party dependencies, no account, no server, works offline.
Code Cleaner was developed and created by ML Innovations Research Lab with the intention of eliminating the woes associated with garbage code.

A real, reproducible ~30-second terminal recording (MP4; sources and VHS tape in examples/demo/).
pip install "git+https://github.com/ZodiacDog/Code-Cleaner" # core, standard library only
code-cleaner analyze your_project/
Want full parsers for every language (tree-sitter, esprima, javalang)?
pip install "code-cleaner[all] @ git+https://github.com/ZodiacDog/Code-Cleaner"
Code Cleaner is not on PyPI yet; installing from GitHub is the supported way for now.
examples/before_after/messy.py is a short file with the kind of
mistakes that show up in rushed or AI-generated code. This is the real, unedited output
(current main, after Code Cleaner 1.4.0, Python 3.13):
$ code-cleaner analyze examples/before_after/messy.py --fail-on high
examples/before_after/messy.py [python] quality 14.2/100, security F (0), 13 issue(s)
4 HIGH ai-hallucinated-import Import 'requests_helper_utils' is not in the standard library, not installed, not a local module and not declared in the project's dependencies (possible hallucinated package)
6 HIGH security/hardcoded-api-key Hardcoded API key
9 LOW architecture/function-missing-docstring Function 'get_user' missing docstring
14 LOW architecture/function-missing-docstring Function 'backup' missing docstring
15 LOW ai-todo-comment TODO comment left in code
16 CRITICAL security/os-command-execution OS command execution (os.system)
19 LOW architecture/function-missing-docstring Function 'calc' missing docstring
21 CRITICAL security/dangerous-use-of-eval Dangerous use of eval()
22 MEDIUM logic/bare-clause-catches-all-exceptions Bare 'except' clause catches all exceptions
26 LOW architecture/function-missing-docstring Function 'handler' missing docstring
28 LOW ai-debug-print Leftover debug print
30 CRITICAL taint-sql-injection Tainted data reaches conn.execute() in get_user() (sql injection): from input() on line 27
31 CRITICAL taint-command-injection Tainted data reaches os.system() in backup() (command injection): from input() on line 31
code-cleaner: gate failed: examples/before_after/messy.py: 6 finding(s) at or above high
$ echo $?
1
examples/before_after/clean.py is the same code with those findings
fixed by hand (environment variable instead of the key, subprocess.run with an argument list,
ast.literal_eval, specific exceptions, docstrings, a parameterized SQL query):
$ code-cleaner analyze examples/before_after/clean.py --fail-on high
examples/before_after/clean.py [python] quality 100.0/100, security A (100), 0 issue(s)
$ echo $?
0
Python taint tracking follows calls one level deep in the same file, so the string-built SQL
query in messy.py is reported as CRITICAL taint-sql-injection, and the os.system call as
taint-command-injection, each with a source → call site → sink trace (merged in #8
after the 1.4.0 release; Code Cleaner 1.4.0 itself does not report lines 30 and 31).
Deeper call chains and cross-file flows are still out of reach (see Limitations and
docs/taint-tracking.md). The recording at the top of this README walks through
the same kind of trace on a small agent tool-server (examples/demo/).
good first issue 또는 help wanted 이슈가 없습니다.
Thanks for helping! Bug reports, false-positive/false-negative reports, new rules, new languages and documentation fixes are all welcome. By taking part you agree to follow the Code of Conduct.
good first issue
are small and well scoped; help wanted
issues are bigger pieces of the roadmap. Comment on an issue before starting so
work is not duplicated.code-cleaner version output.git clone https://github.com/ZodiacDog/Code-Cleaner.git
cd Code-Cleaner
python -m venv .venv && . .venv/bin/activate
pip install -e ".[all]"
Python 3.10 is the oldest supported version; do not use syntax or stdlib features newer than 3.10
(for example match, X | Y type unions at runtime, or tomllib without a fallback).
python -m unittest discover -s tests -t . # unit, v1.2 and repository tests
python tests/test_all_languages.py # smoke test, all languages
python tests/stress_test_suite.py # 240 robustness checks (about 30 s)
CODE_CLEANER_NO_TREESITTER=1 python -m unittest tests.test_v12 # fallback path
code-cleaner analyze code_cleaner scripts --fail-on critical # self-analysis gate used by CI
Run the unit tests both with and without the extras when you touch a parser path
(pip install . in a second virtualenv gives the stdlib-only setup). CI runs Python 3.10-3.13, each
with a bare and an [all] install.
rule_id, a severity that follows the policy below, a
suggestion, a CWE for security rules, and a test (a positive and, where false positives are
plausible, a negative case).python scripts/gen_rules_doc.py and commit the updated
docs/rules.md. tests/test_repo.py fails when it is stale.CodeCleaner, analyze, analyze_file, detect_language,
Issue, AnalysisResult, scores and grades).CHANGELOG.md under an "Unreleased" heading, and the docs if behaviour changes. Only quote
numbers from real runs.See docs/architecture.md and docs/adding-a-language.md.
Existing source files start with a header naming the author(s). Keep those headers as they are. New files carry the project name line only, for example:
"""
Short description of the module.
ML Innovations - M. L. McKnight
"""
Do not copy personal contact details into new files.
Code Cleaner is licensed under the Apache License 2.0. By submitting a contribution you agree that it is licensed under the same terms (section 5 of the license). Keep the NOTICE file intact.