linear-rate-limits
Handle Linear API rate limiting, complexity budgets, and quotas. Use when dealing with 429 errors, implementing throttling, or optimizing request patterns to stay within limits. Trigger: "linear rate limit", "linear throttling", "linear 429", "linear API quota", "linear complexity", "linear request limits".
What this skill does
# Linear Rate Limits
## Overview
Linear uses the **leaky bucket algorithm** with two rate limiting dimensions. Understanding both is critical for reliable integrations:
| Budget | Limit | Refill Rate |
|--------|-------|-------------|
| **Requests** | 5,000/hour per API key | ~83/min constant refill |
| **Complexity** | 250,000 points/hour | ~4,167/min constant refill |
| **Max single query** | 10,000 points | Hard reject if exceeded |
**Complexity scoring:** Each property = 0.1 pt, each object = 1 pt, connections multiply children by `first` arg (default 50), then round up.
## Prerequisites
- `@linear/sdk` installed
- Understanding of HTTP response headers
- Familiarity with async/await patterns
## Instructions
### Step 1: Read Rate Limit Headers
Linear returns rate limit info on every response.
```typescript
const response = await fetch("https://api.linear.app/graphql", {
method: "POST",
headers: {
Authorization: process.env.LINEAR_API_KEY!,
"Content-Type": "application/json",
},
body: JSON.stringify({ query: "{ viewer { id } }" }),
});
// Key headers
const headers = {
requestsRemaining: response.headers.get("x-ratelimit-requests-remaining"),
requestsLimit: response.headers.get("x-ratelimit-requests-limit"),
requestsReset: response.headers.get("x-ratelimit-requests-reset"),
complexityRemaining: response.headers.get("x-ratelimit-complexity-remaining"),
complexityLimit: response.headers.get("x-ratelimit-complexity-limit"),
queryComplexity: response.headers.get("x-complexity"),
};
console.log(`Requests: ${headers.requestsRemaining}/${headers.requestsLimit}`);
console.log(`Complexity: ${headers.complexityRemaining}/${headers.complexityLimit}`);
console.log(`This query cost: ${headers.queryComplexity} points`);
```
### Step 2: Exponential Backoff with Jitter
```typescript
import { LinearClient } from "@linear/sdk";
class RateLimitedClient {
private client: LinearClient;
constructor(apiKey: string) {
this.client = new LinearClient({ apiKey });
}
async withRetry<T>(fn: () => Promise<T>, maxRetries = 5): Promise<T> {
for (let attempt = 0; attempt < maxRetries; attempt++) {
try {
return await fn();
} catch (error: any) {
const isRateLimited = error.status === 429 ||
error.message?.includes("rate") ||
error.type === "ratelimited";
if (!isRateLimited || attempt === maxRetries - 1) throw error;
// Exponential backoff: 1s, 2s, 4s, 8s, 16s + jitter
const delay = 1000 * Math.pow(2, attempt) + Math.random() * 500;
console.warn(`Rate limited (attempt ${attempt + 1}/${maxRetries}), waiting ${Math.round(delay)}ms`);
await new Promise(r => setTimeout(r, delay));
}
}
throw new Error("Unreachable");
}
get sdk() { return this.client; }
}
```
### Step 3: Request Queue with Token Bucket
Prevent bursts by spacing requests evenly.
```typescript
class RequestQueue {
private queue: Array<{ fn: () => Promise<any>; resolve: Function; reject: Function }> = [];
private processing = false;
private intervalMs: number;
constructor(requestsPerSecond = 10) {
this.intervalMs = 1000 / requestsPerSecond;
}
async enqueue<T>(fn: () => Promise<T>): Promise<T> {
return new Promise((resolve, reject) => {
this.queue.push({ fn, resolve, reject });
if (!this.processing) this.processQueue();
});
}
private async processQueue() {
this.processing = true;
while (this.queue.length > 0) {
const { fn, resolve, reject } = this.queue.shift()!;
try {
resolve(await fn());
} catch (error) {
reject(error);
}
if (this.queue.length > 0) {
await new Promise(r => setTimeout(r, this.intervalMs));
}
}
this.processing = false;
}
}
// Usage: 8 requests/second max
const queue = new RequestQueue(8);
const client = new LinearClient({ apiKey: process.env.LINEAR_API_KEY! });
const teamResults = await Promise.all(
teamIds.map(id => queue.enqueue(() => client.team(id)))
);
```
### Step 4: Reduce Query Complexity
```typescript
// HIGH COMPLEXITY (~12,500 pts):
// 250 issues * (1 issue + 50 labels * 0.1 per field) = expensive
// const heavy = await client.issues({ first: 250 });
// LOW COMPLEXITY (~55 pts):
// 50 issues * (5 fields * 0.1 + 1 object) = cheap
const light = await client.issues({
first: 50,
filter: { team: { id: { eq: teamId } } },
});
// Use rawRequest for minimal field selection
const minimal = await client.client.rawRequest(`
query { issues(first: 50) { nodes { id identifier title priority } } }
`);
// Sort by updatedAt to get fresh data first, avoid paginating everything
const fresh = await client.issues({
first: 50,
orderBy: "updatedAt",
filter: { updatedAt: { gte: lastSyncTime } },
});
```
### Step 5: Batch Mutations
Combine multiple mutations into one GraphQL request.
```typescript
// Instead of 100 separate issueUpdate calls (~100 requests):
async function batchUpdatePriority(client: LinearClient, issueIds: string[], priority: number) {
const chunkSize = 20; // Keep each batch under complexity limit
for (let i = 0; i < issueIds.length; i += chunkSize) {
const chunk = issueIds.slice(i, i + chunkSize);
const mutations = chunk.map((id, j) =>
`u${j}: issueUpdate(id: "${id}", input: { priority: ${priority} }) { success }`
).join("\n");
await queue.enqueue(() =>
client.client.rawRequest(`mutation BatchUpdate { ${mutations} }`)
);
}
}
// Batch archive
async function batchArchive(client: LinearClient, issueIds: string[]) {
for (let i = 0; i < issueIds.length; i += 20) {
const chunk = issueIds.slice(i, i + 20);
const mutations = chunk.map((id, j) =>
`a${j}: issueArchive(id: "${id}") { success }`
).join("\n");
await client.client.rawRequest(`mutation { ${mutations} }`);
}
}
```
### Step 6: Rate Limit Monitor
```typescript
class RateLimitMonitor {
private remaining = { requests: 5000, complexity: 250000 };
update(headers: Headers) {
const reqRemaining = headers.get("x-ratelimit-requests-remaining");
const cxRemaining = headers.get("x-ratelimit-complexity-remaining");
if (reqRemaining) this.remaining.requests = parseInt(reqRemaining);
if (cxRemaining) this.remaining.complexity = parseInt(cxRemaining);
}
isLow(): boolean {
return this.remaining.requests < 100 || this.remaining.complexity < 5000;
}
getStatus() {
return {
requests: this.remaining.requests,
complexity: this.remaining.complexity,
healthy: !this.isLow(),
};
}
}
```
## Error Handling
| Error | Cause | Solution |
|-------|-------|----------|
| HTTP 429 | Request or complexity budget exceeded | Parse headers, back off exponentially |
| `Query complexity too high` | Single query > 10,000 pts | Reduce `first` to 50, remove nested relations |
| Burst of 429s on startup | Init fetches too much data | Stagger startup queries, cache static data |
| Timeout on SDK call | Server under load | Add 30s timeout, retry once |
## Examples
### Rate Limit Status Check
```bash
curl -s -I -X POST https://api.linear.app/graphql \
-H "Authorization: $LINEAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "{ viewer { id } }"}' 2>&1 | grep -i ratelimit
```
### Safe Bulk Import
```typescript
const rlClient = new RateLimitedClient(process.env.LINEAR_API_KEY!);
const items = [/* issues to import */];
for (let i = 0; i < items.length; i++) {
await rlClient.withRetry(() =>
rlClient.sdk.createIssue({ teamId: "team-uuid", title: items[i].title })
);
if ((i + 1) % 50 === 0) console.log(`Imported ${i + 1}/${items.length}`);
}
```
## Resources
- [Linear Rate Limiting](https://linear.app/developers/rate-limiting)
- [Query Complexity](https://linear.app/developers/rate-limiting)
- [Best Practices](https://linear.app/developers/graphql)
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.