Skip to main content 홈 크리에이터 jeremylongshore tons-of-skills-marketplace maintainx-cost-tuning
maintainx-cost-tuning Optimize MaintainX API usage for cost efficiency.
Use when managing API costs, optimizing request volume,
or implementing cost-effective integration patterns with MaintainX.
Trigger with phrases like "maintainx cost", "maintainx billing",
"reduce maintainx usage", "maintainx api costs", "maintainx optimization".
설치로 이동 Skills Marketplace 커뮤니티가 만든 AI 스킬을 발견하고 탐색하세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/jeremylongshore/tons-of-skills-marketplace --skill maintainx-cost-tuning명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
Zip 다운로드 다운로드 중... 이 저장소의 다른 Skills langchain-deploy-integration Deploy a LangChain 1.0 / LangGraph 1.0 app to Cloud Run, Vercel, or LangServe correctly — with timeouts sized for chain length, cold-start mitigation, SSE anti-buffering headers, and Secret Manager over .env. Use when prepping a first production deploy, debugging a stream that hangs behind a proxy, or diagnosing p99 latency spikes. Trigger with "langchain deploy", "langchain cloud run", "langchain vercel python", "langchain langserve", or "langchain docker".
langchain-langgraph-agents Build a correct LangGraph 1.0 ReAct agent with create_react_agent — typed tools, error propagation, recursion caps, and stop conditions that actually stop. Use when writing a first tool-calling agent, migrating from AgentExecutor or initialize_agent, or diagnosing an agent that loops on vague prompts. Trigger with "langgraph agent", "create_react_agent", "langgraph tool calling", "AgentExecutor migration", or "agent loop cost".
langchain-langgraph-human-in-loop Build LangGraph 1.0 human-in-the-loop approval flows with interrupt_before /
interrupt_after and Command(resume=...) — JSON-serializable state, clean
resume semantics, and UI wiring for approval decisions. Use when adding an
approval gate before an expensive tool call, wiring a Slack/web UI for agent
approvals, or debugging a graph that crashes on interrupt.
Trigger with "langgraph human in loop", "langgraph interrupt_before",
"langgraph approval flow", "Command resume", "langgraph HITL".
jeremylongshore
jeremylongshore/tons-of-skills-marketplace
GitHub 저장소 열기 name maintainx-cost-tuning description Optimize MaintainX API usage for cost efficiency.
Use when managing API costs, optimizing request volume,
or implementing cost-effective integration patterns with MaintainX.
Trigger with phrases like "maintainx cost", "maintainx billing",
"reduce maintainx usage", "maintainx api costs", "maintainx optimization".
allowed-tools Read, Write, Edit, Bash(npm:*) version 1.11.0 license MIT author Jeremy Longshore <jeremy@intentsolutions.io> tags ["saas","maintainx","api","cost-optimization"] compatibility Designed for Claude Code
MaintainX Cost Tuning
Overview
Reduce MaintainX API request volume and optimize costs through caching, webhook-driven sync, request batching, and smart polling strategies.
Prerequisites
MaintainX integration deployed and working
Redis or in-memory cache available
Baseline API usage metrics
Instructions
Step 1: Request Volume Tracking
class ApiUsageTracker {
private counts : Map <string , number > = new Map ();
private startTime = Date .now ();
record (endpoint : string ) {
const key = endpoint.split ('?' )[0 ];
this .counts .set (key, (this .counts .get (key) || 0 ) + 1 );
}
report ( ) {
const elapsed = (Date .now () - this .startTime ) / 1000 / 60 ;
console .log (`\n=== API Usage Report (${elapsed.toFixed( )} min) ===` );
sorted = [... . . ()]. ( b[ ] - a[ ]);
( [endpoint, count] sorted) {
rate = (count / elapsed). ( );
. ( );
}
. ( );
}
}
tracker = ();
( tracker. (), );
1
const
this
counts
entries
sort
(a, b ) =>
1
1
for
const
of
const
toFixed
1
console
log
` ${endpoint} : ${count} calls (${rate} /min)`
console
log
` TOTAL: ${[...this .counts.values()].reduce((a, b) => a + b, 0 )} calls`
export
const
new
ApiUsageTracker
setInterval
() =>
report
600_000
Step 2: Response Caching
interface CacheEntry <T> {
data : T;
expiresAt : number ;
}
class CachedMaintainXClient {
private cache = new Map <string , CacheEntry <any >>();
private client : MaintainXClient ;
private ttl : Record <string , number > = {
'/users' : 300 ,
'/locations' : 300 ,
'/assets' : 120 ,
'/workorders' : 30 ,
'/teams' : 600 ,
};
constructor (client : MaintainXClient ) {
this .client = client;
}
async get<T>(endpoint : string , params ?: any ): Promise <T> {
const cacheKey = `${endpoint} :${JSON .stringify(params || {})} ` ;
const cached = this .cache .get (cacheKey);
if (cached && cached.expiresAt > Date .now ()) {
console .log (`[CACHE HIT] ${endpoint} ` );
return cached.data ;
}
const basePath = '/' + endpoint.split ('/' ).filter (Boolean )[0 ];
const ttlSec = this .ttl [basePath] || 60 ;
const data = await this .client .request ('GET' , endpoint, undefined , params);
this .cache .set (cacheKey, {
data,
expiresAt : Date .now () + ttlSec * 1000 ,
});
tracker.record (endpoint);
return data as T;
}
invalidate (pattern : string ) {
for (const key of this .cache .keys ()) {
if (key.startsWith (pattern)) {
this .cache .delete (key);
}
}
}
}
Step 3: Webhook-Driven Sync (Replace Polling) Polling every 30 seconds costs thousands of requests/day per endpoint. Webhooks reduce this to near zero.
setInterval (async () => {
const { workOrders } = await client.getWorkOrders ({ status : 'OPEN' });
await syncToLocalDb (workOrders);
}, 30_000 );
app.post ('/webhooks/maintainx' , async (req, res) => {
const { event, data } = req.body ;
if (event === 'workorder.updated' || event === 'workorder.created' ) {
await upsertWorkOrder (data);
}
res.status (200 ).json ({ ok : true });
});
Cost savings : From thousands of daily polling requests to ~50 req/day (webhook-driven deltas only).
Step 4: Smart Polling with Conditional Requests When webhooks are not available, reduce unnecessary fetches:
async function smartPoll (client : MaintainXClient , state : { lastModified?: string } ) {
const response = await client.getWorkOrders ({
updatedAtGte : state.lastModified || new Date (0 ).toISOString (),
limit : 100 ,
});
if (response.workOrders .length === 0 ) {
console .log ('No changes since last poll' );
return [];
}
state.lastModified = new Date ().toISOString ();
return response.workOrders ;
}
Step 5: Request Deduplication
const inFlight = new Map <string , Promise <any >>();
async function deduplicatedGet (client : MaintainXClient , endpoint : string ): Promise <any > {
if (inFlight.has (endpoint)) {
return inFlight.get (endpoint)!;
}
const promise = client.request ('GET' , endpoint);
inFlight.set (endpoint, promise);
try {
return await promise;
} finally {
inFlight.delete (endpoint);
}
}
Output
API usage tracking with per-endpoint request counts
Response caching with resource-specific TTLs
Webhook-driven sync replacing expensive polling loops
Smart polling with updatedAtGte filter for change detection
Request deduplication preventing concurrent identical calls
Error Handling Issue Cause Solution Stale cache data TTL too long for volatile resources Reduce TTL for /workorders to 15-30s Webhook delivery failures Endpoint down or unreachable Fall back to polling with longer interval Cache memory growth No eviction policy Set max cache size, use LRU eviction Duplicate webhook events MaintainX retries Deduplicate by event ID (see webhooks skill)
Resources
Next Steps For architecture patterns, see maintainx-reference-architecture.
Examples Redis-based cache for production :
import Redis from 'ioredis' ;
const redis = new Redis (process.env .REDIS_URL );
async function cachedGet (key : string , ttlSec : number , fetcher : () => Promise <any > ) {
const cached = await redis.get (key);
if (cached) return JSON .parse (cached);
const data = await fetcher ();
await redis.setex (key, ttlSec, JSON .stringify (data));
return data;
}
const workOrders = await cachedGet (
'maintainx:workorders:open' ,
30 ,
() => client.getWorkOrders ({ status : 'OPEN' }),
);