Loading...
Loading...
Use when writing or modifying any code. Enforces naming conventions, function design, and code clarity principles.
npx skill4agent add bumgeunsong/daily-writing-friends code-style// BAD - mixed abstraction levels
function processOrder(order: Order) {
validateOrder(order); // high-level call
const tax = order.total * 0.1; // low-level calculation
await sendConfirmation(order); // high-level call
db.insert('orders', { ...order, tax }); // low-level operation
}
// GOOD - consistent abstraction
function processOrder(order: Order) {
validateOrder(order);
const enrichedOrder = calculateTaxes(order);
await persistOrder(enrichedOrder);
await sendConfirmation(enrichedOrder);
}// BAD
function getDiscount(user: User) {
if (user.isPremium) {
return 0.2;
} else {
return 0;
}
}
// GOOD - guard clause
function getDiscount(user: User) {
if (!user.isPremium) return 0;
return 0.2;
}// BAD
function createUser(data: UserData, sendEmail: boolean) { ... }
// GOOD
function createUser(data: UserData) { ... }
function createUserAndNotify(data: UserData) { ... }// BAD
const d = 7; // days in recovery period
// GOOD
const daysInRecoveryPeriod = 7;// BAD
getUserCmt(), calcRecReq()
// GOOD
getUserComment(), calculateRecoveryRequirement()// BAD
eligible, recovery
// GOOD
isEligible, isRecovering, hasPassedDeadline// BAD
const post = getPosts();
// GOOD
const posts = getPosts();const hasRequiredPostCount = posts.length >= 2;
const isWithinRecoveryWindow = new Date() <= recoveryDeadline;
const canStartRecovery = hasRequiredPostCount && isWithinRecoveryWindow;// BAD
if (streak >= 21) { ... }
// GOOD
const GOLD_BADGE_STREAK_THRESHOLD = 21;
if (streak >= GOLD_BADGE_STREAK_THRESHOLD) { ... }TODO: