backend-coding-guidelines

Enforce a 7-layer Laravel backend architecture with UseCase, Repository, DTO, Service, and Resource patterns.

Updated Dec 29, 2025
One-click install
npx skills add https://github.com/asakuno/template-repository --skill backend-coding-guidelines
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: backend-coding-guidelines
Source: https://github.com/asakuno/template-repository/tree/main/.claude/skills/backend-coding-guidelines
Command: npx skills add https://github.com/asakuno/template-repository --skill backend-coding-guidelines

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Comprehensive Laravel backend guidelines to ensure clean separation of concerns, prevent fat controllers and models, and promote consistent architecture across projects.

Core Features & Use Cases

  • Enforces a 7-layer architecture (Presentation, Request, UseCase, Service, Repository, Model, Resource) specifically tailored for Laravel-native development.
  • Promotes Laravel Data DTOs, Repository pattern, and TypeScript type generation to enable strong typing and easier testing.
  • Provides naming conventions, layering rules, and security/quality best practices to guide implementation and refactoring.

Quick Start

Create or refactor a backend feature by defining a UseCase with a Repository Interface, a matching DTO, and a FormRequest for validation, then wire it into a Controller.

Frequently Asked Questions about backend-coding-guidelines

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

FAQPage Schema
How do I prevent business logic from leaking into Laravel controllers and models?

To prevent business logic from leaking in Laravel, enforce a strict 7-layer architecture separating Presentation, Request, UseCase, Service, Repository, Model, and Resource layers. This ensures clean separation of concerns and keeps controllers and models thin.

What is the best way to structure a Laravel backend for consistent architecture across projects?

The best way to structure a Laravel backend for consistency is applying a standardized 7-layer pattern with UseCase, Repository, DTO, Service, and Resource components. This provides clear dependencies, validation rules, and naming conventions across all projects.

How do I implement the Repository pattern and DTOs in a Laravel application?

To implement the Repository pattern and DTOs in Laravel, define a UseCase with a Repository Interface, create a matching Laravel Data DTO, and use a FormRequest for validation. Wire these components into a Controller to complete the standardized backend feature.

Do I need TypeScript type generation when using Laravel Data DTOs?

TypeScript type generation is promoted alongside Laravel Data DTOs to enable strong typing and easier testing. Generating TypeScript types from DTOs provides a reliable contract between backend services and frontend clients.

Does this 7-layer Laravel architecture support database transactions and testability?

Yes, the 7-layer Laravel architecture fully supports database transactions and testability. It includes detailed guidelines for transaction handling and DTO design specifically to ensure teams can build and refactor backend features reliably with strong typing.

When should I not use a layered UseCase architecture for my Laravel project?

You should avoid a strict 7-layer UseCase architecture for simple Laravel projects lacking complex business logic. The overhead of defining UseCases, Repositories, and DTOs is designed for large applications requiring strict separation of concerns and long-term maintainability.