maintainx-performance-tuning

Optimize MaintainX API integration performance. Use when experiencing slow API responses, optimizing data fetching, or improving integration throughput with MaintainX. Trigger with phrases like "maintainx performance", "maintainx slow", "optimize maintainx", "maintainx caching", "maintainx faster".

1,868 stars

Best use case

maintainx-performance-tuning is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Optimize MaintainX API integration performance. Use when experiencing slow API responses, optimizing data fetching, or improving integration throughput with MaintainX. Trigger with phrases like "maintainx performance", "maintainx slow", "optimize maintainx", "maintainx caching", "maintainx faster".

Teams using maintainx-performance-tuning should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/maintainx-performance-tuning/SKILL.md --create-dirs "https://raw.githubusercontent.com/jeremylongshore/claude-code-plugins-plus-skills/main/plugins/saas-packs/maintainx-pack/skills/maintainx-performance-tuning/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/maintainx-performance-tuning/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How maintainx-performance-tuning Compares

Feature / Agentmaintainx-performance-tuningStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Optimize MaintainX API integration performance. Use when experiencing slow API responses, optimizing data fetching, or improving integration throughput with MaintainX. Trigger with phrases like "maintainx performance", "maintainx slow", "optimize maintainx", "maintainx caching", "maintainx faster".

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# MaintainX Performance Tuning

## Overview
Optimize MaintainX integration performance with caching, connection pooling, efficient pagination, and request deduplication.

## Prerequisites
- MaintainX integration working
- Node.js 18+
- Redis (recommended for production caching)
- Performance baseline measurements

## Instructions

### Step 1: Connection Pooling with Keep-Alive

```typescript
// src/performance/pooled-client.ts
import axios from 'axios';
import http from 'node:http';
import https from 'node:https';

// Reuse TCP connections instead of opening new ones per request
const httpAgent = new http.Agent({ keepAlive: true, maxSockets: 10 });
const httpsAgent = new https.Agent({ keepAlive: true, maxSockets: 10 });

const client = axios.create({
  baseURL: 'https://api.getmaintainx.com/v1',
  headers: {
    Authorization: `Bearer ${process.env.MAINTAINX_API_KEY}`,
    'Content-Type': 'application/json',
  },
  httpAgent,
  httpsAgent,
  timeout: 30_000,
});

// Benefit: Eliminates TCP handshake + TLS negotiation per request
// Typical improvement: 100-200ms saved per request
```

### Step 2: Multi-Level Caching

```typescript
// src/performance/cache.ts

interface CacheLayer<T> {
  get(key: string): Promise<T | undefined>;
  set(key: string, value: T, ttlMs: number): Promise<void>;
}

// L1: In-memory (fastest, per-process)
class MemoryCache<T> implements CacheLayer<T> {
  private store = new Map<string, { value: T; expiresAt: number }>();

  async get(key: string) {
    const entry = this.store.get(key);
    if (entry && entry.expiresAt > Date.now()) return entry.value;
    this.store.delete(key);
    return undefined;
  }

  async set(key: string, value: T, ttlMs: number) {
    this.store.set(key, { value, expiresAt: Date.now() + ttlMs });
  }
}

// L2: Redis (shared across processes)
class RedisCache<T> implements CacheLayer<T> {
  constructor(private redis: any) {}

  async get(key: string) {
    const data = await this.redis.get(`mx:${key}`);
    return data ? JSON.parse(data) : undefined;
  }

  async set(key: string, value: T, ttlMs: number) {
    await this.redis.setex(`mx:${key}`, Math.ceil(ttlMs / 1000), JSON.stringify(value));
  }
}

// Multi-level cache: check L1 first, then L2, then fetch
class MultiCache<T> {
  constructor(private l1: CacheLayer<T>, private l2: CacheLayer<T>) {}

  async getOrFetch(key: string, ttlMs: number, fetcher: () => Promise<T>): Promise<T> {
    // Check L1
    let value = await this.l1.get(key);
    if (value !== undefined) return value;

    // Check L2
    value = await this.l2.get(key);
    if (value !== undefined) {
      await this.l1.set(key, value, ttlMs / 2); // L1 shorter TTL
      return value;
    }

    // Fetch from API
    value = await fetcher();
    await this.l1.set(key, value, ttlMs / 2);
    await this.l2.set(key, value, ttlMs);
    return value;
  }
}
```

### Step 3: DataLoader for Batch Loading

When multiple parts of your app need the same work order, batch and deduplicate:

```typescript
// src/performance/dataloader.ts
import DataLoader from 'dataloader';

const workOrderLoader = new DataLoader<number, any>(
  async (ids: readonly number[]) => {
    // Batch: fetch multiple work orders in parallel
    const results = await Promise.all(
      ids.map((id) =>
        client.get(`/workorders/${id}`).then((r) => r.data)
      ),
    );
    // Return in same order as input ids
    return ids.map((id) => results.find((r) => r.id === id) || null);
  },
  {
    maxBatchSize: 25,
    cacheKeyFn: (id) => String(id),
  },
);

// These 3 calls collapse into 1 batched operation:
const [wo1, wo2, wo3] = await Promise.all([
  workOrderLoader.load(100),
  workOrderLoader.load(200),
  workOrderLoader.load(100), // deduped, same as first
]);
```

### Step 4: Efficient Pagination

```typescript
// Fetch only the fields you need (if API supports field selection)
// Use larger page sizes to reduce round trips

async function efficientFetchAll(client: any, endpoint: string, key: string) {
  const all = [];
  let cursor: string | undefined;
  let pageCount = 0;

  const startTime = Date.now();

  do {
    const { data } = await client.get(endpoint, {
      params: { limit: 100, cursor }, // Max page size
    });
    all.push(...data[key]);
    cursor = data.cursor;
    pageCount++;
  } while (cursor);

  const elapsed = Date.now() - startTime;
  console.log(`Fetched ${all.length} items in ${pageCount} pages (${elapsed}ms)`);
  return all;
}

// Parallel pagination for independent resources
async function fetchAllResources(client: any) {
  const [workOrders, assets, locations] = await Promise.all([
    efficientFetchAll(client, '/workorders', 'workOrders'),
    efficientFetchAll(client, '/assets', 'assets'),
    efficientFetchAll(client, '/locations', 'locations'),
  ]);

  return { workOrders, assets, locations };
}
```

### Step 5: Request Deduplication

```typescript
// src/performance/dedup.ts

class RequestDeduplicator {
  private inflight = new Map<string, Promise<any>>();

  async dedupe<T>(key: string, fetcher: () => Promise<T>): Promise<T> {
    if (this.inflight.has(key)) {
      return this.inflight.get(key)! as Promise<T>;
    }

    const promise = fetcher().finally(() => {
      this.inflight.delete(key);
    });

    this.inflight.set(key, promise);
    return promise;
  }
}

const dedup = new RequestDeduplicator();

// 10 concurrent calls to getWorkOrder(123) = 1 actual API call
async function getWorkOrder(id: number) {
  return dedup.dedupe(`wo:${id}`, () => client.get(`/workorders/${id}`));
}
```

## Performance Benchmarks

| Optimization | Before | After | Improvement |
|-------------|--------|-------|-------------|
| Connection pooling | 350ms/req | 150ms/req | 57% faster |
| L1 cache (hot path) | 150ms/req | < 1ms/req | 99% faster |
| DataLoader batching | 10 calls | 1 call | 90% fewer requests |
| Max page size (100) | 50 pages | 10 pages | 5x fewer round trips |
| Request dedup | N calls | 1 call | (N-1) saved |

## Output
- Connection pooling with keep-alive (reuses TCP connections)
- Multi-level cache (L1 in-memory + L2 Redis)
- DataLoader for batching and deduplication of entity fetches
- Efficient pagination with max page sizes
- Request deduplication preventing redundant concurrent calls

## Error Handling
| Issue | Cause | Solution |
|-------|-------|----------|
| Stale cache data | TTL too long | Reduce TTL, invalidate on writes |
| Memory growth | Unbounded cache | Set max size, use LRU eviction |
| DataLoader errors | One item in batch fails | Handle per-item errors in batch function |
| Connection pool exhaustion | Too many concurrent requests | Increase `maxSockets` or add queue |

## Resources
- [MaintainX API Reference](https://developer.maintainx.com/reference)
- [DataLoader](https://github.com/graphql/dataloader) -- Batching and caching utility
- [Node.js HTTP Agent](https://nodejs.org/api/http.html#class-httpagent)

## Next Steps
For cost optimization, see `maintainx-cost-tuning`.

## Examples

**Benchmark your API response times**:

```bash
# Measure latency for 10 sequential requests
for i in $(seq 1 10); do
  curl -s -o /dev/null -w "Request $i: %{time_total}s\n" \
    "https://api.getmaintainx.com/v1/workorders?limit=1" \
    -H "Authorization: Bearer $MAINTAINX_API_KEY"
done
```

Related Skills

running-performance-tests

1868
from jeremylongshore/claude-code-plugins-plus-skills

Execute load testing, stress testing, and performance benchmarking. Use when performing specialized testing. Trigger with phrases like "run load tests", "test performance", or "benchmark the system".

workhuman-performance-tuning

1868
from jeremylongshore/claude-code-plugins-plus-skills

Workhuman performance tuning for employee recognition and rewards API. Use when integrating Workhuman Social Recognition, or building recognition workflows with HRIS systems. Trigger: "workhuman performance tuning".

workhuman-cost-tuning

1868
from jeremylongshore/claude-code-plugins-plus-skills

Workhuman cost tuning for employee recognition and rewards API. Use when integrating Workhuman Social Recognition, or building recognition workflows with HRIS systems. Trigger: "workhuman cost tuning".

wispr-performance-tuning

1868
from jeremylongshore/claude-code-plugins-plus-skills

Wispr Flow performance tuning for voice-to-text API integration. Use when integrating Wispr Flow dictation, WebSocket streaming, or building voice-powered applications. Trigger: "wispr performance tuning".

wispr-cost-tuning

1868
from jeremylongshore/claude-code-plugins-plus-skills

Wispr Flow cost tuning for voice-to-text API integration. Use when integrating Wispr Flow dictation, WebSocket streaming, or building voice-powered applications. Trigger: "wispr cost tuning".

windsurf-performance-tuning

1868
from jeremylongshore/claude-code-plugins-plus-skills

Optimize Windsurf IDE performance: indexing speed, Cascade responsiveness, and memory usage. Use when Windsurf is slow, indexing takes too long, Cascade times out, or the IDE uses too much memory. Trigger with phrases like "windsurf slow", "windsurf performance", "optimize windsurf", "windsurf memory", "cascade slow", "indexing slow".

windsurf-cost-tuning

1868
from jeremylongshore/claude-code-plugins-plus-skills

Optimize Windsurf licensing costs through seat management, tier selection, and credit monitoring. Use when analyzing Windsurf billing, reducing per-seat costs, or implementing usage monitoring and budget controls. Trigger with phrases like "windsurf cost", "windsurf billing", "reduce windsurf costs", "windsurf pricing", "windsurf budget".

webflow-performance-tuning

1868
from jeremylongshore/claude-code-plugins-plus-skills

Optimize Webflow API performance with response caching, bulk endpoint batching, CDN-cached live item reads, pagination optimization, and connection pooling. Use when experiencing slow API responses or optimizing request throughput. Trigger with phrases like "webflow performance", "optimize webflow", "webflow latency", "webflow caching", "webflow slow", "webflow batch".

webflow-cost-tuning

1868
from jeremylongshore/claude-code-plugins-plus-skills

Optimize Webflow costs through plan selection, CDN read optimization, bulk endpoint usage, and API usage monitoring with budget alerts. Use when analyzing Webflow billing, reducing API costs, or implementing usage monitoring for Webflow integrations. Trigger with phrases like "webflow cost", "webflow billing", "reduce webflow costs", "webflow pricing", "webflow budget".

vercel-performance-tuning

1868
from jeremylongshore/claude-code-plugins-plus-skills

Optimize Vercel deployment performance with caching, bundle optimization, and cold start reduction. Use when experiencing slow page loads, optimizing Core Web Vitals, or reducing serverless function cold start times. Trigger with phrases like "vercel performance", "optimize vercel", "vercel latency", "vercel caching", "vercel slow", "vercel cold start".

vercel-cost-tuning

1868
from jeremylongshore/claude-code-plugins-plus-skills

Optimize Vercel costs through plan selection, function efficiency, and usage monitoring. Use when analyzing Vercel billing, reducing function execution costs, or implementing spend management and budget alerts. Trigger with phrases like "vercel cost", "vercel billing", "reduce vercel costs", "vercel pricing", "vercel expensive", "vercel budget".

veeva-performance-tuning

1868
from jeremylongshore/claude-code-plugins-plus-skills

Veeva Vault performance tuning for REST API and clinical operations. Use when working with Veeva Vault document management and CRM. Trigger: "veeva performance tuning".