@h1dr0n/skill-pool 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +296 -0
- package/bin/cli.js +157 -0
- package/package.json +41 -0
- package/skills/api/agents/backend-specialist.md +69 -0
- package/skills/api/agents/database-optimizer.md +176 -0
- package/skills/api/manifest.yaml +20 -0
- package/skills/api/rules/auth-security.md +45 -0
- package/skills/api/skills/api-patterns/SKILL.md +81 -0
- package/skills/api/skills/api-patterns/api-style.md +42 -0
- package/skills/api/skills/api-patterns/auth.md +24 -0
- package/skills/api/skills/api-patterns/documentation.md +26 -0
- package/skills/api/skills/api-patterns/graphql.md +41 -0
- package/skills/api/skills/api-patterns/rate-limiting.md +31 -0
- package/skills/api/skills/api-patterns/response.md +37 -0
- package/skills/api/skills/api-patterns/rest.md +40 -0
- package/skills/api/skills/api-patterns/scripts/api_validator.py +211 -0
- package/skills/api/skills/api-patterns/security-testing.md +122 -0
- package/skills/api/skills/api-patterns/trpc.md +41 -0
- package/skills/api/skills/api-patterns/versioning.md +22 -0
- package/skills/api/skills/database-patterns.md +126 -0
- package/skills/api/skills/deployment-patterns.md +105 -0
- package/skills/api/skills/docker-patterns.md +135 -0
- package/skills/common/agents/code-reviewer.md +78 -0
- package/skills/common/agents/planner.md +80 -0
- package/skills/common/agents/security-reviewer.md +82 -0
- package/skills/common/agents/software-architect.md +81 -0
- package/skills/common/manifest.yaml +25 -0
- package/skills/common/rules/coding-style.md +39 -0
- package/skills/common/rules/git-workflow.md +33 -0
- package/skills/common/rules/security.md +25 -0
- package/skills/common/skills/architecture/SKILL.md +55 -0
- package/skills/common/skills/architecture/context-discovery.md +43 -0
- package/skills/common/skills/architecture/examples.md +94 -0
- package/skills/common/skills/architecture/pattern-selection.md +68 -0
- package/skills/common/skills/architecture/patterns-reference.md +50 -0
- package/skills/common/skills/architecture/trade-off-analysis.md +77 -0
- package/skills/common/skills/brainstorming/SKILL.md +163 -0
- package/skills/common/skills/brainstorming/dynamic-questioning.md +350 -0
- package/skills/common/skills/clean-code.md +99 -0
- package/skills/common/skills/code-review-checklist.md +86 -0
- package/skills/common/skills/plan-writing/SKILL.md +152 -0
- package/skills/common/skills/skill-feedback.md +94 -0
- package/skills/common/skills/tdd-workflow.md +130 -0
- package/skills/common/skills/verification-loop.md +112 -0
- package/skills/cpp/agents/cpp-build-resolver.md +90 -0
- package/skills/cpp/agents/cpp-reviewer.md +72 -0
- package/skills/cpp/manifest.yaml +15 -0
- package/skills/cpp/skills/cpp-coding-standards.md +722 -0
- package/skills/cpp/skills/cpp-testing.md +323 -0
- package/skills/devops/agents/devops-automator.md +376 -0
- package/skills/devops/agents/sre.md +90 -0
- package/skills/devops/manifest.yaml +20 -0
- package/skills/devops/skills/deployment-patterns.md +427 -0
- package/skills/devops/skills/deployment-procedures/SKILL.md +241 -0
- package/skills/devops/skills/docker-patterns.md +364 -0
- package/skills/devops/skills/e2e-testing.md +326 -0
- package/skills/devops/skills/github-ops.md +144 -0
- package/skills/django/manifest.yaml +16 -0
- package/skills/django/skills/django-patterns.md +734 -0
- package/skills/django/skills/django-security.md +593 -0
- package/skills/django/skills/django-tdd.md +729 -0
- package/skills/django/skills/django-verification.md +469 -0
- package/skills/dotnet/agents/csharp-reviewer.md +101 -0
- package/skills/dotnet/manifest.yaml +14 -0
- package/skills/dotnet/skills/csharp-testing.md +321 -0
- package/skills/dotnet/skills/dotnet-patterns.md +321 -0
- package/skills/go/agents/code-reviewer.md +76 -0
- package/skills/go/agents/go-build-resolver.md +94 -0
- package/skills/go/agents/go-reviewer.md +76 -0
- package/skills/go/manifest.yaml +17 -0
- package/skills/go/rules/go-style.md +55 -0
- package/skills/go/skills/golang-patterns.md +674 -0
- package/skills/go/skills/golang-testing.md +720 -0
- package/skills/java/agents/java-build-resolver.md +153 -0
- package/skills/java/agents/java-reviewer.md +92 -0
- package/skills/java/manifest.yaml +18 -0
- package/skills/java/skills/java-coding-standards.md +147 -0
- package/skills/java/skills/jpa-patterns.md +151 -0
- package/skills/java/skills/springboot-patterns.md +314 -0
- package/skills/java/skills/springboot-security.md +272 -0
- package/skills/kotlin/agents/kotlin-build-resolver.md +118 -0
- package/skills/kotlin/agents/kotlin-reviewer.md +159 -0
- package/skills/kotlin/manifest.yaml +17 -0
- package/skills/kotlin/skills/kotlin-coroutines-flows.md +284 -0
- package/skills/kotlin/skills/kotlin-patterns.md +711 -0
- package/skills/kotlin/skills/kotlin-testing.md +824 -0
- package/skills/laravel/manifest.yaml +15 -0
- package/skills/laravel/skills/laravel-patterns.md +409 -0
- package/skills/laravel/skills/laravel-security.md +279 -0
- package/skills/laravel/skills/laravel-tdd.md +277 -0
- package/skills/laravel/skills/laravel-verification.md +173 -0
- package/skills/mobile/agents/dart-build-resolver.md +201 -0
- package/skills/mobile/agents/flutter-reviewer.md +243 -0
- package/skills/mobile/manifest.yaml +19 -0
- package/skills/mobile/skills/android-clean-architecture.md +339 -0
- package/skills/mobile/skills/dart-flutter-patterns.md +563 -0
- package/skills/mobile/skills/swiftui-patterns.md +259 -0
- package/skills/nestjs/manifest.yaml +13 -0
- package/skills/nestjs/skills/nestjs-patterns.md +230 -0
- package/skills/perl/manifest.yaml +13 -0
- package/skills/perl/skills/perl-patterns.md +504 -0
- package/skills/perl/skills/perl-security.md +503 -0
- package/skills/perl/skills/perl-testing.md +475 -0
- package/skills/python/agents/python-reviewer.md +98 -0
- package/skills/python/manifest.yaml +18 -0
- package/skills/python/rules/python-style.md +69 -0
- package/skills/python/skills/python-patterns/SKILL.md +441 -0
- package/skills/python/skills/python-patterns.md +90 -0
- package/skills/python/skills/python-testing.md +81 -0
- package/skills/rust/agents/rust-build-resolver.md +148 -0
- package/skills/rust/agents/rust-reviewer.md +94 -0
- package/skills/rust/manifest.yaml +16 -0
- package/skills/rust/rules/rust-style.md +107 -0
- package/skills/rust/skills/rust-patterns.md +499 -0
- package/skills/rust/skills/rust-testing.md +500 -0
- package/skills/security/agents/accessibility-auditor.md +316 -0
- package/skills/security/agents/security-reviewer.md +108 -0
- package/skills/security/manifest.yaml +19 -0
- package/skills/security/skills/red-team-tactics/SKILL.md +199 -0
- package/skills/security/skills/security-bounty-hunter.md +99 -0
- package/skills/security/skills/security-review.md +495 -0
- package/skills/security/skills/security-scan.md +165 -0
- package/skills/security/skills/vulnerability-scanner/SKILL.md +276 -0
- package/skills/security/skills/vulnerability-scanner/checklists.md +121 -0
- package/skills/security/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/skills/swift/manifest.yaml +16 -0
- package/skills/swift/skills/swift-actor-persistence.md +142 -0
- package/skills/swift/skills/swift-concurrency.md +216 -0
- package/skills/swift/skills/swift-protocol-di-testing.md +190 -0
- package/skills/swift/skills/swiftui-patterns.md +259 -0
- package/skills/unity/agents/game-designer.md +167 -0
- package/skills/unity/agents/unity-architect.md +52 -0
- package/skills/unity/agents/unity-editor-tool-developer.md +310 -0
- package/skills/unity/agents/unity-multiplayer-engineer.md +321 -0
- package/skills/unity/agents/unity-shader-graph-artist.md +269 -0
- package/skills/unity/manifest.yaml +21 -0
- package/skills/unity/rules/csharp-patterns.md +48 -0
- package/skills/unity/rules/unity-specific.md +53 -0
- package/skills/unity/skills/systematic-debugging.md +92 -0
- package/skills/unity/skills/unity-architecture.md +173 -0
- package/skills/unreal/agents/level-designer.md +208 -0
- package/skills/unreal/agents/technical-artist.md +229 -0
- package/skills/unreal/agents/unreal-multiplayer-architect.md +313 -0
- package/skills/unreal/agents/unreal-systems-engineer.md +310 -0
- package/skills/unreal/agents/unreal-technical-artist.md +256 -0
- package/skills/unreal/agents/unreal-world-builder.md +273 -0
- package/skills/unreal/manifest.yaml +21 -0
- package/skills/unreal/skills/unreal-patterns.md +183 -0
- package/skills/web/agents/frontend-specialist.md +71 -0
- package/skills/web/agents/ui-designer.md +383 -0
- package/skills/web/agents/ux-architect.md +469 -0
- package/skills/web/manifest.yaml +22 -0
- package/skills/web/rules/accessibility.md +54 -0
- package/skills/web/rules/css-performance.md +52 -0
- package/skills/web/skills/e2e-testing.md +132 -0
- package/skills/web/skills/frontend-design/SKILL.md +452 -0
- package/skills/web/skills/frontend-design/animation-guide.md +331 -0
- package/skills/web/skills/frontend-design/color-system.md +311 -0
- package/skills/web/skills/frontend-design/decision-trees.md +418 -0
- package/skills/web/skills/frontend-design/motion-graphics.md +306 -0
- package/skills/web/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/skills/web/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/skills/web/skills/frontend-design/typography-system.md +345 -0
- package/skills/web/skills/frontend-design/ux-psychology.md +1116 -0
- package/skills/web/skills/frontend-design/visual-effects.md +383 -0
- package/skills/web/skills/react-nextjs.md +135 -0
- package/skills/web/skills/tailwind-patterns/SKILL.md +269 -0
- package/src/adapters/antigravity.js +164 -0
- package/src/adapters/claude.js +188 -0
- package/src/adapters/cursor.js +161 -0
- package/src/adapters/index.js +67 -0
- package/src/adapters/windsurf.js +158 -0
- package/src/commands/add.js +266 -0
- package/src/commands/create.js +127 -0
- package/src/commands/diff.js +78 -0
- package/src/commands/info.js +88 -0
- package/src/commands/init.js +224 -0
- package/src/commands/install.js +90 -0
- package/src/commands/list.js +54 -0
- package/src/commands/remove.js +101 -0
- package/src/commands/targets.js +32 -0
- package/src/commands/update.js +57 -0
- package/src/core/manifest.js +57 -0
- package/src/core/plugins.js +86 -0
- package/src/core/resolver.js +84 -0
- package/src/core/tracker.js +49 -0
- package/src/utils/fs.js +80 -0
- package/src/utils/git.js +52 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
# Laravel TDD Workflow
|
|
2
|
+
|
|
3
|
+
Test-driven development for Laravel applications using PHPUnit and Pest with 80%+ coverage (unit + feature).
|
|
4
|
+
|
|
5
|
+
## When to Use
|
|
6
|
+
|
|
7
|
+
- New features or endpoints in Laravel
|
|
8
|
+
- Bug fixes or refactors
|
|
9
|
+
- Testing Eloquent models, policies, jobs, and notifications
|
|
10
|
+
- Prefer Pest for new tests unless the project already standardizes on PHPUnit
|
|
11
|
+
|
|
12
|
+
## How It Works
|
|
13
|
+
|
|
14
|
+
### Red-Green-Refactor Cycle
|
|
15
|
+
|
|
16
|
+
1) Write a failing test
|
|
17
|
+
2) Implement the minimal change to pass
|
|
18
|
+
3) Refactor while keeping tests green
|
|
19
|
+
|
|
20
|
+
### Test Layers
|
|
21
|
+
|
|
22
|
+
- **Unit**: pure PHP classes, value objects, services
|
|
23
|
+
- **Feature**: HTTP endpoints, auth, validation, policies
|
|
24
|
+
- **Integration**: database + queue + external boundaries
|
|
25
|
+
|
|
26
|
+
Choose layers based on scope:
|
|
27
|
+
|
|
28
|
+
- Use **Unit** tests for pure business logic and services.
|
|
29
|
+
- Use **Feature** tests for HTTP, auth, validation, and response shape.
|
|
30
|
+
- Use **Integration** tests when validating DB/queues/external services together.
|
|
31
|
+
|
|
32
|
+
### Database Strategy
|
|
33
|
+
|
|
34
|
+
- `RefreshDatabase` for most feature/integration tests (runs migrations once per test run, then wraps each test in a transaction when supported; in-memory databases may re-migrate per test)
|
|
35
|
+
- `DatabaseTransactions` when the schema is already migrated and you only need per-test rollback
|
|
36
|
+
- `DatabaseMigrations` when you need a full migrate/fresh for every test and can afford the cost
|
|
37
|
+
|
|
38
|
+
Use `RefreshDatabase` as the default for tests that touch the database: for databases with transaction support, it runs migrations once per test run (via a static flag) and wraps each test in a transaction; for `:memory:` SQLite or connections without transactions, it migrates before each test. Use `DatabaseTransactions` when the schema is already migrated and you only need per-test rollbacks.
|
|
39
|
+
|
|
40
|
+
### Testing Framework Choice
|
|
41
|
+
|
|
42
|
+
- Default to **Pest** for new tests when available.
|
|
43
|
+
- Use **PHPUnit** only if the project already standardizes on it or requires PHPUnit-specific tooling.
|
|
44
|
+
|
|
45
|
+
## Examples
|
|
46
|
+
|
|
47
|
+
### PHPUnit Example
|
|
48
|
+
|
|
49
|
+
```php
|
|
50
|
+
use App\Models\User;
|
|
51
|
+
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
52
|
+
use Tests\TestCase;
|
|
53
|
+
|
|
54
|
+
final class ProjectControllerTest extends TestCase
|
|
55
|
+
{
|
|
56
|
+
use RefreshDatabase;
|
|
57
|
+
|
|
58
|
+
public function test_owner_can_create_project(): void
|
|
59
|
+
{
|
|
60
|
+
$user = User::factory()->create();
|
|
61
|
+
|
|
62
|
+
$response = $this->actingAs($user)->postJson('/api/projects', [
|
|
63
|
+
'name' => 'New Project',
|
|
64
|
+
]);
|
|
65
|
+
|
|
66
|
+
$response->assertCreated();
|
|
67
|
+
$this->assertDatabaseHas('projects', ['name' => 'New Project']);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Feature Test Example (HTTP Layer)
|
|
73
|
+
|
|
74
|
+
```php
|
|
75
|
+
use App\Models\Project;
|
|
76
|
+
use App\Models\User;
|
|
77
|
+
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
78
|
+
use Tests\TestCase;
|
|
79
|
+
|
|
80
|
+
final class ProjectIndexTest extends TestCase
|
|
81
|
+
{
|
|
82
|
+
use RefreshDatabase;
|
|
83
|
+
|
|
84
|
+
public function test_projects_index_returns_paginated_results(): void
|
|
85
|
+
{
|
|
86
|
+
$user = User::factory()->create();
|
|
87
|
+
Project::factory()->count(3)->for($user)->create();
|
|
88
|
+
|
|
89
|
+
$response = $this->actingAs($user)->getJson('/api/projects');
|
|
90
|
+
|
|
91
|
+
$response->assertOk();
|
|
92
|
+
$response->assertJsonStructure(['success', 'data', 'error', 'meta']);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Pest Example
|
|
98
|
+
|
|
99
|
+
```php
|
|
100
|
+
use App\Models\User;
|
|
101
|
+
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
102
|
+
|
|
103
|
+
use function Pest\Laravel\actingAs;
|
|
104
|
+
use function Pest\Laravel\assertDatabaseHas;
|
|
105
|
+
|
|
106
|
+
uses(RefreshDatabase::class);
|
|
107
|
+
|
|
108
|
+
test('owner can create project', function () {
|
|
109
|
+
$user = User::factory()->create();
|
|
110
|
+
|
|
111
|
+
$response = actingAs($user)->postJson('/api/projects', [
|
|
112
|
+
'name' => 'New Project',
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
$response->assertCreated();
|
|
116
|
+
assertDatabaseHas('projects', ['name' => 'New Project']);
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Feature Test Pest Example (HTTP Layer)
|
|
121
|
+
|
|
122
|
+
```php
|
|
123
|
+
use App\Models\Project;
|
|
124
|
+
use App\Models\User;
|
|
125
|
+
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
126
|
+
|
|
127
|
+
use function Pest\Laravel\actingAs;
|
|
128
|
+
|
|
129
|
+
uses(RefreshDatabase::class);
|
|
130
|
+
|
|
131
|
+
test('projects index returns paginated results', function () {
|
|
132
|
+
$user = User::factory()->create();
|
|
133
|
+
Project::factory()->count(3)->for($user)->create();
|
|
134
|
+
|
|
135
|
+
$response = actingAs($user)->getJson('/api/projects');
|
|
136
|
+
|
|
137
|
+
$response->assertOk();
|
|
138
|
+
$response->assertJsonStructure(['success', 'data', 'error', 'meta']);
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Factories and States
|
|
143
|
+
|
|
144
|
+
- Use factories for test data
|
|
145
|
+
- Define states for edge cases (archived, admin, trial)
|
|
146
|
+
|
|
147
|
+
```php
|
|
148
|
+
$user = User::factory()->state(['role' => 'admin'])->create();
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Database Testing
|
|
152
|
+
|
|
153
|
+
- Use `RefreshDatabase` for clean state
|
|
154
|
+
- Keep tests isolated and deterministic
|
|
155
|
+
- Prefer `assertDatabaseHas` over manual queries
|
|
156
|
+
|
|
157
|
+
### Persistence Test Example
|
|
158
|
+
|
|
159
|
+
```php
|
|
160
|
+
use App\Models\Project;
|
|
161
|
+
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
162
|
+
use Tests\TestCase;
|
|
163
|
+
|
|
164
|
+
final class ProjectRepositoryTest extends TestCase
|
|
165
|
+
{
|
|
166
|
+
use RefreshDatabase;
|
|
167
|
+
|
|
168
|
+
public function test_project_can_be_retrieved_by_slug(): void
|
|
169
|
+
{
|
|
170
|
+
$project = Project::factory()->create(['slug' => 'alpha']);
|
|
171
|
+
|
|
172
|
+
$found = Project::query()->where('slug', 'alpha')->firstOrFail();
|
|
173
|
+
|
|
174
|
+
$this->assertSame($project->id, $found->id);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Fakes for Side Effects
|
|
180
|
+
|
|
181
|
+
- `Bus::fake()` for jobs
|
|
182
|
+
- `Queue::fake()` for queued work
|
|
183
|
+
- `Mail::fake()` and `Notification::fake()` for notifications
|
|
184
|
+
- `Event::fake()` for domain events
|
|
185
|
+
|
|
186
|
+
```php
|
|
187
|
+
use Illuminate\Support\Facades\Queue;
|
|
188
|
+
|
|
189
|
+
Queue::fake();
|
|
190
|
+
|
|
191
|
+
dispatch(new SendOrderConfirmation($order->id));
|
|
192
|
+
|
|
193
|
+
Queue::assertPushed(SendOrderConfirmation::class);
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
```php
|
|
197
|
+
use Illuminate\Support\Facades\Notification;
|
|
198
|
+
|
|
199
|
+
Notification::fake();
|
|
200
|
+
|
|
201
|
+
$user->notify(new InvoiceReady($invoice));
|
|
202
|
+
|
|
203
|
+
Notification::assertSentTo($user, InvoiceReady::class);
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Auth Testing (Sanctum)
|
|
207
|
+
|
|
208
|
+
```php
|
|
209
|
+
use Laravel\Sanctum\Sanctum;
|
|
210
|
+
|
|
211
|
+
Sanctum::actingAs($user);
|
|
212
|
+
|
|
213
|
+
$response = $this->getJson('/api/projects');
|
|
214
|
+
$response->assertOk();
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### HTTP and External Services
|
|
218
|
+
|
|
219
|
+
- Use `Http::fake()` to isolate external APIs
|
|
220
|
+
- Assert outbound payloads with `Http::assertSent()`
|
|
221
|
+
|
|
222
|
+
### Coverage Targets
|
|
223
|
+
|
|
224
|
+
- Enforce 80%+ coverage for unit + feature tests
|
|
225
|
+
- Use `pcov` or `XDEBUG_MODE=coverage` in CI
|
|
226
|
+
|
|
227
|
+
### Test Commands
|
|
228
|
+
|
|
229
|
+
- `php artisan test`
|
|
230
|
+
- `vendor/bin/phpunit`
|
|
231
|
+
- `vendor/bin/pest`
|
|
232
|
+
|
|
233
|
+
### Test Configuration
|
|
234
|
+
|
|
235
|
+
- Use `phpunit.xml` to set `DB_CONNECTION=sqlite` and `DB_DATABASE=:memory:` for fast tests
|
|
236
|
+
- Keep separate env for tests to avoid touching dev/prod data
|
|
237
|
+
|
|
238
|
+
### Authorization Tests
|
|
239
|
+
|
|
240
|
+
```php
|
|
241
|
+
use Illuminate\Support\Facades\Gate;
|
|
242
|
+
|
|
243
|
+
$this->assertTrue(Gate::forUser($user)->allows('update', $project));
|
|
244
|
+
$this->assertFalse(Gate::forUser($otherUser)->allows('update', $project));
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Inertia Feature Tests
|
|
248
|
+
|
|
249
|
+
When using Inertia.js, assert on the component name and props with the Inertia testing helpers.
|
|
250
|
+
|
|
251
|
+
```php
|
|
252
|
+
use App\Models\User;
|
|
253
|
+
use Inertia\Testing\AssertableInertia;
|
|
254
|
+
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
255
|
+
use Tests\TestCase;
|
|
256
|
+
|
|
257
|
+
final class DashboardInertiaTest extends TestCase
|
|
258
|
+
{
|
|
259
|
+
use RefreshDatabase;
|
|
260
|
+
|
|
261
|
+
public function test_dashboard_inertia_props(): void
|
|
262
|
+
{
|
|
263
|
+
$user = User::factory()->create();
|
|
264
|
+
|
|
265
|
+
$response = $this->actingAs($user)->get('/dashboard');
|
|
266
|
+
|
|
267
|
+
$response->assertOk();
|
|
268
|
+
$response->assertInertia(fn (AssertableInertia $page) => $page
|
|
269
|
+
->component('Dashboard')
|
|
270
|
+
->where('user.id', $user->id)
|
|
271
|
+
->has('projects')
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Prefer `assertInertia` over raw JSON assertions to keep tests aligned with Inertia responses.
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Laravel Verification Loop
|
|
2
|
+
|
|
3
|
+
Run before PRs, after major changes, and pre-deploy.
|
|
4
|
+
|
|
5
|
+
## When to Use
|
|
6
|
+
|
|
7
|
+
- Before opening a pull request for a Laravel project
|
|
8
|
+
- After major refactors or dependency upgrades
|
|
9
|
+
- Pre-deployment verification for staging or production
|
|
10
|
+
- Running full lint -> test -> security -> deploy readiness pipeline
|
|
11
|
+
|
|
12
|
+
## How It Works
|
|
13
|
+
|
|
14
|
+
- Run phases sequentially from environment checks through deployment readiness so each layer builds on the last.
|
|
15
|
+
- Environment and Composer checks gate everything else; stop immediately if they fail.
|
|
16
|
+
- Linting/static analysis should be clean before running full tests and coverage.
|
|
17
|
+
- Security and migration reviews happen after tests so you verify behavior before data or release steps.
|
|
18
|
+
- Build/deploy readiness and queue/scheduler checks are final gates; any failure blocks release.
|
|
19
|
+
|
|
20
|
+
## Phase 1: Environment Checks
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
php -v
|
|
24
|
+
composer --version
|
|
25
|
+
php artisan --version
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- Verify `.env` is present and required keys exist
|
|
29
|
+
- Confirm `APP_DEBUG=false` for production environments
|
|
30
|
+
- Confirm `APP_ENV` matches the target deployment (`production`, `staging`)
|
|
31
|
+
|
|
32
|
+
If using Laravel Sail locally:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
./vendor/bin/sail php -v
|
|
36
|
+
./vendor/bin/sail artisan --version
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Phase 1.5: Composer and Autoload
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
composer validate
|
|
43
|
+
composer dump-autoload -o
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Phase 2: Linting and Static Analysis
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
vendor/bin/pint --test
|
|
50
|
+
vendor/bin/phpstan analyse
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
If your project uses Psalm instead of PHPStan:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
vendor/bin/psalm
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Phase 3: Tests and Coverage
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
php artisan test
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Coverage (CI):
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
XDEBUG_MODE=coverage php artisan test --coverage
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
CI example (format -> static analysis -> tests):
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
vendor/bin/pint --test
|
|
75
|
+
vendor/bin/phpstan analyse
|
|
76
|
+
XDEBUG_MODE=coverage php artisan test --coverage
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Phase 4: Security and Dependency Checks
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
composer audit
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Phase 5: Database and Migrations
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
php artisan migrate --pretend
|
|
89
|
+
php artisan migrate:status
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
- Review destructive migrations carefully
|
|
93
|
+
- Ensure migration filenames follow `Y_m_d_His_*` (e.g., `2025_03_14_154210_create_orders_table.php`) and describe the change clearly
|
|
94
|
+
- Ensure rollbacks are possible
|
|
95
|
+
- Verify `down()` methods and avoid irreversible data loss without explicit backups
|
|
96
|
+
|
|
97
|
+
## Phase 6: Build and Deployment Readiness
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
php artisan optimize:clear
|
|
101
|
+
php artisan config:cache
|
|
102
|
+
php artisan route:cache
|
|
103
|
+
php artisan view:cache
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
- Ensure cache warmups succeed in production configuration
|
|
107
|
+
- Verify queue workers and scheduler are configured
|
|
108
|
+
- Confirm `storage/` and `bootstrap/cache/` are writable in the target environment
|
|
109
|
+
|
|
110
|
+
## Phase 7: Queue and Scheduler Checks
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
php artisan schedule:list
|
|
114
|
+
php artisan queue:failed
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
If Horizon is used:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
php artisan horizon:status
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
If `queue:monitor` is available, use it to check backlog without processing jobs:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
php artisan queue:monitor default --max=100
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Active verification (staging only): dispatch a no-op job to a dedicated queue and run a single worker to process it (ensure a non-`sync` queue connection is configured).
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
php artisan tinker --execute="dispatch((new App\\Jobs\\QueueHealthcheck())->onQueue('healthcheck'))"
|
|
133
|
+
php artisan queue:work --once --queue=healthcheck
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Verify the job produced the expected side effect (log entry, healthcheck table row, or metric).
|
|
137
|
+
|
|
138
|
+
Only run this on non-production environments where processing a test job is safe.
|
|
139
|
+
|
|
140
|
+
## Examples
|
|
141
|
+
|
|
142
|
+
Minimal flow:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
php -v
|
|
146
|
+
composer --version
|
|
147
|
+
php artisan --version
|
|
148
|
+
composer validate
|
|
149
|
+
vendor/bin/pint --test
|
|
150
|
+
vendor/bin/phpstan analyse
|
|
151
|
+
php artisan test
|
|
152
|
+
composer audit
|
|
153
|
+
php artisan migrate --pretend
|
|
154
|
+
php artisan config:cache
|
|
155
|
+
php artisan queue:failed
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
CI-style pipeline:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
composer validate
|
|
162
|
+
composer dump-autoload -o
|
|
163
|
+
vendor/bin/pint --test
|
|
164
|
+
vendor/bin/phpstan analyse
|
|
165
|
+
XDEBUG_MODE=coverage php artisan test --coverage
|
|
166
|
+
composer audit
|
|
167
|
+
php artisan migrate --pretend
|
|
168
|
+
php artisan optimize:clear
|
|
169
|
+
php artisan config:cache
|
|
170
|
+
php artisan route:cache
|
|
171
|
+
php artisan view:cache
|
|
172
|
+
php artisan schedule:list
|
|
173
|
+
```
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dart-build-resolver
|
|
3
|
+
description: Dart/Flutter build, analysis, and dependency error resolution specialist. Fixes `dart analyze` errors, Flutter compilation failures, pub dependency conflicts, and build_runner issues with minimal, surgical changes. Use when Dart/Flutter builds fail.
|
|
4
|
+
tools: ["Read", "Write", "Edit", "Bash", "Grep", "Glob"]
|
|
5
|
+
model: sonnet
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Dart/Flutter Build Error Resolver
|
|
9
|
+
|
|
10
|
+
You are an expert Dart/Flutter build error resolution specialist. Your mission is to fix Dart analyzer errors, Flutter compilation issues, pub dependency conflicts, and build_runner failures with **minimal, surgical changes**.
|
|
11
|
+
|
|
12
|
+
## Core Responsibilities
|
|
13
|
+
|
|
14
|
+
1. Diagnose `dart analyze` and `flutter analyze` errors
|
|
15
|
+
2. Fix Dart type errors, null safety violations, and missing imports
|
|
16
|
+
3. Resolve `pubspec.yaml` dependency conflicts and version constraints
|
|
17
|
+
4. Fix `build_runner` code generation failures
|
|
18
|
+
5. Handle Flutter-specific build errors (Android Gradle, iOS CocoaPods, web)
|
|
19
|
+
|
|
20
|
+
## Diagnostic Commands
|
|
21
|
+
|
|
22
|
+
Run these in order:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Check Dart/Flutter analysis errors
|
|
26
|
+
flutter analyze 2>&1
|
|
27
|
+
# or for pure Dart projects
|
|
28
|
+
dart analyze 2>&1
|
|
29
|
+
|
|
30
|
+
# Check pub dependency resolution
|
|
31
|
+
flutter pub get 2>&1
|
|
32
|
+
|
|
33
|
+
# Check if code generation is stale
|
|
34
|
+
dart run build_runner build --delete-conflicting-outputs 2>&1
|
|
35
|
+
|
|
36
|
+
# Flutter build for target platform
|
|
37
|
+
flutter build apk 2>&1 # Android
|
|
38
|
+
flutter build ipa --no-codesign 2>&1 # iOS (CI without signing)
|
|
39
|
+
flutter build web 2>&1 # Web
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Resolution Workflow
|
|
43
|
+
|
|
44
|
+
```text
|
|
45
|
+
1. flutter analyze -> Parse error messages
|
|
46
|
+
2. Read affected file -> Understand context
|
|
47
|
+
3. Apply minimal fix -> Only what's needed
|
|
48
|
+
4. flutter analyze -> Verify fix
|
|
49
|
+
5. flutter test -> Ensure nothing broke
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Common Fix Patterns
|
|
53
|
+
|
|
54
|
+
| Error | Cause | Fix |
|
|
55
|
+
|-------|-------|-----|
|
|
56
|
+
| `The name 'X' isn't defined` | Missing import or typo | Add correct `import` or fix name |
|
|
57
|
+
| `A value of type 'X?' can't be assigned to type 'X'` | Null safety — nullable not handled | Add `!`, `?? default`, or null check |
|
|
58
|
+
| `The argument type 'X' can't be assigned to 'Y'` | Type mismatch | Fix type, add explicit cast, or correct API call |
|
|
59
|
+
| `Non-nullable instance field 'x' must be initialized` | Missing initializer | Add initializer, mark `late`, or make nullable |
|
|
60
|
+
| `The method 'X' isn't defined for type 'Y'` | Wrong type or wrong import | Check type and imports |
|
|
61
|
+
| `'await' applied to non-Future` | Awaiting a non-async value | Remove `await` or make function async |
|
|
62
|
+
| `Missing concrete implementation of 'X'` | Abstract interface not fully implemented | Add missing method implementations |
|
|
63
|
+
| `The class 'X' doesn't implement 'Y'` | Missing `implements` or missing method | Add method or fix class signature |
|
|
64
|
+
| `Because X depends on Y >=A and Z depends on Y <B, version solving failed` | Pub version conflict | Adjust version constraints or add `dependency_overrides` |
|
|
65
|
+
| `Could not find a file named "pubspec.yaml"` | Wrong working directory | Run from project root |
|
|
66
|
+
| `build_runner: No actions were run` | No changes to build_runner inputs | Force rebuild with `--delete-conflicting-outputs` |
|
|
67
|
+
| `Part of directive found, but 'X' expected` | Stale generated file | Delete `.g.dart` file and re-run build_runner |
|
|
68
|
+
|
|
69
|
+
## Pub Dependency Troubleshooting
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Show full dependency tree
|
|
73
|
+
flutter pub deps
|
|
74
|
+
|
|
75
|
+
# Check why a specific package version was chosen
|
|
76
|
+
flutter pub deps --style=compact | grep <package>
|
|
77
|
+
|
|
78
|
+
# Upgrade packages to latest compatible versions
|
|
79
|
+
flutter pub upgrade
|
|
80
|
+
|
|
81
|
+
# Upgrade specific package
|
|
82
|
+
flutter pub upgrade <package_name>
|
|
83
|
+
|
|
84
|
+
# Clear pub cache if metadata is corrupted
|
|
85
|
+
flutter pub cache repair
|
|
86
|
+
|
|
87
|
+
# Verify pubspec.lock is consistent
|
|
88
|
+
flutter pub get --enforce-lockfile
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Null Safety Fix Patterns
|
|
92
|
+
|
|
93
|
+
```dart
|
|
94
|
+
// Error: A value of type 'String?' can't be assigned to type 'String'
|
|
95
|
+
// BAD — force unwrap
|
|
96
|
+
final name = user.name!;
|
|
97
|
+
|
|
98
|
+
// GOOD — provide fallback
|
|
99
|
+
final name = user.name ?? 'Unknown';
|
|
100
|
+
|
|
101
|
+
// GOOD — guard and return early
|
|
102
|
+
if (user.name == null) return;
|
|
103
|
+
final name = user.name!; // safe after null check
|
|
104
|
+
|
|
105
|
+
// GOOD — Dart 3 pattern matching
|
|
106
|
+
final name = switch (user.name) {
|
|
107
|
+
final n? => n,
|
|
108
|
+
null => 'Unknown',
|
|
109
|
+
};
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Type Error Fix Patterns
|
|
113
|
+
|
|
114
|
+
```dart
|
|
115
|
+
// Error: The argument type 'List<dynamic>' can't be assigned to 'List<String>'
|
|
116
|
+
// BAD
|
|
117
|
+
final ids = jsonList; // inferred as List<dynamic>
|
|
118
|
+
|
|
119
|
+
// GOOD
|
|
120
|
+
final ids = List<String>.from(jsonList);
|
|
121
|
+
// or
|
|
122
|
+
final ids = (jsonList as List).cast<String>();
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## build_runner Troubleshooting
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Clean and regenerate all files
|
|
129
|
+
dart run build_runner clean
|
|
130
|
+
dart run build_runner build --delete-conflicting-outputs
|
|
131
|
+
|
|
132
|
+
# Watch mode for development
|
|
133
|
+
dart run build_runner watch --delete-conflicting-outputs
|
|
134
|
+
|
|
135
|
+
# Check for missing build_runner dependencies in pubspec.yaml
|
|
136
|
+
# Required: build_runner, json_serializable / freezed / riverpod_generator (as dev_dependencies)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Android Build Troubleshooting
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Clean Android build cache
|
|
143
|
+
cd android && ./gradlew clean && cd ..
|
|
144
|
+
|
|
145
|
+
# Invalidate Flutter tool cache
|
|
146
|
+
flutter clean
|
|
147
|
+
|
|
148
|
+
# Rebuild
|
|
149
|
+
flutter pub get && flutter build apk
|
|
150
|
+
|
|
151
|
+
# Check Gradle/JDK version compatibility
|
|
152
|
+
cd android && ./gradlew --version
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## iOS Build Troubleshooting
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# Update CocoaPods
|
|
159
|
+
cd ios && pod install --repo-update && cd ..
|
|
160
|
+
|
|
161
|
+
# Clean iOS build
|
|
162
|
+
flutter clean && cd ios && pod deintegrate && pod install && cd ..
|
|
163
|
+
|
|
164
|
+
# Check for platform version mismatches in Podfile
|
|
165
|
+
# Ensure ios platform version >= minimum required by all pods
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Key Principles
|
|
169
|
+
|
|
170
|
+
- **Surgical fixes only** — don't refactor, just fix the error
|
|
171
|
+
- **Never** add `// ignore:` suppressions without approval
|
|
172
|
+
- **Never** use `dynamic` to silence type errors
|
|
173
|
+
- **Always** run `flutter analyze` after each fix to verify
|
|
174
|
+
- Fix root cause over suppressing symptoms
|
|
175
|
+
- Prefer null-safe patterns over bang operators (`!`)
|
|
176
|
+
|
|
177
|
+
## Stop Conditions
|
|
178
|
+
|
|
179
|
+
Stop and report if:
|
|
180
|
+
- Same error persists after 3 fix attempts
|
|
181
|
+
- Fix introduces more errors than it resolves
|
|
182
|
+
- Requires architectural changes or package upgrades that change behavior
|
|
183
|
+
- Conflicting platform constraints need user decision
|
|
184
|
+
|
|
185
|
+
## Output Format
|
|
186
|
+
|
|
187
|
+
```text
|
|
188
|
+
[FIXED] lib/features/cart/data/cart_repository_impl.dart:42
|
|
189
|
+
Error: A value of type 'String?' can't be assigned to type 'String'
|
|
190
|
+
Fix: Changed `final id = response.id` to `final id = response.id ?? ''`
|
|
191
|
+
Remaining errors: 2
|
|
192
|
+
|
|
193
|
+
[FIXED] pubspec.yaml
|
|
194
|
+
Error: Version solving failed — http >=0.13.0 required by dio and <0.13.0 required by retrofit
|
|
195
|
+
Fix: Upgraded dio to ^5.3.0 which allows http >=0.13.0
|
|
196
|
+
Remaining errors: 0
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Final: `Build Status: SUCCESS/FAILED | Errors Fixed: N | Files Modified: list`
|
|
200
|
+
|
|
201
|
+
For detailed Dart patterns and code examples, see `skill: flutter-dart-code-review`.
|