From edmunds-claude-code
Refactor and clean up code following best practices
How this command is triggered — by the user, by Claude, or both
Slash command
/edmunds-claude-code:code-cleanupclaude-sonnet-4-5commands/misc/The summary Claude sees in its command listing — used to decide when to auto-load this command
Clean up and refactor the following code to improve readability, maintainability, and follow best practices. ## Code to Clean $ARGUMENTS ## Cleanup Checklist for Solo Developers ### 1. **Code Smells to Fix** **Naming** - Descriptive variable/function names - Consistent naming conventions (camelCase, PascalCase) - Avoid abbreviations unless obvious - Boolean names start with is/has/can **Functions** - Single responsibility per function - Keep functions small (<50 lines) - Reduce parameters (max 3-4) - Extract complex logic - Avoid side effects where possible **DRY (D...
Clean up and refactor the following code to improve readability, maintainability, and follow best practices.
$ARGUMENTS
Naming
Functions
DRY (Don't Repeat Yourself)
Complexity
TypeScript
any typesJavaScript/TypeScript
// Use optional chaining
const value = obj?.prop?.nested
// Use nullish coalescing
const result = value ?? defaultValue
// Use destructuring
const { name, email } = user
// Use template literals
const message = `Hello, ${name}!`
// Use array methods
const filtered = arr.filter(x => x.active)
React
// Extract custom hooks
const useUserData = () => {
// logic here
}
// Use proper TypeScript types
interface Props {
user: User
onUpdate: (user: User) => void
}
// Avoid prop drilling with composition
<Provider value={data}>
<Component />
</Provider>
Extract Function
// Before
const process = () => {
// 50 lines of code
}
// After
const validate = () => { /* ... */ }
const transform = () => { /* ... */ }
const save = () => { /* ... */ }
const process = () => {
validate()
const data = transform()
save(data)
}
Replace Conditional with Polymorphism
// Before
if (type === 'A') return processA()
if (type === 'B') return processB()
// After
const processors = {
A: processA,
B: processB
}
return processors[type]()
Introduce Parameter Object
// Before
function create(name, email, age, address)
// After
interface UserData {
name: string
email: string
age: number
address: string
}
function create(userData: UserData)
Remove Dead Code
Improve Error Handling
// Before
try { doSomething() } catch (e) { console.log(e) }
// After
try {
doSomething()
} catch (error) {
if (error instanceof ValidationError) {
// Handle validation
} else {
logger.error('Unexpected error', { error })
throw error
}
}
Consistent Formatting
Better Comments
Server vs Client Components
// Move state to client component
'use client'
function Interactive() {
const [state, setState] = useState()
}
// Keep data fetching in server component
async function Page() {
const data = await fetchData()
}
Proper Data Fetching
// Use SWR/React Query for client
const { data } = useSWR('/api/user')
// Use direct fetch in server components
const data = await fetch('/api/user').then(r => r.json())
Focus on practical improvements that make code more maintainable without over-engineering. Balance clean code with pragmatism.
npx claudepluginhub playerzeroone/edmunds-claude-code --plugin edmunds-claude-code7plugins reuse this command
First indexed Jun 20, 2026
Showing the 6 earliest of 7 plugins