unknot
Health Warn
- License — License: MIT
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Low visibility — Only 7 GitHub stars
Code Pass
- Code scan — Scanned 12 files during light audit, no dangerous patterns found
Permissions Pass
- Permissions — No dangerous permissions requested
No AI report is available for this listing yet.
Architecture linter for TypeScript and JavaScript code written by AI agents. Finds cycles, tangles, state leaks and prop drilling, grades the codebase A to F, and stops the agent at the next knot. Zero config, Claude Code Stop hook.
unknot
Architecture linter for TypeScript and JavaScript code written by AI agents.
Finds the structural knots no test and no file-level linter can see, grades the codebase from A to F,
and stops the agent before it finishes a task with a new one.
Quick start · Leaderboard · Rules · Claude Code plugin · Agents · CI · Configuration
Why
An agent writes code that compiles and passes every test, and still ties the project into knots: folders that import each other, services that reach into each other's state, wrappers that wrap nothing, props carried through five components. ESLint checks one file at a time and tests check behaviour, so nothing fails. The cost shows up later, when every next change is harder than the last.
unknot reads the whole TypeScript or JavaScript project through the TypeScript compiler, builds the real dependency graph and reports each knot with the exact files, the lines and the direction of the fix. A cycle of fourteen folders becomes "remove these four imports".
| Whole-project analysis | Type-aware, built on the TypeScript compiler. Erased type imports, lazy import() and handler slots are understood, so what is reported is real. |
| Zero configuration | npx unknot and nothing else. Layers are read from the code. Monorepos, project references, path aliases and plain JavaScript work out of the box. |
| A grade from A to F | One number for the structure of a codebase, on the same scale as the leaderboard of 104 popular AI repositories. |
| Built for agents | A Claude Code plugin with a Stop hook and skills, AGENTS.md rules for Codex and Cursor, and a CI step. The agent gets the report and keeps working until the structure is clean. |
| Fits an existing project | Today's knots are recorded as known debt. Only new ones fail. |
Works with TypeScript, JavaScript, NestJS, Angular, React, Preact, Solid, Vue, Svelte and Astro.
Quick start
npx unknot # report the knots
npx unknot --score # grade the project from A to F
npx unknot init # record today's debt and guard the code from now on
In Claude Code, one command guards every project: /plugin install unknot --marketplace PatternVoid/unknot.
unknot init does three things: writes today's knots to .unknot.allow as known debt, adds a Stop hook to Claude Code, and puts the rules into AGENTS.md. From that turn on the agent cannot finish with a new knot in the code.
Requires Node 20.11 or newer. Nothing to install, nothing to configure.
The leaderboard
We ran unknot with zero configuration over the 104 most starred TypeScript repositories of the AI ecosystem: 392,854 source files, 8,761 structural findings, every one published with its file and line.
| Grade | |||||
|---|---|---|---|---|---|
| Repositories | 20 | 29 | 25 | 19 | 11 |
The 15 most starred of them, and where each one stands:
| Grade | Repository | Stars | Files | Knots / 1000 files | Rank |
|---|---|---|---|---|---|
| morluto/rea | 479k | 3,380 | 32.3 | 70 of 104 | |
| openclaw/openclaw | 395k | 27,408 | 13.8 | 11 of 104 | |
| deepseek-ai/deepseek-harness | 287k | 3,752 | 23.9 | 36 of 104 | |
| n8n-io/n8n | 212k | 15,578 | 43.0 | 87 of 104 | |
| firecrawl/firecrawl | 210k | 271 | 31.5 | 66 of 104 | |
| stablyai/orca | 139k | 29,982 | 12.7 | 7 of 104 | |
| shadcn-ui/ui | 129k | 1,664 | 8.1 | 4 of 104 | |
| thedotmack/claude-mem | 120k | 1,131 | 28.0 | 53 of 104 | |
| paperclipai/paperclip | 117k | 6,009 | 39.6 | 81 of 104 | |
| supabase/supabase | 116k | 6,855 | 17.3 | 20 of 104 | |
| google-gemini/gemini-cli | 109k | 1,129 | 49.0 | 94 of 104 | |
| Egonex-AI/Understand-Anything | 95k | 204 | 2.0 | 1 of 104 | |
| OpenHands/OpenHands | 94k | 1,520 | 15.4 | 14 of 104 | |
| koala73/worldmonitor | 91k | 1,316 | 31.6 | 67 of 104 | |
| cheaper-inference/OmniRoute | 90k | 7,325 | 19.3 | 25 of 104 |
Cleanest of all: Egonex-AI/Understand-Anything at 2.0 knots per 1000 files. Knottiest: teambit/bit at 128.5.
Full leaderboard: all 104 repositories, the method and every finding →
Grade your own
npx unknot --score
unknot score: B 24.6 knots per 1000 files (38 findings in 1808 files)
npx unknot --badge prints a badge for your README:
[](https://github.com/PatternVoid/unknot)
The rules
| Rule | What it finds |
|---|---|
module-cycle |
Folders that import each other at runtime. The finding puts them in layer order and names the few imports that go upward. |
import-cycle |
Files that import each other in a loop no folder cycle explains: inside one module, or through a parent folder. |
tangle |
Two classes in different files that use each other. |
field-leak |
Another file assigns to a field of a class with behaviour, or mutates the collection it holds. |
shared-state |
A module-level object, array, Map or Set that two or more other files change. |
shallow-module |
A file full of functions that only pass their own arguments to another module. |
wide-injection |
A class that takes more than 9 collaborators (services, not values) through its constructor or inject(). |
forward-ref |
forwardRef() used to silence a dependency cycle in NestJS or Angular. |
prop-drilling |
A prop that travels through 3 or more components that only hand it down. |
wide-component |
A component or custom hook with more than 15 state hooks and effects. |
duplicate-type |
A type, interface, union or enum with 4 or more members declared again, same name and same members, in another file of the package. |
wide-directory |
A directory with more than 40 source files and subdirectories. Migrations and generated components/ui folders do not count. |
long-file |
A file with more than 1500 lines of code. Blank lines, comments, data tables and dictionaries are not counted. |
npx unknot --list-rules prints them. npx unknot --explain <rule> says what a rule means and how to fix it from first principles.
One idea stands behind every rule: deep modules, narrow interfaces (John Ousterhout, A Philosophy of Software Design).
Precise by design. An import the compiler erases is not a dependency, and neither is a lazy import() or a require() inside a function. A class named only in a type does not tangle. Reading a field is not a leak, and neither is assigning a callback slot such as onmessage. Binding a prop to an event of a child is using it, not drilling it. A dictionary with a few formatter functions is data, not a long file. A facade that does real work is not a shallow module. Value objects are not wide injections. Decorated controller methods are not wrappers. A parent folder and its children are one module. A module split into a state file and one file that writes it is not shared state. The same type in two packages that cannot import each other is not a duplicate.
Stack coverage
| Stack | Coverage |
|---|---|
| TypeScript, JavaScript | every rule, type-aware through the TypeScript compiler |
| NestJS, Angular | providers, constructor injection, inject(), forwardRef |
| React, Preact, Solid | components and props across files, state hooks and effects |
| Vue, Svelte, Astro | <script> and <script setup> blocks and frontmatter join the import graph under their own file names |
| Monorepos | every tsconfig.json, workspaces, references, path aliases |
Old knots stay, new knots do not
unknot init writes .unknot.allow: the structural debt the project has today. From then on the run fails only on new findings. Fixing an old entry never fails anything, and a cycle that got smaller still counts as known.
npx unknot --update-allow # record the current state again
npx unknot --adopt # record findings of rules added by a new version
npx unknot --all # show the known debt too
Agents
Claude Code
Install the plugin once and every project is guarded:
/plugin install unknot --marketplace PatternVoid/unknot
On older versions of Claude Code: /plugin marketplace add PatternVoid/unknot, then /plugin install unknot@patternvoid.
| The plugin adds | What it does |
|---|---|
| Stop hook | After a turn that changed source files it runs unknot. With a new knot in the code Claude gets the report and keeps working until the structure is clean. |
/unknot:untie |
The skill Claude follows to fix a finding from first principles: which layer is lower, what the outsider wants from the class, who owns the value. |
/unknot:check |
Runs the report, with --all for the known debt. |
/unknot:score |
Grades the codebase from A to F and names what drives the grade. |
The hook runs only when source files changed, checks the nearest folder with a .unknot.allow or .unknot.json (the repository root otherwise), and skips a tree it has already passed. On the first run in a project it records today's knots in .unknot.allow, so only new ones stop a turn.
To guard a single repository for the whole team instead, commit the hook with it: npx unknot init adds it to .claude/settings.json.
{
"hooks": {
"Stop": [{ "hooks": [{ "type": "command", "command": "npx unknot hook", "timeout": 180 }] }]
}
}
Codex, Cursor and every other agent
npx unknot init writes these rules into AGENTS.md:
Run `npx unknot` before finishing a task.
A finding is fixed from first principles, not by moving code around to hide it:
which module is the lower layer, why does anyone outside need this field,
what single call would the caller want. Fix the leaks of one class together.
Never add entries to `.unknot.allow`.
CI
- run: npx unknot --format github
--format github annotates the pull request diff. --format sarif feeds GitHub code scanning, --format json feeds everything else.
| Exit code | Meaning |
|---|---|
| 0 | no new findings |
| 1 | new findings |
| 2 | usage or setup error |
How to untie a knot
| Knot | The fix |
|---|---|
| Cycle | Read the layer order in the finding. Move the piece both sides share into the lower layer, or invert the call. Remove the named upward imports and the whole cycle is gone. |
| Tangle | One owner calls both classes; the other side receives a callback or an event and stops knowing its partner. |
| Field leak | Ask what the outsider is trying to do and give the class a method that says it: pause() instead of paused = true. |
| Shallow module | Call the target directly, or give the wrapper real work. |
| Prop drilling | Let the owner of the value render the consumer as children, or let the consumer read a context or store. |
| Wide injection | Group collaborators by the job they serve and split the class along those jobs. |
Configuration
None is needed. Everything below is optional.
Command line optionsunknot [dir] [options]
--update-allow write every current finding into .unknot.allow
--adopt record findings of rules added since the baseline, keep the rest
--all show known debt too
--score grade the whole project from A to F, known debt included
--badge print a README badge with the grade
--rule <id> only these rules (repeat or separate with commas)
--format <name> text | json | sarif | github
--json same as --format json
--list-rules print every rule
--explain <id> what a rule means and how to fix it
unknot init [dir] record today's debt, add the Claude Code Stop hook and the rules for agents
unknot hook Claude Code Stop hook
.unknot.json
{
"projects": ["backend/tsconfig.json", "frontend/tsconfig.app.json"],
"ignore": ["scripts/**", "src/generated/**"],
"rules": {
"long-file": { "max": 1000 },
"wide-directory": { "max": 25 },
"wide-injection": { "max": 7 },
"prop-drilling": { "minComponents": 2 },
"shallow-module": { "minForwards": 3 },
"forward-ref": false
}
}
Skipped on their own: test, spec, vitest, cypress and story files, folders named test, tests, __tests__, __mocks__, testing, fixtures and e2e, .d.ts, .json, node_modules, minified files and JavaScript build output. Generated files (a @generated, DO NOT EDIT or autogenerated header, generated folders), vendored code (vendored, third_party) and examples and benchmarks folders that sit beside the product source are skipped too. An unknown rule, option or key in .unknot.json is an error, not a silent no-op.
Contributing
npm install
npm run check # types, tests, and unknot on itself
npm run build
New rules and framework support are welcome: see CONTRIBUTING.md. Security reports: SECURITY.md.
License
Reviews (0)
Sign in to leave a review.
Leave a reviewNo results found