feat: add review-work and ai-slop-remover as built-in skills, add remove-ai-slops command
Embed user-level skills into the plugin's built-in system so they ship with the product rather than requiring per-user configuration. - review-work: 5-agent parallel post-implementation review orchestrator - ai-slop-remover: per-file AI-generated code smell detector and remover - /remove-ai-slops: command that orchestrates parallel ai-slop-remover runs
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { describe, test, expect } from "bun:test"
|
||||
import { loadBuiltinCommands } from "./commands"
|
||||
import { HANDOFF_TEMPLATE } from "./templates/handoff"
|
||||
import { REMOVE_AI_SLOPS_TEMPLATE } from "./templates/remove-ai-slops"
|
||||
import type { BuiltinCommandName } from "./types"
|
||||
|
||||
describe("loadBuiltinCommands", () => {
|
||||
@@ -60,6 +61,77 @@ describe("loadBuiltinCommands", () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe("loadBuiltinCommands — remove-ai-slops", () => {
|
||||
test("should include remove-ai-slops command in loaded commands", () => {
|
||||
//#given
|
||||
const disabledCommands: BuiltinCommandName[] = []
|
||||
|
||||
//#when
|
||||
const commands = loadBuiltinCommands(disabledCommands)
|
||||
|
||||
//#then
|
||||
expect(commands["remove-ai-slops"]).toBeDefined()
|
||||
expect(commands["remove-ai-slops"].name).toBe("remove-ai-slops")
|
||||
})
|
||||
|
||||
test("should exclude remove-ai-slops when disabled", () => {
|
||||
//#given
|
||||
const disabledCommands: BuiltinCommandName[] = ["remove-ai-slops"]
|
||||
|
||||
//#when
|
||||
const commands = loadBuiltinCommands(disabledCommands)
|
||||
|
||||
//#then
|
||||
expect(commands["remove-ai-slops"]).toBeUndefined()
|
||||
})
|
||||
|
||||
test("should include remove-ai-slops template content in command template", () => {
|
||||
//#given - no disabled commands
|
||||
|
||||
//#when
|
||||
const commands = loadBuiltinCommands()
|
||||
|
||||
//#then
|
||||
expect(commands["remove-ai-slops"].template).toContain(REMOVE_AI_SLOPS_TEMPLATE)
|
||||
})
|
||||
|
||||
test("should have correct description for remove-ai-slops", () => {
|
||||
//#given - no disabled commands
|
||||
|
||||
//#when
|
||||
const commands = loadBuiltinCommands()
|
||||
|
||||
//#then
|
||||
expect(commands["remove-ai-slops"].description).toContain("AI-generated code smells")
|
||||
})
|
||||
})
|
||||
|
||||
describe("REMOVE_AI_SLOPS_TEMPLATE", () => {
|
||||
test("should include phase structure", () => {
|
||||
//#given - the template string
|
||||
|
||||
//#when / #then
|
||||
expect(REMOVE_AI_SLOPS_TEMPLATE).toContain("Identify Changed Files")
|
||||
expect(REMOVE_AI_SLOPS_TEMPLATE).toContain("Parallel AI Slop Removal")
|
||||
expect(REMOVE_AI_SLOPS_TEMPLATE).toContain("Critical Review")
|
||||
})
|
||||
|
||||
test("should reference ai-slop-remover skill", () => {
|
||||
//#given - the template string
|
||||
|
||||
//#when / #then
|
||||
expect(REMOVE_AI_SLOPS_TEMPLATE).toContain("ai-slop-remover")
|
||||
})
|
||||
|
||||
test("should include safety verification checklist", () => {
|
||||
//#given - the template string
|
||||
|
||||
//#when / #then
|
||||
expect(REMOVE_AI_SLOPS_TEMPLATE).toContain("Safety Verification")
|
||||
expect(REMOVE_AI_SLOPS_TEMPLATE).toContain("Behavior Preservation")
|
||||
})
|
||||
})
|
||||
|
||||
describe("HANDOFF_TEMPLATE", () => {
|
||||
test("should include session reading instruction", () => {
|
||||
//#given - the template string
|
||||
|
||||
@@ -6,6 +6,7 @@ import { STOP_CONTINUATION_TEMPLATE } from "./templates/stop-continuation"
|
||||
import { REFACTOR_TEMPLATE } from "./templates/refactor"
|
||||
import { START_WORK_TEMPLATE } from "./templates/start-work"
|
||||
import { HANDOFF_TEMPLATE } from "./templates/handoff"
|
||||
import { REMOVE_AI_SLOPS_TEMPLATE } from "./templates/remove-ai-slops"
|
||||
|
||||
const BUILTIN_COMMAND_DEFINITIONS: Record<BuiltinCommandName, Omit<CommandDefinition, "name">> = {
|
||||
"init-deep": {
|
||||
@@ -77,6 +78,16 @@ $ARGUMENTS
|
||||
template: `<command-instruction>
|
||||
${STOP_CONTINUATION_TEMPLATE}
|
||||
</command-instruction>`,
|
||||
},
|
||||
"remove-ai-slops": {
|
||||
description: "(builtin) Remove AI-generated code smells from branch changes and critically review the results",
|
||||
template: `<command-instruction>
|
||||
${REMOVE_AI_SLOPS_TEMPLATE}
|
||||
</command-instruction>
|
||||
|
||||
<user-request>
|
||||
$ARGUMENTS
|
||||
</user-request>`,
|
||||
},
|
||||
handoff: {
|
||||
description: "(builtin) Create a detailed context summary for continuing work in a new session",
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
export const REMOVE_AI_SLOPS_TEMPLATE = `# Remove AI Slops Command
|
||||
|
||||
## What this command does
|
||||
Analyzes all files changed in the current branch (compared to parent commit), removes AI-generated code smells in parallel, then critically reviews the changes to ensure safety and behavior preservation. Fixes any issues found during review.
|
||||
|
||||
## Step 0: Task Planning
|
||||
|
||||
Use TodoWrite to create the task list:
|
||||
1. Get changed files from branch
|
||||
2. Run ai-slop-remover on each file in parallel
|
||||
3. Critically review all changes
|
||||
4. Fix any issues found
|
||||
|
||||
## Role Definition
|
||||
You are a senior code quality engineer specialized in identifying and removing AI-generated code patterns while preserving original functionality. You have deep expertise in code review, refactoring safety, and behavioral preservation.
|
||||
|
||||
## Process
|
||||
|
||||
### Phase 1: Identify Changed Files
|
||||
Execute the following command to get all changed files in the current branch:
|
||||
\\\`\\\`\\\`bash
|
||||
git diff $(git merge-base main HEAD)..HEAD --name-only
|
||||
\\\`\\\`\\\`
|
||||
|
||||
### Phase 2: Parallel AI Slop Removal
|
||||
For each changed file, spawn an agent in parallel using the Task tool with the ai-slop-remover skill:
|
||||
|
||||
\\\`\\\`\\\`
|
||||
task(category="quick", load_skills=["ai-slop-remover"], run_in_background=true, description="Remove AI slops from {filename}", prompt="Remove AI slops from: {file_path}")
|
||||
\\\`\\\`\\\`
|
||||
|
||||
**CRITICAL**: Launch ALL agents in a SINGLE message with multiple Task tool calls for maximum parallelism.
|
||||
|
||||
### Phase 3: Critical Review
|
||||
After all ai-slop-remover agents complete, perform a critical review with the following checklist:
|
||||
|
||||
**Safety Verification**:
|
||||
- [ ] No functional logic was accidentally removed
|
||||
- [ ] All error handling is preserved
|
||||
- [ ] Type hints remain correct and complete
|
||||
- [ ] Import statements are still valid
|
||||
- [ ] No breaking changes to public APIs
|
||||
|
||||
**Behavior Preservation**:
|
||||
- [ ] Return values unchanged
|
||||
- [ ] Side effects unchanged
|
||||
- [ ] Exception behavior unchanged
|
||||
- [ ] Edge case handling preserved
|
||||
|
||||
**Code Quality**:
|
||||
- [ ] Removed changes are genuinely AI slop (not intentional patterns)
|
||||
- [ ] Remaining code follows project conventions
|
||||
- [ ] No orphaned code or dead references
|
||||
|
||||
### Phase 4: Fix Issues
|
||||
If any issues are found during critical review:
|
||||
1. Identify the specific problem
|
||||
2. Explain why it's a problem
|
||||
3. Use git checkout to revert the changes from ai-slop-remover
|
||||
4. If remaining ai-slops are found after reverting, remove them by editing the file yourself - with parallel tool calls, per-file
|
||||
5. Verify the fix doesn't introduce new issues
|
||||
|
||||
## Output Format
|
||||
|
||||
### Summary Report
|
||||
\\\`\\\`\\\`
|
||||
## AI Slop Removal Summary
|
||||
|
||||
### Files Processed
|
||||
- file1.py: X changes
|
||||
- file2.py: Y changes
|
||||
|
||||
### Critical Review Results
|
||||
- Safety: PASS/FAIL
|
||||
- Behavior: PASS/FAIL
|
||||
- Quality: PASS/FAIL
|
||||
|
||||
### Issues Found & Fixed
|
||||
1. [Issue description] -> [Fix applied]
|
||||
|
||||
### Final Status
|
||||
[CLEAN / ISSUES FIXED / REQUIRES ATTENTION]
|
||||
\\\`\\\`\\\`
|
||||
|
||||
## Quality Assurance
|
||||
- NEVER remove code that serves a functional purpose
|
||||
- ALWAYS verify changes compile/parse correctly
|
||||
- ALWAYS preserve test coverage
|
||||
- If uncertain about a change, err on the side of keeping the original code`
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { CommandDefinition } from "../claude-code-command-loader"
|
||||
|
||||
export type BuiltinCommandName = "init-deep" | "ralph-loop" | "cancel-ralph" | "ulw-loop" | "refactor" | "start-work" | "stop-continuation" | "handoff"
|
||||
export type BuiltinCommandName = "init-deep" | "ralph-loop" | "cancel-ralph" | "ulw-loop" | "refactor" | "start-work" | "stop-continuation" | "handoff" | "remove-ai-slops"
|
||||
|
||||
export interface BuiltinCommandConfig {
|
||||
disabled_commands?: BuiltinCommandName[]
|
||||
|
||||
Reference in New Issue
Block a user