Keeping Routines Focused

Extract focused routines from long functions with excessive parameters.

41|27|Updated Oct 6, 2025
One-click install
npx skills add https://github.com/obra/clank --skill keeping-routines-focused-obra
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Keeping Routines Focused
Source: https://github.com/obra/clank/tree/main/skills/coding/keeping-routines-focused
Command: npx skills add https://github.com/obra/clank --skill keeping-routines-focused-obra

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill eliminates the complexity and maintainability issues caused by routines that do too many things, making code harder to understand, test, and modify.

Core Features & Use Cases

  • Single Responsibility Principle: Ensures each function does one thing completely and well.
  • Code Extraction Techniques: Provides systematic methods to split multi-purpose routines into focused components.
  • Use Case: When reviewing a 150-line function that validates user input, calculates pricing, updates inventory, and sends notifications, use this Skill to extract each responsibility into separate, testable functions.

Quick Start

Analyze this function and extract any responsibilities that violate the single responsibility principle:

def process_order(order_data, user_id): # Validate order data if not order_data.get("items"): raise ValueError("No items")

# Calculate pricing
subtotal = sum(item["price"] * item["qty"] for item in order_data["items"])
tax = subtotal * 0.08
total = subtotal + tax

# Check inventory
for item in order_data["items"]:
    if inventory[item["id"]] < item["qty"]:
        raise InventoryError()

# Create order record
order_id = f"ORD-{datetime.now().isoformat()}"
order = {"id": order_id, "user_id": user_id, "total": total}
save_order(order)

# Send confirmation email
send_email(user_id, f"Order {order_id} confirmed")

return order

Frequently Asked Questions about Keeping Routines Focused

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor a function that does too many things?

Refactor by identifying each responsibility in the function and extracting it into a separate, focused function. Look for logic blocks handling validation, calculations, state changes, or side effects—each becomes its own function with a single purpose, improving testability and maintainability.

What's the single responsibility principle and why does it matter for code quality?

The single responsibility principle ensures each function does one thing completely and well. This improves code quality by making functions easier to understand, test in isolation, and modify without unexpected side effects.

How do I know when a function violates single responsibility?

A function violates single responsibility when its description contains the word 'and', it exceeds 200 lines, or has more than seven parameters. These signals indicate multiple concerns that should be extracted into separate, cohesive functions.

Can I use this approach during code reviews?

Yes. Apply this during code reviews to catch functions with multiple responsibilities before they merge. Identify violations and suggest extraction strategies to maintain functional cohesion and testability across your codebase.

What's the benefit of extracting functions by responsibility?

Function extraction by responsibility enables isolated testing, clearer composition, smaller parameter lists, and consistent abstraction levels. Each extracted function becomes independently testable and reusable, reducing complexity and maintenance burden.