codefactory
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.
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-cli[languages]"
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
- The package is
codefactory-clion PyPI (codefactorythere is an unrelated project); the command iscodefactory. Installed from GitHub before?codefactory updatemoves you over. - Python 3.11 or newer. On Windows, run the same commands in PowerShell; use
py -m pipifpipisn't found. On a Mac,brew install pipxand thenpipx install "codefactory-cli[languages]"(Homebrew's Python refuses a plainpip install, and the built-inpython3is too old). - TypeScript/JavaScript projects: run
npm installin 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:lineand 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…) respectedPrivacy 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 signingShell, Make, YAML, HTML, Pkl Credentials in config files (quoted or not); curl … | sh,rm -rf "$DIR/"with an empty variable,evalof 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 TerraformPatches codefactory diff --patch pr.diffchecks the lines a unified diff adds, with no repository: a downloaded pull request, a mailing-list patch, an AI agent's proposed changeDelivery 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 reviewwrites 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 planturns 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. 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.2 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'scoverage-final.json, coverage.py'scoverage.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 sevencodefactory 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.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| codefactory_cli-0.20.2.tar.gz | 262.6 kB | With provenance | Details for codefactory_cli-0.20.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| codefactory_cli-0.20.2-py3-none-any.whl | Python 3 | none | any | Details for codefactory_cli-0.20.2-py3-none-any.whl |
Total release size: 502.9 kB
Release files / codefactory_cli-0.20.2.tar.gz
| Download URL | codefactory_cli-0.20.2.tar.gz |
|---|---|
| Size | 262.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9843d28623c6227f699252918b1c0b93d106f3e5c3ae0a665056dddd2065799a
|
|
BLAKE2b-256 checksum How to use checksums |
079f4a5da56d1e6d0dce69017b6316768d30e7d98e6257fb8e3e5d3b6204cb37
|
| 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 logRelease files / codefactory_cli-0.20.2-py3-none-any.whl
| Download URL | codefactory_cli-0.20.2-py3-none-any.whl |
|---|---|
| Size | 240.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1c982813906caefd93bf11034867bfd4c002fe1984acb344815487f5e7d2d24b
|
|
BLAKE2b-256 checksum How to use checksums |
3cd7d0663bfddf483ead38ef0de577542e5d98de0af2935b94713d5e54e2cac6
|
| 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 logSecurity for codefactory-cli 0.20.2
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.
Attestation for codefactory_cli-0.20.2.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 logA 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.