| name | grammarly-sdk-patterns |
| description | Apply production-ready Grammarly SDK patterns for TypeScript and Python.
Use when implementing Grammarly integrations, refactoring SDK usage,
or establishing team coding standards for Grammarly.
Trigger with phrases like "grammarly SDK patterns", "grammarly best practices",
"grammarly code patterns", "idiomatic grammarly".
|
| allowed-tools | Read, Write, Edit |
| version | 1.8.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","grammarly","writing"] |
| compatibility | Designed for Claude Code |
Grammarly SDK Patterns
Overview
Production patterns for Grammarly API: typed client, token management, text chunking for large documents, and Python integration.
Instructions
Step 1: Typed API Client
class GrammarlyClient {
private token: string;
private expiresAt: number = 0;
private base = 'https://api.grammarly.com/ecosystem/api';
constructor(private clientId: string, private clientSecret: string) {}
private async ensureToken() {
if (Date.now() < this.expiresAt - 60000) return;
const res = await fetch(`${this.base}/v1/oauth/token`, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({ grant_type: 'client_credentials', client_id: this., : . }),
});
{ access_token, expires_in } = res.();
. = access_token;
. = .() + expires_in * ;
}
() {
.();
res = (, {
: ,
: { : , : },
: .({ text }),
});
res.();
}
() {
.();
res = (, {
: ,
: { : , : },
: .({ text }),
});
res.();
}
}