Skip to content
Skillpedia
General coding48k Β· #6113

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.md

Copy 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

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/vibe-code-cleanup/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

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

  1. 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.
  2. 2Make sure your work is saved in git first, so any batch of changes can be undone.
  3. 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.
  4. 4The agent fixes broken imports, then checks each unused-file candidate by searching the whole project, including config and route lists, before removing it.
  5. 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:

  1. No other file imports it (grep-confirmed)
  2. It's not referenced in config, sitemap, or route manifest
  3. 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.

repo: sickn33/agentic-awesome-skills

Popularity

GitHub stars
48k
Ranking position
#6113
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills