agni-kai
Zuko's Agni Kai for bakeoffs. The formal firebending duel, where competing implementations fight under the same rules and a judge…
This skill should be used when the user asks to "refactor code", "rename function", "extract method", "reduce complexity", "migrate code", "code migration", "modernize code", "split class", "move code", or mentions code restructuring and refactoring operations.
$ npx -y skills add tmcfarlane/team-avatar --skill refactoring --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/refactoringContext preview
The summary Claude sees to decide when to auto-load this skill.
This skill should be used when the user asks to "refactor code", "rename function", "extract method", "reduce complexity", "migrate code", "code migration", "modernize code", "split class", "move code", or mentions code restructuring and refactoring operations.
name: Refactoring description: This skill should be used when the user asks to "refactor code", "rename function", "extract method", "reduce complexity", "migrate code", "code migration", "modernize code", "split class", "move code", or mentions code restructuring and refactoring operations. version: 1.0.0
Comprehensive refactoring skill for safe code restructuring, migrations, and modernization.
Rename identifiers across the codebase:
**Rename workflow:**
1. **Find all references**: Search for all usages 2. **Identify scope**: Module-local, package-wide, or public API 3. **Check dependencies**: External code that might break 4. **Perform rename**: Update all occurrences 5. **Verify**: Run tests, check imports
**Search patterns:**
# Find all references to a function grep -rn "function_name" --include="*.py" # Find class usages grep -rn "ClassName" --include="*.py" # Find imports grep -rn "from .* import.*function_name" --include="*.py"
**Renaming considerations:**
Extract code into separate functions:
**When to extract:**
**Extraction process:**
1. Identify the code block to extract 2. Determine inputs (parameters) 3. Determine outputs (return values) 4. Create new function with clear name 5. Replace original code with function call 6. Add tests for new function
**Before:**
def process_order(order):
# Validate order (candidate for extraction)
if not order.items:
raise ValueError("Empty order")
if order.total < 0:
raise ValueError("Invalid total")
for item in order.items:
if item.quantity <= 0:
raise ValueError("Invalid quantity")
# Process payment
payment_result = gateway.charge(order.total)
return payment_result**After:**
def validate_order(order: Order) -> None:
"""Validate order has valid items and total."""
if not order.items:
raise ValueError("Empty order")
if order.total < 0:
raise ValueError("Invalid total")
for item in order.items:
if item.quantity <= 0:
raise ValueError("Invalid quantity")
def process_order(order: Order) -> PaymentResult:
validate_order(order)
return gateway.charge(order.total)Split large classes into focused components:
**When to split:**
**Splitting strategies:**
**Extract class:**
# Before: God class
class OrderManager:
def create_order(self): ...
def validate_order(self): ...
def calculate_tax(self): ...
def calculate_shipping(self): ...
def send_confirmation_email(self): ...
def send_shipping_notification(self): ...
# After: Focused classes
class OrderService:
def create_order(self): ...
def validate_order(self): ...
class PricingService:
def calculate_tax(self): ...
def calculate_shipping(self): ...
class NotificationService:
def send_confirmation_email(self): ...
def send_shipping_notification(self): ...Reduce cyclomatic complexity:
**Replace conditionals with polymorphism:**
# Before: Complex switch
def calculate_price(product_type, base_price):
if product_type == "physical":
return base_price + shipping_cost
elif product_type == "digital":
return base_price
elif product_type == "subscription":
return base_price * 12 * 0.9
else:
raise ValueError("Unknown type")
# After: Polymorphism
class Product(ABC):
@abstractmethod
def calculate_price(self, base_price): ...
class PhysicalProduct(Product):
def calculate_price(self, base_price):
return base_price + self.shipping_cost
class DigitalProduct(Product):
def calculate_price(self, base_price):
return base_price
class Subscription(Product):
def calculate_price(self, base_price):
return base_price * 12 * 0.9**Extract guard clauses:**
# Before: Nested conditionals
def process(data):
if data:
if data.is_valid:
if data.is_ready:
return do_processing(data)
return None
# After: Guard clauses
def process(data):
if not data:
return None
if not data.is_valid:
return None
if not data.is_ready:
return None
return do_processing(data)Migrate code between patterns or versions:
**Migration types:**
**Migration workflow:**
1. **Assess scope**: What needs to change 2. **Create compatibility layer**: If gradual migration 3. **Migrate in phases**: Start with low-risk areas 4. **Maintain tests**: Ensure behavior preserved 5. **Remove old code**: Clean up after migration
**Example: Sync to Async**
# Before: Synchronous
def fetch_user(user_id: int) -> User:
response = requests.get(f"/users/{user_id}")
return User.from_dict(response.json())
# After: Asynchronous
async def fetch_user(user_id: int) -> User:
async with aiohttp.ClientSession() as session:
async with session.get(f"/users/{user_id}") as response:
data = await response.json()
return User.from_dict(data)1. **Ensure test coverage**: Add tests if missing 2. **Run tests**: Verify green baseline 3. **Make small change**: One refactoring at a time 4. **Run tests again**: Verify still green 5. **Commit**: S
Team Avatar: a universal agent orchestrator for Claude Code, Codex, and Cursor. Nine Avatar characters, 58 engineering skills. pstack with Avatar characters on top.
Zuko's Agni Kai for bakeoffs. The formal firebending duel, where competing implementations fight under the same rules and a judge…
Aang showing a new friend around the team. Explains Team Avatar to a user, the roster and who owns what, how to invoke a skill on…
Aang's operating mode for Team Avatar, principal-level engineering where each task goes to the character who owns that…
Aang choosing which bender takes which fight. Configures which model each Team Avatar character runs on, the default reasoning…
Sokka's battle map, the decision trail he keeps so anyone can see how the campaign was won. Use for show-me-your-work,…
Appa's morning departure for picking up paused or handed-off work. The team breaks camp, reads the map they left, and flies on…