laravelconstants-and-configuration

将代码中的硬编码值替换为常量、枚举和配置项,以提高可维护性和可读性。采用 PHP 8.1+ 的枚举特性,并把可变参数移入配置文件,集中管理应用常量与配置。

仓库最近推送
GitHub Stars
157
Forks
3
Issues / PRs
0

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "laravelconstants-and-configuration":https://skillpi.com/zh/skills/deepskill-63c06cc5cff1280d3c76bb95f591cb0bd9f1ed894f30a7fd34f66fc227b57740。安装前核对上游来源和版本:https://github.com/jpcaparas/superpowers-laravel。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

将代码中的硬编码值替换为常量、枚举和配置项,以提高可维护性和可读性。采用 PHP 8.1+ 的枚举特性,并把可变参数移入配置文件,集中管理应用常量与配置。

0 下载

介绍来源: third_party · jpcaparas · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: laravel:constants-and-configuration
description: Replace hardcoded values with constants, enums, and configuration for maintainability; use PHP 8.1+ enums and config files

Constants and Configuration Values

Avoid hardcoded values throughout your codebase. Use constants, configuration files, and enums to make your application more maintainable, refactorable, and debuggable.

The Problem with Hardcoded Values

// BAD: Magic numbers and strings scattered everywhere
if ($user->role === 'admin') { // What other roles exist?
    $cacheTime = 3600; // What does 3600 mean?
}

if ($order->status === 1) { // What does 1 represent?
    $discount = 0.15; // Why 15%?
}

Cache::remember('users_list', 600, fn() => ...); // 600 what?

Solution 1: PHP Constants and Enums

Class Constants

// app/Constants/UserRole.php
class UserRole
{
    public const ADMIN = 'admin';
    public const EDITOR = 'editor';
    public const VIEWER = 'viewer';
    public const GUEST = 'guest';

    public const ALL = [
        self::ADMIN,
        self::EDITOR,
        self::VIEWER,
        self::GUEST,
    ];

    public static function hasPermission(string $role, string $action): bool
    {
        return match($role) {
            self::ADMIN => true,
            self::EDITOR => in_array($action, ['read', 'write', 'edit']),
            self::VIEWER => $action === 'read',
            self::GUEST => false,
            default => false,
        };
    }
}

// Usage
if ($user->role === UserRole::ADMIN) {
    // Clear intent
}

PHP 8.1+ Enums

// app/Enums/OrderStatus.php
enum OrderStatus: string
{
    case PENDING = 'pending';
    case PROCESSING = 'processing';
    case SHIPPED = 'shipped';
    case DELIVERED = 'delivered';
    case CANCELLED = 'cancelled';
    case REFUNDED = 'refunded';

    public function label(): string
    {
        return match($this) {
            self::PENDING => 'Pending Payment',
            self::PROCESSING => 'Processing',
            self::SHIPPED => 'Shipped',
            self::DELIVERED => 'Delivered',
            self::CANCELLED => 'Cancelled',
            self::REFUNDED => 'Refunded',
        };
    }

    public function color(): string
    {
        return match($this) {
            self::PENDING => 'yellow',
            self::PROCESSING => 'blue',
            self::SHIPPED => 'indigo',
            self::DELIVERED => 'green',
            self::CANCELLED => 'red',
            self::REFUNDED => 'gray',
        };
    }

    public function canTransitionTo(self $newStatus): bool
    {
        return match($this) {
            self::PENDING => in_array($newStatus, [
                self::PROCESSING,
                self::CANCELLED,
            ]),
            self::PROCESSING => in_array($newStatus, [
                self::SHIPPED,
                self::CANCELLED,
            ]),
            self::SHIPPED => $newStatus === self::DELIVERED,
            self::DELIVERED => $newStatus === self::REFUNDED,
            default => false,
        };
    }
}

// Model with enum casting
class Order extends Model
{
    protected $casts = [
        'status' => OrderStatus::class,
    ];

    public function transitionTo(OrderStatus $newStatus): void
    {
        if (!$this->status->canTransitionTo($newStatus)) {
            throw new InvalidStateTransition(
                "Cannot transition from {$this->status->value} to {$newStatus->value}"
            );
        }

        $this->update(['status' => $newStatus]);
    }
}

// Usage
$order->transitionTo(OrderStatus::PROCESSING);

Solution 2: Configuration Files

Application-Wide Settings

// config/app.php
return [
    'cache_ttl' => [
        'short' => 60,      // 1 minute
        'medium' => 300,    // 5 minutes
        'long' => 3600,     // 1 hour
        'day' => 86400,     // 24 hours
    ],

    'pagination' => [
        'default' => 20,
        'max' => 100,
        'options' => [10, 20, 50, 100],
    ],

    'upload' => [
        'max_file_size' => 10 * 1024 * 1024, // 10MB
        'allowed_extensions' => ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx'],
        'storage_path' => 'uploads',
    ],

    'business' => [
        'tax_rate' => 0.08,
        'shipping_threshold' => 50.00,
        'discount_tiers' => [
            'bronze' => 0.05,
            'silver' => 0.10,
            'gold' => 0.15,
            'platinum' => 0.20,
        ],
    ],
];

// Usage
Cache::remember(
    'products',
    config('app.cache_ttl.long'),
    fn() => Product::all()
);

$maxSize = config('app.upload.max_file_size');

Feature-Specific Configuration

// config/payment.php
return [
    'stripe' => [
        'key' => env('STRIPE_KEY'),
        'secret' => env('STRIPE_SECRET'),
        'webhook_secret' => env('STRIPE_WEBHOOK_SECRET'),
        'webhook_tolerance' => 300, // seconds
        'currency' => 'usd',
        'minimum_amount' => 50, // cents
    ],

    'retry' => [
        'max_attempts' => 3,
        'delay_seconds' => [5, 10, 30],
    ],

    'statuses' => [
        'pending' => 'pending',
        'processing' => 'processing',
        'succeeded' => 'succeeded',
        'failed' => 'failed',
    ],
];

// Usage in service
class PaymentService
{
    public function charge(int $amount): void
    {
        if ($amount < config('payment.stripe.minimum_amount')) {
            throw new InvalidAmountException('Amount below minimum');
        }

        // Process payment
    }
}

Solution 3: Database-Driven Configuration

Settings Model

// app/Models/Setting.php
class Setting extends Model
{
    protected $fillable = ['key', 'value', 'type'];

    protected $casts = [
        'value' => 'json',
    ];

    public static function get(string $key, mixed $default = null): mixed
    {
        return Cache::remember(
            "settings.{$key}",
            config('app.cache_ttl.long'),
            fn() => static::where('key', $key)->first()?->value ?? $default
        );
    }

    public static function set(string $key, mixed $value): void
    {
        static::updateOrCreate(
            ['key' => $key],
            ['value' => $value]
        );

        Cache::forget("settings.{$key}");
    }

    protected static function booted(): void
    {
        static::saved(function ($setting) {
            Cache::forget("settings.{$setting->key}");
        });
    }
}

// Usage
$maintenanceMode = Setting::get('maintenance_mode', false);
$maxLoginAttempts = Setting::get('max_login_attempts', 5);

Solution 4: Service Constants

// app/Services/CacheService.php
class CacheService
{
    // Cache key patterns
    public const USER_KEY = 'user:%d';
    public const USER_POSTS_KEY = 'user:%d:posts';
    public const POST_KEY = 'post:%d';
    public const TRENDING_KEY = 'trending:%s:page:%d';

    // Cache tags
    public const TAG_USERS = 'users';
    public const TAG_POSTS = 'posts';
    public const TAG_COMMENTS = 'comments';

    public static function getUserKey(int $userId): string
    {
        return sprintf(self::USER_KEY, $userId);
    }

    public static function getUserPostsKey(int $userId): string
    {
        return sprintf(self::USER_POSTS_KEY, $userId);
    }

    public static function rememberUser(int $userId, Closure $callback)
    {
        return Cache::tags([self::TAG_USERS])->remember(
            self::getUserKey($userId),
            config('app.cache_ttl.medium'),
            $callback
        );
    }
}

// Usage
$user = CacheService::rememberUser($userId, fn() => User::find($userId));

Solution 5: Validation Constants

// app/Rules/ValidationRules.php
class ValidationRules
{
    public const NAME_REGEX = '/^[a-zA-Z\s\-\']+$/';
    public const PHONE_REGEX = '/^\+?[1-9]\d{1,14}$/';
    public const USERNAME_REGEX = '/^[a-zA-Z0-9_]{3,20}$/';
    public const SLUG_REGEX = '/^[a-z0-9\-]+$/';

    public const PASSWORD_MIN = 8;
    public const PASSWORD_MAX = 128;
    public const BIO_MAX = 500;
    public const COMMENT_MAX = 1000;

    public static function password(): array
    {
        return [
            'required',
            'string',
            'min:' . self::PASSWORD_MIN,
            'max:' . self::PASSWORD_MAX,
            Password::defaults(),
        ];
    }

    public static function username(): array
    {
        return [
            'required',
            'string',
            'regex:' . self::USERNAME_REGEX,
            'unique:users,username',
        ];
    }
}

// In FormRequest
public function rules(): array
{
    return [
        'username' => ValidationRules::username(),
        'password' => ValidationRules::password(),
        'bio' => ['nullable', 'string', 'max:' . ValidationRules::BIO_MAX],
    ];
}

Solution 6: HTTP Status Constants

// app/Http/Responses/ApiResponse.php
class ApiResponse
{
    // Standard HTTP codes as constants for clarity
    public const OK = 200;
    public const CREATED = 201;
    public const ACCEPTED = 202;
    public const NO_CONTENT = 204;
    public const BAD_REQUEST = 400;
    public const UNAUTHORIZED = 401;
    public const FORBIDDEN = 403;
    public const NOT_FOUND = 404;
    public const VALIDATION_ERROR = 422;
    public const SERVER_ERROR = 500;

    // Custom application codes
    public const CODE_SUCCESS = 1000;
    public const CODE_VALIDATION_FAILED = 2001;
    public const CODE_RESOURCE_NOT_FOUND = 2002;
    public const CODE_UNAUTHORIZED_ACTION = 2003;
    public const CODE_RATE_LIMITED = 2004;

    public static function success($data = null, string $message = 'Success'): JsonResponse
    {
        return response()->json([
            'success' => true,
            'code' => self::CODE_SUCCESS,
            'message' => $message,
            'data' => $data,
        ], self::OK);
    }

    public static function error(string $message, int $httpCode = self::BAD_REQUEST, int $appCode = null): JsonResponse
    {
        return response()->json([
            'success' => false,
            'code' => $appCode ?? $httpCode,
            'message' => $message,
        ], $httpCode);
    }
}

// Usage
return ApiResponse::success($user, 'User created successfully');
return ApiResponse::error('Resource not found', ApiResponse::NOT_FOUND);

Solution 7: Queue Priorities and Job Constants

// app/Jobs/JobPriority.php
class JobPriority
{
    public const CRITICAL = 'critical';
    public const HIGH = 'high';
    public const NORMAL = 'default';
    public const LOW = 'low';

    public const MAX_TRIES = [
        self::CRITICAL => 5,
        self::HIGH => 3,
        self::NORMAL => 3,
        self::LOW => 1,
    ];

    public const TIMEOUT = [
        self::CRITICAL => 300,  // 5 minutes
        self::HIGH => 180,      // 3 minutes
        self::NORMAL => 120,    // 2 minutes
        self::LOW => 60,        // 1 minute
    ];
}

// app/Jobs/ProcessPayment.php
class ProcessPayment implements ShouldQueue
{
    public $tries = JobPriority::MAX_TRIES[JobPriority::HIGH];
    public $timeout = JobPriority::TIMEOUT[JobPriority::HIGH];

    public function __construct(
        public Payment $payment
    ) {}

    public function handle(): void
    {
        // Process payment
    }

    public function queue(): string
    {
        return JobPriority::HIGH;
    }
}

Environment-Specific Constants

// app/Providers/AppServiceProvider.php
class AppServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        // Define environment-specific constants
        if (app()->environment('local', 'testing')) {
            Config::set('app.debug_mode', true);
            Config::set('app.cache_ttl.short', 1); // Shorter cache in dev
        }

        if (app()->environment('production')) {
            Config::set('app.debug_mode', false);
            Config::set('app.rate_limit', 60); // Stricter in production
        }
    }
}

Testing with Constants

test('order status transitions work correctly', function () {
    $order = Order::factory()->create([
        'status' => OrderStatus::PENDING
    ]);

    // Valid transition
    $order->transitionTo(OrderStatus::PROCESSING);
    expect($order->status)->toBe(OrderStatus::PROCESSING);

    // Invalid transition
    expect(fn() => $order->transitionTo(OrderStatus::PENDING))
        ->toThrow(InvalidStateTransition::class);
});

test('cache keys are consistent', function () {
    $userId = 123;

    $key1 = CacheService::getUserKey($userId);
    $key2 = sprintf(CacheService::USER_KEY, $userId);

    expect($key1)->toBe($key2)
        ->and($key1)->toBe('user:123');
});

test('validation rules are applied correctly', function () {
    $data = ['username' => 'ab']; // Too short

    $validator = Validator::make($data, [
        'username' => ValidationRules::username()
    ]);

    expect($validator->fails())->toBeTrue();
});

Best Practices

  1. Group related constants

    class OrderConstants
    {
        // Statuses
        public const STATUS_PENDING = 'pending';
        public const STATUS_PAID = 'paid';
    
        // Limits
        public const MAX_ITEMS = 100;
        public const MIN_TOTAL = 10.00;
    }
  2. Use descriptive names

    // BAD
    const TIMEOUT = 30;
    
    // GOOD
    const API_TIMEOUT_SECONDS = 30;
  3. Document units and meanings

    class RateLimits
    {
        /** Maximum requests per minute for anonymous users */
        public const ANONYMOUS_PER_MINUTE = 20;
    
        /** Maximum requests per minute for authenticated users */
        public const AUTHENTICATED_PER_MINUTE = 60;
    
        /** Lockout duration in minutes after max attempts */
        public const LOCKOUT_MINUTES = 15;
    }
  4. Validate against constants

    public function setRole(string $role): void
    {
        if (!in_array($role, UserRole::ALL)) {
            throw new InvalidArgumentException("Invalid role: {$role}");
        }
    
        $this->role = $role;
    }
  5. Use configuration for environment-specific values

    // Don't use constants for environment-specific values
    // BAD: const API_KEY = 'abc123';
    
    // GOOD: Use config
    'api_key' => env('EXTERNAL_API_KEY'),
  6. Create helper functions for complex constants

    class DateConstants
    {
        public static function secondsIn(string $unit): int
        {
            return match($unit) {
                'minute' => 60,
                'hour' => 3600,
                'day' => 86400,
                'week' => 604800,
                default => throw new InvalidArgumentException("Unknown unit: {$unit}")
            };
        }
    }
    
    // Usage
    $cacheTime = DateConstants::secondsIn('hour') * 2; // 2 hours

Remember: Constants make your code self-documenting, reduce bugs from typos, and make refactoring much safer!

版本历史

  1. v0.1.5 GitHub ↗
    原版更新说明

    # Laravel Superpowers — Release Notes ## v0.1.5 (2025-11-11) Added five new best practice skills based on recommendations from https://saasykit.com/blog/laravel-best-practices to provide comprehensive coverage of Laravel development patterns. ### Added (Skills) - **Routes Best Practices** (`routes-best-practices`) - Keep routes clean and focused on mapping requests to controllers, avoiding business logic in route files - **Data Chunking for Large Datasets** (`data-chunking-large-datasets`) - Handle large datasets efficiently with `chunk()`, `chunkById()`, `lazy()`, and `cursor()` methods - **Internationalization and Translation** (`internationalization-and-translation`) - Build with i18n in mind from day one using Laravel's translation helpers - **Constants and Configuration** (`constants-and-configuration`) - Replace hardcoded values with constants, enums, and configuration for better maintainability - **Documentation Best Practices** (`documentation-best-practices`) - Write meaningful documentation that explains "why" not "what", focusing on complex business logic ### Notes These additions complement the existing comprehensive skill set by filling gaps identified from the SaaSykit Laravel best practices guide. All new skills include extensive examples, anti-patterns, and real-world use cases.

  2. v0.1.4 GitHub ↗
    原版更新说明

    # Laravel Superpowers — Release Notes ## v0.1.4 (2025-11-04) Monorepo-aware SessionStart with multi-app detection, per-app version reporting, and scoped Sail guidance. ### Monorepo Support - Recursively discovers Laravel apps by locating `artisan` anywhere in the repo (ignores heavy/irrelevant folders like `vendor/`, `node_modules/`, `storage/`, VCS/IDE folders). - Supports multiple Laravel apps in a single repository. The hook lists all detected apps with: - Relative path - Laravel version (from `composer.lock` via `jq` when available, with fallback to `composer.json` constraint or a portable parser) - Sail availability, and whether containers appear to be running - Determines the “active” app based on the current working directory; if only one app exists, it becomes active automatically. - Emits Sail guidance and interactive safety for the active app only, to avoid cross-app confusion. ### Testing - Extended `scripts/test_session_start.sh` to cover: - Non-Laravel repo bailout - Single app (no Sail) - Sail present but containers stopped (interactive safety messaging) - Sail present with containers running - Monorepo with two nested apps on different Laravel versions - Monorepo where hook runs inside a nested app (active app semantics) - CI workflow `.github/workflows/test-session-start.yml` continues to run this script; no changes required beyond the added scenarios. ### Notes - If `jq` is unavailable, the hook falls back to a portable parser for version detection; output may show version constraints or `unknown` in minimal setups.

  3. v0.1.3 GitHub ↗
    原版更新说明

    # Laravel Superpowers — Release Notes ## v0.1.2 (2025-11-04) Docs sweep across Laravel 11.x and 12.x, with new skills matching the intersection of stable patterns. Also consolidated duplicates and kept commands thin. ### Added (Skills) - Form Requests & Validation (`laravel:form-requests`) - Policies & Authorization (`laravel:policies-and-authorization`) - Eloquent Relationships & Loading (`laravel:eloquent-relationships`) - Transactions & Consistency (`laravel:transactions-and-consistency`) - HTTP Client Resilience (`laravel:http-client-resilience`) - Task Scheduling (`laravel:task-scheduling`) - API Resources & Pagination (`laravel:api-resources-and-pagination`) - Blade Components & Layouts (`laravel:blade-components-and-layouts`) - Filesystem Uploads & URLs (`laravel:filesystem-uploads`) - Rate Limiting & Throttle (`laravel:rate-limiting`) - Exception Handling & Logging (`laravel:exception-handling-and-logging`) Matching command wrappers were added under `commands/` using the existing convention. ### Changed - Unified caching guidance into `laravel:performance-caching` (added tags, locks, invalidation best‑practices). Removed the duplicate cache strategies skill/command. - De‑duplicated Eloquent guidance: relationships skill now references `laravel:performance-eager-loading` for N+1 detection/measurement. ### Removed - Subagents that duplicated skills (Form Request Builder, Policy Planner, Transaction Auditor, API Resource Designer). The repo keeps subagents minimal; the controller cleaner remains. - Redundant Sail prompt skill (covered by runner selection and integration docs). ### Docs - Summary of 11.x/12.x intersection captured within the new skills themselves.

  4. v0.1.2 GitHub ↗
    原版更新说明

    # Laravel Superpowers — Release Notes ## v0.1.1 (2025-11-04) Smarter Laravel detection, Sail via binary presence, and safer command guidance. ### Detection & Safety - SessionStart now bails out cleanly for non‑Laravel repos (no output), ensuring the plugin does NOT activate outside Laravel projects. - Sail is detected by executable presence only: `vendor/bin/sail` (or a top‑level `./sail` helper). We no longer parse `composer.json` or rely on `jq` for Sail checks. - Determines whether containers are running via `docker compose ps` / `docker-compose ps` (unchanged). - Injects guidance to prefer Sail commands when Sail is available; clearly maps Sail vs host command pairs (artisan/composer/php/node/db). - Interactive safety: when Sail is available but containers are not running, the assistant must ask whether to start containers (`sail up -d`) or proceed using host tools—no host PHP/Composer/DB/Node commands should run until the user chooses. ### Docs & Screenshots - README now includes screenshots of SessionStart with and without Sail. ### Docs & Skills Cleanup - Replaced hardcoded Sail-only lines with Sail/non‑Sail pairs: - `skills/migrations-and-factories/SKILL.md` - `skills/queues-and-horizon/SKILL.md` - `skills/daily-workflow/SKILL.md` - `skills/quality-checks/SKILL.md` - Ensured quality/static analysis and frontend checks include host equivalents. ### New Skill - [Removed] Previously documented interactive Sail prompt skill. Interactive safety is still enforced by the assistant when Sail is declared but containers are not running. ### Reference - Common Sail commands supported: `sail up|stop|restart|ps`, `sail artisan …`, `sail php …`, `sail composer …`, `sail node|npm|npx|pnpm|pnpx|yarn|bun|bunx …`, `sail mysql|mariadb|psql|mongodb|redis|valkey`, `sail test|phpunit|pest|pint|dusk`.

  5. v0.1.0 GitHub ↗
    原版更新说明

    ## v0.1.0 (2025-11-03) First public release of Laravel Superpowers — a Laravel‑focused skills library for Claude Code. It brings proven workflows (TDD, debugging, planning) together with Laravel‑aware guidance that stays platform‑agnostic (works with or without Sail). ### Highlights - Plugin identity and marketplace metadata for the Laravel fork - Renamed plugin to `superpowers-laravel` and pointed metadata to `jpcaparas/superpowers-laravel` - Added local marketplace entry to simplify install during development - Laravel‑aware SessionStart - Startup hook auto‑detects Laravel projects (via `artisan` or `composer.json` with `laravel/framework`) - Injects a concise “Using Superpowers in Laravel Projects” introduction when Laravel is detected - New Laravel skills (all Sail/non‑Sail compatible) - Onboarding & Runner (using‑laravel‑superpowers, runner‑selection) - Development & Testing (tdd‑with‑pest, migrations‑and‑factories) - Quality & Operations (quality‑checks, queues‑and‑horizon) - Architecture & Complexity (ports‑and‑adapters, template‑method‑and‑plugins, complexity‑guardrails) - Optional skills (scaffolding for growing teams) - Nova resource patterns; Horizon dashboards/metrics; E2E Playwright patterns - API surface evolution; Config/Env storage strategy - Key commands (plugin‑namespaced) - `/superpowers-laravel:brainstorm`, `/superpowers-laravel:write-plan`, `/superpowers-laravel:execute-plan` - `/superpowers-laravel:laravel-check`, `/superpowers-laravel:laravel-tdd` - Documentation - Updated README for Laravel‑first usage (now includes repo logo) - Added Related Tools note for Laravel Boost (complementary if installed) - New integration guide: `docs/laravel/INTEGRATION.md` - New installation notes (version‑agnostic): `docs/laravel/INSTALLATION-NOTES.md` ### Files - Hook: `hooks/session-start.sh` (Laravel detection + onboarding) - Skills live under `skills/`; commands under `commands/` - Docs: `docs/laravel/INTEGRATION.md`, `docs/laravel/INSTALLATION-NOTES.md` ### New skills inspired by Clean Coders Guide - Controller cleanup; performance (eager loading, select columns, caching); dependency trimming - Helpers; interfaces + DI; strategy; controller testing ### Commands - Examples provided for core flows and a few advanced skills; run `/help` to see everything available in your environment. ### Maintenance - Moved Laravel skills from `skills/laravel/**` to first‑party `skills/**` - Removed empty directories after consolidation - Cleaned references in README and docs to reflect new locations and command namespace - Added CI validation for skills structure and plugin conventions: `.github/workflows/validate-skills.yml` ### Notes - All skills intentionally include Sail/non‑Sail command pairs to avoid platform lock‑in. - Insights is treated as optional; Pint and static analysis (PHPStan/Psalm) are encouraged as baselines.

当前收录版本

0.0.1

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值85/100

亮点

  • 提供 Laravel 项目中常量、枚举、配置文件的完整最佳实践指南
  • 涵盖 PHP 8.1+ 枚举、配置文件、数据库驱动配置等多种方案
  • 包含丰富的代码示例和测试用例,实用性强
触发精准95/100

亮点

  • 触发描述清晰明确,准确表达 Skill 核心功能
  • 指定技术栈(PHP 8.1+、Laravel)和使用场景,边界清晰
结构规范90/100

待提升项

  • 缺少显式 When to Use 章节 原报告严重程度:轻微

    文档未设置独立的 When to Use 章节说明适用场景

    改进建议:建议在开头添加 When to Use 段落,明确说明本 Skill 适用于 Laravel 项目重构、代码规范制定等场景

  • 文档长度偏长 原报告严重程度:轻微

    SKILL.md 文件约1800行,可能影响加载和阅读体验

    改进建议:考虑将部分内容拆分为引用文件,或添加目录导航提升可读性

  • frontmatter 字段不完整 原报告严重程度:轻微

    缺少 author、version、tags 等可选但推荐的元数据字段

    改进建议:建议补充 author、version、tags 等字段以增强 Skill 可发现性

亮点

  • 结构清晰,分多个解决方案逐步展开
  • 每个方案均包含代码示例、用法说明和最佳实践
  • frontmatter 基础字段完整,符合规范
执行可靠90/100

亮点

  • 所有代码示例语法正确,符合 Laravel 和 PHP 8.1+ 规范
  • 配置项来源明确,参数设置合理
  • 涵盖缓存、验证、队列等关键场景,可靠性高
证据可验 (前四项均值)90/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

  • 账号、密钥或授权

    使用专用、最小权限账号,不把密钥粘贴到公开内容或命令日志;核对接收数据的服务与租户。

    主文档提及 · 第 579, 582 行

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。