tdd-workflows-tdd-refactor by sickn33/antigravity-awesome-skills
npx skills add https://github.com/sickn33/antigravity-awesome-skills --skill tdd-workflows-tdd-refactorresources/implementation-playbook.md。使用全面的测试安全网,自信地进行代码重构:
[扩展思考:此工具使用 tdd-orchestrator 代理(opus 模型)进行复杂的重构,同时保持所有测试通过。它应用设计模式,提高代码质量,并在全面测试覆盖的安全保障下优化性能。]
使用 Task 工具并设置 subagent_type="tdd-orchestrator" 来执行安全重构。
提示:"重构此代码,同时保持所有测试通过:$ARGUMENTS。应用 TDD 重构阶段:
1. 预评估
2. 代码异味检测
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
4. SOLID 原则
5. 重构技术
6. 性能优化
7. 增量步骤
8. 架构演进
9. 安全验证
10. 高级模式
提交前:
如果测试失败:
重构前:
class OrderProcessor {
processOrder(order: Order): ProcessResult {
// Validation
if (!order.customerId || order.items.length === 0) {
return { success: false, error: "Invalid order" };
}
// Calculate totals
let subtotal = 0;
for (const item of order.items) {
subtotal += item.price * item.quantity;
}
let total = subtotal + (subtotal * 0.08) + (subtotal > 100 ? 0 : 15);
// Process payment...
// Update inventory...
// Send confirmation...
}
}
重构后:
class OrderProcessor {
async processOrder(order: Order): Promise<ProcessResult> {
const validation = this.validateOrder(order);
if (!validation.isValid) return ProcessResult.failure(validation.error);
const orderTotal = OrderTotal.calculate(order);
const inventoryCheck = await this.inventoryService.checkAvailability(order.items);
if (!inventoryCheck.available) return ProcessResult.failure(inventoryCheck.reason);
await this.paymentService.processPayment(order.paymentMethod, orderTotal.total);
await this.inventoryService.reserveItems(order.items);
await this.notificationService.sendOrderConfirmation(order, orderTotal);
return ProcessResult.success(order.id, orderTotal.total);
}
private validateOrder(order: Order): ValidationResult {
if (!order.customerId) return ValidationResult.invalid("Customer ID required");
if (order.items.length === 0) return ValidationResult.invalid("Order must contain items");
return ValidationResult.valid();
}
}
应用的技术: 提取方法、值对象、依赖注入、异步模式
待重构的代码:$ARGUMENTS"
每周安装次数
115
代码仓库
GitHub 星标数
27.1K
首次出现时间
2026年1月28日
安全审计
安装于
opencode109
gemini-cli108
github-copilot104
codex104
cursor100
claude-code93
resources/implementation-playbook.md.Refactor code with confidence using comprehensive test safety net:
[Extended thinking: This tool uses the tdd-orchestrator agent (opus model) for sophisticated refactoring while maintaining all tests green. It applies design patterns, improves code quality, and optimizes performance with the safety of comprehensive test coverage.]
Use Task tool with subagent_type="tdd-orchestrator" to perform safe refactoring.
Prompt: "Refactor this code while keeping all tests green: $ARGUMENTS. Apply TDD refactor phase:
1. Pre-Assessment
2. Code Smell Detection
3. Design Patterns
4. SOLID Principles
5. Refactoring Techniques
6. Performance Optimization
7. Incremental Steps
8. Architecture Evolution
9. Safety Verification
10. Advanced Patterns
Before committing:
If tests fail:
Before:
class OrderProcessor {
processOrder(order: Order): ProcessResult {
// Validation
if (!order.customerId || order.items.length === 0) {
return { success: false, error: "Invalid order" };
}
// Calculate totals
let subtotal = 0;
for (const item of order.items) {
subtotal += item.price * item.quantity;
}
let total = subtotal + (subtotal * 0.08) + (subtotal > 100 ? 0 : 15);
// Process payment...
// Update inventory...
// Send confirmation...
}
}
After:
class OrderProcessor {
async processOrder(order: Order): Promise<ProcessResult> {
const validation = this.validateOrder(order);
if (!validation.isValid) return ProcessResult.failure(validation.error);
const orderTotal = OrderTotal.calculate(order);
const inventoryCheck = await this.inventoryService.checkAvailability(order.items);
if (!inventoryCheck.available) return ProcessResult.failure(inventoryCheck.reason);
await this.paymentService.processPayment(order.paymentMethod, orderTotal.total);
await this.inventoryService.reserveItems(order.items);
await this.notificationService.sendOrderConfirmation(order, orderTotal);
return ProcessResult.success(order.id, orderTotal.total);
}
private validateOrder(order: Order): ValidationResult {
if (!order.customerId) return ValidationResult.invalid("Customer ID required");
if (order.items.length === 0) return ValidationResult.invalid("Order must contain items");
return ValidationResult.valid();
}
}
Applied: Extract Method, Value Objects, Dependency Injection, Async patterns
Code to refactor: $ARGUMENTS"
Weekly Installs
115
Repository
GitHub Stars
27.1K
First Seen
Jan 28, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode109
gemini-cli108
github-copilot104
codex104
cursor100
claude-code93
后端测试指南:API端点、业务逻辑与数据库测试最佳实践
11,800 周安装