Plugin Service Registry

SkillDev tools

Register and retrieve services at runtime using a thread-safe service registry pattern for loose coupling between plugins.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the Plugin Service Registry skill

What this skill tells your AI

The instructions your AI receives, as published by cliqrelay/cliqrelay in .agents/skills/backend/service-registry/SKILL.md and read by ahel’s review.

When to use this skill

  • Register services created by plugins for other plugins to discover
  • Retrieve services from the registry in plugin initialization
  • Enable loose coupling between plugins via service lookup
  • Access core services (User, Account, Session, etc.) in plugins

Key principles

  1. Lazy discovery: Services retrieved when needed, not all upfront
  2. Thread-safe: RWMutex allows concurrent reads, exclusive writes
  3. Type-safe: Use type assertions to convert any back to specific interfaces
  4. Named services: Service IDs are constants from models/services.go

Pattern

Services are registered in plugin Init() methods using the registry interface:

// Get a core service
service, ok := ctx.ServiceRegistry.Get(models.ServiceXxx.String()).(ServiceInterface)
if !ok {
    return errors.New("service not available")
}

// Register your plugin's service
ctx.ServiceRegistry.Register(models.ServicePlugin.String(), myService)

Always check the ok flag on type assertions. Store retrieved services in plugin struct for internal use.

Service initialization order

  1. Core repositories created (all depend on database)
  2. Core services created and registered
  3. Plugins initialize in order (retrieve core services)
  4. Plugin services registered as created
  5. Routes registered after plugins

See bootstrap.go for implementation.

Code references

Common mistakes

  1. Not checking ok flag on type assertions
  2. Using string literals instead of models.ServiceXxx constants
  3. Registering before implementation complete
  4. Creating circular dependencies between plugins
  5. Assuming services are available in wrong initialization phase

Related skills

Signals

GitHub stars
40
Forks
1
Last commit
Sep 2026
Advanced
Catalog kind
skill
Gateway key
service-registry-cliqrelay
Source
github.com/cliqrelay/cliqrelay