Open Source AI Code Quality Framework Guide
Part of the AI Code Quality guide. Start with How to Reduce AI Coding Mistakes: A Practical Guide
A test that calls a new helper directly can pass even if the application never calls that helper. The implementation exists, its unit test is green, the route still uses the old path, and a reviewer has to notice the missing connection.
That's the kind of gap I want an AI code quality framework to make visible.
I split the work into four layers below, with a different question for each one, because a formatting check can't decide whether a feature meets its requirement, and a written requirement can't enforce a formatting rule. Open-source tools cover much of the checking. Someone still has to choose the rules and inspect what the tools didn't establish.
Start with a starter repo, then choose your rules
I built the ai-codebase-boilerplate repository, an MIT-licensed reference for TypeScript projects rather than a standard every team has to adopt; its README also recommends Pharaoh, which I build. Most of the setup lives in FRAMEWORK.md, a six-phase plan meant to run one phase per Claude Code session, which has you create the Biome, Knip and Lefthook configuration, Claude Code hooks, a GitHub Actions workflow and a Stryker config. The template/ directory holds the package.json scripts for those tools plus jscpd and madge, eight Claude Code slash commands and a script that flags orphaned exports.
ai-codebase-boilerplate describes its own setup in three layers. The four layers here are my way of organizing the decisions around a workflow, not a claim about that repository's design.
Read the configuration before copying it. A rule that fits the starter's directory layout, test runner, dependency graph, or release process may need changing in your application, and importing the whole stack makes you responsible for maintaining all of it.
Layer 1: Write down what blocks a merge
Start with one real change. Suppose you're adding a permission check to an endpoint, the helper already has tests, and the question left for review is whether the endpoint actually invokes it, with the right inputs.
I'd put the acceptance rule next to the task: an integration test must exercise the endpoint and demonstrate the denied request. That gives the reviewer something specific to check.
For shared exports, require a caller review before changing a signature. For a new helper, ask the agent to find existing implementations first, record the places it checked, explain why reuse won't work if it proposes another function, and leave that decision in the PR.
Keep the rules short enough to use. For a written starting point, the boilerplate's review command is a ten-item checklist, from dead code and duplication to test quality and security, that marks each finding BLOCK, WARN or NIT. The broader task habits belong in the guide to reducing AI coding mistakes.
Layer 2: Give repeatable checks a defined job
Choose checks by the question you need answered, the languages in your repository, the configuration you can maintain, and the evidence you'll expect when something fails. Here's a small menu rather than a requirement to install everything.
| Tool | Job in this workflow | Limit to keep in view |
|---|---|---|
| Biome | Formatting and lint rules | Passing the configured rules doesn't establish application behavior. |
| Ruff | Python lint rules | Choose rules for your Python project; this isn't a replacement for behavioral tests. |
| Semgrep Community Edition | Static analysis using selected rules | The engine is open source; Semgrep-maintained rules have a separate license. |
| jscpd | Find duplicated token sequences across files | A reported copy still needs a decision about whether the duplication is appropriate. |
| Knip | Find unused files, dependencies, and exports | Its entry points and project configuration determine what it considers reachable. |
| StrykerJS | Change code and run tests to assess whether the tests detect the changes | Review surviving mutations before deciding what test to add. |
| pre-commit | Install and run configured hooks | It's a hook runner; the configured tools perform the checks. |
The table's limits are review rules I'm proposing, not product scores. Keep your existing type checks and integration tests, decide which additional failures should block a merge, introduce new scans where you can inspect their findings, and tighten the policy once you understand the noise.
pre-commit manages hook execution. It isn't a type checker, and installing it doesn't supply a test suite.
A first pass for a Node project
In an existing project, inspect the package scripts before adding tools, keep the repository's package manager, check the new configuration into version control, and use the same checks in CI. These examples use npm, following the tools' documentation.
For Biome's documented installation, then initialization and a check that doesn't rewrite files:
npm install --save-dev --save-exact @biomejs/biome
npx @biomejs/biome init
npx @biomejs/biome ci .
npm records that exact Biome version in the project. Review the generated configuration before making its result a merge requirement.
For Knip's initializer, which currently requires Node.js 20.19.0 or newer, or Bun:
npm init @knip/config
npm run knip
Then try the documented token-copy scan over your source directory, substituting the path your project actually uses:
npx jscpd src
jscpd reports copies for inspection. Don't turn every match into a shared abstraction.
For a Python project with uv available, Ruff documents direct invocation through uvx:
uvx ruff check .
uvx runs the tool in an environment isolated from the project. For a repeatable team setup, pin the tool version, retain its configuration, run it in CI, and save the result with the change you're reviewing.
Layer 3: Check how the change connects
Knip already analyzes a graph of project usage. Missing entries can distort the result, as its entry-point explanation shows, so when the report marks a file unused, inspect the configured start files, then trace the reported export before deleting it.
knip.json belongs in review when you change how the application starts: as Knip's docs put it, miss one entry, and everything reachable only from it looks unused.
For endpoint changes, inspect route registration and follow the new call path. For shared functions, identify callers and decide which application paths need testing.
I build Pharaoh, a hosted service that gives agents repository structure over MCP. It supports TypeScript, JavaScript, Python, C and C++, and its tools can return module context, function matches, caller impact, and entry-point reachability. The service itself isn't open source; its parser has an MIT license.
Captured get_unused_code output, from repository Pharaoh-so/cal.diy, revision 54343aa6, with the recorded entry-point path to checkAdminOrOwner:
# Reachability in cal.diy
- checkAdminOrOwner (packages/features/auth/lib/checkAdminOrOwner.ts): reachable: getAtomEventTypeApp → getEventTypesAppIntegration → checkAdminOrOwner
That gives you a path to inspect. It doesn't demonstrate that the permission policy is correct.
Pharaoh's graph describes the default branch, so for a working-branch change, inspect the changed files locally, run the relevant tests, and check the new wiring there. Live repositories are re-mapped after default-branch pushes; uncommitted edits aren't in that graph.
For cleanup, get_unused_code separates Dead from Possibly unused. A result is Dead only when no entry-point path reaches it, no other file names it, no production file imports its file, and all those signals agree. Possibly unused keeps the references visible for review before deletion.
The code graph MCP server guide covers the context layer in more detail.
Layer 4: Measure what changed in review
Save the revision and configuration with a baseline run, separate existing findings from ones introduced by the change, record which findings reviewers accepted, and keep a short explanation for dismissals. I'd rather read that than a count of every warning printed.
Use a small review log:
-
Time spent reviewing the change.
-
Confirmed defects found before merge, with links to fixes.
-
Regressions found after merge, with the missed check recorded.
-
Dismissed findings and the reason for dismissal.
Stryker adds another way to question a green test run. Mutation testing changes the code and runs the unit tests against it, so when a change survives, inspect what changed, decide whether the behavior matters, and strengthen the test if it does.
Start with Stryker's initializer, inspect the generated configuration, choose the files to mutate, and then run the mutation tests, keeping that configuration alongside the results.
npm init stryker@latest
# Review and adapt the generated configuration before running.
npx stryker run
npx stryker run uses the project's mutation-test configuration. Start with a bounded part of the codebase so you can read the findings.
The longer maintenance consequences belong in the guide to AI technical debt.
Try the framework on one change
Pick a shared-function change, write down its acceptance rule, run the checks you've configured, and attach the caller or wiring evidence to the review. After it ships, record what escaped and which check would have helped.
If you want to try the hosted context option, connect Pharaoh to your repository and AI client, choose a shared function you already understand, ask your agent for its callers, and compare the answer with the code before using it for an unfamiliar change.
Open Source AI Code Quality Framework FAQ
What should an open source AI code quality framework include?
It can combine written merge rules, repeatable checks, connection and reachability reviews, and measurement of findings and regressions. The article presents these as four layers to organize workflow decisions.
Which tools can support an AI code quality workflow?
The article discusses Biome, Ruff, Semgrep Community Edition, jscpd, Knip, StrykerJS, and pre-commit. Choose tools based on the question you need answered, your repository's languages, maintainable configuration, and the evidence you expect when checks fail.
Do these checks replace behavioral tests?
No. Passing formatting or lint rules does not establish application behavior, and pre-commit only manages hook execution. Keep existing type checks and integration tests, and use acceptance rules such as an integration test for a denied endpoint request.
How should teams introduce the framework?
Start with one real change, write down its acceptance rule, run the configured checks, and attach caller or wiring evidence to the review. Record what escaped after the change ships and which check might have helped.
Article Record
ReferencesPrimary sources used for this article
- AI Codebase Boilerplate
- FRAMEWORK.md
- CLI
- GitHub - biomejs/biome: A toolchain for web projects, aimed to provide functionalities to maintain them. Biome offers formatter and linter, usable via CLI and LSP. · GitHub
- The Ruff Linter
- Installing Ruff
- How Knip works
- Getting Started
- pre-commit: A framework for managing and maintaining multi-language pre-commit hooks
- Semgrep Community Edition
- What is mutation testing?
- Getting started
- jscpd
Update HistoryMeaningful revisions to this article
- Added four frequently asked questions about open-source AI code quality frameworks to help readers find useful answers more easily.