AI models are trained to be helpful, which often means they are overly verbose. They explain the obvious, repeat patterns unnecessarily, and write "safe" code that lacks elegance.
The Symptoms
1. The "Try-Catch" Everything
AI loves to wrap everything in a try-catch block, even when it's not needed or when the error handling is just console.log(error).
**AI Code:**
async function getData() {
try {
const response = await fetch('/api/data');
const json = await response.json();
return json;
} catch (error) {
console.error("Error fetching data:", error);
return null;
}
}
**Human Refactor:**
// Let the caller handle errors, or use a global boundary
const getData = async () =>
(await fetch('/api/data')).json();
2. The Comment Echo
AI often writes comments that just repeat what the code says.
**AI Code:**
# Increment i by 1
i = i + 1
# Check if user is valid
if user.is_valid:
return True
**Human Refactor:**
i += 1
if user.is_valid:
return True
*(No comments needed. The code speaks for itself.)*
3. Structural Repetition
AI models are autocomplete engines. Once they start a pattern, they stick to it, even if it leads to redundancy.
**AI Code:**
.header { margin: 10px; padding: 20px; color: blue; }
.footer { margin: 10px; padding: 20px; color: blue; }
.sidebar { margin: 10px; padding: 20px; color: blue; }
**Human Refactor:**
.container {
margin: 10px;
padding: 20px;
color: blue;
}
The Cure
Refactoring AI code is about **subtraction**.