Agent skill

Laravel TDD

by affaan-m in affaan-m/ECC

使用 PHPUnit 和 Pest、工厂、数据库测试、模拟以及覆盖率目标进行 Laravel 的测试驱动开发. An agent skill from affaan-m/ECC.

MITAuto-check passedBackend & APIs

Install Laravel TDD

skills CLI
$ npx skills add affaan-m/ECC --skill laravel-tdd -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install affaan-m/ECC laravel-tdd --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/affaan-m/ECC.git skills-src && mkdir -p .claude/skills && cp -r skills-src/docs/zh-CN/skills/laravel-tdd .claude/skills/laravel-tdd && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
laravel-tdd
GitHub stars
277k
Used in
1 other repo
Token cost
~1.4k tokens
SKILL.md length
150 words
Files
1
Skills in repo
683
Repo updated
First seen
Licence
MIT

At a glance

使用 PHPUnit 和 Pest、工厂、数据库测试、模拟以及覆盖率目标进行 Laravel 的测试驱动开发. An agent skill from affaan-m/ECC.

  • Works in 3 steps: 编写一个失败的测试 → 实施最小更改以通过测试 → 在保持测试通过的同时进行重构
  • Tasks that involve Backend development
  • SKILL.md covers 使用时机, 工作原理 and 示例
  • Calls php

What it does

Laravel TDD is an agent skill from affaan-m/ECC. 使用 PHPUnit 和 Pest、工厂、数据库测试、模拟以及覆盖率目标进行 Laravel 的测试驱动开发。

Its SKILL.md is about 1.4k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Backend & APIs, covering Backend development and Test-driven development. It works with Laravel. The repository describes itself as: The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond. The licence is MIT.

When your agent uses it

  • Tasks that involve Backend development
  • Tasks that involve Test-driven development

Example prompts

  • “/laravel-tdd”

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  1. 编写一个失败的测试
  2. 实施最小更改以通过测试
  3. 在保持测试通过的同时进行重构

What it can do on your machine

Read from SKILL.md and the folder at commit 2d515e4. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • php

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Laravel TDD loads about 1.4k tokens when it runs. Until then it costs about 17 tokens; SKILL.md has 150 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~17
When it runs · the whole SKILL.md, loaded when a task matches
~1.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from affaan-m/ECC at commit 2d515e4, republished under its MIT licence (© affaan-m). 150 words, ~1,449 tokens.

Download SKILL.mdSave it as .claude/skills/laravel-tdd/SKILL.md (or your agent's skills folder).
name
laravel-tdd
description
使用 PHPUnit 和 Pest、工厂、数据库测试、模拟以及覆盖率目标进行 Laravel 的测试驱动开发。
origin
ECC

Laravel TDD 工作流

使用 PHPUnit 和 Pest 为 Laravel 应用程序进行测试驱动开发,覆盖率(单元 + 功能)达到 80% 以上。

使用时机

  • Laravel 中的新功能或端点
  • 错误修复或重构
  • 测试 Eloquent 模型、策略、作业和通知
  • 除非项目已标准化使用 PHPUnit,否则新测试首选 Pest

工作原理

红-绿-重构循环
  1. 编写一个失败的测试
  2. 实施最小更改以通过测试
  3. 在保持测试通过的同时进行重构
测试层级
  • 单元:纯 PHP 类、值对象、服务
  • 功能:HTTP 端点、身份验证、验证、策略
  • 集成:数据库 + 队列 + 外部边界

根据范围选择层级:

  • 对纯业务逻辑和服务使用单元测试。
  • 对 HTTP、身份验证、验证和响应结构使用功能测试。
  • 当需要验证数据库/队列/外部服务组合时使用集成测试。
数据库策略
  • 对于大多数功能/集成测试使用 RefreshDatabase(每次测试运行运行一次迁移,然后在支持时将每个测试包装在事务中;内存数据库可能每次测试重新迁移)
  • 当模式已迁移且仅需要每次测试回滚时使用 DatabaseTransactions
  • 当每次测试都需要完整迁移/刷新且可以承担其开销时使用 DatabaseMigrations

将 RefreshDatabase 作为触及数据库的测试的默认选择:对于支持事务的数据库,它每次测试运行运行一次迁移(通过静态标志)并将每个测试包装在事务中;对于 :memory: SQLite 或不支持事务的连接,它在每次测试前进行迁移。当模式已迁移且仅需要每次测试回滚时使用 DatabaseTransactions。

测试框架选择
  • 新测试默认使用 Pest(当可用时)。
  • 仅在项目已标准化使用它或需要 PHPUnit 特定工具时使用 PHPUnit。

示例

PHPUnit 示例
php
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

final class ProjectControllerTest extends TestCase
{
    use RefreshDatabase;

    public function test_owner_can_create_project(): void
    {
        $user = User::factory()->create();

        $response = $this->actingAs($user)->postJson('/api/projects', [
            'name' => 'New Project',
        ]);

        $response->assertCreated();
        $this->assertDatabaseHas('projects', ['name' => 'New Project']);
    }
}
功能测试示例(HTTP 层)
php
use App\Models\Project;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

final class ProjectIndexTest extends TestCase
{
    use RefreshDatabase;

    public function test_projects_index_returns_paginated_results(): void
    {
        $user = User::factory()->create();
        Project::factory()->count(3)->for($user)->create();

        $response = $this->actingAs($user)->getJson('/api/projects');

        $response->assertOk();
        $response->assertJsonStructure(['success', 'data', 'error', 'meta']);
    }
}
Pest 示例
php
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;

use function Pest\Laravel\actingAs;
use function Pest\Laravel\assertDatabaseHas;

uses(RefreshDatabase::class);

test('owner can create project', function () {
    $user = User::factory()->create();

    $response = actingAs($user)->postJson('/api/projects', [
        'name' => 'New Project',
    ]);

    $response->assertCreated();
    assertDatabaseHas('projects', ['name' => 'New Project']);
});
Pest 功能测试示例(HTTP 层)
php
use App\Models\Project;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;

use function Pest\Laravel\actingAs;

uses(RefreshDatabase::class);

test('projects index returns paginated results', function () {
    $user = User::factory()->create();
    Project::factory()->count(3)->for($user)->create();

    $response = actingAs($user)->getJson('/api/projects');

    $response->assertOk();
    $response->assertJsonStructure(['success', 'data', 'error', 'meta']);
});
工厂和状态
  • 使用工厂生成测试数据
  • 为边缘情况定义状态(已归档、管理员、试用)
php
$user = User::factory()->state(['role' => 'admin'])->create();
数据库测试
  • 使用 RefreshDatabase 保持干净状态
  • 保持测试隔离和确定性
  • 优先使用 assertDatabaseHas 而非手动查询
持久性测试示例
php
use App\Models\Project;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

final class ProjectRepositoryTest extends TestCase
{
    use RefreshDatabase;

    public function test_project_can_be_retrieved_by_slug(): void
    {
        $project = Project::factory()->create(['slug' => 'alpha']);

        $found = Project::query()->where('slug', 'alpha')->firstOrFail();

        $this->assertSame($project->id, $found->id);
    }
}
副作用模拟
  • 作业使用 Bus::fake()
  • 队列工作使用 Queue::fake()
  • 通知使用 Mail::fake() 和 Notification::fake()
  • 领域事件使用 Event::fake()
php
use Illuminate\Support\Facades\Queue;

Queue::fake();

dispatch(new SendOrderConfirmation($order->id));

Queue::assertPushed(SendOrderConfirmation::class);
php
use Illuminate\Support\Facades\Notification;

Notification::fake();

$user->notify(new InvoiceReady($invoice));

Notification::assertSentTo($user, InvoiceReady::class);
身份验证测试(Sanctum)
php
use Laravel\Sanctum\Sanctum;

Sanctum::actingAs($user);

$response = $this->getJson('/api/projects');
$response->assertOk();
HTTP 和外部服务
  • 使用 Http::fake() 隔离外部 API
  • 使用 Http::assertSent() 断言出站负载
覆盖率目标
  • 对单元 + 功能测试强制执行 80% 以上的覆盖率
  • 在 CI 中使用 pcov 或 XDEBUG_MODE=coverage
测试命令
  • php artisan test
  • vendor/bin/phpunit
  • vendor/bin/pest
测试配置
  • 使用 phpunit.xml 设置 DB_CONNECTION=sqlite 和 DB_DATABASE=:memory: 以进行快速测试
  • 为测试保持独立的环境,以避免触及开发/生产数据
授权测试
php
use Illuminate\Support\Facades\Gate;

$this->assertTrue(Gate::forUser($user)->allows('update', $project));
$this->assertFalse(Gate::forUser($otherUser)->allows('update', $project));
Inertia 功能测试

使用 Inertia.js 时,使用 Inertia 测试辅助函数来断言组件名称和属性。

php
use App\Models\User;
use Inertia\Testing\AssertableInertia;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

final class DashboardInertiaTest extends TestCase
{
    use RefreshDatabase;

    public function test_dashboard_inertia_props(): void
    {
        $user = User::factory()->create();

        $response = $this->actingAs($user)->get('/dashboard');

        $response->assertOk();
        $response->assertInertia(fn (AssertableInertia $page) => $page
            ->component('Dashboard')
            ->where('user.id', $user->id)
            ->has('projects')
        );
    }
}

优先使用 assertInertia 而非原始 JSON 断言,以保持测试与 Inertia 响应一致。

© affaan-m, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in docs/zh-CN/skills/laravel-tdd of affaan-m/ECC.

Open the folder on GitHubat commit 2d515e4

Used in 1 other repository

We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in affaan-m/ECC, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Laravel TDD next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Laravel TDD compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Laravel TDD this skillaffaan-m/ECC277k1 repos~1.4kAutomated safety check: PassMIT
Pest Testingliberusoftware/real-estate-laravel1121 repos~1.8kAutomated safety check: PassMIT
Pest TestingMineTrax/minetrax116—~787Automated safety check: PassMIT
Pest Testingluadotsh/lua3431 repos~1.2kAutomated safety check: PassMIT
Pest Testingmnapoli/vibephp158—~1.4kAutomated safety check: PassMIT
Laraveldaily Testing AuditLaravelDaily/AI-Workflows-For-Laravel136—~4.6kAutomated safety check: NotesNone

Similar skills

  • Pest Testing

    liberusoftware/real-estate-laravel

    A skill your agent uses for Pest PHP testing in Laravel projects only.

    112 GitHub starsUsed in 1 repo~1.8k tokens
    Testing & QAAuto-check passed
  • Pest Testing

    MineTrax/minetrax

    A skill your agent uses for Pest PHP testing in Laravel projects only.

    116 GitHub stars~787 tokensUpdated 1 mo ago
    Testing & QAAuto-check passed
  • Pest Testing

    luadotsh/lua

    A skill your agent uses for Pest PHP testing in Laravel projects only.

    343 GitHub starsUsed in 1 repo~1.2k tokens
    Testing & QAAuto-check passed
  • Pest Testing

    mnapoli/vibephp

    A skill your agent uses for Pest PHP testing in Laravel projects only.

    158 GitHub stars~1.4k tokensUpdated 3 mo ago
    Testing & QAAuto-check passed
  • Laraveldaily Testing Audit

    LaravelDaily/AI-Workflows-For-Laravel

    This skill should be used when the user asks to "audit Laravel tests", "review test coverage", "check testing practices", "find missing tests", "testing review", "improve tests", or wants to analyze…

    136 GitHub stars~4.6k tokensUpdated 5 mo ago
    Backend & APIsAuto-check: notes
  • Rails Concern

    ThibautBaissac/rails_ai_agents

    Creates Rails concerns for shared behavior across models or controllers with TDD.

    665 GitHub stars~1.7k tokensUpdated 4 mo ago
    Backend & APIsAuto-check passed

More from affaan-m/ECC

All 682 skills in this repo
  • Skill Stocktake

    affaan-m/ECC

    Audits your installed Claude skills and commands for quality, with a quick mode for recently changed skills and a full mode that evaluates all of them through subagents.

    277k GitHub starsUsed in 5 repos~3.1k tokens
    Auto-check passed
  • Ingests, indexes, searches, edits and monitors video, audio and live streams through the VideoDB Python SDK, returning stream links, clips and timestamps.

    277k GitHub starsUsed in 3 repos~3.5k tokens
    Auto-check: notes
  • Docs Governance

    affaan-m/ECC

    Route broad documentation-governance requests to existing ECC skills and run an opt-in, read-only audit of mapped documentation roles, links, ADR indexes, and evidence references.

    277k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Rules Distillation

    affaan-m/ECC

    Scans installed skills for principles that recur across them and proposes rule-file changes: append, revise, add a section, create a file or leave as covered.

    277k GitHub starsUsed in 2 repos~2.3k tokens
    Auto-check passed
  • Builds DRAFT counterparty agreements from one markdown template and a small JSON spec per party, with clauses picked by the party's role.

    277k GitHub stars~2.9k tokensUpdated today
    Auto-check passed
  • Set an ECC-specific frontend design direction for production UI work.

    277k GitHub starsUsed in 1 repo~2.2k tokens
    Auto-check passed

Works with

Questions about Laravel TDD

What does Laravel TDD do?

使用 PHPUnit 和 Pest、工厂、数据库测试、模拟以及覆盖率目标进行 Laravel 的测试驱动开发. An agent skill from affaan-m/ECC. Laravel TDD is an agent skill from affaan-m/ECC.

When should I use Laravel TDD?

Laravel TDD fits situations like: tasks that involve Backend development; tasks that involve Test-driven development.

How do I install Laravel TDD in Claude Code?

Run `npx skills add affaan-m/ECC --skill laravel-tdd -a claude-code`. Or copy the skill folder (docs/zh-CN/skills/laravel-tdd in affaan-m/ECC) into .claude/skills/laravel-tdd in your project. Claude Code loads it when a task matches its description.

How do I install Laravel TDD in Codex?

Run `npx skills add affaan-m/ECC --skill laravel-tdd -a codex`. Or copy the skill folder (docs/zh-CN/skills/laravel-tdd in affaan-m/ECC) into .agents/skills/laravel-tdd in your project. Codex loads it when a task matches its description.

Can I use Laravel TDD in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add affaan-m/ECC --skill laravel-tdd -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/laravel-tdd, .gemini/skills/laravel-tdd, .github/skills/laravel-tdd and .opencode/skills/laravel-tdd in your project.

What does Laravel TDD need to run?

Going by SKILL.md and its folder, Laravel TDD needs the command-line tools its instructions call (php).

Does Laravel TDD access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Laravel TDD safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Laravel TDD use?

Laravel TDD is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Laravel TDD use?

About 1.4k tokens (SKILL.md is roughly 5.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Laravel TDD?

Skills that share tags, products or a category with Laravel TDD: Pest Testing (liberusoftware/real-estate-laravel, 112 stars), Pest Testing (MineTrax/minetrax, 116 stars), Pest Testing (luadotsh/lua, 343 stars) and Pest Testing (mnapoli/vibephp, 158 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Laravel TDD?

affaan-m (a GitHub user) maintains it in affaan-m/ECC, which has 276,673 GitHub stars. The repository holds 683 skills in this directory. The repository was last updated on October 11, 2026.

Source: affaan-m/ECC on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.