insomnia-collection-generator
Generates Insomnia collection export files from Express, Next.js, Fastify, or other API routes. Creates organized workspaces with request groups, environments, and authentication. Use when users request "generate insomnia collection", "export to insomnia", "create insomnia workspace", or "insomnia import".
What this skill does
# Insomnia Collection Generator
Generate importable Insomnia workspaces from your API codebase automatically.
## Core Workflow
1. **Scan routes**: Find all API route definitions
2. **Extract metadata**: Methods, paths, params, bodies
3. **Create workspace**: Organize into request groups
4. **Configure environments**: Base URLs, auth tokens
5. **Add authentication**: Bearer, Basic, API Key
6. **Export collection**: Insomnia v4 JSON format
## Insomnia Export v4 Schema
```json
{
"_type": "export",
"__export_format": 4,
"__export_date": "2024-01-15T10:30:00.000Z",
"__export_source": "insomnia.desktop.app:v2023.5.8",
"resources": []
}
```
## Resource Types
```typescript
interface InsomniaWorkspace {
_id: string;
_type: "workspace";
name: string;
description: string;
scope: "collection" | "design";
}
interface InsomniaRequestGroup {
_id: string;
_type: "request_group";
name: string;
parentId: string;
description?: string;
}
interface InsomniaRequest {
_id: string;
_type: "request";
name: string;
parentId: string;
method: string;
url: string;
body: InsomniaBody;
headers: InsomniaHeader[];
parameters: InsomniaParameter[];
authentication: InsomniaAuth;
}
interface InsomniaEnvironment {
_id: string;
_type: "environment";
name: string;
parentId: string;
data: Record<string, string>;
}
```
## Collection Generator
```typescript
// scripts/generate-insomnia.ts
import { v4 as uuidv4 } from "uuid";
interface RouteInfo {
method: string;
path: string;
name: string;
body?: object;
params?: { name: string; type: "path" | "query" }[];
}
interface InsomniaExport {
_type: "export";
__export_format: 4;
__export_date: string;
__export_source: string;
resources: InsomniaResource[];
}
type InsomniaResource =
| InsomniaWorkspace
| InsomniaRequestGroup
| InsomniaRequest
| InsomniaEnvironment;
function generateInsomniaCollection(
routes: RouteInfo[],
options: {
name: string;
baseUrl: string;
description?: string;
}
): InsomniaExport {
const workspaceId = `wrk_${uuidv4().replace(/-/g, "")}`;
const baseEnvId = `env_${uuidv4().replace(/-/g, "")}`;
const devEnvId = `env_${uuidv4().replace(/-/g, "")}`;
const resources: InsomniaResource[] = [];
// Create workspace
resources.push({
_id: workspaceId,
_type: "workspace",
name: options.name,
description: options.description || "Auto-generated API collection",
scope: "collection",
});
// Create base environment
resources.push({
_id: baseEnvId,
_type: "environment",
name: "Base Environment",
parentId: workspaceId,
data: {},
});
// Create development environment
resources.push({
_id: devEnvId,
_type: "environment",
name: "Development",
parentId: baseEnvId,
data: {
base_url: options.baseUrl,
auth_token: "",
},
});
// Group routes by resource
const groupedRoutes = groupRoutesByResource(routes);
for (const [resource, resourceRoutes] of Object.entries(groupedRoutes)) {
// Create request group (folder)
const groupId = `fld_${uuidv4().replace(/-/g, "")}`;
resources.push({
_id: groupId,
_type: "request_group",
name: capitalize(resource),
parentId: workspaceId,
description: `${resource} endpoints`,
});
// Create requests in group
for (const route of resourceRoutes) {
resources.push(createInsomniaRequest(route, groupId));
}
}
return {
_type: "export",
__export_format: 4,
__export_date: new Date().toISOString(),
__export_source: "api-generator:v1.0.0",
resources,
};
}
function createInsomniaRequest(
route: RouteInfo,
parentId: string
): InsomniaRequest {
const requestId = `req_${uuidv4().replace(/-/g, "")}`;
// Convert :param to {{ _.param }} for Insomnia
const url = route.path.replace(/:(\w+)/g, "{{ _.$1 }}");
const request: InsomniaRequest = {
_id: requestId,
_type: "request",
name: route.name,
parentId,
method: route.method,
url: `{{ _.base_url }}${url}`,
body: {
mimeType: "application/json",
text: route.body ? JSON.stringify(route.body, null, 2) : "",
},
headers: [
{
name: "Content-Type",
value: "application/json",
},
],
parameters: route.params
?.filter((p) => p.type === "query")
.map((p) => ({
name: p.name,
value: "",
disabled: false,
})) || [],
authentication: {
type: "bearer",
token: "{{ _.auth_token }}",
disabled: true,
},
};
return request;
}
function groupRoutesByResource(
routes: RouteInfo[]
): Record<string, RouteInfo[]> {
const groups: Record<string, RouteInfo[]> = {};
for (const route of routes) {
const parts = route.path.split("/").filter(Boolean);
const resource = parts[0] || "root";
if (!groups[resource]) {
groups[resource] = [];
}
groups[resource].push(route);
}
return groups;
}
function capitalize(str: string): string {
return str.charAt(0).toUpperCase() + str.slice(1);
}
```
## Complete Export Example
```json
{
"_type": "export",
"__export_format": 4,
"__export_date": "2024-01-15T10:30:00.000Z",
"__export_source": "api-generator:v1.0.0",
"resources": [
{
"_id": "wrk_abc123",
"_type": "workspace",
"name": "My API",
"description": "Auto-generated API collection",
"scope": "collection"
},
{
"_id": "env_base123",
"_type": "environment",
"name": "Base Environment",
"parentId": "wrk_abc123",
"data": {}
},
{
"_id": "env_dev123",
"_type": "environment",
"name": "Development",
"parentId": "env_base123",
"data": {
"base_url": "http://localhost:3000/api",
"auth_token": ""
}
},
{
"_id": "env_prod123",
"_type": "environment",
"name": "Production",
"parentId": "env_base123",
"data": {
"base_url": "https://api.example.com",
"auth_token": ""
}
},
{
"_id": "fld_users123",
"_type": "request_group",
"name": "Users",
"parentId": "wrk_abc123"
},
{
"_id": "req_getusers",
"_type": "request",
"name": "Get All Users",
"parentId": "fld_users123",
"method": "GET",
"url": "{{ _.base_url }}/users",
"body": {},
"headers": [
{ "name": "Content-Type", "value": "application/json" }
],
"parameters": [
{ "name": "page", "value": "1", "disabled": false },
{ "name": "limit", "value": "10", "disabled": false }
],
"authentication": {
"type": "bearer",
"token": "{{ _.auth_token }}"
}
},
{
"_id": "req_getuser",
"_type": "request",
"name": "Get User by ID",
"parentId": "fld_users123",
"method": "GET",
"url": "{{ _.base_url }}/users/{{ _.user_id }}",
"body": {},
"headers": [],
"authentication": {}
},
{
"_id": "req_createuser",
"_type": "request",
"name": "Create User",
"parentId": "fld_users123",
"method": "POST",
"url": "{{ _.base_url }}/users",
"body": {
"mimeType": "application/json",
"text": "{\n \"name\": \"John Doe\",\n \"email\": \"[email protected]\"\n}"
},
"headers": [
{ "name": "Content-Type", "value": "application/json" }
],
"authentication": {
"type": "bearer",
"token": "{{ _.auth_token }}"
}
}
]
}
```
## Authentication Types
```typescript
// Bearer Token
{
"type": "bearer",
"token": "{{ _.auth_token }}",
"prefix": "Bearer"
}
// Basic Auth
{
"type": "basic",
"username": "{{ _.username }}",
"password": "{{ _.password }}"
}
// API Key
{
"type": "apikey",
"key": "X-API-Key",
"value": "{{ _.api_key }}",
"addTo": "header"
}
// OAuth 2.0
{
"type": "oauth2",
"granRelated in Web Dev
generating-lwc-components
IncludedLightning Web Components with PICKLES methodology and 165-point scoring. Use this skill when the user creates or edits LWC components, builds wire service patterns, or writes Jest tests for LWC. TRIGGER when: user creates/edits LWC components, touches lwc/**/*.js, .html, .css, .js-meta.xml files, or asks about wire service, SLDS, or Jest LWC tests. DO NOT TRIGGER when: Apex classes (use generating-apex), Aura components, or Visualforce.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Set up queries with useQuery, mutations with useMutation, configure QueryClient caching strategies, implement optimistic updates, and handle infinite scroll with useInfiniteQuery. Use when: setting up data fetching in React projects, migrating from v4 to v5, or fixing object syntax required errors, query callbacks removed issues, cacheTime renamed to gcTime, isPending vs isLoading confusion, keepPreviousData removed problems.
document-processor-api
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
nutrient-document-processing
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Covers useMutationState, simplified optimistic updates, throwOnError, network mode (offline/PWA), and infiniteQueryOptions. Use when setting up data fetching, fixing v4→v5 migration errors (object syntax, gcTime, isPending, keepPreviousData), or debugging SSR/hydration issues with streaming server components.
accelint-nextjs-best-practices
IncludedNext.js performance optimization and best practices. Use when writing Next.js code (App Router or Pages Router); implementing Server Components, Server Actions, or API routes; optimizing RSC serialization, data fetching, or server-side rendering; reviewing Next.js code for performance issues; fixing authentication in Server Actions; or implementing Suspense boundaries, parallel data fetching, or request deduplication.