aiskillstore/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.
This is a copy. The original lives at comeonoliver/ai-code-cleanup.
npx skills add https://github.com/aiskillstore/marketplace --skill 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.
Remove AI slop from this branch
Clean up the code in this pull request
Remove unnecessary comments and defensive code from src/
Patterns:
Example:
// ❌ AI-generated: Obvious comment
// Set the user's name
user.name = name;
// ✅ Clean: Self-documenting code
user.name = name;
Patterns:
Example:
// ❌ 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();
}
Patterns:
any to bypass type issuesas X)@ts-ignore or @ts-expect-error without legitimate reasonExample:
// ❌ 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);
Patterns:
Example:
// ❌ 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);
Patterns:
git diff $(git merge-base HEAD main)..HEAD --name-only
For each changed file:
Input: Remove unnecessary comments from src/auth.js
Output:
## 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
// 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
Input: Remove defensive bloat from src/api/users.js
Output:
## 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
// 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
references/REFACTORING_PLAN.template.md - Refactoring plan template with code smells, before/after metrics, and rollback strategyTake aiskillstore/ai-code-cleanup from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.