service-registry
Registry pattern for managing external service connections, configurations,and health checks.Triggers: service registry, service discovery, health checks, service configuration,multi-service integration, unified execution, service managementUse when: managing multiple external services, implementing health checks,centralizing service configuration, unified service executionDO NOT use when: single service integration without registry needs.Consult this skill when implementing service registry patterns.
When & Why to Use This Skill
The Service Registry skill provides a robust framework for managing external service connections, configurations, and health checks within Claude-powered workflows. By implementing the registry pattern, it enables seamless service discovery, unified execution, and automated failover logic, ensuring that multi-service integrations remain resilient, scalable, and easy to maintain.
Use Cases
- Multi-Service API Management: Centralize configurations for various external providers (like LLM APIs or cloud services) to simplify authentication, environment variable management, and quota tracking.
- Automated Health Monitoring: Implement real-time health checks across all integrated services to detect outages early and ensure the agent only interacts with healthy endpoints.
- Resilient Failover Systems: Build logic that automatically switches to secondary service providers if the primary service fails, hits rate limits, or experiences high latency.
- Unified Execution Interface: Standardize how different external tools and commands are executed, providing a consistent output format for better error handling and data processing.
| name | service-registry |
|---|---|
| description | | |
| Triggers | service registry, service discovery, health checks, service configuration, |
| Use when | managing multiple external services, implementing health checks, |
| DO NOT use when | single service integration without registry needs. |
| category | infrastructure |
| tags | [services, registry, execution, health-checks, integration] |
| dependencies | [quota-management, usage-logging] |
| tools | [service-executor] |
| infrastructure | [service-registry, health-monitoring, execution-engine] |
| patterns | [service-discovery, unified-execution, configuration-management] |
| complexity | intermediate |
| estimated_tokens | 550 |
| progressive_loading | true |
Table of Contents
- Overview
- When to Use
- Core Concepts
- Service Configuration
- Execution Result
- Quick Start
- Register Services
- Execute via Service
- Health Checks
- Service Selection
- Auto-Selection
- Failover Pattern
- Integration Pattern
- Detailed Resources
- Exit Criteria
Service Registry
Overview
A registry pattern for managing connections to external services. Handles configuration, health checking, and execution across multiple service integrations.
When to Use
- Managing multiple external services.
- Need consistent execution interface.
- Want health monitoring across services.
- Building service failover logic.
Core Concepts
Service Configuration
@dataclass
class ServiceConfig:
name: str
command: str
auth_method: str # "api_key", "oauth", "token"
auth_env_var: str
quota_limits: dict
models: list[str] = field(default_factory=list)
Verification: Run the command with --help flag to verify availability.
Execution Result
@dataclass
class ExecutionResult:
success: bool
stdout: str
stderr: str
exit_code: int
duration: float
tokens_used: int
Verification: Run the command with --help flag to verify availability.
Quick Start
Register Services
from leyline.service_registry import ServiceRegistry
registry = ServiceRegistry()
registry.register("gemini", ServiceConfig(
name="gemini",
command="gemini",
auth_method="api_key",
auth_env_var="GEMINI_API_KEY",
quota_limits={"rpm": 60, "daily": 1000}
))
Verification: Run the command with --help flag to verify availability.
Execute via Service
result = registry.execute(
service="gemini",
prompt="Analyze this code",
files=["src/main.py"],
model="gemini-2.5-pro"
)
if result.success:
print(result.stdout)
Verification: Run the command with --help flag to verify availability.
Health Checks
# Check single service
status = registry.health_check("gemini")
# Check all services
all_status = registry.health_check_all()
for service, healthy in all_status.items():
print(f"{service}: {'OK' if healthy else 'FAILED'}")
Verification: Run the command with --help flag to verify availability.
Service Selection
Auto-Selection
# Select best service for task
service = registry.select_service(
requirements={
"large_context": True,
"fast_response": False
}
)
Verification: Run the command with --help flag to verify availability.
Failover Pattern
def execute_with_failover(prompt: str, files: list) -> ExecutionResult:
for service in registry.get_healthy_services():
result = registry.execute(service, prompt, files)
if result.success:
return result
raise AllServicesFailedError()
Verification: Run the command with --help flag to verify availability.
Integration Pattern
# In your skill's frontmatter
dependencies: [leyline:service-registry]
Verification: Run the command with --help flag to verify availability.
Detailed Resources
- Service Config: See
modules/service-config.mdfor configuration options. - Execution Patterns: See
modules/execution-patterns.mdfor advanced usage.
Exit Criteria
- Services registered with configuration.
- Health checks passing.
- Execution results properly handled.
Troubleshooting
Common Issues
Command not found Ensure all dependencies are installed and in PATH
Permission errors Check file permissions and run with appropriate privileges
Unexpected behavior
Enable verbose logging with --verbose flag