Communitygithub.com

Laravel 驗證迴圈

用於 Laravel 專案的完整驗證流程:環境檢查、程式碼風格檢查、靜態分析、測試涵蓋率、安全性掃描以及部署就緒評估。適用於合併或部署前對 Laravel 專案進行 lint、靜態分析、測試、涵蓋率及安全性驗證。

Laravel 驗證迴圈 是什麼?

這個技能提供了一個結構化的「Laravel 驗證迴圈」工作流程,專為合併請求 (PR) 提交前、重大重構後或部署至正式環境前設計。它將 Laravel 專案的常見驗證任務(環境檢查、Composer 驗證、Linting、靜態分析、測試、安全性掃描、資料庫遷移審查、快取最佳化、佇列及排程檢查)組織成七個循序漸進的階段。每個階段都建立在上一階段之上,允許在早期階段快速失敗(例如環境或 Composer 錯誤),從而避免浪費時間在後續步驟。該技能支援多種工具:Pint 或 PHPCS 用於 Linting、PHPStan 或 Psalm 用於靜態分析、Xdebug 用於測試涵蓋率、以及 Composer Audit 用於安全性檢查。它還包含 Laravel 特有步驟,例如 Horizon 監控、排程檢查、佇列健康檢查(尤其是透過健康檢查佇列)。使用者可以按照文件中提供的標準 CI/CD 範例,將此技能整合至任何 CI 管道中,或手動執行各個階段。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/laravel-verification

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Laravel 驗證迴圈 是做什麼的?

在 PR 之前、重大變更之後以及部署之前執行。

使用時機

  • 為 Laravel 專案開啟合併請求之前
  • 重大重構或依賴套件升級之後
  • 預備環境 (staging) 或正式環境 (production) 的部署前驗證
  • 執行完整的 lint → 測試 → 安全 → 部署就緒管線

運作方式

  • 依序從環境檢查執行到部署就緒,讓每一層都建立在前一層的基礎上。
  • 環境和 Composer 檢查會做為所有後續步驟的閘門;若失敗則立即停止。
  • 在執行完整的測試和涵蓋率之前,Linting/靜態分析應保持乾淨。
  • 安全性和遷移審查在測試之後執行,以便在進行資料或發布步驟之前先驗證行為。
  • 建置/部署就緒以及佇列/排程檢查是最後的閘門;任何失敗都會阻擋發布。

第一階段:環境檢查

php -v
composer --version
php artisan --version
  • 確認 .env 檔案存在且必要的金鑰已設定
  • 在正式環境中確認 APP_DEBUG=false
  • 確認 APP_ENV 符合目標部署環境 (production, staging)

若在本機使用 Laravel Sail:

./vendor/bin/sail php -v
./vendor/bin/sail artisan --version

第一.五階段:Composer 與自動載入

composer validate
composer dump-autoload -o

第二階段:Linting 與靜態分析

vendor/bin/pint --test
vendor/bin/phpstan analyse

若專案使用 Psalm 而非 PHPStan:

vendor/bin/psalm

第三階段:測試與涵蓋率

php artisan test

涵蓋率 (CI):

XDEBUG_MODE=coverage php artisan test --coverage

CI 範例 (格式 → 靜態分析 → 測試):

vendor/bin/pint --test
vendor/bin/phpstan analyse
XDEBUG_MODE=coverage php artisan test --coverage

第四階段:安全性與依賴套件檢查

composer audit

第五階段:資料庫與遷移

php artisan migrate --pretend
php artisan migrate:status
  • 仔細審查具有破壞性 (destructive) 的遷移
  • 確保遷移檔案名稱遵循 Y_m_d_His_* 格式(例如 2025_03_14_154210_create_orders_table.php)並清楚描述變更內容
  • 確保可以回滾 (rollback)
  • 驗證 down() 方法,若無明確備份則避免不可逆的資料遺失

第六階段:建置與部署就緒

php artisan optimize:clear
php artisan config:cache
php artisan route:cache
php artisan view:cache
  • 確保快取熱載入 (warmups) 在正式環境設定中成功
  • 驗證佇列工作者 (queue workers) 和排程器 (scheduler) 已設定
  • 確認目標環境中的 storage/ 和 bootstrap/cache/ 目錄可寫入

第七階段:佇列與排程檢查

php artisan schedule:list
php artisan queue:failed

若使用 Horizon:

php artisan horizon:status

若可使用 queue:monitor,則使用它來檢查佇列積壓 (backlog),而不需處理任務:

php artisan queue:monitor default --max=100

主動驗證 (僅限預備環境):將一個空操作 (no-op) 任務分派到專用的佇列,並執行單一工作者來處理它(確保已設定非 sync 的佇列連線)。

php artisan tinker --execute="dispatch((new App\Jobs\QueueHealthcheck())->onQueue('healthcheck'))"
php artisan queue:work --once --queue=healthcheck

驗證該任務產生了預期的副作用 (side effect)(日誌記錄、健康檢查資料表行或指標)。

僅在非正式環境中執行此操作,確保處理測試任務是安全的。

範例

最小流程:

php -v
composer --version
php artisan --version
composer validate
vendor/bin/pint --test
vendor/bin/phpstan analyse
php artisan test
composer audit
php artisan migrate --pretend
php artisan config:cache
php artisan queue:failed

CI 風格的管線:

composer validate
composer dump-autoload -o
vendor/bin/pint --test
vendor/bin/phpstan analyse
XDEBUG_MODE=coverage php artisan test --coverage
composer audit
php artisan migrate --pretend
php artisan optimize:clear
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan schedule:list

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

相關技能