vibe-code-cleanup
Skill này làm gì
Công cụ này giúp dọn dẹp và sắp xếp mã trong các ứng dụng web được xây dựng nhanh, bằng cách loại bỏ những phần không cần thiết hoặc bị hỏng mà không thay đổi những gì đã hoạt động. Mục tiêu là làm mã an toàn hơn và dễ bảo trì hơn khi dùng thực tế.
Khi nào nên dùng
- ✓Khi một ứng dụng hoạt động nhưng có lỗi import hoặc mã không dùng đến.
- ✓Trước khi ra mắt ứng dụng hoặc bàn giao cho người khác.
- ✓Khi bạn cần dọn gọn mã mà không thay đổi các tính năng cốt lõi như route hoặc API.
Liên kết skill
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/vibe-code-cleanup/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Hãy dọn dẹp mã của tôi, loại bỏ các phần không dùng và sửa các import bị lỗi.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Công cụ phân tích mã để tìm các import bị lỗi và mã không dùng đến. Nó cẩn thận loại bỏ các phần này, đảm bảo các tính năng quan trọng như route và API vẫn hoạt động.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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.
…
Câu hỏi thường gặp
‘Dead code’ (mã chết) là gì?
Mã chết là mã đã được viết nhưng không bao giờ được dùng ở bất kỳ đâu trong ứng dụng.
Công cụ này có thể làm hỏng website của tôi không?
Không, mục tiêu chính là ngăn việc làm hỏng. Nó chỉ loại bỏ những gì chắc chắn không được dùng và chỉ thực hiện các thay đổi nhỏ, an toàn.
Tôi có thể dùng công cụ này cho mọi ứng dụng web không?
Có, nó đặc biệt hữu ích cho các ứng dụng web xây dựng bằng Next.js, React và Node.js, phổ biến trong phát triển fullstack.
Chi tiết
Mô tả gốc của tác giả
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.
Độ phổ biến
- Sao GitHub
- 48k
- Vị trí xếp hạng
- #6113
- Giấy phép
- MIT
- Cập nhật
- 15/10/2026
Bình luận
- …
Thêm skill từ kho mã này
00-andruia-consultant
48kGiúp agent của bạn bắt đầu hoặc cải thiện các dự án AI. Phân tích mã, gợi ý công cụ và lập kế hoạch hành động bằng tiếng Tây Ban Nha.
007
48kCho phép agent của bạn thực hiện kiểm toán bảo mật và mô hình hóa mối đe dọa. Hữu ích để bảo vệ dự án khỏi các cuộc tấn công và lỗ hổng.
10-andruia-skill-smith
48kGiúp agent của bạn tạo hoặc cải thiện các công cụ AI. Xác định cách công cụ hoạt động, viết tài liệu và kiểm tra cấu trúc.
20-andruia-niche-intelligence
48kGiúp agent của bạn tạo bản tóm tắt về một ngành cụ thể. Hữu ích để hiểu bối cảnh, quy tắc, cách người dùng tương tác và rủi ro của dự án.
Skill tương tự
diffs
394kGiúp agent của bạn tạo một diff có thể chia sẻ về các chỉnh sửa, dưới dạng liên kết xem hoặc file ảnh, thay vì một bản tóm tắt viết tay.
coding-agent
394kGiúp agent của bạn giao một việc lập trình lớn cho Codex, Claude Code hoặc OpenCode chạy nền, rồi theo dõi tiến độ của nó.
gh-issues
394kGiúp agent của bạn tìm issue trên GitHub, chọn những issue cần xử lý và mở pull request với bản sửa, kể cả theo dõi nhận xét đánh giá.