From doover-development
Clean up AI-generated code drift after solving a hard problem. Run this in the same chat where you built your solution — it uses conversation context to understand what to keep and what to clean. Works across single or multiple repos.
npx claudepluginhub getdoover/doover-skills --plugin doover-developmentThis skill uses the workspace's default tool permissions.
Clean up code that has drifted from convention during an extended AI-assisted debugging or development session. This skill is designed to be run **in the same chat window** where the solution was built, so that the full conversation context (the problem, failed approaches, and final solution) is available.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Checks Next.js compilation errors using a running Turbopack dev server after code edits. Fixes actionable issues before reporting complete. Replaces `next build`.
Clean up code that has drifted from convention during an extended AI-assisted debugging or development session. This skill is designed to be run in the same chat window where the solution was built, so that the full conversation context (the problem, failed approaches, and final solution) is available.
Step 1: Context Summary → Review conversation, summarize problem + solution
Step 2: Repo Discovery → Find all repos with uncommitted changes
Step 3: Diff Analysis → Get and categorize every change
Step 4: Cleanup Plan → Present plan to user for approval
Step 5: Apply Cleanup → Edit files, preserving the solution
Step 6: Verification → Confirm nothing is broken
Step 7: Summary → Report what was cleaned
Review the full conversation history to build a mental model of:
Present a brief summary to the user:
Before I clean up, let me confirm I understand the situation:
**Problem:** [1-2 sentences]
**Solution:** [1-2 sentences describing the core fix/feature]
**Key files:** [list the files central to the solution]
Does this look right?
Use AskUserQuestion to confirm. Do not proceed until the user agrees the summary is accurate. If the user corrects something, update your understanding before continuing.
Determine which repositories have uncommitted changes.
Single repo mode: If the current working directory is a git repo, check it:
git status --porcelain
git diff --stat
git diff --cached --stat
Multi-repo mode: If the user mentions multiple repos, or if the conversation involved work across multiple directories, check each one. Also check for common multi-repo layouts:
# Check if cwd contains multiple repos
for dir in */; do
if [ -d "$dir/.git" ]; then
echo "=== $dir ==="
git -C "$dir" status --porcelain
fi
done
For each repo with changes, record:
If the user has already committed some changes and the diff is between commits rather than uncommitted, ask the user which commit range to examine. Support comparing against:
HEAD~1)main..HEAD)For each repo with changes, get the full diff:
# Uncommitted changes
git diff
git diff --cached
# Or if comparing commits
git diff <base>..<head>
For every changed file, categorize each change as one of:
| Category | Description | Action |
|---|---|---|
| Essential | Directly implements the solution | Keep as-is |
| Essential but messy | Part of the solution but poorly written | Refactor |
| Abandoned approach | Leftover from a failed attempt | Revert |
| Debug artifact | Print statements, console.logs, temporary comments | Remove |
| Unnecessary addition | Extra imports, unused variables, redundant error handling | Remove |
| Style drift | Working code that breaks project conventions | Restyle |
| Over-engineering | Abstractions or patterns beyond what's needed | Simplify |
How to identify each category:
print(), console.log(), # DEBUG, # TODO: remove, breakpoint(), temporary test values, hardcoded test datafrom x import y) but the new code uses another (e.g., import x; x.y). Or inconsistent naming conventions, spacing, etc.Present a file-by-file cleanup plan to the user. For each file:
### `path/to/file.py`
- **Keep**: [describe essential changes]
- **Refactor**: [describe what will be cleaned up and how]
- **Remove**: [describe what will be removed and why]
- **Revert**: [describe what will be reverted to original]
At the end of the plan, include:
**Files to fully revert** (no solution-relevant changes):
- path/to/file1.py — only contained debug logging
- path/to/file2.py — leftover from abandoned approach
**Risk assessment**: [Low/Medium/High] — [brief justification]
Use AskUserQuestion to get approval:
Do not proceed until the user approves.
Execute the cleanup plan file by file. For each file:
git checkout -- <file> to restore the originalgit checkout -- <file> or rm <file> as appropriateCleanup principles:
After cleanup, verify the solution still works.
Always do:
# Check for syntax errors (Python)
python -m py_compile <file>
# Check for syntax errors (JavaScript/TypeScript)
npx --yes acorn --ecma2020 <file> # or similar
# Check imports resolve
python -c "import <module>"
If the project has tests:
# Run relevant tests
pytest <test_file_or_directory>
npm test
If the project has a build step:
# Verify it builds
npm run build
uv run export-config
If the user previously ran a specific verification command during the conversation (check the conversation history), run that same command again.
If verification fails:
Report to the user:
## Rebase Complete
**Repos cleaned:** [count]
### [repo-name]
- **Files modified:** [count]
- **Files reverted:** [count]
- **Lines added (net):** [count]
- **Lines removed (net):** [count]
- **Verification:** [passed/failed with details]
**Changes cleaned up:**
- [Brief list of what was removed/refactored]
**Solution preserved:**
- [Brief list of what was kept, confirming the core solution is intact]
Ask the user if they'd like to:
git diff)When working across multiple repos:
This prevents partial cleanup states where one repo is cleaned but another isn't.
No uncommitted changes:
If git status shows a clean working tree, check if the user has already committed. Look at recent commits:
git log --oneline -5
If the solution was already committed, offer to do an interactive rebase-style cleanup by examining the diff between the solution commit(s) and the branch point. Apply cleanup edits as a new commit on top.
Staged vs unstaged changes: If some changes are staged and others aren't, note this in the plan. Ask the user if the staging is intentional before proceeding.
New files: For entirely new files, apply the same categorization. If a new file is entirely from an abandoned approach, it should be deleted. If it's part of the solution, clean it up like any other file.
Binary files / generated files: Skip these. Note them in the summary but don't attempt to clean them.