Agent skill
glean-sdk-patterns
Apply production-ready Glean API patterns with typed clients, batch indexing, pagination, and error handling. Trigger: "glean SDK patterns", "glean best practices", "glean API client".
Install this agent skill to your Project
npx add-skill https://github.com/jeremylongshore/claude-code-plugins-plus-skills/tree/main/plugins/saas-packs/glean-pack/skills/glean-sdk-patterns
SKILL.md
Glean SDK Patterns
Typed Glean Client
class GleanClient {
private indexUrl: string;
private searchUrl: string;
constructor(private domain: string, private indexToken: string, private clientToken: string) {
this.indexUrl = `https://${domain}/api/index/v1`;
this.searchUrl = `https://${domain}/api/client/v1`;
}
async indexDocuments(datasource: string, docs: GleanDocument[]) {
const res = await fetch(`${this.indexUrl}/indexdocuments`, {
method: 'POST',
headers: { 'Authorization': `Bearer ${this.indexToken}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ datasource, documents: docs }),
});
if (!res.ok) throw new Error(`Glean index error ${res.status}: ${await res.text()}`);
return res.json();
}
async search(query: string, options: { pageSize?: number; datasource?: string } = {}) {
const res = await fetch(`${this.searchUrl}/search`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${this.clientToken}`,
'X-Glean-Auth-Type': 'BEARER',
'Content-Type': 'application/json',
},
body: JSON.stringify({
query,
pageSize: options.pageSize ?? 20,
requestOptions: options.datasource ? { datasourceFilter: options.datasource } : undefined,
}),
});
if (!res.ok) throw new Error(`Glean search error ${res.status}: ${await res.text()}`);
return res.json();
}
async bulkIndex(datasource: string, docs: GleanDocument[], batchSize = 100) {
const uploadId = `bulk-${Date.now()}`;
for (let i = 0; i < docs.length; i += batchSize) {
const batch = docs.slice(i, i + batchSize);
await fetch(`${this.indexUrl}/bulkindexdocuments`, {
method: 'POST',
headers: { 'Authorization': `Bearer ${this.indexToken}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
datasource, uploadId,
isFirstPage: i === 0,
isLastPage: i + batchSize >= docs.length,
documents: batch,
}),
});
}
}
}
interface GleanDocument {
id: string;
title: string;
url: string;
body: { mimeType: string; textContent: string };
author?: { email: string };
updatedAt?: string;
permissions?: { allowAnonymousAccess?: boolean; allowedUsers?: Array<{ email: string }> };
}
Resources
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
dockerfile-generator
Dockerfile Generator - Auto-activating skill for DevOps Basics. Triggers on: dockerfile generator, dockerfile generator Part of the DevOps Basics skill category.
branch-naming-helper
Branch Naming Helper - Auto-activating skill for DevOps Basics. Triggers on: branch naming helper, branch naming helper Part of the DevOps Basics skill category.
readme-generator
Readme Generator - Auto-activating skill for DevOps Basics. Triggers on: readme generator, readme generator Part of the DevOps Basics skill category.
makefile-generator
Makefile Generator - Auto-activating skill for DevOps Basics. Triggers on: makefile generator, makefile generator Part of the DevOps Basics skill category.
gitignore-generator
Gitignore Generator - Auto-activating skill for DevOps Basics. Triggers on: gitignore generator, gitignore generator Part of the DevOps Basics skill category.
pre-commit-hook-setup
Pre Commit Hook Setup - Auto-activating skill for DevOps Basics. Triggers on: pre commit hook setup, pre commit hook setup Part of the DevOps Basics skill category.
Didn't find tool you were looking for?