
Laravel API Production-Ready Architecture — JSON:API v1.1 skill for Claude Code
概览
Открытый проект EQ Platform — страница проекта 一项为 AI 编码代理(Claude Code、Cursor、Copilot 等)设计的技能,在 Laravel API 项目中强制执行架构规范:JSON:API v1.1,分层架构,严格类型,全面测试覆盖。 首次使用时,该技能会自动检查你项目的 CLAUDE.md:- — 用模板/CLAUDE.md 和 Laravel 架构规则创建一个 - — 附加 Laravel 部分 - — 正常进行 CLAUDE.md 模板起到一个功能——它检测你正在做什么(创建实体、审查代码、编写测试),并强制代理在写代码前阅读正确的参考文件。 激活后,该技能会为每个 Laravel API 项目强制执行严格的分层架构: 要求代理创建一个新实体,它会按照架构生成: 1. 迁移 2.模型(使用ULID公钥)3.枚举 4.创建DTO + 更新DTO(空间数据) 5.存储请求 + 更新请求(带toDto()) 6.查询构建器 7.
概述(AI 翻译)
Открытый проект EQ Platform — страница проекта
Читать на русском (README.ru.md)
一项为 AI 编码代理(Claude Code、Cursor、Copilot 等)设计的技能,在 Laravel API 项目中强制执行架构规范:JSON:API v1.1,分层架构,严格类型,全面测试覆盖。
安装
第一步:安装技能
步骤2:设置 CLAUDE.md(自动)
首次使用时,技能会自动检查你项目的CLAUDE.md:
- No CLAUDE.md? — 用 Laravel 架构规则从
templates/CLAUDE.md创建一个 - CLAUDE.md 存在但没有Laravel部分? — 附加于Laravel部分
- 已配置好吗? — 正常进行
CLAUDE.md 模板充当 相位调度器——它检测你正在做什么(创建实体、审查代码、编写测试),并强制代理在编写任何代码前读取正确的参考文件。
手动设置(另类)
如果你喜欢手动设置:
或者附加在已有 CLAUDE.md 上:
它的作用
激活后,该技能会为每个 Laravel API 项目强制执行严格的分层架构:
层边界
| 层 | 有 | 没有 |
|---|
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Laravel API Production-Ready Architecture Skill
Открытый проект EQ Platform — страница проекта
A skill for AI coding agents (Claude Code, Cursor, Copilot, etc.) that enforces architectural discipline in Laravel API projects: JSON:API v1.1, layered architecture, strict types, full test coverage.
Installation
Step 1: Install the skill
npx skills add streeboga/laravel-api-skill
Step 2: Setup CLAUDE.md (automatic)
On first use, the skill automatically checks your project’s CLAUDE.md:
- No CLAUDE.md? — Creates one from
templates/CLAUDE.mdwith Laravel architecture rules - CLAUDE.md exists but no Laravel section? — Appends the Laravel section
- Already configured? — Proceeds normally
The CLAUDE.md template acts as a phase dispatcher — it detects what you’re doing (creating an entity, reviewing code, writing tests) and forces the agent to read the correct reference files before writing any code.
Manual setup (alternative)
If you prefer to set it up manually:
# Copy the template to your project root
cp ~/.claude/skills/laravel-api/templates/CLAUDE.md ./CLAUDE.md
Or append to an existing CLAUDE.md:
cat ~/.claude/skills/laravel-api/templates/CLAUDE.md >> ./CLAUDE.md
What It Does
When activated, the skill enforces a strict layered architecture for every Laravel API project:
HTTP Request → Route → Middleware → Controller → Service → Repository → QueryBuilder → Model → DB
Response ← JsonApiResource ← Service ← Repository ← QueryBuilder
Layer Boundaries
| Layer | Does | Does NOT |
|---|---|---|
| Controller | Accept request, call Service, return JsonApiResource | Access DB, inject Repository/Model, contain logic |
| Service | Business logic, transactions, events, caching | Query DB directly, grow into God Class |
| Repository | CRUD operations, delegates queries to QueryBuilder | Contain business logic |
| QueryBuilder | Scopes, filters, sorts, eager loading, pagination | Contain CRUD or business logic |
| Model | Relations, casts, accessors. NO scopes | Contain scopeXxx() methods |
| DTO | Type-safe data transfer between layers | – |
| JsonApiResource | Transform model to JSON:API format | – |
| Enum | All constants, statuses, cache keys | – |
New Entity Generation
Ask the agent to create a new entity and it generates 14 files following the architecture:
- Migration
- Model (with ULID public keys)
- Enum(s)
- Create DTO + Update DTO (Spatie Data)
- Store Request + Update Request (with
toDto()) - QueryBuilder
- Repository Interface + Implementation
- Service
- Controller (thin, JSON:API compliant)
- JsonApiResource
- Routes (versioned, PATCH for updates)
- Service Provider binding
- Feature Tests
Code Review
推荐工具
换一个关键词,或者移除筛选条件。
安装
npx skillfish add streeboga/laravel-api-skill