/flexport-pack:flexport-performance-tuningfrom flexport-pack
Optimizes Flexport API performance with pagination, caching, parallel requests, and connection pooling. Triggered by 'flexport performance', 'flexport slow API'.
Ships in flexport-pack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Optimize Flexport API integration performance. The API is rate-limited and serves logistics data that changes infrequently (shipments update hourly, products rarely). Cache aggressively for reads, batch writes, and use maximum page sizes.
// Default per=25. Use per=100 (max) to reduce API calls by 4x
async function fetchAllShipments(): Promise<Shipment[]> {
const all: Shipment[] = [];
let page = 1;
while (true) {
const res = await flexport(`/shipments?per=100&page=${page}`);
all.push(...res.data.records);
if (res.data.records.length < 100) break;
page++;
}
return all;
// 1000 shipments = 10 API calls instead of 40
}
import { LRUCache } from 'lru-cache';
const cache = new LRUCache<string, any>({
max: 500,
ttl: 5 * 60 * 1000, // 5 min for shipment data
});
// Products change rarely — cache longer
const productCache = new LRUCache<string, any>({
max: 1000,
ttl: 60 * 60 * 1000, // 1 hour
});
async function cachedFlexport(path: string, ttlCache = cache): Promise<any> {
const cached = ttlCache.get(path);
if (cached) return cached;
const data = await flexport(path);
ttlCache.set(path, data);
return data;
}
import PQueue from 'p-queue';
const queue = new PQueue({ concurrency: 5, interval: 1000, intervalCap: 10 });
// Fetch details for multiple shipments in parallel
async function enrichShipments(ids: string[]) {
return Promise.all(
ids.map(id => queue.add(() => flexport(`/shipments/${id}`)))
);
}
// Instead of polling, invalidate cache on webhook events
async function handleWebhook(event: any) {
if (event.type.startsWith('shipment.')) {
cache.delete(`/shipments/${event.data.shipment_id}`);
cache.delete('/shipments'); // Invalidate list cache
}
if (event.type.startsWith('product.')) {
productCache.delete(`/products/${event.data.product_id}`);
}
}
| Metric | Target | Strategy |
|---|---|---|
| Shipment list load | < 500ms | Cache with 5min TTL |
| Product lookup | < 100ms | Cache with 1hr TTL |
| Bulk shipment fetch | < 3s for 100 | Parallel with p-queue |
| Dashboard refresh | < 2s | Stale-while-revalidate |
For cost optimization, see flexport-cost-tuning.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
flexport, api-performance, caching, parallel-requests, pagination
npx claudepluginhub flight505/skill-forge --plugin flexport-pack24 skills in this plugin
/flexport-ci-integrationConfigure CI/CD pipelines for Flexport logistics integrations with GitHub Actions,
automated API contract testing, and deployment workflows.
Trigger: "flexport CI", "flexport GitHub Actions", "flexport CI/CD pipeline".
/flexport-common-errorsDiagnose and fix common Flexport API errors including HTTP status codes,
webhook failures, and data validation issues.
Trigger: "flexport error", "fix flexport", "flexport not working", "debug flexport API".
/flexport-core-workflow-aExecute Flexport primary workflow: shipment booking and purchase order management.
Use when creating bookings, managing purchase orders, tracking freight,
or building the core shipment lifecycle integration.
Trigger: "flexport booking", "flexport purchase order", "create flexport shipment".
/flexport-core-workflow-bExecute Flexport secondary workflow: commercial invoices, products catalog, and freight invoices.
Use when managing commercial invoices for customs, maintaining product catalogs,
or handling freight billing through the Flexport API.
Trigger: "flexport invoice", "flexport products", "flexport customs documents".
/flexport-cost-tuningOptimize Flexport API usage costs through efficient pagination, caching,
webhook-driven updates, and monitoring API call volume.
Trigger: "flexport costs", "flexport API usage", "reduce flexport calls", "flexport billing".
/flexport-data-handlingImplement data handling for Flexport supply chain data including PII redaction,
shipment data retention, GDPR compliance, and secure document management.
Trigger: "flexport data handling", "flexport PII", "flexport GDPR", "flexport data retention".
Other plugins' skills for the same job