home / skills / jeremylongshore / claude-code-plugins-plus-skills / deepgram-local-dev-loop

This skill streamlines configuring a local Deepgram workflow with rapid feedback, tests, and fixtures for faster development iterations.

npx playbooks add skill jeremylongshore/claude-code-plugins-plus-skills --skill deepgram-local-dev-loop

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
4.1 KB
---
name: deepgram-local-dev-loop
description: |
  Configure Deepgram local development workflow with testing and iteration.
  Use when setting up development environment, configuring test fixtures,
  or establishing rapid iteration patterns for Deepgram integration.
  Trigger with phrases like "deepgram local dev", "deepgram development setup",
  "deepgram test environment", "deepgram dev workflow".
allowed-tools: Read, Write, Edit, Bash(npm:*), Bash(pip:*), Grep
version: 1.0.0
license: MIT
author: Jeremy Longshore <[email protected]>
---

# Deepgram Local Dev Loop

## Overview
Set up an efficient local development workflow for Deepgram integration with fast feedback cycles.

## Prerequisites
- Completed `deepgram-install-auth` setup
- Node.js 18+ with npm/pnpm or Python 3.10+
- Sample audio files for testing
- Environment variables configured

## Instructions

### Step 1: Create Project Structure
```bash
mkdir -p src tests fixtures
touch src/transcribe.ts tests/transcribe.test.ts
```

### Step 2: Set Up Environment Files
```bash
# .env.development
DEEPGRAM_API_KEY=your-dev-api-key
DEEPGRAM_MODEL=nova-2

# .env.test
DEEPGRAM_API_KEY=your-test-api-key
DEEPGRAM_MODEL=nova-2
```

### Step 3: Create Test Fixtures
```bash
# Download sample audio for testing
curl -o fixtures/sample.wav https://static.deepgram.com/examples/nasa-podcast.wav
```

### Step 4: Set Up Watch Mode
```json
{
  "scripts": {
    "dev": "tsx watch src/transcribe.ts",
    "test": "vitest",
    "test:watch": "vitest --watch"
  }
}
```

## Output
- Project structure with src, tests, fixtures directories
- Environment files for development and testing
- Watch mode scripts for rapid iteration
- Sample audio fixtures for testing

## Error Handling
| Error | Cause | Solution |
|-------|-------|----------|
| Fixture Not Found | Missing audio file | Run fixture download script |
| Env Not Loaded | dotenv not configured | Install and configure dotenv |
| Watch Mode Fails | Missing tsx | Install tsx: `npm i -D tsx` |
| API Rate Limited | Too many dev requests | Use cached responses in tests |

## Examples

### TypeScript Dev Setup
```typescript
// src/transcribe.ts
import { createClient } from '@deepgram/sdk';
import { config } from 'dotenv';

config(); // Load .env

const deepgram = createClient(process.env.DEEPGRAM_API_KEY!);

export async function transcribeAudio(audioPath: string) {
  const audio = await Bun.file(audioPath).arrayBuffer();

  const { result, error } = await deepgram.listen.prerecorded.transcribeFile(
    Buffer.from(audio),
    { model: process.env.DEEPGRAM_MODEL || 'nova-2', smart_format: true }
  );

  if (error) throw error;
  return result.results.channels[0].alternatives[0].transcript;
}

// Dev mode: run with sample
if (import.meta.main) {
  transcribeAudio('./fixtures/sample.wav').then(console.log);
}
```

### Test Setup with Vitest
```typescript
// tests/transcribe.test.ts
import { describe, it, expect, beforeAll } from 'vitest';
import { transcribeAudio } from '../src/transcribe';

describe('Deepgram Transcription', () => {
  it('should transcribe audio file', async () => {
    const transcript = await transcribeAudio('./fixtures/sample.wav');
    expect(transcript).toBeDefined();
    expect(transcript.length).toBeGreaterThan(0);
  });

  it('should handle empty audio gracefully', async () => {
    await expect(transcribeAudio('./fixtures/empty.wav'))
      .rejects.toThrow();
  });
});
```

### Mock Responses for Testing
```typescript
// tests/mocks/deepgram.ts
export const mockTranscriptResponse = {
  results: {
    channels: [{
      alternatives: [{
        transcript: 'This is a test transcript.',
        confidence: 0.99,
        words: [
          { word: 'This', start: 0.0, end: 0.2, confidence: 0.99 },
          { word: 'is', start: 0.2, end: 0.3, confidence: 0.99 },
        ]
      }]
    }]
  }
};
```

## Resources
- [Deepgram SDK Reference](https://developers.deepgram.com/docs/sdk)
- [Vitest Documentation](https://vitest.dev/)
- [dotenv Configuration](https://github.com/motdotla/dotenv)

## Next Steps
Proceed to `deepgram-sdk-patterns` for production-ready code patterns.

Overview

This skill configures a fast local development loop for Deepgram integrations, combining environment setup, test fixtures, and watch-mode iteration. It provides a minimal project layout, sample fixtures, and scripts to run development and test workflows quickly. The goal is reliable, repeatable local testing before moving to production patterns.

How this skill works

The skill scaffolds folders (src, tests, fixtures), environment files for dev and test, and download scripts for sample audio used in tests. It wires a small transcribe module using the Deepgram SDK and exposes watch and test scripts (dev, test, test:watch) to enable rapid feedback. Mock responses and cached fixtures are recommended to avoid API rate limits during automated tests.

When to use it

  • Setting up a new Deepgram integration project locally
  • Creating repeatable test fixtures for audio transcription
  • Establishing rapid edit-run-test cycles with watch mode
  • Running CI-friendly tests with fixture-based mocks
  • Validating error handling and edge cases (empty audio, rate limits)

Best practices

  • Keep API keys out of source control: use .env.development and .env.test and gitignore them
  • Use small, deterministic sample audio in fixtures to keep tests fast and reliable
  • Mock Deepgram responses for unit tests to avoid hitting API rate limits
  • Run vitest in watch mode during development and CI in single-run mode
  • Cache or snapshot transcripts for stable assertions in tests

Example use cases

  • Quickly prototype transcription logic in src/transcribe.ts and iterate with npm run dev
  • Automate end-to-end transcription tests using fixtures/sample.wav and vitest
  • Simulate API responses with tests/mocks/deepgram.ts to validate parsing logic
  • Verify error handling by testing empty or corrupt audio fixtures
  • Prepare a reproducible dev environment for onboarding or demos

FAQ

What prerequisites are required?

Install Node.js 18+ (or Python 3.10+ if using Python examples), configure dotenv, and complete deepgram-install-auth to obtain API keys.

How do I avoid hitting Deepgram rate limits in tests?

Use mocked responses or cached transcript fixtures for unit tests. Reserve live API calls for a small set of integration tests.