CtrlK
BlogDocsLog inGet started
Tessl Logo

service-layer

Defines application service structure and business orchestration boundaries

59

Quality

68%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide

SecuritybySnyk

Passed

No findings from the security scan

Fix and improve this skill with Tessl

tessl review fix ./.claude/skills/service-layer/SKILL.md
SKILL.md
Quality
Evals
Security

Service Layer

Services are the only place business logic lives. They are framework-agnostic.


1. Responsibility

Services MUST:

  • contain business logic
  • coordinate models
  • enforce domain rules
  • return models or DTOs

Services MUST NOT:

  • accept or return HTTP request/response objects
  • contain UI logic
  • use app() or resolve() internally

2. Dependency Rule

Constructor injection only:

public function __construct(
    private InvoiceRepository $repository
) {}

3. DTO Rule

DTOs are not required when the source is a validated FormRequest::validated() array. Arrays are fine there.

Use DTOs when:

  • crossing system boundaries (API, queues, external integrations)
  • multiple services share a contract
  • the payload must be stable across refactors

Skip DTOs when:

  • input comes from a single controller action's validated request
  • the data is short-lived and not reused

4. Standard Shape

app/Services/{Domain}/{Model}Service.php

e.g. app/Services/Task/TaskService.php, app/Services/Offer/OfferService.php.

Standard method names: create, update, delete, findByExternalId. Prefer one service class per domain holding both create/update (see TaskService) over splitting into separate per-action service classes.

Repository
Bottelet/DaybydayCRM
Last updated
First committed

Is this your skill?

If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.