mcpField
L
laravel-project-patterns

laravel-project-patterns

github.com/hosmelq开发1569 次安装1 天前更新
代码仓库

关于 laravel-project-patterns

用于按 Laravel 项目约定编写代码和测试的技能,通过检查现有模式并检索针对性示例提供指导。它强调保留真实 API、测试约定和项目工厂行为。

主要功能

  1. 01检查邻近代码与配置
  2. 02搜索并读取模式示例
  3. 03保留规范测试约定
  4. 04应用工厂关系指导

适用场景

  1. 01按 Laravel 约定实现功能
  2. 02添加符合测试套件规范的测试
  3. 03处理工厂及关联记录

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/hosmelq/skills --skill laravel-project-patterns

安装后在 Claude Code 中输入/laravel-project-patterns确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

agents/
openai.yaml
docs/
benchmark.md
search.md
references/actions/
00-action-implementation-order.md
01-input-fields.md
02-input-settings.md
03-input-ranges.md
04-input-relations.md
05-create-update.md
06-create-owner.md
07-create-dispatch.md
08-update-dispatch.md
09-active-parent.md
10-create-child.md
11-create-assignment.md
12-create-range.md
13-update-parent.md
14-update-child.md
15-update-range.md
16-update-group-order.md
17-simple-lifecycle.md
18-delete-history.md
19-delete-cascade.md
20-delete-parent.md
21-delete-child.md
22-state-lifecycle.md
23-deactivate-parent.md
24-reactivate-child.md
25-select-default.md
26-select-initial.md

README 原文English

来自项目 README

README 暂无中文译文,以下为英文原文;中文介绍见上方。

Laravel Project Patterns

Adapt fictional domain types and helpers to inspected contracts, keep reference-project identities confidential, and preserve real APIs such as sqid and HasSqid. For uncovered behavior, report the gap and follow the project’s conventions.

Inspect affected code, nearby examples and applicable configuration; use their actual namespaces and, for tests, suite paths.

Retrieve Missing Patterns

Reuse examples and candidate descriptions already in this context first. For missing behavior, write temporary JSON with request, paths (actual project paths), and code_context (concise inspected facts), then use:

uv run <skill-directory>/scripts/search.py search --task-file=<task.json> --session=<session.json>
uv run <skill-directory>/scripts/search.py read --session=<session.json> --ids <id> <id>

Search returns five ranked candidates; new IDs include applicability and token cost, known IDs only id and read. Select the smallest applicable set. For implementation use the model guide, enum guide, action guide, request guide, controller guide, resource guide, policy guide, job example, listener example, middleware guide, exception guide, support guide, console-notifications guide, bootstrap guide, database guide, forms guide, tooling guide. For a complete test block select its ordered checklist: create, destroy, edit, index, show, store, update, authentication or move. Initial and default selection include their ordered cases. For model tests use the model checklist; for HTTP Resources use the resource checklist; for enum tests use the enum checklist; for action tests use the action checklist; for jobs use the job checklist; for middleware use the middleware checklist; for support helpers use the support checklist; for console commands use the console checklist; for architecture use the complete ordered example. Media dimensions belong to Listener tests. Keep standalone tests at file scope when the suite uses no describe. A specialized example covers its stated assertions; retrieve another only for missing contracts. Search uncovered requirements with relevant facts; --limit=10 can broaden a shortlist. Rank and shortlist size do not prove coverage. Do not glob the catalog or open its linked files directly.

Read emits complete Markdown examples and a receipt; blocked IDs need another batch (4,000 source tokens per response). read: true means already emitted: reuse that content; repeated reads omit it. Use one temporary session outside the skill per task/agent context. After compaction use a new session to restore descriptions, or read --repeat if the needed ID remains known. Receipts are not model memory. Changed sources require searching again.

For tests, keep canonical names, documented case order, fixtures, assertions and datasets. Keep behavior qualifiers (parent/ancestor, case-insensitive, relation state). Add : field_name only to distinguish separate tests within one block; named dataset rows already distinguish fields. Do not introduce behavior to match an example. Prefer one line for simple calls of up to 100 characters; wrap longer calls or when a break improves readability.

Inspect factory definitions: use recycle() for existing default parents and derive unmodified intermediates from the created record. Keep trashed parents explicit. Use for() for optional or role-specific relations, root-only tenant assignment and deliberate mismatches. Recycling reaches nested factories, matches model type and leaves fixed/derived foreign keys unchanged; verify option-list membership and avoid same-type pools when an exact parent matters.

First search installs dependencies, downloads the model and builds the index; later searches refresh changed Markdown. Read loads no model. Resolve failures using the search guide. Benchmark evidence is optional. Maintainers may inspect catalog files directly.

评论

支持 Markdown