jeremylongshore/claude-code-plugins-plus-skills
deepgram-pack
plugins/saas-packs/deepgram-pack/skills/deepgram-sdk-patterns/SKILL.md
January 22, 2026
Select agents to install to:
npx add-skill https://github.com/jeremylongshore/claude-code-plugins-plus-skills/blob/main/plugins/saas-packs/deepgram-pack/skills/deepgram-sdk-patterns/SKILL.md -a claude-code --skill deepgram-sdk-patternsInstallation paths:
.claude/skills/deepgram-sdk-patterns/# Deepgram SDK Patterns
## Overview
Production-ready patterns for Deepgram SDK integration with proper error handling, typing, and structure.
## Prerequisites
- Completed `deepgram-install-auth` setup
- Familiarity with async/await patterns
- Understanding of error handling best practices
## Instructions
### Step 1: Create Type-Safe Client Singleton
Implement a singleton pattern for the Deepgram client.
### Step 2: Add Robust Error Handling
Wrap all API calls with proper error handling and logging.
### Step 3: Implement Response Validation
Validate API responses before processing.
### Step 4: Add Retry Logic
Implement exponential backoff for transient failures.
## Output
- Type-safe client singleton
- Robust error handling with structured logging
- Automatic retry with exponential backoff
- Runtime validation for API responses
## Error Handling
| Error | Cause | Solution |
|-------|-------|----------|
| Type Mismatch | Incorrect response shape | Add runtime validation |
| Client Undefined | Singleton not initialized | Call init() before use |
| Memory Leak | Multiple client instances | Use singleton pattern |
| Timeout | Large audio file | Increase timeout settings |
## Examples
### TypeScript Client Singleton
```typescript
// lib/deepgram.ts
import { createClient, DeepgramClient } from '@deepgram/sdk';
let client: DeepgramClient | null = null;
export function getDeepgramClient(): DeepgramClient {
if (!client) {
const apiKey = process.env.DEEPGRAM_API_KEY;
if (!apiKey) {
throw new Error('DEEPGRAM_API_KEY environment variable not set');
}
client = createClient(apiKey);
}
return client;
}
export function resetClient(): void {
client = null;
}
```
### Typed Transcription Response
```typescript
// types/deepgram.ts
export interface TranscriptWord {
word: string;
start: number;
end: number;
confidence: number;
punctuated_word?: string;
}
export interface TranscriptAlternative {
transcript: string;
confidence: nu