Best for
- Use this skill when writing or reviewing API endpoint tests — integration tests, contract validation, response structure checks, or external service mocking.
event4u-app/agent-config/src/skills/api-testing/SKILL.md
Use when writing API endpoint tests — integration tests, contract validation, response assertions, mocked external services — even when the user says 'test this route' without naming API testing.
Decision brief
Use when writing API endpoint tests — integration tests, contract validation, response assertions, mocked external services — even when the user says 'test this route' without naming API testing.
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/event4u-app/agent-config --skill "src/skills/api-testing"Inspect the Agent Skill "api-testing" from https://github.com/event4u-app/agent-config/blob/0adf49a8ae84b0ff6e2de8759eea43257e020eff/src/skills/api-testing/SKILL.md at commit 0adf49a8ae84b0ff6e2de8759eea43257e020eff. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
1. Understand the endpoint — Read the controller, form request, and existing tests. Understand expected behavior, edge cases, and auth requirements before writing anything. 2. Set up test data — Use seeders (preferred) or factories. Mock external services with Http::fake(). 3. E…
API tests cover the contract layer. When an endpoint feeds a UI surface (Livewire component, Blade-rendered page, SPA route), complement the API test with a thin UI probe: a livewire test for wired components, or a Playwright spec / browser screenshot for the rendered shell. Nev…
Use this skill when writing or reviewing API endpoint tests — integration tests, contract validation, response structure checks, or external service mocking.
Review the “Example” section in the pinned source before continuing.
Test the expected success scenario with valid input:
Permission review
No configured static risk pattern was detected
This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.
Evidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 93/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 7 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Use this skill when writing or reviewing API endpoint tests — integration tests, contract validation, response structure checks, or external service mocking.
Http::fake().test-case-discovery funnel first; cover success, validation errors, authorization failures, and edge cases — floor per behavior: 1 happy + 1 boundary + 1 error (+1 abuse case; on data-returning endpoints the three broken-access-control negative tests are mandatory).assertJsonStructure().describe('GET /api/v1/projects', function () {
it('returns paginated projects for authenticated user', function () {
$user = loginAsTestUser();
$response = $this->getJson('/api/v1/projects');
$response->assertOk()
->assertJsonStructure([
'data' => [['id', 'title', 'status']],
'meta' => ['current_page', 'per_page', 'total'],
]);
});
it('returns 401 for unauthenticated request', function () {
$this->getJson('/api/v1/projects')
->assertUnauthorized();
});
it('returns 403 when user lacks permission', function () {
loginAsRestrictedUser();
$this->getJson('/api/v1/projects')
->assertForbidden();
});
});
Test the expected success scenario with valid input:
it('creates a project', function () {
loginAsTestUser();
$this->postJson('/api/v1/projects', [
'title' => 'New Project',
'customer_id' => $customerId,
])
->assertCreated()
->assertJsonPath('data.title', 'New Project');
$this->assertDatabaseHas('projects', ['title' => 'New Project']);
});
Test that invalid input is rejected with correct error messages:
it('rejects project without title', function () {
loginAsTestUser();
$this->postJson('/api/v1/projects', [
'customer_id' => $customerId,
])
->assertUnprocessable()
->assertJsonValidationErrors(['title']);
});
Test that unauthorized access is blocked:
it('prevents non-owner from updating project', function () {
$otherUser = loginAsOtherUser();
$this->putJson("/api/v1/projects/{$project->id}", [
'title' => 'Hijacked',
])
->assertForbidden();
});
Test boundary conditions:
it('handles empty collection', function () {
loginAsTestUser();
$this->getJson('/api/v1/projects')
->assertOk()
->assertJsonCount(0, 'data');
});
it('paginates large result sets', function () {
loginAsTestUser();
$this->getJson('/api/v1/projects?per_page=5')
->assertOk()
->assertJsonPath('meta.per_page', 5);
});
// Verify response shape (keys exist)
$response->assertJsonStructure([
'data' => ['id', 'title', 'status', 'created_at'],
]);
// Verify exact values
$response->assertJsonPath('data.status', 'active');
// Verify collection count
$response->assertJsonCount(3, 'data');
// When strict typing matters
$data = $response->json('data');
expect($data['id'])->toBeInt();
expect($data['title'])->toBeString();
expect($data['total'])->toBeString(); // Money as string, not float
When a failing test dumps the full JSON body, narrow the diagnosis with jq or grep
instead of scrolling the whole payload:
# Extract only the failing assertion path
echo "$RESPONSE_JSON" | jq '.data.status, .errors'
# Targeted log scan
rg --json 'API call failed' storage/logs/laravel.log | jq -r '.data.lines.text'
it('handles external API failure gracefully', function () {
Http::fake([
'external-api.com/*' => Http::response(null, 500),
]);
loginAsTestUser();
$this->postJson('/api/v1/sync')
->assertStatus(502)
->assertJsonPath('message', 'External service unavailable');
});
| Category | Tests needed |
|---|---|
| Auth | Unauthenticated (401), unauthorized (403) |
| Validation | Missing fields, wrong types, boundary values |
| Happy path | Success with valid input, correct status code |
| Response | JSON structure, field types, pagination meta |
| Side effects | Database changes, events dispatched, jobs queued |
| Edge cases | Empty results, large payloads, concurrent access |
API tests cover the contract layer. When an endpoint feeds a UI surface (Livewire component, Blade-rendered page, SPA route), complement the API test with a thin UI probe: a livewire test for wired components, or a Playwright spec / browser screenshot for the rendered shell. Never assume the UI works just because the API test is green.
Http::fake() — never hit real services in tests.Http::fake() without also testing the real integration path.When a test fails, do not retry blindly with tweaked assertions until something passes. Diagnose the root cause first: print the actual response shape once, compare it to the contract, then write a targeted fix. Trial-and-error retries hide real regressions.
If the endpoint contract is ambiguous (unclear status code, optional fields, error envelope shape), do not assume. Ask the user or check the OpenAPI spec / route definition before writing assertions — never guess the response shape from the route name.
Alternatives
coreyhaines31/marketingskills
When the user wants to plan, design, or implement an A/B test or experiment, or build a growth experimentation program. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," "hypothesis," "should I test this," "which version is better," "test two versions," "statistical significance," "how long should I run this test," "growth experiments," "experiment velocity," "experiment backlog," "ICE score," "experimentation program
event4u-app/agent-config
Use when the user says "review the design", "check the UI", or wants a comprehensive UI/UX review. Uses a 7-phase methodology covering interaction, responsiveness, accessibility, and more.
affaan-m/ECC
Design, implement, and refactor Ports & Adapters systems with clear domain boundaries, dependency inversion, and testable use-case orchestration across TypeScript, Java, Kotlin, and Go services.
event4u-app/agent-config
Use when shaping a Playwright suite — locator strategy, Page Object boundaries, fixture composition, flake-prevention architecture, CI-vs-local split — even on 'design our E2E tests'.