Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

code-quality

БесплатноБез исполняемых скриптовНе проверен

PHP and Laravel code quality toolchain — static analysis with Larastan/PHPStan, code style enforcement with Pint, automated refactoring with Rector, baseline…

nasrulhazimот nasrulhazim★ 26 звёзд на GitHub

Об этом скилле

Code Quality Toolchain

Static analysis, code style enforcement, automated refactoring, and CI quality gates for Laravel projects. Built on top of Laravel Kickoff's existing PHPStan, Pint, Rector, and GitHub Actions configuration.

Command Reference

Command Description
/quality check Run Larastan analysis, interpret errors, suggest fixes
/quality fix Auto-fix Pint violations with explanations of what changed
/quality baseline Generate or update PHPStan baseline for legacy code
/quality rector Suggest and apply Rector rules for code modernisation
/quality ci Extend GitHub Actions CI with custom quality gates

Kickoff Baseline

Laravel Kickoff projects ship with these tools pre-configured:

Tool Config File Purpose
PHPStan / Larastan phpstan.neon Static analysis
Laravel Pint pint.json Code style (PSR-12 / Laravel preset)
Rector rector.php Automated refactoring
GitHub Actions .github/workflows/ci.yml CI pipeline

This skill extends that baseline — it does not replace it. Always read the existing config files before suggesting changes. Never overwrite without confirming with the user.


1. /quality check — Larastan Analysis

Step 1: Run Analysis

./vendor/bin/phpstan analyse --memory-limit=512M

If a baseline exists (phpstan-baseline.neon), PHPStan automatically excludes baselined errors. Only new errors are reported.

Step 2: Interpret Errors

For each error, explain:

  1. What the error means in plain language
  2. Why PHPStan flags it (type safety, missing return, undefined method, etc.)
  3. How to fix it with a concrete code change

Common Error Patterns

Error Pattern Meaning Fix
Parameter #1 $x expects string, int given Type mismatch in function call Cast or validate the input type
Call to an undefined method Method does not exist on the resolved type Add @method PHPDoc or fix the class reference
Property $x has no type declaration Missing property type Add typed property: public string $x;
Method should return X but returns Y Return type mismatch Fix return value or widen the return type
Access to an undefined property Property not declared on the class Declare the property or add @property PHPDoc
Dead catch — Throwable is never thrown Catching an exception that cannot occur Remove the dead catch or fix the try block
If condition is always true/false Redundant conditional logic Simplify the condition or remove dead code

Step 3: Suggest Fixes

Present fixes grouped by file. For each fix:

File: app/Services/PaymentService.php:42
Error: Parameter #1 $amount expects int, string given

Current:
    $this->charge($request->input('amount'));

Fix:
    $this->charge((int) $request->input('amount'));

Explanation: Request input returns string|null. Cast to int before passing
to charge() which expects an integer parameter.

Error Levels

Refer to references/larastan-rules.md for the full error level breakdown (0-9). Recommend the user start at level 5 for existing projects and work up incrementally.


2. /quality fix — Pint Code Style

Step 1: Preview Changes

./vendor/bin/pint --test

This shows what would change without modifying files.

Step 2: Apply Fixes

./vendor/bin/pint

Step 3: Explain Changes

After fixing, explain the most impactful changes. Group by rule:

Pint fixed 23 files:

Spacing & Alignment (14 files):
  - binary_operator_spaces: aligned = and => operators
  - no_extra_blank_lines: removed double blank lines

Imports (6 files):
  - ordered_imports: sorted use statements alphabetically
  - no_unused_imports: removed 4 unused imports

Type Declarations (3 files):
  - fully_qualified_strict_types: converted FQCN to imports

Step 4: Preset Recommendations

If the user has no pint.json or uses the default preset, recommend a preset based on project context. Refer to references/pint-presets.md for preset details and common rule customisations.

Context Recommended Preset
New Laravel project laravel (default)
Open-source package psr12
Strict team standards per with custom rules
Symfony-influenced symfony

3. /quality baseline — PHPStan Baseline Management

When to Use

  • Legacy codebase with hundreds of existing errors
  • Upgrading PHPStan level (e.g., 5 to 6) without fixing all errors immediately
  • Onboarding a team — prevent new errors while gradually fixing old ones

Step 1: Generate Baseline

./vendor/bin/phpstan analyse --generate-baseline

This creates phpstan-baseline.neon containing all current errors as "accepted" — future runs only flag new code.

Step 2: Include Baseline in Config

Verify phpstan.neon includes the baseline:

includes:
    - phpstan-
Полный SKILL.md на GitHub

Установить code-quality в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/larastan-rules.mdreferences/pint-presets.mdreferences/rector-sets.md

FAQ

Что делает скилл code-quality?

PHP and Laravel code quality toolchain — static analysis with Larastan/PHPStan, code style enforcement with Pint, automated refactoring with Rector, baseline management for legacy codebases, and CI pipeline integration via GitHub Actions. Use this skill whenever the user asks to check code quality, fix linting errors, run static analysis, modernise PHP code, set up CI quality gates, manage PHPStan baselines, configure Pint presets, or apply Rector rules. Triggers for requests like "run quality check", "fix my code style", "analyse with larastan", "update phpstan baseline", "modernise my PHP code", "set up CI for quality", "check code quality", "pint tak jalan", "nak fix phpstan error", "setup rector", "betulkan code style", "tambah quality gate dalam CI", or "baseline phpstan untuk legacy code". Assumes Laravel Kickoff as the baseline — PHPStan, Pint, Rector, and GitHub Actions CI are already configured. This skill extends and customises that baseline.

Как установить скилл code-quality?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл code-quality запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить code-quality с