Install
openclaw skills install code-smell-analyzerAnalyzes code for improvements including code smells, design patterns, and best practices. Invoke when user asks for code analysis, code review, or suggestions to improve code quality.
openclaw skills install code-smell-analyzerAnalyzes code files for potential improvements including code smells, design patterns, and best practices. Provides suggestions for enhancing readability, maintainability, and performance while preserving functionality.
Invoke this skill when:
Identify any code smells such as:
Suggest appropriate design patterns that could improve the code structure:
Check adherence to language-specific best practices:
Evaluate code clarity:
Assess how easy the code would be to modify and extend:
Identify potential performance optimizations:
For each suggestion, provide:
Clear explanation of the issue or improvement opportunity.
// Show the problematic code
// Show the improved code
Explain why the change would be beneficial.
Priority: High
Current Code:
function processOrder(order) {
// Validate order
if (!order.items || order.items.length === 0) {
throw new Error('Order has no items');
}
if (!order.customer) {
throw new Error('Customer is required');
}
// Calculate totals
let subtotal = 0;
for (const item of order.items) {
subtotal += item.price * item.quantity;
}
const tax = subtotal * 0.1;
const total = subtotal + tax;
// Apply discount
if (order.discountCode) {
total = total * 0.9;
}
// Save to database
db.orders.insert({
...order,
subtotal,
tax,
total,
createdAt: new Date(),
});
// Send confirmation email
emailService.send(order.customer.email, 'Order Confirmed', total);
return {orderId: order.id, total};
}
Suggested Improvement:
function processOrder(order) {
validateOrder(order);
const pricing = calculatePricing(order);
saveOrder(order, pricing);
sendConfirmation(order, pricing.total);
return {orderId: order.id, total: pricing.total};
}
function validateOrder(order) {
if (!order.items?.length) throw new Error('Order has no items');
if (!order.customer) throw new Error('Customer is required');
}
function calculatePricing(order) {
const subtotal = order.items.reduce((sum, item) => sum + item.price * item.quantity, 0);
const tax = subtotal * 0.1;
let total = subtotal + tax;
if (order.discountCode) {
total *= 0.9;
}
return {subtotal, tax, total};
}
function saveOrder(order, pricing) {
db.orders.insert({
...order,
...pricing,
createdAt: new Date(),
});
}
function sendConfirmation(order, total) {
emailService.send(order.customer.email, 'Order Confirmed', total);
}
Rationale:
const/let instead of var?.) and nullish coalescing (??)any type in TypeScriptwith statements)wx:key for list rendering