Communitygithub.com

laravel-verification

Laravel 项目的验证循环:环境检查、代码风格检查、静态分析、带覆盖率的测试、安全扫描以及部署就绪检查。在合并或部署前验证 Laravel 项目时使用——依次执行代码风格检查、静态分析、测试、覆盖率检查。

laravel-verification 是什么?

这是一个专为 Laravel 项目设计的综合性验证技能。它提供一个分阶段的自动化验证流程,涵盖环境检查、Composer 依赖验证、代码风格检查(Linting)、静态分析、测试并支持覆盖率、安全审计、数据库迁移检查以及部署就绪性评估。该技能支持多种 Laravel 运行环境(本地、Sail、CI),并能根据环境自动调整命令(如使用 `XDEBUG_MODE=coverage` 进行覆盖率测试)。其核心价值在于将复杂的发布前验证过程结构化为可重复执行的七阶段流水线,确保代码质量和部署安全。它兼容流行的 Laravel 工具链,包括 Pint(代码风格)、PHPStan/Psalm(静态分析)以及 Horizon(队列监控)。最终输出一系列可直接在终端或 CI 流程中运行的命令,帮助开发者在合并或部署前发现潜在问题。

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

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Laravel 验证循环

在 PR 前、重大更改后以及部署前运行。

何时使用

  • 为 Laravel 项目开启 Pull Request 前
  • 重大重构或依赖升级后
  • 预部署验证(用于 Staging 或 Production)
  • 运行完整的:代码风格检查 -> 测试 -> 安全 -> 部署就绪流水线

工作原理

  • 按阶段顺序执行,从环境检查到部署就绪,每个阶段基于上一阶段的结果。
  • 环境和 Composer 检查是所有后续步骤的门槛;如果失败则立即停止。
  • 代码风格/静态分析必须在运行完整测试和覆盖率之前清理干净。
  • 安全和迁移审查在测试之后进行,以便在数据或发布步骤之前验证行为。
  • 构建/部署就绪以及队列/调度检查是最终的门槛;任何失败都会阻止发布。

阶段 1:环境检查

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

阶段 1.5:Composer 和自动加载

composer validate
composer dump-autoload -o

阶段 2:代码风格检查和静态分析

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

如果你的项目使用 Psalm 而非 PHPStan:

vendor/bin/psalm

阶段 3:测试和覆盖率

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

阶段 4:安全和依赖检查

composer audit

阶段 5:数据库和迁移

php artisan migrate --pretend
php artisan migrate:status
  • 仔细审查破坏性迁移
  • 确保迁移文件名遵循 Y_m_d_His_*(例如 2025_03_14_154210_create_orders_table.php),并且清楚地描述了更改内容
  • 确保回滚是可行的
  • 验证 down() 方法,避免在没有显式备份的情况下造成不可逆的数据丢失

阶段 6:构建和部署就绪

php artisan optimize:clear
php artisan config:cache
php artisan route:cache
php artisan view:cache
  • 确保在生产配置下缓存预热成功
  • 验证队列工作者(Worker)和调度器(Scheduler)已配置
  • 确认目标环境中的 storage/ 和 bootstrap/cache/ 目录可写

阶段 7:队列和调度检查

php artisan schedule:list
php artisan queue:failed

如果使用 Horizon:

php artisan horizon:status

如果 queue:monitor 可用,可以用它来检查积压而无需处理作业:

php artisan queue:monitor default --max=100

主动验证(仅限 Staging):将一个空操作作业分发到专用队列,并运行一个单次工作者进行处理(确保配置了非 sync 的队列连接)。

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

验证作业是否产生了预期的副作用(日志条目、健康检查表行或指标)。

仅可在非生产环境中运行,此时处理测试作业是安全的。

示例

最小流程:

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/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

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.

相关技能