-
Notifications
You must be signed in to change notification settings - Fork 36
feat: add ai-slop-remover agent for code quality #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| --- | ||
| model: opus | ||
| _base: "{{ _base | default: 'main' }}" | ||
| --- | ||
|
|
||
| # Remove AI Code Slop | ||
|
|
||
| Identify and remove AI-generated code artifacts introduced in this branch. | ||
|
|
||
| ## Diff Analysis | ||
|
|
||
| Analyzing changes against `{{ _base }}`: | ||
|
|
||
| ``` | ||
| Files changed: | ||
| !git diff {{ _base }}...HEAD --stat | ||
|
|
||
| Actual diff: | ||
| !git diff {{ _base }}...HEAD | ||
| ``` | ||
|
|
||
| ## Slop Detection | ||
|
|
||
| Look for and remove: | ||
|
|
||
| ### 1. Excessive Comments | ||
| - Comments that explain obvious code | ||
| - Block comments that restate code | ||
| - Multiple comments on consecutive lines | ||
| - Comments inconsistent with file style | ||
| - "TODO" or "FIXME" left by AI | ||
|
|
||
| Example to remove: | ||
| ```typescript | ||
| // Check if user is valid | ||
| if (!user) { | ||
| return null; | ||
| } | ||
|
|
||
| // Loop through items | ||
| items.forEach(item => { | ||
| // Process the item | ||
| process(item); | ||
| }); | ||
| ``` | ||
|
|
||
| Better: | ||
| ```typescript | ||
| if (!user) return null; | ||
|
|
||
| items.forEach(item => process(item)); | ||
| ``` | ||
|
Comment on lines
+34
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specify language for TypeScript examples. All TypeScript code examples should have language identifiers. Example to remove:
-```typescript
+```typescript
// Check if user is valid
if (!user) {
return null;
}
// Loop through items
items.forEach(item => {
// Process the item
process(item);
});
-```
+```typescript
Better:
-```typescript
+```typescript
if (!user) return null;
items.forEach(item => process(item));
-```
+```typescript🤖 Prompt for AI Agents |
||
|
|
||
| ### 2. Defensive Checks | ||
| - Extra null/undefined checks on validated inputs | ||
| - Redundant type guards after type narrowing | ||
| - Try/catch blocks for functions that don't throw | ||
| - Validation in code paths already validated upstream | ||
|
|
||
| Example to remove: | ||
| ```typescript | ||
| // After already checking user exists | ||
| if (user) { | ||
| if (user.id) { | ||
| try { | ||
| const result = processUser(user); | ||
| } catch (error) { | ||
| // This function never throws | ||
| console.error(error); | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ### 3. Type Casts (`any`) | ||
| - `as any` to bypass type errors | ||
| - `// @ts-ignore` comments | ||
| - `any` typed parameters that should be specific | ||
|
|
||
| Example to remove: | ||
| ```typescript | ||
| const data = response.data as any; // Instead of properly typing | ||
| if ((error as any).statusCode === 404) {} // Instead of type guard | ||
| ``` | ||
|
Comment on lines
+81
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specify language for type cast examples. Add typescript identifier to the code block. Example to remove:
-```typescript
+```typescript
const data = response.data as any; // Instead of properly typing
if ((error as any).statusCode === 404) {} // Instead of type guard
-```
+```typescript🤖 Prompt for AI Agents |
||
|
|
||
| ### 4. Inconsistent Style | ||
| - Logging inconsistent with the file | ||
| - Error handling that doesn't match patterns | ||
| - Variable naming that diverges from conventions | ||
| - Formatting different from surrounding code | ||
| - Excessive whitespace or empty lines | ||
|
|
||
| Example to remove: | ||
| ```typescript | ||
| // If file never logs debug info: | ||
| console.debug("Processing item", item); | ||
|
|
||
| // If file uses throw, not console.error: | ||
| console.error("Failed"); | ||
| ``` | ||
|
Comment on lines
+94
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specify language for inconsistent style examples. Add typescript identifier to the code block. Example to remove:
-```typescript
+```typescript
// If file never logs debug info:
console.debug("Processing item", item);
// If file uses throw, not console.error:
console.error("Failed");
-```
+```typescript🤖 Prompt for AI Agents |
||
|
|
||
| ## Instructions | ||
|
|
||
| For each file with changes: | ||
|
|
||
| 1. Review the actual code changes | ||
| 2. Identify obvious AI slop (unnecessary comments, defensive checks, casts) | ||
| 3. Remove it while preserving functionality | ||
| 4. Ensure remaining code matches file style | ||
| 5. Run: `npm test` to verify no breakage | ||
|
|
||
| Generate a clean, minimal diff that removes only the slop. | ||
|
|
||
| ## Modified Files | ||
|
|
||
| ``` | ||
| !git diff {{ _base }}...HEAD --name-only | ||
| ``` | ||
|
Comment on lines
+116
to
+118
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add language identifier to git diff command block. The fenced code block is missing a language identifier. Specify -```
+```bash
!git diff {{ _base }}...HEAD --name-only
-```
+```🧰 Tools🪛 markdownlint-cli2 (0.18.1)116-116: Fenced code blocks should have a language specified (MD040, fenced-code-language) 🤖 Prompt for AI Agents |
||
|
|
||
| For each file above, review and clean. | ||
|
|
||
| ## Validation | ||
|
|
||
| After cleanup: | ||
| ```bash | ||
| npm test | ||
| npm run lint | ||
| git diff {{ _base }}...HEAD | ||
| ``` | ||
|
|
||
| Ensure diff is minimal and removes only slop, not functionality. | ||
|
|
||
| --- | ||
|
|
||
| **Output**: Show the cleaned diff with brief explanation of what was removed. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add language identifier to git diff command block.
The fenced code block is missing a language identifier. Since it contains a shell command with template variable substitution, use
bashas the language identifier for consistency with the validation section below (line 125) and to satisfy markdown linting requirements.🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
14-14: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents