create-service

Guide TypeScript backend service creation with resource versus utility distinctions.

1|Updated May 21, 2025
One-click install
npx skills add https://github.com/madooei/backend-template --skill create-service
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: create-service
Source: https://github.com/madooei/backend-template/tree/main/.claude/skills/create-service
Command: npx skills add https://github.com/madooei/backend-template --skill create-service

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a structured guide for creating service layer components in a backend template, helping teams decide between resource and utility services and directing to the appropriate skill for implementation.

Core Features & Use Cases

  • Distinguishes between Resource Service (CRUD for domain entities) and Utility Service (cross-cutting concerns like auth and notifications).
  • Enforces best practices for service design: business logic in services, dependency injection, domain-centric errors, and returning domain types.
  • Provides naming conventions and project structure guidance for placing services under src/services and aligning with existing repositories.

Quick Start

Create a new service by selecting the appropriate type and implementing it under src/services with the naming convention {service-name}.service.ts.

Frequently Asked Questions about create-service

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

FAQPage Schema
How do I structure a backend service layer in TypeScript with dependency injection?

A structured backend service layer in TypeScript places business logic in services, uses dependency injection for coupling, and defines return-type contracts with domain-centric errors. Components reside under src/services with the {name}.service.ts naming convention.

When should I use a resource service versus a utility service in my backend architecture?

Use a resource service for CRUD operations on domain entities and a utility service for cross-cutting concerns like authentication or notifications. Distinguishing between them ensures proper separation of concerns in your service-oriented architecture.

What is the best way to name and organize service files in a service-oriented architecture?

The best way to organize service files is placing them under src/services and following the {service-name}.service.ts naming convention. This aligns with existing repositories and maintains consistency across the TypeScript project structure.

How do I handle domain errors when creating a service layer that returns domain types?

Handling domain errors in a service layer requires throwing domain-centric errors and enforcing return-type contracts that return domain types. This keeps business logic decoupled from transport-layer concerns and preserves type safety.

Does this service layer guide work with existing TypeScript repositories?

Yes, this guide applies to TypeScript projects using a repository layer and service-oriented architecture. It aligns new services with existing repositories to maintain consistent data access patterns and dependency injection.

Why should business logic live in services instead of controllers in a backend template?

Business logic should live in services to keep controllers thin and ensure domain rules are centralized, testable, and reusable. Services manage dependencies and return domain types, preventing logic leakage into the transport layer.