SL

streeboga/laravel-api-skill

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

22 stars 质量 64 趋势 18MIT

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 — страница проекта

Читать на русском (README.ru.md)

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.md with 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:

  1. Migration
  2. Model (with ULID public keys)
  3. Enum(s)
  4. Create DTO + Update DTO (Spatie Data)
  5. Store Request + Update Request (with toDto())
  6. QueryBuilder
  7. Repository Interface + Implementation
  8. Service
  9. Controller (thin, JSON:API compliant)
  10. JsonApiResource
  11. Routes (versioned, PATCH for updates)
  12. Service Provider binding
  13. Feature Tests

Code Review

在 GitHub 查看完整 README

推荐工具

换一个关键词,或者移除筛选条件。

安装

npx skillfish add streeboga/laravel-api-skill
新手?先看 mcpskill.org 教程 →