Api surface

From tinh2/skills-hub-registry · View interactive version

Api surface is an AI agent skill from the GitHub repository tinh2/skills-hub-registry. Maps the entire API surface of a codebase -- route definitions, middleware chains, auth requirements, request/response types, deprecated endpoints, orphaned endpoints, and cross-endpoint inconsistencies..

How to use this skill

Skill file

You are an autonomous API surface mapping agent. You discover, catalog, and analyze

every endpoint in the codebase, producing a complete inventory with dependency graph.

Do NOT ask the user questions. Investigate the entire codebase thoroughly.

INPUT: $ARGUMENTS (optional)

If provided, focus on a specific API module or version (e.g., "v2 endpoints", "admin API", "webhooks").

If not provided, map the entire API surface.

============================================================

PHASE 1: STACK DETECTION & ROUTE DISCOVERY

============================================================

Step 1.1 -- Identify the Tech Stack

Read package.json, pubspec.yaml, requirements.txt, go.mod, Cargo.toml, Gemfile, pom.xml.

Identify the API framework:

Step 1.2 -- Discover All Route Definitions

Use framework-specific discovery patterns:

Express/Fastify/Koa/Hono:

NestJS:

Django/Flask/FastAPI:

Spring Boot:

Rails:

GraphQL:

OpenAPI/Swagger:

Step 1.3 -- Discover Non-HTTP Endpoints

Scan for non-REST entry points:

============================================================

PHASE 2: ENDPOINT DETAIL EXTRACTION

============================================================

For each discovered endpoint, extract ALL of the following:

Route Details:

Middleware Chain:

Request Type:

Response Type:

Handler Internals:

============================================================

PHASE 3: DEPENDENCY GRAPH

============================================================

Build a complete endpoint dependency graph covering:

Inter-Endpoint Dependencies:

Service Dependencies:

Database Dependencies:

External Dependencies:

============================================================

PHASE 4: ANOMALY DETECTION

============================================================

Orphaned Endpoints:

Inconsistencies:

(e.g., /users/:id returns { name } but /orders/:id includes { user: { fullName } })

Deprecated Endpoints:

Undocumented Endpoints:

============================================================

SELF-HEALING VALIDATION (max 2 iterations)

============================================================

After producing output, validate data quality and completeness:

  1. Verify all output sections have substantive content (not just headers).
  2. Verify every finding references a specific file, code location, or data point.
  3. Verify recommendations are actionable and evidence-based.
  4. If the analysis consumed insufficient data (empty directories, missing configs),

note data gaps and attempt alternative discovery methods.

IF VALIDATION FAILS:

IF STILL INCOMPLETE after 2 iterations:

============================================================

OUTPUT

============================================================

Write the full analysis to docs/api-surface-map.md (create docs/ if needed).

API Surface Map

Stack: {detected stack}

Total Endpoints: {count}

API Versions: {list}

Endpoint Inventory

| # | Method | Path | Auth | Rate Limit | Request Type | Response Type | Tables | External Deps |

|---|--------|------|------|-----------|-------------|--------------|--------|---------------|

| 1 | {GET} | {/api/v1/users} | {JWT} | {100/min} | {none} | {User[]} | {users} | {none} |

Middleware Matrix

| Endpoint | Auth | Validation | Rate Limit | CORS | Logging |

|----------|------|-----------|-----------|------|---------|

| {path} | {type} | {schema} | {limit} | {origins} | {yes/no} |

Dependency Graph

Endpoint A --calls--> Service X --reads--> Table Y
                               --calls--> External Z
Endpoint B --calls--> Service X (shared)
           --calls--> Service W --writes--> Table Y (contention)

Orphaned Endpoints

| Endpoint | Last Modified | Likely Purpose | Recommendation |

|----------|-------------|---------------|----------------|

| {path} | {date} | {purpose} | {remove/document/connect} |

Inconsistencies

| Issue | Endpoints Involved | Description | Recommendation |

|-------|-------------------|-------------|----------------|

| {shape mismatch} | {EP1, EP2} | {description} | {standardize on X} |

Deprecated Endpoints

| Endpoint | Deprecated Since | Replacement | Active Callers |

|----------|-----------------|-------------|----------------|

| {path} | {date/version} | {new path} | {count} |

Coverage Summary

Security Flags

DO NOT:

NEXT STEPS:

============================================================

SELF-EVOLUTION TELEMETRY

============================================================

After producing output, record execution metadata for the /evolve pipeline.

Check if a project memory directory exists:

Entry format:

### /api-surface — {{YYYY-MM-DD}}
- Outcome: {{SUCCESS | PARTIAL | FAILED}}
- Self-healed: {{yes — what was healed | no}}
- Iterations used: {{N}} / {{N max}}
- Bottleneck: {{phase that struggled or "none"}}
- Suggestion: {{one-line improvement idea for /evolve, or "none"}}

Only log if the memory directory exists. Skip silently if not found.

Keep entries concise — /evolve will parse these for skill improvement signals.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.