services-layer

Define and enforce a structured service layer with domain-specific errors.

4.7k|374|Updated Mar 16, 2023
One-click install
npx skills add https://github.com/EpicenterHQ/epicenter --skill services-layer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: services-layer
Source: https://github.com/EpicenterHQ/epicenter/tree/main/.agents/skills/services-layer
Command: npx skills add https://github.com/EpicenterHQ/epicenter --skill services-layer

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Defines and enforces a clean, testable service layer pattern with domain-specific errors and consistent Result-based flows across platforms.

Core Features & Use Cases

  • Domain-specific errors via createTaggedError with contextual metadata support.
  • Namespace export pattern and three-layer architecture (Service → Query → UI) for modularity.
  • Platform-aware variants and strong error-handling guidelines to improve reliability.

Quick Start

Create a new service by defining domain errors with createTaggedError, exporting a live instance, and implementing methods that follow the three-layer architecture.

Frequently Asked Questions about services-layer

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

FAQPage Schema
What is a service layer pattern and when do I need it for TypeScript architecture?

A service layer pattern separates business logic from UI and data access using a three-layer architecture (Service → Query → UI). You need it to enforce modularity, create testable services, and standardize domain-specific error handling across platforms.

How do I structure domain-specific errors in a TypeScript service layer?

Structure domain-specific errors using createTaggedError to attach contextual metadata. This Result-based error handling approach ensures consistent error messaging, namespaces exports correctly, and maintains reliable service flows across desktop and web variants.

How do I implement Result-based error handling for robust applications?

Implement Result-based error handling by creating tagged domain errors with contextual metadata and structuring service methods to return Result objects. This enforces consistent messaging and testing practices across your three-layer architecture.

Can I use a three-layer architecture across desktop and web platform variants?

Yes, the service layer pattern applies platform-aware variants to support both desktop and web. It organizes namespace exports and domain logic to maintain consistent errors and flows across different platform implementations.

What is the best way to organize service exports and domain errors?

The best way is using a namespace export pattern alongside tagged error creation. This modular approach cleanly separates service instances, domain errors with contextual data, and platform-specific variants for maintainable code.

How do I test domain errors and service layer implementations?

Test domain errors and service implementations by validating createTaggedError metadata and Result-based flows. The structured three-layer architecture ensures services remain isolated, allowing you to verify consistent error messaging and domain logic independently.