/hypervibe:cleanfrom hypervibe
Audits a project for unused files, dead code, AI leftovers, unused dependencies, orphan env vars, DB tables with no callers, and obsolete migrations. Produces a report with certainty and danger levels, then applies validated deletions on a separate branch for verification before merge.
Ships in hypervibe. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
/bootstrap carries no language signal by itself). If nothing in the conversation gives a signal, fall back to the OS locale (node -e "console.log(Intl.DateTimeFormat().resolvedOptions().locale)") before defaulting to English. ALWAYS reply in that language for every user-facing message: questions, progress, confirmations, summaries, errors - including any example text quoted in this skill, which is illustrative and must be translated, never sent verbatim.You audit the project to find what is no longer used, then you propose deletions on a separate branch so the user can verify before merging.
Disclaimer to display at the start of the audit:
⚠️ This report is a diagnostic. Some findings are false positives: your code may use elements in a way that static analysis cannot detect (dynamic imports, references in the database, an env var read by a transitive dependency, external links to pages, and so on). Nothing will be deleted without your explicit approval, and the deletions will be made on a separate branch that you test before merging.
The report must be readable by someone who is not a developer. You may be dealing with a user who knows what they want, but not all the technical jargon.
Concrete rules:
.bak file = "a forgotten photocopy", an unused dependency = "a tool in the toolbox that no one uses", a DB table with no caller = "a storage room that no one has the key to".grep -r 'Foo'". Example of a good phrasing: "Open a terminal and type grep -r 'Foo' src/ - you should only see the file that defines Foo. If you see other files, that means Foo is used somewhere, and you must not delete it."This rule applies to the report (step 2) and to the proposed checks (step 3). In your internal scan (step 1), you can stay brief.
This is the most important rule of this skill. Everything that is technically verifiable, you verify yourself before producing the report. You return to the user only the questions that they alone can decide.
grep / find searches in the code → you have the tool..env, package.json, drizzle.config.ts) → you have the tool.git add away from a commit, and the maintained .gitignore only covers .env): T="$(node -p "require('os').tmpdir()")/hypervibe-env-check-$$.env" && vercel env pull "$T" --yes, read the values, then rm "$T".node "${CLAUDE_SKILL_DIR}/../../scripts/neon/run-sql.mjs" "SELECT ..." (SQL-over-HTTP, reads DATABASE_URL from the .env). List/inspect branches → Neon REST API (GET https://console.neon.tech/api/v2/projects/{id}/branches, key NEON.api_key from the vault).gh, vercel, wrangler, render).In the report, present these checks as facts, not as homework for the user. Examples:
❌ "To verify before deleting: open your editor, do Ctrl+Shift+F on 'db.select', you should get 0 results"
✅ "Verified: 0 occurrence of db.select / db.insert / db.update / db.query in src/."
❌ "To verify: run vercel env pull and check whether DATABASE_URL is a fake localhost"
✅ "Verified on Vercel: DATABASE_URL = postgresql://placeholder:placeholder@localhost:5432/db (fake value left by the bootstrap, never used)."
Keep the "To verify" list short and human. If you verified everything yourself, this section can simply be absent - replaced by a "Checks done:" line that lists the technical checks already performed.
At startup, display a checklist in natural language (not "Step N"). During execution, announce each action with ↳ … then mark ✅ once done. At the end, every box must be ✅. NEVER mention the internal step numbers to the user.
Example of an opening checklist:
Here is what I am going to do:
- ⬜ Scan orphan files
- ⬜ Detect dead code (exports, imports, unreferenced pages)
- ⬜ Spot AI leftovers (stubs, TODOs, duplicates)
- ⬜ List unused dependencies
- ⬜ Compare environment variables .env ↔ code ↔ Vercel
- ⬜ Check DB tables with no caller
- ⬜ Check obsolete Drizzle migrations
- ⬜ Do a global checkup (look beyond the planned categories)
- ⬜ Produce the report with certainty and danger levels
- ⬜ If you approve, create a cleanup branch (code + DB) and apply
Go through each category and keep the findings silently. Only display them in step 2 (consolidated report).
Search at the root and in src/, scripts/:
*.bak, *.tmp, *.old, *.orig, *.backup.*_old-*, *-old.*, *-copy.*, *-copie.*, *_v1.*, *_v2.*, *-test.* (if there is no test runner), temp-*, _tmp**.sql outside the drizzle/ folder or migrationsmigrate-*.ts, fix-*.ts, seed-once.ts, debug-*.tsNOTES.md, TODO.md, TEMP.md, scratch.mdTool: find or git ls-files + filter.
pnpm tsc --noEmit (already covered by TS) or the linter (pnpm lint).knip or ts-prune is available (pnpm dlx knip works without install), use it. Otherwise, manual grep: for each named export in src/, grep -r "exportName" --include="*.ts" --include="*.tsx" outside the declaration file. If 0 results, it is a candidate..tsx files under src/components/ that are not imported anywhere.src/app/**/page.tsx and src/app/api/**/route.ts that no other file references via href=, <Link>, fetch(, router.push(, or via the sitemap / navigation. Careful: a page can also be reachable via an external link / a marketing email / a manually typed URL..query/.mutation of the router, check that there is at least one api.X.Y.useQuery / api.X.Y.useMutation / await api.X.Y(...) in src/.Typical traces left by Claude / Cursor / Copilot:
// This function takes X and returns Y, // Here we iterate over the array, // eslint-disable-next-line without justification// TODO (Claude), // TODO: implement, // FIXME, // STUB:Button.tsx + Button2.tsx, UserForm.tsx + UserFormNew.tsx, index.ts + index.old.ts_plan.md, prompt.txt, steps.md at the rootconsole.log(, console.debug( in non-test code (to flag, not to delete automatically since they are sometimes intentional)// removed, // was: xxx, // (old implementation)Run pnpm dlx depcheck (or pnpm dlx knip --dependencies) and capture the result.
Frequent false positives to flag as "to verify manually":
drizzle-kit)@types/*) that are only used implicitlyCompare three sources:
.env (listed keys)grep -r "process\.env\." src/ → list of vars readvercel env ls (if the CLI is authenticated)Three types of findings:
NEXTAUTH_URL, DATABASE_URL by Drizzle, VERCEL_URL, NODE_ENV).Read src/server/db/schema.ts (or equivalent), extract the table names and their exported variables. For each one, check that there is at least one grep that references it on the code side (db.select().from(X), db.insert(X), import { X } from "...schema").
⚠️ The riskiest category of the report - see danger level below.
List the files in drizzle/ (or src/db/migrations/).
db:push (no versioned migrations) → no action..sql) or the migrations whose content is entirely cancelled out by a later migration (added then removed the same column).This is the most important distinction of the skill. The Hypervibe plugin (and T3, and shadcn/ui) intentionally scaffold elements that are not used right away, but that are ready to wire up as soon as the user needs them. These elements:
The rule: you do NOT propose them as leftovers to validate. You list them in a separate section of the report, ℹ️ Ready-to-use scaffolding - recommendation: keep, purely informational. The user can always ask to remove them if they wish, but the default is to keep them.
DATABASE_URL is a placeholder like postgresql://placeholder@localhost:5432/* and no query is made:
src/server/db/schema.ts, src/server/db/index.ts, drizzle.config.ts, start-database.shdrizzle-orm, drizzle-kit, postgres, eslint-plugin-drizzlepackage.json scripts: db:push, db:studio, db:generate, db:migrate - they are an integral part of the DB kit, keep them as long as the DB stack is kept. Removing them would make the stack unusable even if we wire it up later.db context in src/server/api/trpc.ts/add-db can plug in a real DB later without re-scaffolding.src/trpc/server.ts, createCaller in src/server/api/root.ts): 30 lines of T3 boilerplate to call tRPC on the server side without going through the network. Low cost to keep, painful to recreate by hand if the need comes back.RouterInputs, RouterOutputs in src/trpc/react.tsx): standard T3 boilerplate (type RouterInputs = inferRouterInputs<AppRouter>), 2-3 lines, useful as soon as a component needs to type an input/output of a query/mutation. Keep.src/components/ui/: all of them, without exception, whether they were installed at bootstrap or added later. Even unused today, they are part of the coherent UI kit (same version, same imports, same Tailwind variants). Cost to keep = none, cost to recreate consistently with the rest of the kit = non-trivial. Never propose a shadcn component as a leftover, even if it is imported nowhere.Conversely, some files look like scaffolding but are not. T3 does not create them - they were added manually or by an earlier Claude conversation:
src/components/**/index.ts (barrel re-exports): T3 and Hypervibe do not generate any. If you find one that is never imported, it is a human/AI addition that you can propose for normal deletion (🟢 low risk).src/components/<domain>/ that are never imported: not scaffolding, real dead code.src/lib/ other than those explicitly shipped by T3 / Hypervibe (cn.ts, utils.ts from shadcn): same, verify the origin before deciding.Three signals that help you decide:
If all three are false → it is real dead code and you put it in category 1b.
ℹ️ Ready-to-use scaffolding (recommendation: keep)
- Complete DB stack (Drizzle + Postgres + placeholder DATABASE_URL)
Reason: pre-wiring left by /bootstrap to plug in a real DB via
/add-db without re-scaffolding. Not used today, but cost to keep
= none, cost to recreate = 10-15 min + risk of version drift.
Suggestion: keep. If you are sure you will never wire up a DB,
tell me "remove the DB stack" and I will do it.
- src/trpc/server.ts + createCaller
Reason: standard T3 helper for server-side tRPC calls. ~30 lines.
Suggestion: keep.
- shadcn/ui components: avatar, scroll-area, separator
Origin: installed in a batch by the bootstrap (seen in the initial commit).
Suggestion: keep. They are part of the version-coherent kit.
You can also, if you detect an ambiguous case (e.g. a shadcn component that was added in a later commit), flag it as 🟡 in the normal category rather than as scaffolding.
Do not stop at the 7 categories above. Go through the project with the meticulous eye of a newcomer, and flag anything that strikes you as odd / useless / dated, even if it does not fit any predefined box.
Examples of possible findings (non-exhaustive list, for inspiration):
/public/ never referenced in the code nor the legal pages (images, PDF, favicon v1 replaced by v2, fonts loaded twice).src/messages/*.json but never called via t("...") / useTranslations.app/contact/page.tsx AND an app/(marketing)/contact/page.tsx - Next.js will only keep one of the two).if (FEATURE_X) conditions where FEATURE_X is always true (the flag can be removed and the code simplified).grep -r "^\s*//" src/ and by looking at the big blocks)..ts/.tsx of fewer than 10 lines with no useful export..test.ts whose tested file no longer exists.shadcn/ui components generated but never used in src/components/ui/ (they are committed as is - we can remove the ones that serve no purpose).next.config.js, tsconfig.json, eslint.config.mjs, drizzle.config.ts): commented-out options, empty experimental: {}, ESLint rules disabled without a documented reason.formatDate in lib/utils.ts AND in lib/date.ts), two near-identical Zod validators, etc.package.json with a default name ("test", "my-app", "t3-app", "create-next-app", or a name that matches neither the folder nor the GitHub repo): a vestige of a scaffold whose name no one changed. Rename it to kebab-case consistent with the project (derived from the folder or from the repo in git remote get-url origin). Safe to fix - zero runtime impact, just cleaner in the logs and in pnpm --filter.For each finding outside the categories, use the same format as the others (certainty + danger + checks). In the category, note it under "Other findings" in the report.
For each finding, display in the following format. Apply the educational rule: each technical term is accompanied by a rephrasing in parentheses the first time it appears.
[🟢🟡🔴] <File / symbol / table name>
Category : <category>
In plain terms : <rephrasing in everyday language - what it is, what it normally does>
Certainty : 🟢 High | 🟡 Medium | 🔴 Low
Danger if wrongly deleted : 🟢 Low | 🟡 Medium | 🔴 High (+ a sentence that concretely explains what would break)
Why it might be a leftover :
<short explanation, no jargon>
To verify before deleting :
- <check 1 - concrete action + what the check is for>
- <check 2>
Example render (excerpt) for a non-technical user:
🟡 src/components/OldSignupForm.tsx
Category : Unimported component
In plain terms : A signup form (a React component - an interface building block) that is no
longer wired to any page.
Certainty : 🟡 Medium
Danger if wrongly deleted : 🟢 Low - if no one uses it, the site will not change.
If by chance it is loaded dynamically, a page will error out - you would see it
right away by clicking on that page.
Why it might be a leftover :
There is a SignupForm.tsx (without the "Old") that is more recent, and that is the one used
everywhere in the project.
To verify before deleting :
- Open your editor, do a global search (Ctrl+Shift+F) for "OldSignupForm".
You should only see this file itself. If you see an `import OldSignupForm …` somewhere,
that means it is still used - we do not touch it.
- Quickly check whether a page on the site still uses the old form
(the "oldest" pages of the project, typically).
| Category | Typical certainty | Danger if wrong |
|---|---|---|
.bak / .tmp / _old-* file | 🟢 High | 🟢 Low (recoverable via git log --diff-filter=D) |
| One-shot script at the root | 🟡 Medium | 🟢 Low (it could be a useful archived script) |
| Unused import | 🟢 High | 🟢 Low (lint / tsc catches it immediately) |
| Unused export (internal util) | 🟢 High | 🟢 Low (breaks at compile time) |
Export from a lib index.ts file | 🟡 Medium | 🟡 Medium (might be a public API of the package) |
| Unimported React component | 🟡 Medium | 🟢 Low (if truly unused, 0 visual effect) |
Orphan app/**/page.tsx page | 🔴 Low | 🔴 High (external links / SEO / email shares) |
Orphan API route app/api/**/route.ts | 🔴 Low | 🔴 High (external webhook, mobile app, third-party integration) |
| tRPC procedure not called on the client | 🟡 Medium | 🟡 Medium (might be called in SSR or via another front end) |
| Verbose AI comment | 🟢 High | 🟢 None (no behavior) |
| Forgotten TODO marker | 🟢 High | 🟢 None (but may hide an undone task worth recalling) |
Component duplicate (X2.tsx) | 🟡 Medium | 🟡 Medium (which of the two is used?) |
| Forgotten console.log | 🟡 Medium | 🟢 Low (but sometimes intentional in dev) |
depcheck dependency | 🟡 Medium | 🟢 Low (reinstallable, the lockfile keeps a trace) |
| Env var in .env never read in the code | 🟡 Medium | 🔴 High (a transitive dep may read it, e.g. NEXTAUTH_URL) |
| DB table with no caller | 🔴 Low | 🔴 Very high - never delete without a backup + human validation |
| Old Drizzle migration already applied | 🟢 High | 🟡 Medium (useless, but breaks nothing if left) |
Asset in /public/ not referenced | 🟡 Medium | 🟡 Medium (may be used in an email / external document) |
| Unreferenced i18n key | 🟢 High | 🟢 Low (will show the raw key if called) |
shadcn/ui component in src/components/ui/ | - | ℹ️ Never proposed - ready-to-use scaffolding (see 1g-bis) |
| Commented-out code (dead block) | 🟢 High | 🟢 None (git keeps the history) |
| Constant feature flag | 🟡 Medium | 🟡 Medium (may be useful to quickly re-enable the feature) |
| Logic duplicate (identical utils) | 🟡 Medium | 🟡 Medium (make sure both really do the same thing) |
| Other finding outside the categories | to assess case by case | to assess case by case |
Group the report by decreasing danger level, so the user first sees the risky things (to study thoroughly) and finishes with the safe things (that they can accept in bulk).
Before the detail, display:
📊 Summary
Orphan files : X found (Y high certainty)
Dead code : X found
AI leftovers : X found
Unused deps : X
Questionable env vars : X
DB tables to verify : X
Obsolete migrations : X
Other findings (off-category) : X
─────────────────────────────
Estimated gains : ~X files, ~Y lines, ~Z MB node_modules
ℹ️ Detected but NOT proposed for deletion (ready-to-use scaffolding):
- DB stack (Drizzle + placeholder DATABASE_URL)
- tRPC SSR helpers
- shadcn components installed at bootstrap: X
→ If you want to remove one, ask for it explicitly.
Ask the user to validate category by category (not all at once), in increasing order of danger (we start with the safe ones):
Where do we start?
- AI comments / forgotten TODOs (🟢 no risk) - X findings
- Unused imports / exports (🟢 no risk) - X findings
.bak/.tmpfiles (🟢 no risk) - X findingsdepcheckdependencies (🟢 low risk) - X findings- Unimported React components (🟡 to verify) - X findings
- One-shot scripts (🟡 to verify) - X findings
- Other off-category findings (variable risk level, to look at case by case) - X findings
- Orphan env vars (🔴 risky) - X findings
- Orphan pages / API routes (🔴 risky) - X findings
- DB tables (🔴 very risky) - X findings
For each category, I will list the items one by one, and you decide which ones to delete.
For 🔴 categories, NEVER propose a bulk action. Item by item, with the checks to do explicitly cited.
Language reminder. From here to the end, every progress message, every command description and the account of each deletion stay in the user's language, even though the code, the tool output and this skill are in English. This is the stretch where it slips.
Once the deletions are validated, do not touch main directly. Propose:
First check whether this folder is yours alone right now: git status --porcelain (changes that are not committed) and git log --oneline @{u}..HEAD (local commits that are not online yet; with no upstream branch there is nothing to compare, say so). If both print nothing:
git checkout -b cleanup/YYYY-MM-DD
(Name: cleanup/YYYY-MM-DD or cleanup/YYYY-MM-DD-HHMM if there are several sessions in one day.)
If either shows something, the user or another session may be at work in this folder: say what you found, and treat the repository as shared. Switching branch there would move their files under their feet, so the branch lives in a separate working folder (a git worktree), in a temporary folder of its own, and the shared folder is never touched:
WT=$(node -e "const fs=require('fs'),os=require('os'),p=require('path');console.log(fs.mkdtempSync(p.join(os.tmpdir(),'cleanup-')).split(p.sep).join('/'))")
git worktree add -b cleanup/YYYY-MM-DD "$WT" HEAD
(cd "$WT" && pnpm install --frozen-lockfile --prefer-offline)
HEAD, local commits included. What is not committed in the shared folder is not in it: a deletion that touches a file with uncommitted changes is left out, and you say so..env goes into that folder, ever: a second copy of the project's secrets in a temporary folder is exactly what gets forgotten there. tsc reads no variable, and where a command still loads the project's configuration, the T3 environment file skips its own validation with SKIP_ENV_VALIDATION=1 in front (SKIP_ENV_VALIDATION=1 pnpm lint). The database steps of 4b take the one value they need in the command itself (SKIP_ENV_VALIDATION=1 DATABASE_URL="$BRANCH_URL" pnpm db:push), never from a file written there.git -C "$WT" status --porcelain prints nothing; otherwise stop, uncommitted work would be lost):git worktree remove "$WT" 2>/dev/null || node -e "require('fs').rmSync(process.argv[1],{recursive:true,force:true,maxRetries:5,retryDelay:300})" "$WT"
git worktree prune
On Windows git refuses to delete a folder that holds node_modules ("Directory not empty") and leaves it behind: the second command is what removes it, and prune clears what git remembered of it. The branch itself stays in the repository. Check the folder is gone (test -d "$WT") before saying it is, and if it is still there, name its path to the user rather than leaving it silently.
All the deletions (files, code, deps, env vars) happen on this branch. One commit per category to be able to roll back finely:
cleanup: remove orphan backup filescleanup: remove unused exportscleanup: remove ai leftovers (todo, verbose comments)cleanup: drop unused depscleanup: prune env vars (⚠️ test very carefully)If some changes touch the database (deletion of tables, columns, migrations):
main via the Neon REST API (POST https://console.neon.tech/api/v2/projects/{id}/branches, key NEON.api_key from the vault, read into a shell variable). There is no neonctl on this stack: the REST API is the only way.
cleanup-YYYY-MM-DDconnection_string without ever displaying it: a connection string is a secret, whole. Extract it in the same command that writes it where it is needed (a shell variable piped into .env.local, or node scripts/push-env-vars.mjs --target=preview --stdin), and check the result by its HOST only (node -e "console.log(new URL(process.env.U).host)"), never by printing the value.DATABASE_URL for the previews of the cleanup/* branch. Or simply replace DATABASE_URL in the .env.local during the verification phase.pnpm db:push or the Drizzle migration)Provide a test checklist targeted at what was deleted:
To verify before merging cleanup/YYYY-MM-DD:
☐ pnpm tsc --noEmit → OK
☐ pnpm lint → OK
☐ pnpm build → OK (no "module not found" warning)
☐ Dev server (pnpm dev) starts without error
☐ Vercel preview: open the URL and click on every main section
☐ Deleted pages: test that they indeed return 404 and not a 500 (and check that no link on the site points to them)
☐ Deleted API routes: if external services call them (Stripe webhooks, Vercel cron, mobile app), test them
☐ Deleted env vars: re-read the Vercel Preview logs looking for "undefined" or "missing"
☐ Deleted DB tables: open Drizzle Studio on the cleanup Neon branch and check that the app works
When the user confirms that everything works:
main (→ Vercel redeploys to prod)pnpm db:push pointed at prod)git branch -d cleanup/YYYY-MM-DDDELETE https://console.neon.tech/api/v2/projects/{id}/branches/{branch_id}, with curl -sf so that a refusal is seen as a failure). List the branches first and check the name of the one about to go: the id of main in that URL would destroy production and every backup with it. The guardrail asks for a confirmation on this call, that is expected.git push --force nor drop table without double validation.Even if the user validates, refuse and ask for a second confirmation if:
SELECT COUNT(*) > 0)/api/webhooks/*, /api/stripe/*, /api/cron/*)NEXTAUTH_*, AUTH_*, VERCEL_*, NODE_*, NEXT_PUBLIC_*)Phrase it: "You validated N risky elements at once. I prefer that we do them one by one so you have time to review. OK?"
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub flavien-ia/hypervibe-craft --plugin hypervibe90 skills in this plugin
/accessibilityAccessibility audit of a Next.js app: reads the code (images, buttons, links, form fields, keyboard, focus, zoom, motion), measures the live pages with PageSpeed Insights, explains each problem plainly, then applies the fixes the user approves./add-2faAdd two-factor authentication (2FA TOTP) to an existing T3 project's login. Orchestrator - asks which authenticator app the user wants, detects whether the project uses admin auth (single fixed login) or user accounts, and delegates to the right setup. Admin mode - 2FA is mandatory for the single admin, secret + backup codes stored in the Bitwarden vault. User mode - 2FA is optional per user, each user enables it from their account page, secrets + backup codes stored per-user in the database. Requires the project to already have hypervibe auth (`/add-auth`)./Other plugins' skills for the same job