/grammarly-pack:grammarly-sdk-patternsfrom grammarly-pack
Provides production-ready Grammarly SDK patterns for TypeScript and Python: typed client, token management, text chunking, and AI detection.
Ships in grammarly-pack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Production patterns for Grammarly API: typed client, token management, text chunking for large documents, and Python integration.
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.clientId, client_secret: this.clientSecret }),
});
const { access_token, expires_in } = await res.json();
this.token = access_token;
this.expiresAt = Date.now() + expires_in * 1000;
}
async score(text: string) {
await this.ensureToken();
const res = await fetch(`${this.base}/v2/scores`, {
method: 'POST',
headers: { 'Authorization': `Bearer ${this.token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ text }),
});
return res.json();
}
async detectAI(text: string) {
await this.ensureToken();
const res = await fetch(`${this.base}/v1/ai-detection`, {
method: 'POST',
headers: { 'Authorization': `Bearer ${this.token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ text }),
});
return res.json();
}
}
function chunkText(text: string, maxChars = 90000): string[] {
if (text.length <= maxChars) return [text];
const chunks: string[] = [];
const paragraphs = text.split('\n\n');
let current = '';
for (const p of paragraphs) {
if ((current + '\n\n' + p).length > maxChars) {
if (current) chunks.push(current);
current = p;
} else {
current = current ? current + '\n\n' + p : p;
}
}
if (current) chunks.push(current);
return chunks;
}
import os, requests
from dotenv import load_dotenv
load_dotenv()
class GrammarlyClient:
BASE = 'https://api.grammarly.com/ecosystem/api'
def __init__(self):
self.token = None
self._authenticate()
def _authenticate(self):
r = requests.post(f'{self.BASE}/v1/oauth/token', data={
'grant_type': 'client_credentials',
'client_id': os.environ['GRAMMARLY_CLIENT_ID'],
'client_secret': os.environ['GRAMMARLY_CLIENT_SECRET'],
})
self.token = r.json()['access_token']
def score(self, text: str):
r = requests.post(f'{self.BASE}/v2/scores',
headers={'Authorization': f'Bearer {self.token}', 'Content-Type': 'application/json'},
json={'text': text})
return r.json()
Apply patterns in grammarly-core-workflow-a.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
24 skills in this plugin
/grammarly-ci-integrationConfigure Grammarly CI/CD integration with GitHub Actions and testing.
Use when setting up automated testing, configuring CI pipelines,
or integrating Grammarly tests into your build process.
Trigger with phrases like "grammarly CI", "grammarly GitHub Actions",
"grammarly automated tests", "CI grammarly".
/grammarly-common-errorsDiagnose and fix Grammarly common errors and exceptions.
Use when encountering Grammarly errors, debugging failed requests,
or troubleshooting integration issues.
Trigger with phrases like "grammarly error", "fix grammarly",
"grammarly not working", "debug grammarly".
/grammarly-core-workflow-aExecute Grammarly primary workflow: Core Workflow A.
Use when implementing primary use case,
building main features, or core integration tasks.
Trigger with phrases like "grammarly main workflow",
"primary task with grammarly".
/grammarly-core-workflow-bExecute Grammarly secondary workflow: Core Workflow B.
Use when implementing secondary use case,
or complementing primary workflow.
Trigger with phrases like "grammarly secondary workflow",
"secondary task with grammarly".
/grammarly-cost-tuningOptimize Grammarly costs through tier selection, sampling, and usage monitoring.
Use when analyzing Grammarly billing, reducing API costs,
or implementing usage monitoring and budget alerts.
Trigger with phrases like "grammarly cost", "grammarly billing",
"reduce grammarly costs", "grammarly pricing", "grammarly expensive", "grammarly budget".
/grammarly-data-handlingImplement Grammarly data handling patterns for document processing.
Use when handling large documents, managing text chunking,
or implementing data pipelines for Grammarly API.
Trigger with phrases like "grammarly data", "grammarly documents",
"grammarly text processing", "grammarly pipeline".
npx claudepluginhub flight505/skill-forge --plugin grammarly-packOther plugins' skills for the same job