From grammarly-pack
Implements exponential backoff and queueing for Grammarly API rate limits using TypeScript. Handles 429 errors, retries, and optimizes throughput with PQueue.
npx claudepluginhub jeremylongshore/claude-code-plugins-plus-skills --plugin grammarly-packThis skill is limited to using the following tools:
| API | Limit | Notes |
Optimizes Grammarly API performance with caching, parallel calls, and batching strategies to reduce latency in JS/TS integrations.
Guides Next.js Cache Components and Partial Prerendering (PPR): 'use cache' directives, cacheLife(), cacheTag(), revalidateTag() for caching, invalidation, static/dynamic optimization. Auto-activates on cacheComponents: true.
Guides building MCP servers enabling LLMs to interact with external services via tools. Covers best practices, TypeScript/Node (MCP SDK), Python (FastMCP).
Share bugs, ideas, or general feedback.
| API | Limit | Notes |
|---|---|---|
| Writing Score | Plan-dependent | Per minute |
| AI Detection | Plan-dependent | Per minute |
| Plagiarism | Plan-dependent | Async, poll for results |
| Token endpoint | ~10/hour | Client credentials |
async function grammarlyWithBackoff<T>(fn: () => Promise<T>, maxRetries = 3): Promise<T> {
for (let i = 0; i <= maxRetries; i++) {
try { return await fn(); }
catch (err: any) {
if (err.status !== 429 || i === maxRetries) throw err;
const delay = 1000 * Math.pow(2, i) + Math.random() * 1000;
await new Promise(r => setTimeout(r, delay));
}
}
throw new Error('Unreachable');
}
import PQueue from 'p-queue';
const grammarlyQueue = new PQueue({ concurrency: 2, interval: 1000, intervalCap: 5 });
async function queuedScore(text: string, token: string) {
return grammarlyQueue.add(() =>
fetch('https://api.grammarly.com/ecosystem/api/v2/scores', {
method: 'POST',
headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ text }),
}).then(r => r.json())
);
}
For security, see grammarly-security-basics.