Agent Skillsrelaticle/relaticle › spatie-laravel-php

spatie-laravel-php

GitHub

为 Laravel/PHP 代码提供编码规范指导,涵盖控制器、模型、路由及 Blade 模板的生成、编辑、重构与格式化,确保符合 Spatie 标准及 PSR-12。

.claude/skills/spatie-laravel-php/SKILL.md relaticle/relaticle

Trigger Scenarios

创建或编辑 Laravel/PHP 代码文件 代码格式化和重构 审查 Laravel/PHP 代码风格

Install

npx skills add relaticle/relaticle --skill spatie-laravel-php -g -y
More Options

Non-standard path

npx skills add https://github.com/relaticle/relaticle/tree/main/.claude/skills/spatie-laravel-php -g -y

Use without installing

npx skills use relaticle/relaticle@spatie-laravel-php

指定 Agent (Claude Code)

npx skills add relaticle/relaticle --skill spatie-laravel-php -a claude-code -g -y

安装 repo 全部 skill

npx skills add relaticle/relaticle --all -g -y

预览 repo 内 skill

npx skills add relaticle/relaticle --list

SKILL.md

Frontmatter
{
    "name": "spatie-laravel-php",
    "license": "MIT",
    "metadata": {
        "author": "Spatie"
    },
    "description": "Apply Spatie's Laravel and PHP coding standards for any task that creates, edits, reviews, refactors, or formats Laravel\/PHP code or Blade templates; use for controllers, Eloquent models, routes, config, validation, migrations, tests, and related files to align with Laravel conventions and PSR-12."
}

Spatie Laravel & PHP Guidelines

Overview

Apply Spatie's Laravel and PHP guidelines to keep code style consistent and Laravel-native.

When to Activate

  • Activate this skill for any Laravel or PHP coding work, even if the user does not explicitly mention Spatie.
  • Activate this skill when asked to generate, edit, format, refactor, review, or align Laravel/PHP code.
  • Activate this skill when working on .php or .blade.php files, routes, controllers, models, config, validation, migrations, or tests.

Scope

  • In scope: .php, .blade.php, Laravel conventions (routes, controllers, config, validation, migrations, tests).
  • Out of scope: JS/TS, CSS, infrastructure, database schema design, non-Laravel frameworks.

Workflow

  1. Identify the artifact (controller, route, config, model, Blade, test, etc.).
  2. Read references/spatie-laravel-php-guidelines.md and focus on the relevant sections.
  3. Apply the core Laravel principle first, then PHP standards, then section-specific rules.
  4. If a rule conflicts with existing project conventions, follow Laravel conventions and keep changes consistent.

Core Rules (Summary)

  • Follow Laravel conventions first.
  • Follow PSR-1, PSR-2, and PSR-12.
  • Prefer typed properties and explicit return types (including void).
  • Use short nullable syntax like ?string.
  • Use constructor property promotion when all properties can be promoted.
  • One trait per line with separate use statements.
  • Once a method chain breaks across lines, put every subsequent -> on a new line; never mix single-line and multi-line chaining.
  • Prefer early returns and avoid else when possible.
  • Always use curly braces for control structures.
  • Use string interpolation over concatenation.
  • Happy path last: handle error conditions first.

Do and Don't

Do:

  • Use kebab-case URLs, camelCase route names, and camelCase route parameters.
  • Use tuple notation for routes: [Controller::class, 'method'].
  • Use plural resource names for controllers (PostsController).
  • Use array notation for validation rules.
  • Use config() helper and avoid env() outside config files.
  • Add service configs to config/services.php, not new files.
  • Use __() for translations instead of @lang.
  • Use PascalCase for enum values and class constants.

Don't:

  • Add docblocks when full type hints already exist.
  • Use fully qualified classnames in docblocks.
  • Use final or readonly by default.
  • Use else when early returns work.
  • Add spaces after Blade control structures.

Examples

// Happy path last with early returns
if (! $user) {
    return null;
}

if (! $user->isActive()) {
    return null;
}

// Process active user...

// Short ternary
$name = $isFoo ? 'foo' : 'bar';

// Constructor property promotion
class MyClass {
    public function __construct(
        protected string $firstArgument,
        protected string $secondArgument,
    ) {}
}
@if($condition)
    Something
@endif

References

  • references/spatie-laravel-php-guidelines.md

Version History

  • 1f433f8 Current 2026-08-20 14:43

Same Skill Collection

.claude/skills/echo-development/SKILL.md
.claude/skills/laravel-query-builder/SKILL.md
.claude/skills/medialibrary-development/SKILL.md
.claude/skills/socialite-development/SKILL.md
.claude/skills/spatie-javascript/SKILL.md
.claude/skills/spatie-security/SKILL.md
.claude/skills/spatie-version-control/SKILL.md
.github/skills/custom-fields-development/SKILL.md
.github/skills/flowforge-development/SKILL.md
.claude/skills/agent-browser-relaticle/SKILL.md
.claude/skills/ai-sdk-development/SKILL.md
.claude/skills/business-review/SKILL.md
.claude/skills/cashier-stripe-development/SKILL.md
.claude/skills/configuring-horizon/SKILL.md
.claude/skills/fortify-development/SKILL.md
.claude/skills/infer-conventions/SKILL.md
.claude/skills/laravel-best-practices/SKILL.md
.claude/skills/livewire-development/SKILL.md
.claude/skills/mcp-development/SKILL.md
.claude/skills/passport-development/SKILL.md
.claude/skills/pennant-development/SKILL.md
.claude/skills/pest-testing/SKILL.md
.claude/skills/screenshot-with-callout/SKILL.md
.claude/skills/tailwindcss-development/SKILL.md
.github/skills/livewire-development/SKILL.md
.github/skills/manual-testing/SKILL.md
.github/skills/tailwindcss-development/SKILL.md

Metadata

Files
0
Version
1f433f8
Hash
63927b12
Indexed
2026-08-20 14:43

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-24 22:32
浙ICP备14020137号-1 $방문자$