$npx -y skills add LambdaTest/agent-skills --skill api-inference-from-filesInfer and list REST API endpoints from file names or project directory structures. Use this skill whenever a user shares a list of file names, a folder/project structure, or mentions phrases like "what APIs can I build", "infer endpoints from files", "generate API list", "what ro
| 1 | # API Endpoint Inferrer |
| 2 | |
| 3 | Generate a concise list of REST API endpoints inferred from file names or project structures. Output is intentionally minimal: one line per endpoint — the method + path + a single-sentence description. No schemas, no request bodies, no examples, no documentation blocks. |
| 4 | |
| 5 | --- |
| 6 | |
| 7 | ## Input Formats Accepted |
| 8 | |
| 9 | - A flat list of file names: `userController.js`, `productService.py`, etc. |
| 10 | - A directory tree (from `tree`, `ls -R`, `find`, or copy-pasted folder structure) |
| 11 | - A mix of both |
| 12 | - File names with or without extensions |
| 13 | - Any backend language/framework (Node, Python, Go, Ruby, Java, PHP, etc.) |
| 14 | |
| 15 | --- |
| 16 | |
| 17 | ## Inference Rules |
| 18 | |
| 19 | ### 1. Extract Resources |
| 20 | Identify the core resource name from each file. Strip common suffixes: |
| 21 | - `Controller`, `Router`, `Route`, `Handler`, `Service`, `Model`, `View`, `Schema`, `Repository`, `Repo`, `Store`, `Manager`, `API` |
| 22 | |
| 23 | Examples: |
| 24 | - `userController.js` → resource: `user` |
| 25 | - `product_routes.py` → resource: `product` |
| 26 | - `OrderService.java` → resource: `order` |
| 27 | - `auth.go` → resource: `auth` |
| 28 | |
| 29 | ### 2. Map Files to Standard CRUD Endpoints |
| 30 | For each resource, infer standard REST endpoints based on typical conventions: |
| 31 | |
| 32 | | Pattern | Endpoints to infer | |
| 33 | |---|---| |
| 34 | | `*Controller`, `*Router`, `*Route`, `*Handler` | Full CRUD: GET list, GET by ID, POST, PUT/PATCH, DELETE | |
| 35 | | `*Service` | Same as controller (services back controllers) | |
| 36 | | `*Model`, `*Schema` | GET list, GET by ID, POST (data-centric) | |
| 37 | | `auth*`, `*Auth*` | POST /login, POST /logout, POST /register, POST /refresh | |
| 38 | | `*upload*`, `*file*`, `*media*` | POST upload, GET file by ID, DELETE file | |
| 39 | | `*search*` | GET /search with query params | |
| 40 | | `*config*`, `*settings*` | GET settings, PUT settings | |
| 41 | | `*health*`, `*status*`, `*ping*` | GET /health or GET /status | |
| 42 | | `*webhook*` | POST /webhook | |
| 43 | | `*middleware*`, `*interceptor*` | Skip — not an endpoint | |
| 44 | | `*util*`, `*helper*`, `*constant*` | Skip — not an endpoint | |
| 45 | | `*test*`, `*spec*`, `*mock*` | Skip — not an endpoint | |
| 46 | |
| 47 | ### 3. Naming Convention → URL Path |
| 48 | Convert resource names to kebab-case plural paths: |
| 49 | - `User` → `/users` |
| 50 | - `ProductCategory` → `/product-categories` |
| 51 | - `OrderItem` → `/order-items` |
| 52 | - `auth` stays → `/auth` |
| 53 | |
| 54 | ### 4. Version Prefix (Optional) |
| 55 | If project structure contains a `v1/`, `v2/`, `api/` folder — prefix routes accordingly (e.g., `/api/v1/users`). Otherwise use bare paths. |
| 56 | |
| 57 | ### 5. Nested Resources |
| 58 | If two related files exist (e.g., `commentController` alongside `postController`), infer nested routes: |
| 59 | - `GET /posts/:id/comments` |
| 60 | - `POST /posts/:id/comments` |
| 61 | |
| 62 | --- |
| 63 | |
| 64 | ## Output Format |
| 65 | |
| 66 | Output a clean, unstyled list. No headers, no bold, no code blocks unless the user asks. Just: |
| 67 | |
| 68 | ``` |
| 69 | METHOD /path/to/endpoint — One sentence explaining what it does. |
| 70 | ``` |
| 71 | |
| 72 | Group by resource. Separate groups with a blank line. Keep descriptions under 12 words. |
| 73 | |
| 74 | ### Example Output |
| 75 | |
| 76 | Given files: `userController.js`, `productRouter.js`, `authService.js`, `orderModel.js` |
| 77 | |
| 78 | --- |
| 79 | |
| 80 | GET /users — Retrieve a list of all users. |
| 81 | GET /users/:id — Fetch a single user by ID. |
| 82 | POST /users — Create a new user. |
| 83 | PUT /users/:id — Update an existing user's details. |
| 84 | DELETE /users/:id — Remove a user by ID. |
| 85 | |
| 86 | GET /products — List all available products. |
| 87 | GET /products/:id — Get details of a specific product. |
| 88 | POST /products — Add a new product. |
| 89 | PUT /products/:id — Update a product's information. |
| 90 | DELETE /products/:id — Delete a product. |
| 91 | |
| 92 | POST /auth/register — Register a new account. |
| 93 | POST /auth/login — Authenticate and receive a token. |
| 94 | POST /auth/logout — Invalidate the current session. |
| 95 | POST /auth/refresh — Refresh an expired access token. |
| 96 | |
| 97 | GET /orders — List all orders. |
| 98 | GET /orders/:id — Retrieve a specific order. |
| 99 | POST /orders — Place a new order. |
| 100 | |
| 101 | --- |
| 102 | |
| 103 | ## Edge Cases |
| 104 | |
| 105 | - **Unknown/ambiguous file names** (e.g., `utils.js`, `index.ts`): Skip unless context makes the resource clear. |
| 106 | - **Multiple files for same resource** (e.g., `userController.js` + `userRouter.js`): Deduplicate — list each endpoint only once. |
| 107 | - **Non-REST files** (e.g., `app.js`, `server.py`, `main.go`, `config.json`) |