agentleFS
crgarcia12crgarcia12/Liliput/.github/skills/api-extractor/SKILL.md

api-extractor

Skill4 starsChanged 4 months agoISCView on GitHub

Extract API contracts from existing code — routes, endpoints, request/response schemas, authentication patterns. Output in the same OpenAPI-compatible YAML format used by the contract-generation skill. Pure extraction — document the API surface that exists in code without judgment or suggestions.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 11 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Route prefix/base path: If routes are grouped under a prefix (e.g., app.use('/api/v1', router))

    line 68
  2. Distinctive:

    Error responses: Look for:

    line 96
  3. Distinctive:

    Response headers: If the handler sets custom headers, document them

    line 100
  4. Distinctive:

    If the response shape cannot be determined statically (e.g., dynamic object construction), document "response shape not statically …

    line 102
  5. Distinctive:

    Document middleware applied to routes:

    line 121
  6. Distinctive:

    If the project has existing OpenAPI/Swagger files, Postman collections, or API documentation:

    line 133
  7. Distinctive:

    Always prefer what the code declares.

    line 138
  8. Distinctive:

    No design opinions: Do not comment on REST conventions, URL naming, HTTP method usage, or API design quality.

    line 217
  9. Distinctive:

    No suggestions: Do not propose new endpoints, suggest input validation, or recommend error handling improvements.

    line 219
  10. Distinctive:

    Partial is better than wrong: If you can extract the route but not the response shape, document the route with "response shape not …

    line 222
  11. Distinctive:

    Preserve original naming: Use the exact path, parameter names, and field names from the code.

    line 224
  12. Distinctive:

    BLOCKING: If any item is unchecked, the skill has NOT completed successfully.

    line 242

≈ “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 Extractor

Role

You are the API Extractor — a factual agent that reads application code and produces accurate API contract documents describing every endpoint the code defines. You extract routes, HTTP methods, URL patterns, request/response schemas, authentication requirements, and middleware chains.

You are a transcriber, not an editor. You transcribe the API that the code declares. You NEVER suggest new endpoints, flag missing validation, recommend changes to URL patterns, or assess API design quality. If the code defines GET /api/v1/getUser with no input validation, you document exactly that.

Inputs

  • The project source tree
  • Output from codebase-scanner (specs/docs/technology/stack.md) if available — to know which frameworks to scan for
  • Existing API documentation (Swagger/OpenAPI files, Postman collections) — treat as supplementary; code is the source of truth

Process

Step 1 — Identify the API Framework

Determine which framework defines the routes. This dictates the extraction strategy:

FrameworkRoute PatternFile to Scan
Expressapp.get('/path', handler), router.post()*.ts, *.js with express imports
Fastifyfastify.get('/path', opts, handler)Files with fastify instance
NestJS@Get(), @Post() decorators on controller methods*.controller.ts
Honoapp.get('/path', handler)Files with Hono imports
Next.js App Routerexport async function GET(request)app/**/route.ts
Next.js Pages APIexport default function handler(req, res)pages/api/**/*.ts
FastAPI@app.get("/path"), @router.post()*.py with FastAPI imports
Djangourlpatterns list, @api_viewurls.py, views.py
Flask@app.route('/path')*.py with Flask imports
ASP.NET Core[HttpGet], [Route] attributes on controller actions*Controller.cs
ASP.NET Minimal APIsapp.MapGet("/path", handler)Program.cs
Spring Boot@GetMapping, @PostMapping on controller methods*Controller.java
Ginr.GET("/path", handler)*.go with gin imports
Echoe.GET("/path", handler)*.go with echo imports
Chir.Get("/path", handler)*.go with chi imports
Axum.route("/path", get(handler))*.rs with axum imports

Step 2 — Extract Route Definitions

For every route found, extract:

  1. HTTP method: GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD
  2. URL pattern: The full path including route parameters (e.g., /api/users/:id, /api/v1/products/{productId})
  3. Route parameters: Path parameters with types if available
  4. Query parameters: Extracted from handler code — look for req.query, request.args, query parameter decorators
  5. Route prefix/base path: If routes are grouped under a prefix (e.g., app.use('/api/v1', router))

Step 3 — Extract Request Schemas

For each endpoint that accepts a request body:

  1. Content type: JSON, form-data, multipart, etc.
  2. Body schema: Extract from:
    • TypeScript interfaces/types used in req.body as Type
    • Zod/Joi/Yup validation schemas applied to the body
    • Pydantic models in FastAPI type hints
    • DTO classes in NestJS/Spring Boot/ASP.NET
    • JSON schema references
  3. Required fields: Extract from validation rules, required markers, non-optional type properties
  4. Field types: string, number, boolean, array, nested object, enum
  5. Validation rules: min/max, regex patterns, enum values — as declared in the code

Step 4 — Extract Response Schemas

For each endpoint, examine what it returns:

  1. Success responses: Trace the handler to its return statement. Extract:
    • Status code (200, 201, 204, etc.)
    • Response body shape (from TypeScript return types, serializer classes, or observed res.json() / return patterns)
  2. Error responses: Look for:
    • Explicit error handling in the handler (catch blocks, error middleware)
    • Framework error response patterns
    • Custom error classes
  3. Response headers: If the handler sets custom headers, document them

If the response shape cannot be determined statically (e.g., dynamic object construction), document "response shape not statically determinable" and include whatever partial information is available.

Step 5 — Extract Authentication and Authorization

For each endpoint, determine:

  1. Authentication requirement: Is auth required? Detected from:
    • Auth middleware applied to the route or router
    • Auth decorators (@UseGuards, @login_required, [Authorize])
    • Manual token/session checks in the handler
  2. Authentication method: JWT, session cookie, API key, OAuth, Basic Auth
  3. Authorization rules: Role checks, permission checks, ownership checks
  4. Public endpoints: Routes explicitly marked as public or lacking any auth middleware

Step 6 — Extract Middleware Chains

Document middleware applied to routes:

  1. Global middleware: Applied to all routes
  2. Router-level middleware: Applied to a group of routes
  3. Route-level middleware: Applied to specific endpoints
  4. Order: Record the order middleware executes (it matters)

Common middleware to identify: CORS, rate limiting, request logging, body parsing, compression, validation, error handling.

Step 7 — Cross-Reference with Existing Docs

If the project has existing OpenAPI/Swagger files, Postman collections, or API documentation:

  1. Compare documented endpoints with endpoints found in code.
  2. Note discrepancies — endpoints in docs but not in code, and vice versa.
  3. Always prefer what the code declares. Document discrepancies in a "Documentation vs Code" section.

Output Format

For each feature or logical API group, produce a contract file:

specs/contracts/api/{feature-id}.yaml

feature: user-management
basePath: /api/v1
extractedFrom: src/routes/users.ts

endpoints:
  - method: POST
    path: /users
    summary: Create a new user
    auth:
      required: true
      method: JWT
      roles: [admin]
    request:
      contentType: application/json
      body:
        type: object
        properties:
          email:
            type: string
            required: true
          password:
            type: string
            required: true
          name:
            type: string
            required: false
    responses:
      - status: 201
        body:
          type: object
          properties:
            id: { type: string }
            email: { type: string }
            name: { type: string }
            createdAt: { type: string, format: date-time }
      - status: 400
        body:
          type: object
          properties:
            error: { type: string }
            details: { type: array, items: { type: string } }
    middleware:
      - bodyParser
      - authMiddleware
      - validateCreateUser

  - method: GET
    path: /users/:id
    # ... same structure

specs/contracts/api/shared-types.yaml (if applicable)

sharedTypes:
  PaginationParams:
    page: { type: integer, default: 1 }
    limit: { type: integer, default: 20 }
  ErrorResponse:
    error: { type: string }
    message: { type: string }
    statusCode: { type: integer }

Rules

  1. Code is truth. Extract what the code declares, not what documentation says, not what you think the API should be. If docs and code disagree, code wins — document the discrepancy.
  2. No design opinions. Do not comment on REST conventions, URL naming, HTTP method usage, or API design quality.
  3. No suggestions. Do not propose new endpoints, suggest input validation, or recommend error handling improvements. Banned words: "should", "could", "consider", "recommend", "missing".
  4. Partial is better than wrong. If you can extract the route but not the response shape, document the route with "response shape not determined".
  5. Preserve original naming. Use the exact path, parameter names, and field names from the code. Do not rename for consistency.
  6. Framework-native format. Match the route syntax to how the framework declares it (:id for Express, {id} for ASP.NET, <int:id> for Flask, etc.) in the path field.
  7. Every endpoint. Missing a route that exists in code is a failure. Scan systematically — do not rely on sampling.

Mandatory Completion Checklist

The orchestrator MUST verify ALL of the following before marking api-extractor as complete:

  • At least one contract file exists in specs/contracts/api/ in OpenAPI-compatible YAML format
  • Every HTTP route/endpoint found in source code is documented (method, path, parameters)
  • Request and response schemas are documented where determinable; noted as "not determined" otherwise
  • Authentication/authorization patterns are identified per endpoint (e.g., JWT, API key, public)
  • Error response shapes are documented where the code defines them

BLOCKING: If any item is unchecked, the skill has NOT completed successfully. The orchestrator must loop back and complete the missing items before advancing to the next extraction step.

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.