Build reusable HTTP API test artifacts from user-provided endpoints, authentication, request data, expected results, and validation rules. Use this skill whe...
---
name: http-api-test-runner
description: Build reusable HTTP API test artifacts from user-provided endpoints, authentication, request data, expected results, and validation rules. Use this skill when the user wants to create .http files, run HTTP/REST API checks, replay browser or curl requests, validate JSON fields or response markers, compare expected vs actual responses, or generate formatted PASS/FAIL API test reports.
---
# HTTP API Test Runner
Use this skill to turn one-off HTTP checks into reusable `.http` cases and a runnable verification script.
Generate two artifacts by default:
- `<feature>.api-tests.http`
- `<feature>.api-verify.sh`
The `.http` file is the source of truth. The shell script executes the cases, prints readable `PASS/FAIL/SKIP` output, and exits non-zero when any non-skipped case fails.
## Quick Start
1. Collect only the missing inputs: host, method, auth, request data, cases, and expected results.
2. Choose a starting point:
- Use `templates/` for a new endpoint.
- Use `examples/` when the endpoint looks similar to an existing example.
- Use `references/complex-scenarios.md` for multi-step or advanced validation.
3. Generate or update:
- `<feature>.api-tests.http`
- `<feature>.api-verify.sh`
4. Validate the generated script:
```bash
bash -n './<feature>.api-verify.sh'
bash './<feature>.api-verify.sh'
COOKIE='full Cookie header' AUTH_TOKEN='token value' bash './<feature>.api-verify.sh'
```
5. If cases fail, classify the problem before editing assertions:
- auth mismatch
- request shape mismatch
- environment or fixture mismatch
- business assertion mismatch
See `references/debugging-cookbook.md` for the failure checklist.
## What To Collect
Ask only for fields the user did not already provide.
| Input | Needed for |
| --- | --- |
| Base URL / host | Resolving request targets |
| HTTP method | Building the request |
| Authentication | Cookie, bearer, custom headers, or none |
| Request data | Path params, query params, JSON body, form body |
| Cases | Positive, negative, auth failure, boundary checks |
| Expected results | Status, JSON path, marker text, list membership, error behavior |
| Output preference | Brief summary, key fields, raw response save path |
For cookie-based tests, tell the user to copy the full `Cookie:` request header from a successful browser Network request. Do not reconstruct cookies from the storage panel.
Generated comments and final usage notes should follow the user's language.
## Choose Your Starting Point
- `templates/basic.api-tests.http.txt`
- Fastest path for a new endpoint.
- Includes a small set of common variables and assertions.
- `templates/basic.api-verify.sh`
- Runnable shell script with timeout handling, env-based secrets, and formatted output.
- `examples/resource-detail/`
- Resource detail lookup with cookie auth and JSON field assertions.
- `examples/auth-login-required/`
- Unauthenticated and invalid-auth cases.
- `examples/list-assertions/`
- List projection, membership, and absence checks.
- `examples/async-job-polling/`
- Submit -> poll -> verify pattern with a runnable pre-step script for async workflows.
Note: publishable skill assets use `.http.txt` to satisfy upload restrictions, while generated runtime artifacts should still use `.api-tests.http`.
## Artifact Contract
The generated `.http` file should:
- declare variables such as `@host`, `@cookie`, `@token`, `@resourceId`
- use `###` titles for each case
- keep one request per case
- add explicit `expect.*` comments
- keep real secrets out of the file by default
The generated shell script should:
- read the `.http` file
- resolve `{{variable}}` placeholders
- accept secrets from environment variables
- print `PASS/FAIL/SKIP` output for each case
- print a summary line
- exit non-zero if any non-skipped case fails
## Safety Rules
- Do not commit real cookies, tokens, passwords, or internal credentials.
- Use placeholders such as `@cookie = <set via COOKIE>` and `@token = <set via AUTH_TOKEN>`.
- When secrets are missing, authenticated cases should `SKIP` with a clear reason instead of crashing the parser.
- Before publishing or committing generated artifacts, run a lightweight secret scan:
```bash
rg -n "password|secret|session_id|auth_token|access_token|refresh_token" <artifact-dir>
rg -n "Authorization: Bearer [A-Za-z0-9._-]+|C[o]okie: [A-Za-z0-9_%-]+=" <artifact-dir>
```
## Reference Map
- Assertion reference: `references/assertion-cheatsheet.md`
- Complex flows and advanced validation: `references/complex-scenarios.md`
- Failure diagnosis and triage: `references/debugging-cookbook.md`
- Lightweight publishable example: `references/http_test_artifact_example.md`
## Default Running Checks
After generating artifacts, run:
```bash
bash -n './<feature>.api-verify.sh'
bash './<feature>.api-verify.sh'
COOKIE='full Cookie header' AUTH_TOKEN='token value' bash './<feature>.api-verify.sh'
```
Interpretation:
- `bash -n` catches shell syntax errors.
- Running without secrets should verify parsing and expected `SKIP` behavior.
- Running with secrets should verify actual API behavior and assertions.
don't have the plugin yet? install it then click "run inline in claude" again.
added explicit intent, organized inputs with table and external connection guidance, numbered all procedure steps with input/output pairs, extracted 8 decision points from scattered guidance, clarified output contract with file locations and formats, and documented success criteria with 7 concrete signals.
Turn one-off HTTP checks into reusable .http cases and a runnable verification script. use this skill when the user wants to create .http files, run HTTP/REST API checks, replay browser or curl requests, validate JSON fields or response markers, compare expected vs actual responses, or generate formatted PASS/FAIL API test reports.
Generate two production artifacts (a .http file and a shell verification script) that codify HTTP API test cases with explicit authentication, request payloads, and validation rules. the .http file becomes the source of truth. the script executes cases, prints readable PASS/FAIL/SKIP output per case, and exits non-zero if any non-skipped case fails. use this when you need repeatable API test coverage that doesn't require a full test framework, or when you want to version-control API contracts alongside your codebase.
| input | format | notes |
|---|---|---|
| base URL / host | string (e.g., https://api.example.com) |
required. resolves all request targets. |
| HTTP method | GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS | required for each case. |
| authentication | cookie header, bearer token, basic auth, custom headers, or none | optional. if provided, must include full header string (for cookies) or token value (for bearer). do not reconstruct from browser storage panel. copy exact Cookie: header from network tab. |
| request data | path params, query params, JSON body, form-encoded body | optional. path params use {param} syntax. query params use ?key=value&key2=value2. JSON bodies must be valid. |
| test cases | array of named case objects | each case has: name, method, path, optional body, optional headers, optional auth override. |
| expected results | status code, JSON path assertions, marker text, list membership, error messages | required per case. status code is always checked. JSON paths use dot notation (e.g., data.user.id). |
| output preference | brief summary, key fields only, raw response save path | optional. defaults to summary mode. |
| environment variables for secrets | COOKIE, AUTH_TOKEN, API_KEY, etc. |
optional. if auth inputs are missing, authenticated cases will skip with a reason instead of failing. |
external connections:
collect inputs from the user. ask only for fields not already provided. use the table above as a checklist. if a field is unclear, ask for a concrete example (real or sanitized).
choose a starting point:
templates/basic.api-tests.http.txt for a new endpoint. includes common variables and assertions.templates/basic.api-verify.sh as the shell script template. includes timeout handling, env-based secrets, formatted output.examples/resource-detail/ if the endpoint looks like a resource lookup with JSON field assertions.examples/auth-login-required/ if you need unauthenticated and invalid-auth cases.examples/list-assertions/ if validation involves list projection or membership checks.examples/async-job-polling/ if the flow is submit then poll then verify.references/complex-scenarios.md for multi-step or advanced validation patterns.input for this step: user description, any code snippet, curl command, browser network tab export, or endpoint documentation. output for this step: choice of template + rationale noted in comments.
generate the .http file (<feature>.api-tests.http) with:
@host, @cookie, @token, @resourceId). use <set via COOKIE> placeholders for secrets.### title per case (e.g., ### login with valid credentials).expect.* comments before each request (e.g., // expect status 200, data.user.email in response).input for this step: collected user inputs (base URL, method, auth, cases, assertions).
output for this step: .http file text, ready to save.
generate the shell script (<feature>.api-verify.sh) with:
#!/bin/bash..http file line by line.{{variable}} placeholders from shell variables or env vars.COOKIE, AUTH_TOKEN, API_KEY). if a secret is missing and a case requires it, mark the case as SKIP.curl or http CLI. capture status code and response body.PASS, FAIL, or SKIP for each case with a short reason.5 passed, 1 failed, 1 skipped).--max-time 10 for curl) to prevent hanging.input for this step: .http file text, validation rules.
output for this step: shell script text, ready to save and execute.
validate the generated script by running:
bash -n './<feature>.api-verify.sh'
bash './<feature>.api-verify.sh'
COOKIE='full Cookie header' AUTH_TOKEN='token value' bash './<feature>.api-verify.sh'
bash -n catches syntax errors.SKIP behavior.input for this step: generated script, curl or http client on user's system. output for this step: validation report (syntax pass/fail, case results, summary).
if cases fail, classify the problem before editing assertions:
references/debugging-cookbook.md for the failure checklist.input for this step: test output, actual API response.
output for this step: diagnosis + corrected .http file or script.
before publishing or committing, run a lightweight secret scan:
rg -n "password|secret|session_id|auth_token|access_token|refresh_token" <artifact-dir>
rg -n "Authorization: Bearer [A-Za-z0-9._-]+|C[o]okie: [A-Za-z0-9_%-]+=" <artifact-dir>
remove or redact any real credentials found.
input for this step: generated .http file and script.
output for this step: clean artifacts, safe to commit.
if the user provides a curl command or browser network request:
extract method, path, headers, and body. map to .http syntax. prompt for expected results and additional test cases (positive, negative, boundary).
if the user provides endpoint documentation (swagger, openapi, postman collection): parse the spec. extract method, path, params, request/response schemas. generate baseline cases. ask for custom auth and edge cases specific to their usage.
if authentication is required but no credential is provided:
generate the .http file with placeholder variables (e.g., @token = <set via AUTH_TOKEN>). in the shell script, skip authenticated cases with reason: "skipped: AUTH_TOKEN not set". do not crash the parser.
if a case uses cookie-based auth:
instruct the user to copy the full Cookie: request header from the browser network tab after a successful login. do not reconstruct cookies from the browser storage panel (inconsistent headers, missing attributes). assign to variable @cookie = <set via COOKIE>.
if expected results include json path assertions:
use dot notation (e.g., data.user.email) or array indices (e.g., items[0].id). validate that the JSON path is valid before generating. if the path is invalid or the response is not JSON, mark the case as FAIL with reason: "response not valid JSON" or "path not found".
if a case is marked as "skip" or "todo":
in the .http file, prefix the case title with SKIP:. in the shell script, skip the case and print reason: "skipped: marked as todo".
if the user wants to save raw responses for manual review:
add an optional --output-dir flag to the shell script. save response bodies to <output-dir>/<case-name>.json or .txt. do not overwrite without warning.
if rate limiting or network timeouts occur during test execution: catch curl error codes (e.g., 28 for timeout, 7 for connection failed). print diagnostic message (e.g., "FAIL: timeout after 10s") and include in failure count. do not retry automatically; let the user decide.
.http artifact (<feature>.api-tests.http):
.http dialect (IntelliJ, VS Code REST Client, or similar).@name = value syntax. secrets use <set via ENV_VAR> placeholders.### section title per test case.{param} placeholders), query string, headers, body.expect.* comment above each request documenting assertion intent.<feature>.api-tests.http in the project root or tests/api/ directory.shell script artifact (<feature>.api-verify.sh):
#!/bin/bash..http file and resolves placeholders from env vars.[PASS/FAIL/SKIP] <case-name>: <reason>.<N> passed, <M> failed, <K> skipped. exit code: <0 or 1>.<feature>.api-verify.sh in the project root or tests/api/ directory.chmod +x on unix).validation report (if provided):
the skill worked when:
.http file and shell script) are generated and saved to the specified location.bash -n './<feature>.api-verify.sh' exits 0 (no syntax errors).bash './<feature>.api-verify.sh' executes all cases, prints readable output with status per case, and prints a summary line.COOKIE='...' AUTH_TOKEN='...' bash './<feature>.api-verify.sh') produces actual test results against the API endpoint..http file contains no real secrets and can be safely committed.