agentleFS
Baba01hacker666Baba01hacker666/dummyskills/skills/general-engineering/api-contract-tester/SKILL.md

api-contract-tester

Skill0 starsChanged 2 months agoMITView on GitHub

Guides agents through validating REST/HTTP API endpoints against expected request/response contracts, status codes, and JSON schemas.

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 6 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Verify that API routes fulfill their external contracts before deployment.

    line 11
  2. Distinctive:

    Use this skill when:

    line 14
  3. Very specific:

    Do not use for unit testing internal functions.

    line 20
  4. Distinctive:

    If endpoint is missing: ask for target URL.

    line 28
  5. Very specific:

    Default method to GET if unspecified.

    line 29
  6. Distinctive:

    Follow these numbered actions:

    line 32
  7. Very specific:

    Check if status matches expected_status.

    line 38
  8. Distinctive:

    Verify required keys exist and match types.

    line 41
  9. Very specific:

    If status code matches but payload is missing required schema keys: mark as CONTRACT_VIOLATION.

    line 46
  10. Distinctive:

    Stop and ask the user when:

    line 74

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

API Contract Tester

Validates HTTP/REST endpoints against contract specifications. Tests status codes, headers (Content-Type), and JSON response schema conformity using curl or test clients.

1. Purpose

Verify that API routes fulfill their external contracts before deployment.

2. When to Use

Use this skill when:

  • Verifying newly implemented HTTP routes.
  • Testing error responses (400, 401, 404, 429).
  • Auditing response schema against OpenAPI / JSON Schema contracts.

3. When Not to Use

  • Do not use for unit testing internal functions; use test-runner-debugger.

4. Required Inputs

  • endpoint: URL path (e.g. http://localhost:3000/api/users).
  • method: GET, POST, PUT, DELETE.
  • expected_status: Expected HTTP status code (e.g. 200, 400).

5. Missing-Input Behavior

  1. If endpoint is missing: ask for target URL.
  2. Default method to GET if unspecified.

6. Procedure

Follow these numbered actions:

  1. Action 1: Formulate Test Request
    • Construct curl -s -i -X <METHOD> <URL>.
  2. Action 2: Execute Request
    • Capture HTTP status code, headers, and body.
  3. Action 3: Validate Status & Headers
    • Check if status matches expected_status.
    • Check Content-Type: application/json.
  4. Action 4: Validate Body Schema
    • Verify required keys exist and match types.
  5. Action 5: Emit Contract Report
    • Format per Section 8.

7. Decision Rules

  • If status code matches but payload is missing required schema keys: mark as CONTRACT_VIOLATION.

8. Output Format

Emit the report using this template:

### API Contract Test Report: [METHOD] [Endpoint]

- **Status**: [PASSED | FAILED | CONTRACT_VIOLATION]
- **HTTP Code**: [Observed] (Expected: [Expected])
- **Content-Type**: `[Header]`

#### Payload Validation
- [x] Status code matches contract
- [x] Response body valid JSON
- [x] Required keys present: `[keys]`

9. Verification Checklist

  • HTTP status code matches expected.
  • Content-Type header verified.
  • Response body matches schema.

10. Common Failures and Recovery

Failure SymptomCauseRecovery Action
curl: (7) Failed to connectServer not runningStart local test server before executing curl.

11. Stop or Escalation Conditions

Stop and ask the user when:

  • Endpoint triggers destructive live external actions (e.g. real credit card charges).

12. Examples

Example 1: Successful Execution

Input:

Endpoint: http://localhost:3000/health
Method: GET
Expected: 200

Output:

### API Contract Test Report: GET /health

- **Status**: PASSED
- **HTTP Code**: 200 (Expected: 200)
- **Content-Type**: `application/json; charset=utf-8`

#### Payload Validation
- [x] Status code matches contract
- [x] Response body valid JSON (`{"status":"ok"}`)
- [x] Required keys present: `status`

Example 2: Ambiguous or Missing Input

Input:

Test API.

Output:

### API Contract Test Report: Halted - Missing Endpoint

- **Status**: Halted

Please provide the API endpoint URL and expected HTTP status code.

Example 3: Expected Final Output

Output:

### API Contract Test Report: POST /api/login

- **Status**: PASSED
- **HTTP Code**: 401 (Expected: 401)
- **Content-Type**: `application/json`

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.