vibe-code-cleanup
What it does
This tool helps clean and organize code in quickly built web applications by removing unnecessary or broken parts without altering what already works. The goal is to make the code safer and easier to maintain for production use.
When to use it
- βWhen an app works but has import errors or unused code.
- βBefore launching an app or handing it over to someone else.
- βWhen you need to tidy up code without changing core features like routes or APIs.
Skill link
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/vibe-code-cleanup/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βClean up my code, removing unused parts and fixing broken imports.β
5 new skills a week. 1 minute to read.
vibe-code-cleanup: full guide
Apps built fast with an AI agent often work on screen but are messy underneath. Imports point to files that moved. Old files sit unused. The same block of code is pasted in many places. Environment variables are used in code but not written down anywhere. None of this stops the app from running today, but it makes launch and handoff risky.
This skill gives your agent a careful cleanup routine for that situation. It works in small steps, checks each step, and treats routes, API shapes, the database schema and login logic as off-limits. It is meant for Next.js, React and Node.js projects, and for people who have a working app they now need to hand over or ship.
Use cases
Fixing a build that fails on imports
Your Next.js app ran fine until the agent renamed a folder. Now the build stops on a missing module. The skill starts with the TypeScript error list and fixes the import path first. It does not delete the file the import points to unless nothing uses it.
Getting ready to hand the project to a freelancer
You built a booking site over a few weekends and a developer will take over on Monday. You ask for a tidy baseline. The agent removes only verified unused files, lists env variables missing from .env.example, and makes small commits the new developer can read.
Pulling repeated metadata into one helper
Twelve pages each repeat the same Open Graph and Twitter card block, with slightly different URLs. The skill treats this as a good target because it appears in three or more places. It moves the block into one shared function and leaves the page paths unchanged.
Step by step
- 1Install the skill so your agent can find it, for example in ~/.claude/skills/vibe-code-cleanup/ or the project's .claude/skills/ folder. Open your project in the agent.
- 2Make sure your work is saved in git first, so any batch of changes can be undone.
- 3Ask for cleanup. The agent first maps your pages and routes, lists TypeScript errors and notes debug leftovers such as console.log, without changing anything yet.
- 4The agent fixes broken imports, then checks each unused-file candidate by searching the whole project, including config and route lists, before removing it.
- 5After each batch it runs the type check, lint, build and tests. If one fails, it reverts that batch. Review the small commits, then merge.
Example
What to ask
βMy Next.js app builds with errors after a refactor. Fix the broken imports, remove only files you can prove are unused, and list any env variables missing from .env.example. Don't touch routes or API endpoints.β
What you get
The agent lists 6 TypeScript errors and fixes 5 wrong import paths. It finds one unused helper file, confirms no file imports it, and removes it in a separate commit. It reports two variables used in code but missing from .env.example, and the build passes.
Tips
- βAsk for one kind of cleanup at a time, such as imports first, then dead files. Small batches are easier to review and to undo.
- βA search finding no imports is only a candidate for deletion. Files loaded by name at runtime or used by the framework can look unused. Check anything you are unsure about yourself.
- βLimit: it does not know what your product should do. If a route or component looks old but you still need it, say so before cleanup starts, because the skill cannot guess intent from code.
Alternatives
- deslop-shared-libs
Pick it when your main goal is finding repeated logic in recent work and pulling it into shared code, rather than a full pre-launch cleanup.
- code-review
Pick it after cleanup to check your changes against your repo's coding standards and the original spec before you merge.
- ponytail-debt
Pick it when you want a list of shortcuts marked for later, to see what still needs fixing, instead of changing code now.
Questions and answers
Should I run this on a project without git?
Put the project in git first. The skill works in small commits so you can undo any batch. Without version control, a bad deletion is hard to reverse. Even a local repository with one starting commit helps.
Does it handle environment variables and secrets?
It lists variable names used in code and compares them with .env.example, flagging missing ones. It is told to avoid printing values from .env.local and never to add secrets to version control.
Will it improve my app's speed or add features?
No. It aims to make the code safer and easier to maintain while keeping behavior the same. It does not add features, change how the app works, or tune performance. Use a different skill for those goals.
How it works
The tool analyzes the code to find broken imports and unused code. It carefully removes these parts, ensuring important features like routes and APIs continue to function.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Vibe-Code Cleanup β Production Refactor Skill
A safe, incremental cleanup workflow for AI-generated / vibe-coded fullstack apps. The goal is to make the codebase production-ready without breaking anything that already works.
When to Use
- Use when a rapidly built app works but has broken imports, duplicated logic, dead code, unclear environment variables, or fragile release hygiene.
- Use before launch or handoff to convert exploratory code into a maintainable production baseline.
- Use when cleanup must preserve existing behavior and avoid broad rewrites of routes, APIs, auth, data models, or integrations.
Core Philosophy
Surgery, not demolition. Remove only what is provably dead. Preserve everything else.
Never:
- Rewrite working systems for cosmetic reasons
- Rename routes, slugs, or API endpoints that may be indexed or cached
- Change tool inputs/outputs, API contracts, DB schema, or auth flow
- Delete files you haven't verified are unused
- Make broad sweeping changes in a single commit
Always:
- Make small, targeted, reversible changes
- Validate after every meaningful batch of changes
- Prefer shared helpers over copy-pasted blocks
- Keep backward compatibility
Step 1 β Reconnaissance (read before touching)
Before changing anything, map the codebase:
# List all pages/routes
find . -type f \( -name 'page.js' -o -name 'page.jsx' -o -name 'page.ts' -o -name 'page.tsx' \)
find pages -type f \( -name '*.js' -o -name '*.jsx' -o -name '*.ts' -o -name '*.tsx' \) | rg -v '/_' | sort
# Find broken imports (TS projects)
npx tsc --noEmit 2>&1 | head -80
# Find unused exports (optional, for larger projects)
npx ts-prune 2>/dev/null | head -40
# Check for console.log / debug leftovers
grep -r "console\.log\|debugger\|TODO\|FIXME\|HACK" --include="*.{js,ts,jsx,tsx}" -l
Document what you find. Do NOT change yet.
Step 2 β Fix Broken Imports First
Broken imports cause build failures and should be fixed before anything else.
# TypeScript: list all errors
npx tsc --noEmit 2>&1
# Common patterns to fix:
# - Missing file (file was deleted or renamed)
# - Wrong relative path (../lib vs ../../lib)
# - Named export that doesn't exist
Fix rule: Fix the import reference. Do NOT delete the referenced file unless you've confirmed it's unused everywhere.
Step 3 β Identify Dead Code (verify before removing)
A file/export is safe to remove only if:
- No other file imports it (grep-confirmed)
- It's not referenced in config, sitemap, or route manifest
- It's not a public-facing URL (page.js, route.js)
# Check if a file is imported anywhere
grep -r "from.*my-file\|require.*my-file" --include="*.{js,ts,jsx,tsx}" .
# Check if a component is used anywhere
grep -r "MyComponent" --include="*.{js,ts,jsx,tsx}" .
Step 4 β Consolidate Repeated Logic into Helpers
Look for repeated patterns (metadata blocks, API fetch wrappers, error handlers) that appear in 3+ places.
Good consolidation targets:
- Page-level SEO metadata (Open Graph, Twitter cards, canonical)
- Fetch wrappers with error handling
- Repeated utility functions (slugify, formatDate, truncate)
Bad consolidation targets (leave alone):
- One-off business logic
- Route handlers with different contracts
- Anything touching DB schema or auth
Pattern for shared metadata helper (Next.js):
// lib/socialMetadata.js
export function buildPageMetadata({ title, description, path, image }) {
const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || 'https://yourdomain.com';
const imageUrl = image?.startsWith('http') ? image : `${baseUrl}${image}`;
return {
title,
description,
openGraph: {
title,
description,
url: `${baseUrl}${path}`,
images: [{ url: imageUrl, width: 1200, height: 630, alt: title }],
},
twitter: {
card: 'summary_large_image',
title,
description,
images: [imageUrl],
},
alternates: {
canonical: `${baseUrl}${path}`,
},
};
}
Step 5 β Environment Variable Audit
# List all env vars used in code
grep -r "process\.env\." --include="*.{js,ts,jsx,tsx}" . | grep -oP 'process\.env\.\w+' | sort -u
# Compare against .env.example or .env.local
cat .env.example 2>/dev/null || cat .env.local 2>/dev/null
Flag any env vars used in code but missing from .env.example. Never add secrets to version control.
β¦
FAQ
What is 'dead code'?
Dead code is code that was written but is never actually used anywhere in the application.
Can this tool break my website?
No, the main goal is to prevent breakage. It only removes what it's certain isn't used and makes small, safe changes.
Can I use this on any web app?
Yes, it's particularly useful for web apps built with technologies like Next.js, React, and Node.js, common in fullstack development.
Details
Original description by the author
Safe production cleanup and hardening for vibe-coded fullstack apps (Next.js, React, Node.js, etc.). Removes dead imports, unused files, and broken references without breaking routes or APIs.
Popularity
- GitHub stars
- 48k
- Ranking position
- #6113
- License
- MIT
- Updated
- 10/15/2026
Comments
- β¦
More skills from this repository
00-andruia-consultant
48kHelps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
007
48kLets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
10-andruia-skill-smith
48kHelps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
20-andruia-niche-intelligence
48kLets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.