بنقرة واحدة
refactor-assistant
智能代码重构,提供设计模式建议、代码异味检测和保持行为不变的安全转换策略。
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
智能代码重构,提供设计模式建议、代码异味检测和保持行为不变的安全转换策略。
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
自动分析B站视频内容,下载视频并拆解成帧图片,使用AI分析并生成详细的专题文档或实操教程。
设计RESTful API并生成OpenAPI/Swagger规范文档,遵循行业最佳实践。包括端点命名、请求/响应模式和错误处理模式。
为GitHub Actions、GitLab CI、Azure DevOps和Jenkins生成CI/CD流水线,包含构建、测试、部署阶段、缓存和密钥管理。
全面的代码审查技能,分析代码质量、识别问题、安全漏洞,并提供带严重性评级的改进建议。
设计和优化数据库模式,支持PostgreSQL、MySQL、SQLite和MongoDB。包括ER建模、规范化、索引优化和迁移脚本生成。
创建和管理多容器应用的Docker Compose配置,包含生产级设置、健康检查和网络配置。
| name | refactor-assistant |
| description | 智能代码重构,提供设计模式建议、代码异味检测和保持行为不变的安全转换策略。 |
| metadata | {"short-description":"使用设计模式重构代码"} |
Improve code quality through systematic refactoring with design pattern recommendations.
/refactor commandYou are a refactoring expert that improves code quality while preserving behavior.
// ❌ Before: Long method with multiple responsibilities
function processOrder(order: Order) {
// Validate order
if (!order.items.length) throw new Error('Empty order');
if (!order.customer) throw new Error('No customer');
// Calculate total
let total = 0;
for (const item of order.items) {
total += item.price * item.quantity;
if (item.discount) {
total -= item.discount;
}
}
// Apply tax
const tax = total * 0.1;
total += tax;
// Save and notify
db.save(order);
emailService.send(order.customer.email, `Order total: ${total}`);
}
// ✅ After: Small, focused methods
function processOrder(order: Order) {
validateOrder(order);
const total = calculateTotal(order);
saveAndNotify(order, total);
}
function validateOrder(order: Order): void {
if (!order.items.length) throw new Error('Empty order');
if (!order.customer) throw new Error('No customer');
}
function calculateTotal(order: Order): number {
const subtotal = order.items.reduce((sum, item) => {
const itemTotal = item.price * item.quantity - (item.discount ?? 0);
return sum + itemTotal;
}, 0);
return subtotal * 1.1; // Include 10% tax
}
// ❌ Before: Switch statement for different behaviors
function calculateShipping(order: Order): number {
switch (order.shippingMethod) {
case 'standard': return order.weight * 0.5;
case 'express': return order.weight * 1.5 + 10;
case 'overnight': return order.weight * 3 + 25;
default: throw new Error('Unknown method');
}
}
// ✅ After: Strategy pattern
interface ShippingStrategy {
calculate(order: Order): number;
}
class StandardShipping implements ShippingStrategy {
calculate(order: Order): number {
return order.weight * 0.5;
}
}
class ExpressShipping implements ShippingStrategy {
calculate(order: Order): number {
return order.weight * 1.5 + 10;
}
}
class ShippingCalculator {
constructor(private strategy: ShippingStrategy) {}
calculate(order: Order): number {
return this.strategy.calculate(order);
}
}
// ✅ Factory for creating different notification types
interface Notification {
send(message: string): Promise<void>;
}
class NotificationFactory {
static create(type: 'email' | 'sms' | 'push'): Notification {
switch (type) {
case 'email': return new EmailNotification();
case 'sms': return new SmsNotification();
case 'push': return new PushNotification();
}
}
}
// Usage
const notification = NotificationFactory.create('email');
await notification.send('Hello!');
refactoring, design-patterns, code-quality, clean-code, architecture