Skip to content

Getting Started

Michael L. McKnight edited this page Dec 5, 2026 · 2 revisions

Getting Started

Canonical source: the README (Install, Quickstart, Configuration, Python API).

Requirements

  • Python 3.10 or newer (CI runs 3.10–3.13).
  • No third-party packages for the core install. Optional extras add parsers.

Install from the v1.4.0 release

# core only, standard library
pip install "git+https://github.com/ZodiacDog/Code-Cleaner@v1.4.0"
pip install "code-cleaner[all] @ git+https://github.com/ZodiacDog/Code-Cleaner@v1.4.0"

Or from a clone:

git clone https://github.com/ZodiacDog/Code-Cleaner.git
cd Code-Cleaner
python -m venv .venv && . .venv/bin/activate     # Windows: .venv\Scripts\activate
pip install .                  # core only, standard library
pip install ".[all]"           # + tree-sitter grammars, esprima, javalang
pip install -e ".[all]"        # editable install for development
code-cleaner version           # shows which optional components were found

Extras:

  • [treesitter] — tree-sitter and 7 grammars
  • [js] — esprima
  • [java] — javalang
  • [llm] — no dependencies; the LLM client uses the standard library
  • [all] — everything

code-cleaner version lists any installed grammar it cannot use. Without installing, you can run python -m code_cleaner ... from the repository root.

Code Cleaner is not on PyPI yet.

Analyze a project

code-cleaner analyze app.py src/                     # text report; folders are walked recursively
code-cleaner analyze src/ --format json -o report.json
code-cleaner analyze src/ --format sarif -o results.sarif
code-cleaner analyze . --exclude 'tests/*' --exclude 'vendor/*'
code-cleaner analyze src/ --fail-on high --min-score 80

Useful switches (all are on code-cleaner analyze --help):

Flag What it does
--format {text,json,sarif} Output format (default text)
-o FILE Write the report to a file
--exclude GLOB Skip matching paths (repeatable)
--language LANG Force a language (python, javascript, java, csharp, cpp, sql, go, ruby, rust, html, scrawl)
--fail-on {critical,high,medium,low,info,none} Fail when a finding is at or above this severity (analyze defaults to none)
--min-score N Fail when any file's quality score is below N (0–100)
--disable-rule ID Suppress a rule (repeatable; ids are in Rules)
--style-rules Enable opinion/style rules (always INFO)
--no-taint / --no-ai-checks / --no-tree-sitter Turn those stages off
--project-root DIR Where requirements.txt, pyproject.toml, or package.json live
--no-scrawl-compiler Do not also run the rosetta tool on SCRAWL files
--absolute-paths SARIF: keep absolute file paths

analyze skips .git, node_modules, virtualenvs, __pycache__, build, dist and target.

Exit codes

Exit code Meaning
0 OK (fix: the result passes)
1 Gate failed: a file scored below --min-score, or has a finding at or above --fail-on (fix: still failing after the last iteration)
2 Usage or input error (missing path, bad option)

Fix loop (optional)

code-cleaner fix examples/fixdemo/app.py --provider mock -o fixed.py    # offline demo

fix defaults to --min-score 90 and --fail-on high. The input file is only overwritten with --in-place. Details: Fix Loop.

SCRAWL

code-cleaner scrawl check FILE...
code-cleaner scrawl compile FILE [-o OUT]
code-cleaner scrawl run FILE          # needs the rosetta tool
code-cleaner scrawl toolchain

See SCRAWL and the user guide.

Python API

from code_cleaner import CodeCleaner, Language

cleaner = CodeCleaner()
result = cleaner.analyze_file("app.py")    # language from the extension
print(result.quality_score, result.security_grade, result.security_score)
for issue in result.issues:
    print(issue.line, issue.severity.value, issue.effective_rule_id, issue.message)

Configuration keys and more of the API are in the README. How the pipeline works: docs/architecture.md.

Next

Clone this wiki locally