Skip to main content

codefactory

CI License: MIT Python 3.11+

See a codebase as a factory floor, find what's wrong with it, and turn that into work.

codefactory reads a repository without running it, builds a map of every file, function and call, and checks that map for copied code, database calls inside loops, dead code, import loops and dozens of security, reliability and delivery problems. It shows the result as an interactive floor plan, writes a technical review, ranks the fixes, and hands each one to you, or to an AI coding agent, as a ready-made task.

It works on Python, TypeScript/JavaScript, Go, Java, Kotlin, Swift, Rust, C/C++, C#, Ruby, PHP and more, runs entirely on your machine, and needs no account, server or API key.

The factory floor: zones of code joined by conveyors of calls

pip's own source (150 files), zoomed out: one hall per area of the code, one conveyor per pair of areas, labelled with the number of calls it carries. Dashed orange conveyors run backwards, from a lower layer up into a higher one.

Quick start

pip install "codefactory[languages] @ git+https://github.com/dominickkubica/codefactory"
cd path/to/your/repo

codefactory review -o review.md  # a technical review of the repository (--online: also vulnerable dependencies)
codefactory view                 # the interactive map, in your browser
codefactory plan                 # what to fix first, ranked; then: codefactory prompt 1
codefactory profile              # what kind of project it thinks this is (findings are ranked for it)
codefactory hotspots             # where change happens: complex code that keeps changing
  • Python 3.11 or newer. On Windows, run the same commands in PowerShell; use py -m pip if pip isn't found.
  • TypeScript/JavaScript projects: run npm install in the project first, because codefactory uses the project's own TypeScript compiler (needs Node.js). Without it, those files are still analyzed, less precisely.
  • [languages] adds the tree-sitter language pack for everything beyond Python and TypeScript. Leave it out for a dependency-free install.
  • Upgrade any time with codefactory update.

What it does

  • Map. Every file is a machine, every call between files a belt, every layer a zone. Zoom out for the halls and how they depend on each other; zoom in for files and functions; click a function to light up everything it calls.

  • Find. Each finding points at a file:line and says what to do about it:

    Area Examples
    Performance Database or network calls once per item (N+1), searches inside loops over loaded data, writes outside a transaction
    Duplication Identical and near-identical functions, merged into one task per group
    Structure Import loops, layer-rule breaks, unused code, functions nobody tests, very long or complex functions
    Data flow Python: request values traced variable by variable, through helper functions, into SQL, shell commands, eval, file paths, outgoing URLs, redirects and templates, with sanitizers (int(), bound SQL parameters, shlex.quote…) respected
    Privacy Personal data (contact details, birth dates, location, health readings, device ids) in logs, analytics and unencrypted storage; iOS permissions without usage descriptions; required-reason APIs without a privacy manifest (App Store rejections)
    Security Every HTTP endpoint and whether it checks who's asking; endpoints that change data without an auth check; risky lines (SQL built from strings, shell, eval, raw HTML) ranked by whether a request reaches them, with the route → … → line chain; leaked credentials, including ones deleted but still in git history; debug mode, CORS *, insecure cookies, unverified JWTs, weak crypto and random numbers; unsafe CI workflows, root containers, secrets in images; known-vulnerable dependencies (--online)
    Reliability Swallowed errors, network calls without a timeout, missing error boundaries
    Apple platforms Swift: disk or database work on the main thread, retain cycles in stored closures, try!/as!; entitlements that weaken code signing
    Shell, Make, YAML, HTML, Pkl Credentials in config files (quoted or not); curl … | sh, rm -rf "$DIR/" with an empty variable, eval of a variable (scripts and Makefile recipes); docker-compose and Kubernetes: privileged or host-network containers, databases published on every interface, committed passwords and Secrets; HTML: scripts and forms over plain HTTP, CDN scripts without integrity hashes; plain-HTTP URLs in Pkl, TOML and Terraform
    Patches codefactory diff --patch pr.diff checks the lines a unified diff adds, with no repository: a downloaded pull request, a mailing-list patch, an AI agent's proposed change
    Delivery No CI or CI without tests, floating dependency versions, no lockfile, no runtime pin
  • Assess. Before judging, it works out what the project is: a local-first mobile app, a deployed API with accounts, a LAN tool, a command-line tool or a library; where it runs, who uses it, and whether it holds health, financial or other sensitive data. Findings are ranked for that, each change with its reason: SQL built from strings matters less in a single-user offline app; an untested write matters more when the phone holds the only copy. Git history adds the other half: hotspots (complex code that changes every week, where debt costs the most), files that always change together with nothing linking them, and code only one person knows.

  • Review. codefactory review writes a technical review in the shape a principal engineer would: summary, project profile, system map, where change happens, findings by severity with evidence, what's working, gaps and open questions. No AI needed.

  • Fix. codefactory plan turns findings into ranked tasks with steps and the tests to run. Each task becomes a self-contained prompt for Claude Code, and a baseline keeps new problems out in CI.

Duplication lens: copies of the same code joined by arcs, with how similar they are A traced function: the floor shows only what it reaches; the panel lists each call by depth
Duplication lens. Files holding copies of each other's code, joined by arcs labelled with their similarity. Trace. Everything a function eventually calls, by depth, with the total amount of code involved.

Languages

Language How calls are resolved Notes
Python Precisely: imports, self/cls, classes, re-exports, dispatch tables, getattr Standard library only
TypeScript, JavaScript Precisely: the project's own TypeScript type checker (path aliases, hooks, JSX, lazy require) Needs Node.js and npm install
Go, Java, Kotlin, Swift, Rust, C, C++, C#, Ruby, PHP, Scala, Dart, Lua, Elixir and more By name, plus declared types, through tree-sitter [languages] install; grammars download once, then work offline
Shell, Makefiles, YAML (docker-compose, Kubernetes, GitHub Actions), HTML, Pkl, TOML, Terraform, .diff/.patch Not a call graph: line checks for credentials, unsafe commands and configuration No install needed

For the by-name languages, call, impact and unused-code findings are leads to confirm, and the review says so.

Commands

Command What it gives you
review A full technical review in Markdown; --for-ai adds an evidence pack for an AI to finish the judgement calls
view The interactive factory floor (one HTML file), with lenses for duplication, efficiency and size
flags Every issue with file:line; --min warn, --kind similar, --json, --github
plan / prompt Ranked tasks with steps and tests / one task as a ready-to-paste Claude Code prompt
diff What a change adds and fixes, compared with the base branch: a pull-request comment, annotations or JSON; --patch file.diff checks a patch on its own, no repository needed
profile What kind of project this is (mobile app, web service, CLI, library…), where it runs, who uses it, what sensitive data it holds, with evidence; the review ranks findings for it
hotspots From git history: complex code that changes often, files that change together without importing each other, code only one person knows
sbom A CycloneDX software bill of materials of every pinned dependency
org A dashboard across many repositories: health, findings, trends, and findings per owning team
surface The attack surface: every HTTP endpoint, its auth check, and whether it changes data or reaches risky code
accept Mark a finding as intended, with the reason, so later runs show only what's new
brief / context A compact map of the repo / everything about one file or function before you change it
trace / path What a function eventually calls / how one function reaches another
baseline / check Save today's issues / fail CI or a pre-commit hook only on new ones
sarif Issues for GitHub code scanning and VS Code (SARIF 2.1.0)
query / sql Ask anything in SQL / export the graph as a SQLite database
analyze The raw graph as JSON
skill Teach Claude Code in a repository when and how to use all of the above (--hook: keep it current)
update Upgrade codefactory to the latest version

Commands that take a name work from inside the repository: codefactory context checkout. codefactory --help and codefactory <command> --help list every option.

With Claude Code

codefactory skill --hook   # once per repository; commit .claude/

This writes a skill (.claude/skills/codefactory/SKILL.md) and a session-start hook. Every Claude Code session in that repository, on your machine or in the cloud, then starts with codefactory installed, upgraded at most once a day, and its instructions matching the installed version.

Then ask in plain words: "what should I clean up first?", "review the codebase", "what breaks if I change useCart?", "did my change add any problems?". Claude Code runs the right command, reads a few thousand tokens of findings instead of the whole repository, and verifies each change with the tests codefactory lists.

In CI

Comment on every pull request with the findings it adds and fixes (one comment, updated on each push), and optionally fail on new ones:

# .github/workflows/codefactory.yml
on: pull_request
permissions: { contents: read, pull-requests: write }
jobs:
  codefactory:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with: { fetch-depth: 0 }
      - uses: dominickkubica/codefactory@v0   # follows releases; or pin v0.20.1 or a commit SHA
        with: { fail-on: high }

Locally, codefactory diff --base main shows the same. Findings are matched by identity, not line, so code that moved isn't "new", and each one names its owners when the repository has a CODEOWNERS file.

codefactory sarif -o codefactory.sarif feeds GitHub code scanning instead. The usage guide has complete workflows.

How far to trust it

Analysis is static: nothing is executed. Most of codefactory's accuracy came from running it on real projects and fixing what it got wrong: each false positive got a test before its fix, and snapshot tests of every finding on three sample apps make any change in output visible in CI.

  • Precision and recall are measured on a labeled corpus in eight languages, in CI: 91% precision and 84% recall the first time it met code it hadn't been tuned on; 100% and 100% after fixing what that found. Details, per check, in Accuracy.

  • Checked on real code in each language family: two production apps (React Native, FastAPI), pip, Python's and Go's standard libraries, Apache commons-lang (Java), OkHttp (Kotlin), Rack (Ruby), and 24 public projects assessed in three rounds (Rails, Django, Laravel, Spring, ASP.NET, Phoenix, Next.js, Rust, Go, Kotlin Android, Swift, Flutter, Electron, data pipelines). Every false finding they showed was fixed, with a regression test copied from the real repository; the results are in Accuracy.

  • Hints are labelled as hints. Calls through reflection or untyped objects can be missed, so "unused" and "no test reaches it" are reported as leads to verify.

  • Measured where it can be. With a coverage report in the repository (coverage/lcov.info, Istanbul's coverage-final.json, coverage.py's coverage.json), "untested" comes from what actually ran. Without one, the call-graph estimate matched Jest's real coverage for 97.6% of functions on a 500-file React Native app.

  • Intended findings stay quiet. Mark them once, in the code or from the command line, and say why:

    // codefactory: ignore io_in_loop — one query per table, and there are seven
    
    codefactory accept sql_built src/db/encrypt.ts --why "the key is 64 hex characters we generate"
    

Speed

Files are parsed on every core and cached one by one, so a repeat run re-reads only what changed:

Codebase (full review, 4 cores) First run Nothing changed
A React Native app with a Swift watch app, 535 files, 36k lines 11 s 2 s
A TypeScript monorepo (Actual Budget), 2,400 files, 1,500 commits of history 22 s 4.5 s
Python's standard library and packages, 3,900 files, 1.7M lines 54 s 11 s

A changed file re-reads just that file, except TypeScript*.

*The TypeScript type checker needs the whole program, so a TypeScript change re-runs it. Other commands (flags, brief, context, plan) answer from the cache in well under a second when nothing changed.

Privacy

Everything runs locally and nothing is uploaded. The map is a single HTML file with no network access. The only network use is the install itself, codefactory update, tree-sitter grammars downloading the first time a language is analyzed, and review --online, which sends package names and versions (nothing else) to OSV.dev. Caches live in .codefactory/ inside the repository, which ignores itself in git.

Documentation

  • Usage guide: every command, the viewer, every check, configuration, CI and Claude Code
  • Design: how it works and why, data model, algorithms, trade-offs and limits
  • Accuracy: precision and recall per check, measured, and the real-code spot checks
  • Changelog · Contributing

Status and license

Version 0.20, actively developed and used on real projects. Issues and pull requests are welcome; see Contributing. MIT licensed: use it, change it, share it.

Metadata

Release files for codefactory-cli 0.20.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codefactory-cli 0.20.1
File Size Uploaded Provenance Actions
codefactory_cli-0.20.1.tar.gz 260.8 kB With provenance Details for codefactory_cli-0.20.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for codefactory-cli 0.20.1
File Interpreter ABI Platform Actions
codefactory_cli-0.20.1-py3-none-any.whl Python 3 none any Details for codefactory_cli-0.20.1-py3-none-any.whl

Total release size: 500.2 kB

Release files / codefactory_cli-0.20.1.tar.gz

Download URL codefactory_cli-0.20.1.tar.gz
Size 260.8 kB
Tags Source
SHA-256 checksum
How to use checksums
886fef29d7e268d3801f1658983b48ddca6b580b63aaf1ac8b4ce64cb0f379a0
BLAKE2b-256 checksum
How to use checksums
66584a273d29bd615585a7b71ddca7d6ff8fa8aafc0c71a5f21eb3b191460349
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / codefactory_cli-0.20.1-py3-none-any.whl

Download URL codefactory_cli-0.20.1-py3-none-any.whl
Size 239.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
215a67ce1b4b74a158e9ba7d5b9ba68190721c95aea858928ecde50c85589af5
BLAKE2b-256 checksum
How to use checksums
062a8dfc23f2f635bab34f16e9ada32929f49d72676084e40a1429763dc79df4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for codefactory-cli 0.20.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for codefactory_cli-0.20.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.20.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page