lucidchart-sdk-patterns
Sdk Patterns for Lucidchart. Trigger: "lucidchart sdk patterns".
What this skill does
# Lucidchart SDK Patterns
## Overview
Lucid's REST API uses OAuth 2.0 with versioned `Lucid-Api-Version` headers to manage documents, pages, shapes, data-linked fields, and collaborative comments. A structured SDK client is essential because the API requires version negotiation on every request, returns deeply nested shape tree hierarchies, and enforces document-level locking for concurrent edits. These patterns provide OAuth token lifecycle management, typed shape and document models, fluent query building for filtered shape searches, and mock factories for diagramming test scenarios.
## Prerequisites
- Node.js 18+, TypeScript 5+
- `LUCID_CLIENT_ID` and `LUCID_CLIENT_SECRET` environment variables (OAuth 2.0 app credentials)
- `LUCID_ACCESS_TOKEN` or refresh token flow for per-user access
- `axios` or `node-fetch` for HTTP transport
## Singleton Client
```typescript
interface LucidConfig {
clientId: string;
clientSecret: string;
accessToken: string;
apiVersion?: string;
baseUrl?: string;
}
let client: LucidClient | null = null;
export function getLucidClient(overrides?: Partial<LucidConfig>): LucidClient {
if (!client) {
const config: LucidConfig = {
clientId: process.env.LUCID_CLIENT_ID ?? '',
clientSecret: process.env.LUCID_CLIENT_SECRET ?? '',
accessToken: process.env.LUCID_ACCESS_TOKEN ?? '',
apiVersion: '2',
baseUrl: 'https://api.lucid.co',
...overrides,
};
if (!config.accessToken) throw new Error('LUCID_ACCESS_TOKEN is required');
client = new LucidClient(config);
}
return client;
}
```
## Error Wrapper
```typescript
interface LucidApiError { status: number; errorCode: string; message: string; documentId?: string; }
async function safeLucid<T>(fn: () => Promise<T>): Promise<T> {
try { return await fn(); }
catch (err: any) {
const parsed: LucidApiError = {
status: err.response?.status ?? 500,
errorCode: err.response?.data?.errorCode ?? 'INTERNAL',
message: err.response?.data?.message ?? err.message,
documentId: err.response?.data?.documentId,
};
if (parsed.status === 429) {
const wait = parseInt(err.response?.headers?.['x-ratelimit-reset'] ?? '10', 10);
await new Promise(r => setTimeout(r, wait * 1000));
return fn();
}
if (parsed.errorCode === 'DOCUMENT_LOCKED') throw new Error(`Document ${parsed.documentId} is locked by another editor`);
if (parsed.status === 403) throw new Error(`Insufficient permissions: ${parsed.message}`);
throw new Error(`Lucid ${parsed.errorCode} (${parsed.status}): ${parsed.message}`);
}
}
```
## Request Builder
```typescript
class ShapeQueryBuilder {
private params: Record<string, string> = {};
inDocument(docId: string) { this.params.documentId = docId; return this; }
onPage(pageId: string) { this.params.pageId = pageId; return this; }
ofType(shapeType: string) { this.params.className = shapeType; return this; }
withDataField(key: string, value: string) { this.params[`data.${key}`] = value; return this; }
limit(n: number) { this.params.limit = String(Math.min(n, 200)); return this; }
offset(n: number) { this.params.offset = String(n); return this; }
build(): URLSearchParams { return new URLSearchParams(this.params); }
}
```
## Response Types
```typescript
interface LucidDocument { id: string; title: string; editUrl: string; pageCount: number; lastModified: string; owner: string; }
interface LucidPage { id: string; title: string; index: number; width: number; height: number; }
interface LucidShape { id: string; className: string; boundingBox: { x: number; y: number; w: number; h: number }; text: string; dataFields: Record<string, string>; }
interface LucidComment { id: string; author: string; body: string; shapeId?: string; resolved: boolean; createdAt: string; }
```
## Middleware Pattern
```typescript
type Middleware = (req: RequestInit, next: () => Promise<Response>) => Promise<Response>;
const versionMiddleware: Middleware = (req, next) => {
req.headers = { ...req.headers as Record<string, string>, 'Lucid-Api-Version': '2' };
return next();
};
const oauthRefreshMiddleware = (refreshToken: string): Middleware => async (req, next) => {
const res = await next();
if (res.status === 401) {
const tokens = await refreshOAuthToken(refreshToken);
(req.headers as Record<string, string>).Authorization = `Bearer ${tokens.access_token}`;
return next();
}
return res;
};
```
## Testing Utilities
```typescript
function mockDocument(overrides?: Partial<LucidDocument>): LucidDocument {
return { id: 'doc_abc123', title: 'Architecture Diagram', editUrl: 'https://lucid.app/documents/edit/doc_abc123', pageCount: 3, lastModified: '2025-06-01T12:00:00Z', owner: '[email protected]', ...overrides };
}
function mockShape(overrides?: Partial<LucidShape>): LucidShape {
return { id: 'shape_001', className: 'ProcessBlock', boundingBox: { x: 100, y: 50, w: 200, h: 100 }, text: 'API Gateway', dataFields: {}, ...overrides };
}
function mockComment(shapeId: string): LucidComment {
return { id: 'cmt_xyz', author: '[email protected]', body: 'Needs error path', shapeId, resolved: false, createdAt: '2025-06-02T09:00:00Z' };
}
```
## Error Handling
| Pattern | When to Use | Example |
|---------|-------------|---------|
| Version negotiation | API returns 400 on outdated version header | Catch version mismatch, retry with server-suggested version |
| Document lock retry | 409 DOCUMENT_LOCKED during shape updates | Exponential backoff up to 3 retries, then surface to user |
| OAuth token refresh | 401 on any endpoint | Use refresh token middleware, update stored access token |
| Permission escalation | 403 on shared document operations | Check document sharing settings before write operations |
| Shape tree validation | Creating shapes with invalid parent references | Validate page and container IDs exist before shape POST |
## Resources
- [Lucid API Reference](https://developer.lucid.co/reference/overview)
## Next Steps
Apply in `lucidchart-core-workflow-a`.
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.