bamboohr-performance-tuning
Optimize BambooHR API performance with caching, batch reports, incremental sync, and connection pooling. Use when experiencing slow API responses, implementing caching, or optimizing sync throughput. Trigger with phrases like "bamboohr performance", "optimize bamboohr", "bamboohr latency", "bamboohr caching", "bamboohr slow", "bamboohr batch".
What this skill does
# BambooHR Performance Tuning
## Overview
Optimize BambooHR API performance through request reduction, caching, incremental sync, and connection pooling. The biggest wins come from eliminating N+1 query patterns using custom reports and the changed-since endpoint.
## Prerequisites
- BambooHR API client configured
- Redis or in-memory cache available (optional)
- Performance monitoring in place
## Instructions
### Step 1: Eliminate N+1 Queries with Custom Reports
The single biggest performance improvement: use `POST /reports/custom` instead of individual employee GETs.
```typescript
// BAD: 501 API calls for 500 employees
const dir = await client.getDirectory(); // 1 call
for (const emp of dir.employees) {
await client.getEmployee(emp.id, ['salary', 'hireDate']); // 500 calls
}
// GOOD: 1 API call for all employees with all needed fields
const report = await client.customReport([
'firstName', 'lastName', 'department', 'jobTitle',
'hireDate', 'workEmail', 'status', 'location',
'supervisor', 'employeeNumber',
]);
// 1 call, returns all employees with all fields
```
**Performance impact:** 500x reduction in API calls. Custom reports return all active employees in one request.
### Step 2: Incremental Sync with Changed-Since
```typescript
import { readFileSync, writeFileSync } from 'fs';
const LAST_SYNC_FILE = '.bamboohr-last-sync';
async function incrementalSync(client: BambooHRClient): Promise<string[]> {
// Read last sync timestamp
let lastSync: string;
try {
lastSync = readFileSync(LAST_SYNC_FILE, 'utf-8').trim();
} catch {
lastSync = new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString(); // Default: 24h ago
}
// GET /employees/changed/?since=... — returns only changed employee IDs
const changed = await client.request<{
employees: Record<string, { id: string; lastChanged: string }>;
}>('GET', `/employees/changed/?since=${lastSync}`);
const changedIds = Object.keys(changed.employees || {});
console.log(`${changedIds.length} employees changed since ${lastSync}`);
if (changedIds.length === 0) return [];
// Fetch only changed employees' details
// For large sets, use custom report with filter; for small sets, individual GETs
if (changedIds.length > 20) {
// Bulk: use custom report (returns all, then filter client-side)
const report = await client.customReport([
'firstName', 'lastName', 'department', 'status',
]);
const changedData = report.employees.filter(e =>
changedIds.includes(e.id?.toString()),
);
// Process changedData...
} else {
// Small set: individual GETs are fine
for (const id of changedIds) {
const emp = await client.getEmployee(id, ['firstName', 'lastName', 'department', 'status']);
// Process emp...
}
}
// Save sync timestamp
writeFileSync(LAST_SYNC_FILE, new Date().toISOString());
return changedIds;
}
```
**Also available for table data:**
```typescript
// GET /employees/changed/tables/{tableName}?since=...
const changedJobs = await client.request<any>(
'GET', `/employees/changed/tables/jobInfo?since=${lastSync}`,
);
// Returns { employees: { "123": { lastChanged: "..." }, ... } }
```
### Step 3: Response Caching
```typescript
import { LRUCache } from 'lru-cache';
// BambooHR directory data changes infrequently — cache aggressively
const cache = new LRUCache<string, any>({
max: 500,
ttl: 5 * 60 * 1000, // 5 minutes for directory data
});
async function cachedRequest<T>(
key: string,
fetcher: () => Promise<T>,
ttlMs?: number,
): Promise<T> {
const cached = cache.get(key) as T | undefined;
if (cached) {
console.log(`Cache hit: ${key}`);
return cached;
}
const result = await fetcher();
cache.set(key, result, { ttl: ttlMs });
return result;
}
// Usage
const directory = await cachedRequest(
'directory',
() => client.getDirectory(),
5 * 60 * 1000, // Cache for 5 min
);
// Single employee — shorter cache
const employee = await cachedRequest(
`employee:${id}`,
() => client.getEmployee(id, fields),
60 * 1000, // Cache for 1 min
);
```
**Redis caching for multi-instance deployments:**
```typescript
import Redis from 'ioredis';
const redis = new Redis(process.env.REDIS_URL);
async function redisCached<T>(
key: string,
fetcher: () => Promise<T>,
ttlSec = 300,
): Promise<T> {
const cached = await redis.get(`bamboohr:${key}`);
if (cached) return JSON.parse(cached);
const result = await fetcher();
await redis.setex(`bamboohr:${key}`, ttlSec, JSON.stringify(result));
return result;
}
// Invalidate on webhook
async function invalidateCache(employeeId: string) {
await redis.del(`bamboohr:employee:${employeeId}`);
await redis.del('bamboohr:directory'); // Directory includes this employee
}
```
### Step 4: Connection Pooling
```typescript
import { Agent } from 'https';
// Reuse TCP connections for BambooHR API calls
const keepAliveAgent = new Agent({
keepAlive: true,
maxSockets: 5, // Max 5 parallel connections
maxFreeSockets: 2,
timeout: 30_000,
keepAliveMsecs: 10_000,
});
// Pass to fetch via undici or node-fetch
// For native fetch in Node 20+, connection pooling is automatic
```
### Step 5: Request Batching with DataLoader
```typescript
import DataLoader from 'dataloader';
// Batch individual employee GETs into a custom report
const employeeLoader = new DataLoader<string, Record<string, string>>(
async (ids) => {
// One custom report instead of N individual GETs
const report = await client.customReport([
'id', 'firstName', 'lastName', 'department', 'jobTitle',
]);
const byId = new Map(report.employees.map(e => [e.id, e]));
return ids.map(id => byId.get(id) || new Error(`Employee ${id} not found`));
},
{
maxBatchSize: 100,
batchScheduleFn: cb => setTimeout(cb, 50), // Batch window: 50ms
cache: true,
},
);
// Usage — automatically batched into one API call
const [emp1, emp2, emp3] = await Promise.all([
employeeLoader.load('1'),
employeeLoader.load('2'),
employeeLoader.load('3'),
]);
```
### Step 6: Performance Monitoring
```typescript
class BambooHRMetrics {
private requests: { duration: number; status: number; endpoint: string }[] = [];
record(endpoint: string, status: number, durationMs: number) {
this.requests.push({ duration: durationMs, status, endpoint });
// Keep last 1000 requests
if (this.requests.length > 1000) this.requests.shift();
}
summary() {
const durations = this.requests.map(r => r.duration).sort((a, b) => a - b);
const errors = this.requests.filter(r => r.status >= 400);
return {
totalRequests: this.requests.length,
errorRate: (errors.length / Math.max(this.requests.length, 1) * 100).toFixed(1) + '%',
p50: durations[Math.floor(durations.length * 0.5)] || 0,
p95: durations[Math.floor(durations.length * 0.95)] || 0,
p99: durations[Math.floor(durations.length * 0.99)] || 0,
topEndpoints: this.topEndpoints(),
};
}
private topEndpoints() {
const counts = new Map<string, number>();
for (const r of this.requests) {
counts.set(r.endpoint, (counts.get(r.endpoint) || 0) + 1);
}
return [...counts.entries()].sort((a, b) => b[1] - a[1]).slice(0, 5);
}
}
```
## Output
- N+1 queries eliminated via custom reports (500x reduction)
- Incremental sync using changed-since endpoint
- Multi-tier caching (LRU in-memory + Redis)
- Connection pooling with keep-alive
- DataLoader-based request batching
- Performance metrics with p50/p95/p99
## Performance Reference
| Optimization | Before | After | Improvement |
|-------------|--------|-------|-------------|
| Custom reports vs N+1 | 501 calls | 1 call | 500x |
| Incremental sync | Full pull | Delta only | 10-100x |
| Directory caching (5 min) | Every request | 1/5 min | 50x |
| Connection pooling | New conn/request | Reused | 2-3x latency |
## Error Handling
| Issue | Cause | Solution |
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.