What it does
CODE reads your JavaScript and TypeScript with a real parser, writes a plan of renames and moves, then applies it one step at a time with your build and tests run before and after every step.
- Scan: every function with its
file:line, what it calls, what calls it, network calls, storage and DOM events, plus a health score. - Plan:
CODE-PLAN.md, a list you (or your AI) can read and edit before anything changes. - Apply: one rename, move or extract per step. Renames follow every import and call site; it is never search-and-replace. A step that breaks anything is put back on its own.
- Map:
CODEMAP.mdanswers "where do I fix…?" with a file and a line, anddocs/CALLS.mdlists every public function, endpoint and event.
Easiest path: paste the prompt into your coding AI in the project. It runs the commands below, fills in good names, shows you the plan and asks before it applies anything.
Same text as /code/prompt.md and the product page. Commands are pinned to this release.
Scan, plan, apply, map
Run these from your project root. scan and plan never change your code.
Open CODE-PLAN.md. Fix any names you don't like, fill in every ?, and tick or untick lines. Then:
Changed your mind? code undo puts back the last step; code undo all puts back everything.
Commands
Every command is a sub-command of the pinned CLI: code …
| Command | What it does |
|---|---|
code scan [--json] | Parses every JS/TS file, writes .vibe/code/scan.json, prints the score and findings. Changes nothing. |
code plan [--json] | Writes CODE-PLAN.md (and .vibe/code/plan.json). Edit it: names, checkboxes, add your own lines. |
code apply [--only safe] [--step R1,M2] [--dry-run] [--yes] | Runs the baseline build and tests, then one step at a time: change, re-test, commit. Failures are reverted automatically. Commit your own changes first (or --allow-dirty); without git, one patch file per step in .vibe/code/patches/. --yes when there is no terminal to ask. |
code map [--html] [--jsdoc] | Writes CODEMAP.md, docs/CALLS.md, CODE-RULES.md and the AI rules block. --html also writes CODEMAP.html; --jsdoc adds a one-line doc comment to each exported function from .vibe/code/purposes.json. |
code check [--json] | Re-scans against the last baseline. Exits 1 on new cryptic names, big files or long functions, so it can run in CI. The first run is the baseline. |
code undo [step|all] | A git revert of that step's commit (or restores its patch). With no step: the last one. |
code status | Score, plan progress and which steps were applied, put back or are still to do. |
code prompt | Prints the AI prompt, pinned to this release. |
The plan file
CODE-PLAN.md is a checklist. Each line is one step. [x] steps run, [ ] steps don't. Keep the format exactly; you can change names, tick or untick, delete lines and add your own.
- [x] R4 · rename · `src/app.js#valActCheck` → `startFaceScan` · safe · 5 refs in 3 files - does: opens the camera, sends one frame to /api/face/verify and saves the session - evidence: calls getUserMedia, grab, fetch · used by src/main.js:5, test/face.test.js:8 - [ ] R25 · rename · `src/legacy.js#loadPrfl` → `loadProfile` · risky · 0 refs in 1 file - ⚠ "loadPrfl" also appears in a data- attribute at index.html:12 - [x] M2 · move · `src/utils2.js` → `src/lib/utils.js` · safe · 3 importers - [ ] E4 · extract · `src/app.js#showMsg` → `src/features/toast/toast.js` · medium · section "toast" - D1 · dedupe · src/api.js:4 (fetchData2), src/api.js:13 (getUsr) · same 7-line block … - X1 · dead · `src/app.js#saveP` (line 109) · exported and never used …
| Kind | Id | Applied? |
|---|---|---|
| rename | R1, R2… | Yes when ticked. Usually safe. |
| move | M1… | Yes when ticked. Every import is rewritten. |
| extract | E1… | medium: unticked by default. Moves a function into its own file. |
| dedupe, dead | D1, X1… | Never. Listed with the evidence for you or your AI to decide. |
A rename whose new name is ? is skipped: CODE never guesses a name silently. The names come from your AI reading the code, grounded in the scan.
Findings and score
| Finding | What counts |
|---|---|
| Cryptic names | Names that don't say what they do: doStuff2, valActCheck, tmp, handle. |
| God files | Files over 400 lines. |
| Long functions | Over 60 lines, or nesting deeper than 4. |
| Duplicated blocks | The same code in more than one place. |
| Dead exports | Exported, but nothing imports it. |
| Mixed concerns | UI, network and storage all in one function. |
| Magic values | Unnamed strings and numbers repeated across the code. |
| Mixed naming | camelCase and snake_case side by side. |
The score runs from 0 to 100 with a grade from A to F. code status shows it before and after.
How it keeps your app working
- Before anything changes: it runs your
package.jsonbuild,test,lintandtypecheckscripts. If the build or tests already fail, it stops (exit 2) and changes nothing; a lint or typecheck that already fails is left out of the checks, with a warning. - After every step: the same scripts again, plus its own check that every file still parses, every import resolves and no name became undefined.
- Auto-revert: a step that fails any of those is put back and reported. The run moves on to the next step.
- One commit per step: so
code undo <step>is a normalgit revert. Without git, each step is a patch file. - No tests? It writes a small smoke test first (does it build, do pages load, do exported functions keep their shape), so "nothing broke" is measured, not assumed.
- Public names: anything your package exports for other code keeps its old name as an alias marked
@deprecated. - Dynamic references: code like
obj[name]can't be followed safely, so anything it might reach is flagged risky and left unticked.
Don't edit files by hand while code apply runs. Commit or stash your own changes first (CODE's own files don't count), so every step is its own clean commit. Without a terminal to ask (an AI or CI), it needs --yes.
Files it writes
| File | What's in it |
|---|---|
CODE-PLAN.md | Every rename, move and extract with its risk and call sites. Safe ones checked. |
CODEMAP.md | Features → files → functions with file:line, and "Where do I fix…?". |
docs/CALLS.md | Every public function, endpoint and event with its inputs and side effects. |
CODE-RULES.md | Naming and folder rules for this project. |
CLAUDE.md / AGENTS.md / .cursorrules | A short rules block, added at the end. Never overwritten. |
CODEMAP.html | With code map --html: the map as a searchable page. |
test/code-smoke.test.mjstest/code-smoke.snapshot.json | Only when the project has no tests: the smoke test and the shapes it checks. |
.vibe/code/scan.json | The full scan. |
.vibe/code/plan.json | The plan as data. |
.vibe/code/steps.json | What was applied, put back, and each step's commit. |
.vibe/code/purposes.json | Written by your AI: one plain-English line per function, used by code map. |
.vibe/code/patches/ | Without git: one patch file per step. |
Exit codes
| Code | Meaning |
|---|---|
0 | OK. |
1 | Findings (code check: new cryptic names or god files), or a step failed and was put back. |
2 | The baseline build or tests were already failing. Nothing was changed. |
3 | No plan yet, or uncommitted changes to your files. Nothing was changed. |
Scope and limits
- Languages: JavaScript and TypeScript today (JSX, TSX, React, Next.js, Vite, Node). Python is on the roadmap.
- Applied for you: renames and file moves (
safe). - Unticked by default: moving a function into its own file (
medium). - Left to you: merging duplicated code and deleting unused exports. Listed with the evidence, never done automatically.
- Never renamed: anything in
node_modules, public URLs, API routes, or names code outside the project uses (those keep a deprecated alias). - Names: come from your AI reading the code. A name it can't work out shows as
?and the step is skipped.
Nothing is uploaded: CODE runs on your machine, in your project.