ai-code-cleanup
Remove AI-generated code slop from branches. Use after AI-assisted coding sessions to clean up defensive bloat, unnecessary comments, type casts, and style inconsistencies. Focuses on identifying and removing AI artifacts that degrade code quality.
Best use case
ai-code-cleanup is best used when you need a repeatable AI agent workflow instead of a one-off prompt. It is especially useful for teams working in multi. Remove AI-generated code slop from branches. Use after AI-assisted coding sessions to clean up defensive bloat, unnecessary comments, type casts, and style inconsistencies. Focuses on identifying and removing AI artifacts that degrade code quality.
Remove AI-generated code slop from branches. Use after AI-assisted coding sessions to clean up defensive bloat, unnecessary comments, type casts, and style inconsistencies. Focuses on identifying and removing AI artifacts that degrade code quality.
Users should expect a more consistent workflow output, faster repeated execution, and less time spent rewriting prompts from scratch.
Practical example
Example input
Use the "ai-code-cleanup" skill to help with this workflow task. Context: Remove AI-generated code slop from branches. Use after AI-assisted coding sessions to clean up defensive bloat, unnecessary comments, type casts, and style inconsistencies. Focuses on identifying and removing AI artifacts that degrade code quality.
Example output
A structured workflow result with clearer steps, more consistent formatting, and an output that is easier to reuse in the next run.
When to use this skill
- Use this skill when you want a reusable workflow rather than writing the same prompt again and again.
When not to use this skill
- Do not use this when you only need a one-off answer and do not need a reusable workflow.
- Do not use it if you cannot install or maintain the related files, repository context, or supporting tools.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/ai-code-cleanup/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How ai-code-cleanup Compares
| Feature / Agent | ai-code-cleanup | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Remove AI-generated code slop from branches. Use after AI-assisted coding sessions to clean up defensive bloat, unnecessary comments, type casts, and style inconsistencies. Focuses on identifying and removing AI artifacts that degrade code quality.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Cursor vs Codex for AI Workflows
Compare Cursor and Codex for AI coding workflows, repository assistance, debugging, refactoring, and reusable developer skills.
SKILL.md Source
# AI Code Cleanup
This skill identifies and removes AI-generated artifacts that degrade code quality, including defensive bloat, unnecessary comments, type casts, and style inconsistencies.
## When to Use This Skill
- After AI-assisted coding sessions
- Before code reviews or merging branches
- When cleaning up code that feels "over-engineered"
- When removing unnecessary defensive code
- When standardizing code style after AI generation
- When preparing code for production
## What This Skill Does
1. **Identifies AI Artifacts**: Detects patterns typical of AI-generated code
2. **Removes Bloat**: Eliminates unnecessary defensive code and comments
3. **Fixes Type Issues**: Removes unnecessary type casts and workarounds
4. **Standardizes Style**: Ensures consistency with project conventions
5. **Preserves Functionality**: Maintains code behavior while improving quality
6. **Validates Changes**: Ensures code still compiles and tests pass
## How to Use
### Clean Up Branch
```
Remove AI slop from this branch
```
```
Clean up the code in this pull request
```
### Specific Cleanup
```
Remove unnecessary comments and defensive code from src/
```
## Slop Patterns to Remove
### 1. Unnecessary Comments
**Patterns:**
- Comments explaining obvious code
- Comments inconsistent with file's documentation style
- Redundant comments that restate the code
- Over-documentation of simple operations
**Example:**
```javascript
// ❌ AI-generated: Obvious comment
// Set the user's name
user.name = name;
// ✅ Clean: Self-documenting code
user.name = name;
```
### 2. Defensive Bloat
**Patterns:**
- Extra try/catch blocks abnormal for that codebase
- Defensive null/undefined checks on trusted paths
- Redundant input validation when callers already validate
- Error handling that can never trigger
**Example:**
```javascript
// ❌ AI-generated: Unnecessary defensive code
function processUser(user) {
try {
if (user && user.name && typeof user.name === 'string') {
return user.name.toUpperCase();
}
return null;
} catch (error) {
console.error(error);
return null;
}
}
// ✅ Clean: Trust the input, handle real errors
function processUser(user) {
return user.name.toUpperCase();
}
```
### 3. Type Workarounds
**Patterns:**
- Casts to `any` to bypass type issues
- Unnecessary type assertions (`as X`)
- `@ts-ignore` or `@ts-expect-error` without legitimate reason
- Overly complex generic constraints
**Example:**
```typescript
// ❌ AI-generated: Type workaround
const data = response.data as any;
const result = processData(data as ProcessedData);
// ✅ Clean: Proper typing
const data = response.data;
const result = processData(data);
```
### 4. Style Inconsistencies
**Patterns:**
- Naming conventions different from rest of file
- Formatting that doesn't match surrounding code
- Import organization inconsistent with file patterns
- Variable declarations inconsistent with file style
**Example:**
```javascript
// ❌ AI-generated: Inconsistent style
const UserData = fetchUser();
var processedData = process(UserData);
let FinalResult = format(processedData);
// ✅ Clean: Consistent style
const userData = fetchUser();
const processedData = process(userData);
const finalResult = format(processedData);
```
### 5. AI Tells
**Patterns:**
- Unnecessary emoji usage in code or comments
- Overly verbose variable names
- Redundant intermediate variables
- "Just in case" code with no actual use case
## Cleanup Process
### 1. Get the Diff
```bash
git diff $(git merge-base HEAD main)..HEAD --name-only
```
### 2. Analyze Each File
For each changed file:
- Read the full file to understand existing style
- Identify patterns from slop categories
- Make surgical edits to remove slop
- Preserve functionality
### 3. Verification
- Ensure code still compiles/runs
- Changes should reduce code, not add more
- Run tests to verify behavior
- Check for any regressions
## Examples
### Example 1: Comment Cleanup
**Input**: Remove unnecessary comments from `src/auth.js`
**Output**:
```markdown
## AI Code Cleanup: src/auth.js
### Removed
- 12 redundant comments explaining obvious code
- 3 comments inconsistent with file style
- 5 over-documented simple operations
### Changes
```javascript
// Before
// Function to validate user email
// Takes email string as input
// Returns boolean indicating validity
function validateEmail(email) {
// Check if email is not empty
if (!email) {
return false; // Return false if empty
}
// Return regex test result
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
}
// After
function validateEmail(email) {
if (!email) return false;
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
}
```
### Result
- Lines reduced: 12 → 4
- Functionality preserved
- Tests pass
```
### Example 2: Defensive Bloat Removal
**Input**: Remove defensive bloat from `src/api/users.js`
**Output**:
```markdown
## AI Code Cleanup: src/api/users.js
### Removed
- 3 unnecessary try/catch blocks
- 8 redundant null checks on validated inputs
- 2 error handlers that can never trigger
### Changes
```javascript
// Before
async function getUser(userId) {
try {
if (!userId || typeof userId !== 'string') {
throw new Error('Invalid userId');
}
const user = await db.users.findById(userId);
if (user && user.id) {
return user;
}
return null;
} catch (error) {
console.error(error);
throw error;
}
}
// After
async function getUser(userId) {
const user = await db.users.findById(userId);
return user || null;
}
```
### Result
- Code reduced: 15 lines → 3 lines
- Functionality preserved
- Error handling appropriate for context
```
## Reference Files
- **`references/REFACTORING_PLAN.template.md`** - Refactoring plan template with code smells, before/after metrics, and rollback strategy
## Best Practices
### Cleanup Guidelines
1. **Preserve Functionality**: Only remove code that doesn't affect behavior
2. **Maintain Style**: Follow existing project conventions
3. **Keep Real Errors**: Don't remove legitimate error handling
4. **Test After Changes**: Always verify code still works
5. **Incremental**: Make changes incrementally, test as you go
### What to Keep
- Legitimate error handling
- Necessary type assertions
- Helpful comments that add context
- Defensive code for untrusted inputs
- Style that matches the codebase
### What to Remove
- Obvious comments
- Unnecessary defensive code
- Type workarounds
- Style inconsistencies
- AI-generated artifacts
## Related Use Cases
- Post-AI coding cleanup
- Code review preparation
- Code quality improvement
- Style standardization
- Removing technical debtRelated Skills
codebase-cleanup-tech-debt
You are a technical debt expert specializing in identifying, quantifying, and prioritizing technical debt in software projects. Analyze the codebase to uncover debt, assess its impact, and create acti
codebase-cleanup-refactor-clean
You are a code refactoring expert specializing in clean code principles, SOLID design patterns, and modern software engineering best practices. Analyze and refactor the provided code to improve its quality, maintainability, and performance.
codebase-cleanup-deps-audit
You are a dependency security expert specializing in vulnerability scanning, license compliance, and supply chain security. Analyze project dependencies for known vulnerabilities, licensing issues, outdated packages, and provide actionable remediation strategies.
aws-cost-cleanup
Automated cleanup of unused AWS resources to reduce costs
azure-quotas
Check/manage Azure quotas and usage across providers. For deployment planning, capacity validation, region selection. WHEN: "check quotas", "service limits", "current usage", "request quota increase", "quota exceeded", "validate capacity", "regional availability", "provisioning limits", "vCPU limit", "how many vCPUs available in my subscription".
raindrop-io
Manage Raindrop.io bookmarks with AI assistance. Save and organize bookmarks, search your collection, manage reading lists, and organize research materials. Use when working with bookmarks, web research, reading lists, or when user mentions Raindrop.io.
zlibrary-to-notebooklm
自动从 Z-Library 下载书籍并上传到 Google NotebookLM。支持 PDF/EPUB 格式,自动转换,一键创建知识库。
discover-skills
当你发现当前可用的技能都不够合适(或用户明确要求你寻找技能)时使用。本技能会基于任务目标和约束,给出一份精简的候选技能清单,帮助你选出最适配当前任务的技能。
web-performance-seo
Fix PageSpeed Insights/Lighthouse accessibility "!" errors caused by contrast audit failures (CSS filters, OKLCH/OKLAB, low opacity, gradient text, image backgrounds). Use for accessibility-driven SEO/performance debugging and remediation.
project-to-obsidian
将代码项目转换为 Obsidian 知识库。当用户提到 obsidian、项目文档、知识库、分析项目、转换项目 时激活。 【激活后必须执行】: 1. 先完整阅读本 SKILL.md 文件 2. 理解 AI 写入规则(默认到 00_Inbox/AI/、追加式、统一 Schema) 3. 执行 STEP 0: 使用 AskUserQuestion 询问用户确认 4. 用户确认后才开始 STEP 1 项目扫描 5. 严格按 STEP 0 → 1 → 2 → 3 → 4 顺序执行 【禁止行为】: - 禁止不读 SKILL.md 就开始分析项目 - 禁止跳过 STEP 0 用户确认 - 禁止直接在 30_Resources 创建(先到 00_Inbox/AI/) - 禁止自作主张决定输出位置
obsidian-helper
Obsidian 智能笔记助手。当用户提到 obsidian、日记、笔记、知识库、capture、review 时激活。 【激活后必须执行】: 1. 先完整阅读本 SKILL.md 文件 2. 理解 AI 写入三条硬规矩(00_Inbox/AI/、追加式、白名单字段) 3. 按 STEP 0 → STEP 1 → ... 顺序执行 4. 不要跳过任何步骤,不要自作主张 【禁止行为】: - 禁止不读 SKILL.md 就开始工作 - 禁止跳过用户确认步骤 - 禁止在非 00_Inbox/AI/ 位置创建新笔记(除非用户明确指定)
internationalizing-websites
Adds multi-language support to Next.js websites with proper SEO configuration including hreflang tags, localized sitemaps, and language-specific content. Use when adding new languages, setting up i18n, optimizing for international SEO, or when user mentions localization, translation, multi-language, or specific languages like Japanese, Korean, Chinese.