{"id":"ba07fd13-749e-48bf-8713-6c333bd54ad4","shortId":"7JEq2q","kind":"skill","title":"tdd-workflows-tdd-refactor","tagline":"Use when working with tdd workflows tdd refactor","description":"## Use this skill when\n\n- Working on tdd workflows tdd refactor tasks or workflows\n- Needing guidance, best practices, or checklists for tdd workflows tdd refactor\n\n## Do not use this skill when\n\n- The task is unrelated to tdd workflows tdd refactor\n- You need a different domain or tool outside this scope\n\n## Instructions\n\n- Clarify goals, constraints, and required inputs.\n- Apply relevant best practices and validate outcomes.\n- Provide actionable steps and verification.\n- If detailed examples are required, open `resources/implementation-playbook.md`.\n\nRefactor code with confidence using comprehensive test safety net:\n\n[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.]\n\n## Usage\n\nUse Task tool with subagent_type=\"tdd-orchestrator\" to perform safe refactoring.\n\nPrompt: \"Refactor this code while keeping all tests green: $ARGUMENTS. Apply TDD refactor phase:\n\n## Core Process\n\n**1. Pre-Assessment**\n- Run tests to establish green baseline\n- Analyze code smells and test coverage\n- Document current performance metrics\n- Create incremental refactoring plan\n\n**2. Code Smell Detection**\n- Duplicated code → Extract methods/classes\n- Long methods → Decompose into focused functions\n- Large classes → Split responsibilities\n- Long parameter lists → Parameter objects\n- Feature Envy → Move methods to appropriate classes\n- Primitive Obsession → Value objects\n- Switch statements → Polymorphism\n- Dead code → Remove\n\n**3. Design Patterns**\n- Apply Creational (Factory, Builder, Singleton)\n- Apply Structural (Adapter, Facade, Decorator)\n- Apply Behavioral (Strategy, Observer, Command)\n- Apply Domain (Repository, Service, Value Objects)\n- Use patterns only where they add clear value\n\n**4. SOLID Principles**\n- Single Responsibility: One reason to change\n- Open/Closed: Open for extension, closed for modification\n- Liskov Substitution: Subtypes substitutable\n- Interface Segregation: Small, focused interfaces\n- Dependency Inversion: Depend on abstractions\n\n**5. Refactoring Techniques**\n- Extract Method/Variable/Interface\n- Inline unnecessary indirection\n- Rename for clarity\n- Move Method/Field to appropriate classes\n- Replace Magic Numbers with constants\n- Encapsulate fields\n- Replace Conditional with Polymorphism\n- Introduce Null Object\n\n**6. Performance Optimization**\n- Profile to identify bottlenecks\n- Optimize algorithms and data structures\n- Implement caching where beneficial\n- Reduce database queries (N+1 elimination)\n- Lazy loading and pagination\n- Always measure before and after\n\n**7. Incremental Steps**\n- Make small, atomic changes\n- Run tests after each modification\n- Commit after each successful refactoring\n- Keep refactoring separate from behavior changes\n- Use scaffolding when needed\n\n**8. Architecture Evolution**\n- Layer separation and dependency management\n- Module boundaries and interface definition\n- Event-driven patterns for decoupling\n- Database access pattern optimization\n\n**9. Safety Verification**\n- Run full test suite after each change\n- Performance regression testing\n- Mutation testing for test effectiveness\n- Rollback plan for major changes\n\n**10. Advanced Patterns**\n- Strangler Fig: Gradual legacy replacement\n- Branch by Abstraction: Large-scale changes\n- Parallel Change: Expand-contract pattern\n- Mikado Method: Dependency graph navigation\n\n## Output Requirements\n\n- Refactored code with improvements applied\n- Test results (all green)\n- Before/after metrics comparison\n- Applied refactoring techniques list\n- Performance improvement measurements\n- Remaining technical debt assessment\n\n## Safety Checklist\n\nBefore committing:\n- ✓ All tests pass (100% green)\n- ✓ No functionality regression\n- ✓ Performance metrics acceptable\n- ✓ Code coverage maintained/improved\n- ✓ Documentation updated\n\n## Recovery Protocol\n\nIf tests fail:\n- Immediately revert last change\n- Identify breaking refactoring\n- Apply smaller incremental changes\n- Use version control for safe experimentation\n\n## Example: Extract Method Pattern\n\n**Before:**\n```typescript\nclass OrderProcessor {\n  processOrder(order: Order): ProcessResult {\n    // Validation\n    if (!order.customerId || order.items.length === 0) {\n      return { success: false, error: \"Invalid order\" };\n    }\n\n    // Calculate totals\n    let subtotal = 0;\n    for (const item of order.items) {\n      subtotal += item.price * item.quantity;\n    }\n    let total = subtotal + (subtotal * 0.08) + (subtotal > 100 ? 0 : 15);\n\n    // Process payment...\n    // Update inventory...\n    // Send confirmation...\n  }\n}\n```\n\n**After:**\n```typescript\nclass OrderProcessor {\n  async processOrder(order: Order): Promise<ProcessResult> {\n    const validation = this.validateOrder(order);\n    if (!validation.isValid) return ProcessResult.failure(validation.error);\n\n    const orderTotal = OrderTotal.calculate(order);\n    const inventoryCheck = await this.inventoryService.checkAvailability(order.items);\n    if (!inventoryCheck.available) return ProcessResult.failure(inventoryCheck.reason);\n\n    await this.paymentService.processPayment(order.paymentMethod, orderTotal.total);\n    await this.inventoryService.reserveItems(order.items);\n    await this.notificationService.sendOrderConfirmation(order, orderTotal);\n\n    return ProcessResult.success(order.id, orderTotal.total);\n  }\n\n  private validateOrder(order: Order): ValidationResult {\n    if (!order.customerId) return ValidationResult.invalid(\"Customer ID required\");\n    if (order.items.length === 0) return ValidationResult.invalid(\"Order must contain items\");\n    return ValidationResult.valid();\n  }\n}\n```\n\n**Applied:** Extract Method, Value Objects, Dependency Injection, Async patterns\n\nCode to refactor: $ARGUMENTS\"\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.","tags":["tdd","workflows","refactor","antigravity","awesome","skills","sickn33","agent-skills","agentic-skills","ai-agent-skills","ai-agents","ai-coding"],"capabilities":["skill","source-sickn33","skill-tdd-workflows-tdd-refactor","topic-agent-skills","topic-agentic-skills","topic-ai-agent-skills","topic-ai-agents","topic-ai-coding","topic-ai-workflows","topic-antigravity","topic-antigravity-skills","topic-claude-code","topic-claude-code-skills","topic-codex-cli","topic-codex-skills"],"categories":["antigravity-awesome-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/sickn33/antigravity-awesome-skills/tdd-workflows-tdd-refactor","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add sickn33/antigravity-awesome-skills","source_repo":"https://github.com/sickn33/antigravity-awesome-skills","install_from":"skills.sh"}},"qualityScore":"0.700","qualityRationale":"deterministic score 0.70 from registry signals: · indexed on github topic:agent-skills · 34460 github stars · SKILL.md body (6,191 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-22T06:51:58.983Z","embedding":null,"createdAt":"2026-04-18T21:45:56.917Z","updatedAt":"2026-04-22T06:51:58.983Z","lastSeenAt":"2026-04-22T06:51:58.983Z","tsv":"'+1':341 '0':534,545,561,630 '0.08':558 '1':165 '10':425 '100':483,560 '15':562 '2':189 '3':229 '4':261 '5':291 '6':321 '7':352 '8':379 '9':402 'abstract':290,435 'accept':490 'access':399 'action':78 'adapt':239 'add':258 'advanc':426 'agent':107 'algorithm':329 'alway':347 'analyz':175 'appli':70,119,159,232,237,242,247,457,465,508,639 'appropri':217,305 'architectur':380 'argument':158,651 'ask':685 'assess':168,475 'async':573,646 'atom':357 'await':593,601,605,608 'baselin':174 'before/after':462 'behavior':243,373 'benefici':336 'best':29,72 'bottleneck':327 'boundari':388,693 'branch':433 'break':506 'builder':235 'cach':334 'calcul':541 'chang':269,358,374,411,424,439,441,504,511 'checklist':32,477 'clarif':687 'clarifi':64 'clariti':301 'class':204,218,306,524,571 'clear':259,660 'close':274 'code':90,123,152,176,190,194,227,454,491,648 'command':246 'commit':364,479 'comparison':464 'comprehens':94,132 'condit':315 'confid':92 'confirm':568 'const':547,578,587,591 'constant':311 'constraint':66 'contain':635 'contract':444 'control':514 'core':163 'coverag':134,180,492 'creat':185 'creation':233 'criteria':696 'current':182 'custom':625 'data':331 'databas':338,398 'dead':226 'debt':474 'decompos':199 'decor':241 'decoupl':397 'definit':391 'depend':286,288,385,448,644 'describ':664 'design':120,230 'detail':83 'detect':192 'differ':56 'document':181,494 'domain':57,248 'driven':394 'duplic':193 'effect':419 'elimin':342 'encapsul':312 'envi':213 'environ':676 'environment-specif':675 'error':538 'establish':172 'event':393 'event-driven':392 'evolut':381 'exampl':84,518 'expand':443 'expand-contract':442 'experiment':517 'expert':681 'extend':98 'extens':273 'extract':195,294,519,640 'facad':240 'factori':234 'fail':500 'fals':537 'featur':212 'field':313 'fig':429 'focus':201,284 'full':406 'function':202,486 'goal':65 'gradual':430 'graph':449 'green':117,157,173,461,484 'guidanc':28 'id':626 'identifi':326,505 'immedi':501 'implement':333 'improv':122,456,470 'increment':186,353,510 'indirect':298 'inject':645 'inlin':296 'input':69,690 'instruct':63 'interfac':281,285,390 'introduc':318 'invalid':539 'inventori':566 'inventorycheck':592 'inventorycheck.available':597 'inventorycheck.reason':600 'invers':287 'item':548,636 'item.price':552 'item.quantity':553 'keep':154,369 'larg':203,437 'large-scal':436 'last':503 'layer':382 'lazi':343 'legaci':431 'let':543,554 'limit':652 'liskov':277 'list':209,468 'load':344 'long':197,207 'magic':308 'maintain':114 'maintained/improved':493 'major':423 'make':355 'manag':386 'match':661 'measur':348,471 'method':198,215,447,520,641 'method/field':303 'method/variable/interface':295 'methods/classes':196 'metric':184,463,489 'mikado':446 'miss':698 'model':109 'modif':276,363 'modul':387 'move':214,302 'must':634 'mutat':415 'n':340 'navig':450 'need':27,54,378 'net':97 'null':319 'number':309 'object':211,222,252,320,643 'observ':245 'obsess':220 'one':266 'open':87,271 'open/closed':270 'optim':126,323,328,401 'opus':108 'orchestr':106,144 'order':527,528,540,575,576,581,590,610,618,619,633 'order.customerid':532,622 'order.id':614 'order.items':550,595,607 'order.items.length':533,629 'order.paymentmethod':603 'orderprocessor':525,572 'ordertot':588,611 'ordertotal.calculate':589 'ordertotal.total':604,615 'outcom':76 'output':451,670 'outsid':60 'pagin':346 'parallel':440 'paramet':208,210 'pass':482 'pattern':121,231,254,395,400,427,445,521,647 'payment':564 'perform':127,146,183,322,412,469,488 'permiss':691 'phase':162 'plan':188,421 'polymorph':225,317 'practic':30,73 'pre':167 'pre-assess':166 'primit':219 'principl':263 'privat':616 'process':164,563 'processord':526,574 'processresult':529 'processresult.failure':585,599 'processresult.success':613 'profil':324 'promis':577 'prompt':149 'protocol':497 'provid':77 'qualiti':124 'queri':339 'reason':267 'recoveri':496 'reduc':337 'refactor':5,13,23,37,52,89,112,148,150,161,187,292,368,370,453,466,507,650 'regress':413,487 'relev':71 'remain':472 'remov':228 'renam':299 'replac':307,314,432 'repositori':249 'requir':68,86,452,627,689 'resources/implementation-playbook.md':88 'respons':206,265 'result':459 'return':535,584,598,612,623,631,637 'revert':502 'review':682 'rollback':420 'run':169,359,405 'safe':147,516 'safeti':96,130,403,476,692 'scaffold':376 'scale':438 'scope':62,663 'segreg':282 'send':567 'separ':371,383 'servic':250 'singl':264 'singleton':236 'skill':16,42,655 'skill-tdd-workflows-tdd-refactor' 'small':283,356 'smaller':509 'smell':177,191 'solid':262 'sophist':111 'source-sickn33' 'specif':677 'split':205 'statement':224 'step':79,354 'stop':683 'strangler':428 'strategi':244 'structur':238,332 'subag':140 'substitut':278,280,673 'subtot':544,551,556,557,559 'subtyp':279 'success':367,536,695 'suit':408 'switch':223 'task':24,45,137,659 'tdd':2,4,10,12,20,22,34,36,49,51,105,143,160 'tdd-orchestr':104,142 'tdd-workflows-tdd-refactor':1 'technic':473 'techniqu':293,467 'test':95,116,133,156,170,179,360,407,414,416,418,458,481,499,679 'think':99 'this.inventoryservice.checkavailability':594 'this.inventoryservice.reserveitems':606 'this.notificationservice.sendorderconfirmation':609 'this.paymentservice.processpayment':602 'this.validateorder':580 'tool':59,101,138 'topic-agent-skills' 'topic-agentic-skills' 'topic-ai-agent-skills' 'topic-ai-agents' 'topic-ai-coding' 'topic-ai-workflows' 'topic-antigravity' 'topic-antigravity-skills' 'topic-claude-code' 'topic-claude-code-skills' 'topic-codex-cli' 'topic-codex-skills' 'total':542,555 'treat':668 'type':141 'typescript':523,570 'unnecessari':297 'unrel':47 'updat':495,565 'usag':135 'use':6,14,40,93,102,136,253,375,512,653 'valid':75,530,579,678 'validateord':617 'validation.error':586 'validation.isvalid':583 'validationresult':620 'validationresult.invalid':624,632 'validationresult.valid':638 'valu':221,251,260,642 'verif':81,404 'version':513 'work':8,18 'workflow':3,11,21,26,35,50","prices":[{"id":"3f14196d-bb88-4ff8-9c5a-6437928ee616","listingId":"ba07fd13-749e-48bf-8713-6c333bd54ad4","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"sickn33","category":"antigravity-awesome-skills","install_from":"skills.sh"},"createdAt":"2026-04-18T21:45:56.917Z"}],"sources":[{"listingId":"ba07fd13-749e-48bf-8713-6c333bd54ad4","source":"github","sourceId":"sickn33/antigravity-awesome-skills/tdd-workflows-tdd-refactor","sourceUrl":"https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/tdd-workflows-tdd-refactor","isPrimary":false,"firstSeenAt":"2026-04-18T21:45:56.917Z","lastSeenAt":"2026-04-22T06:51:58.983Z"}],"details":{"listingId":"ba07fd13-749e-48bf-8713-6c333bd54ad4","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"sickn33","slug":"tdd-workflows-tdd-refactor","github":{"repo":"sickn33/antigravity-awesome-skills","stars":34460,"topics":["agent-skills","agentic-skills","ai-agent-skills","ai-agents","ai-coding","ai-workflows","antigravity","antigravity-skills","claude-code","claude-code-skills","codex-cli","codex-skills","cursor","cursor-skills","developer-tools","gemini-cli","gemini-skills","kiro","mcp","skill-library"],"license":"mit","html_url":"https://github.com/sickn33/antigravity-awesome-skills","pushed_at":"2026-04-22T06:40:00Z","description":"Installable GitHub library of 1,400+ agentic skills for Claude Code, Cursor, Codex CLI, Gemini CLI, Antigravity, and more. Includes installer CLI, bundles, workflows, and official/community skill collections.","skill_md_sha":"cee420a8113fb98bf0ef514a5eae862aae381d8c","skill_md_path":"skills/tdd-workflows-tdd-refactor/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/tdd-workflows-tdd-refactor"},"layout":"multi","source":"github","category":"antigravity-awesome-skills","frontmatter":{"name":"tdd-workflows-tdd-refactor","description":"Use when working with tdd workflows tdd refactor"},"skills_sh_url":"https://skills.sh/sickn33/antigravity-awesome-skills/tdd-workflows-tdd-refactor"},"updatedAt":"2026-04-22T06:51:58.983Z"}}