klaviyo-local-dev-loop
Configure Klaviyo local development with hot reload, mocking, and testing. Use when setting up a development environment, configuring test workflows, or establishing a fast iteration cycle with the Klaviyo API. Trigger with phrases like "klaviyo dev setup", "klaviyo local development", "klaviyo dev environment", "develop with klaviyo", "klaviyo testing".
Best use case
klaviyo-local-dev-loop is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Configure Klaviyo local development with hot reload, mocking, and testing. Use when setting up a development environment, configuring test workflows, or establishing a fast iteration cycle with the Klaviyo API. Trigger with phrases like "klaviyo dev setup", "klaviyo local development", "klaviyo dev environment", "develop with klaviyo", "klaviyo testing".
Teams using klaviyo-local-dev-loop should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/klaviyo-local-dev-loop/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How klaviyo-local-dev-loop Compares
| Feature / Agent | klaviyo-local-dev-loop | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Configure Klaviyo local development with hot reload, mocking, and testing. Use when setting up a development environment, configuring test workflows, or establishing a fast iteration cycle with the Klaviyo API. Trigger with phrases like "klaviyo dev setup", "klaviyo local development", "klaviyo dev environment", "develop with klaviyo", "klaviyo testing".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Cursor vs Codex for AI Workflows
Compare Cursor and Codex for AI coding workflows, repository assistance, debugging, refactoring, and reusable developer skills.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
SKILL.md Source
# Klaviyo Local Dev Loop
## Overview
Set up a fast, reproducible local development workflow for Klaviyo integrations with hot reload, SDK mocking, and integration tests.
## Prerequisites
- Completed `klaviyo-install-auth` setup
- Node.js 18+ with npm/pnpm
- `klaviyo-api` package installed
## Instructions
### Step 1: Project Structure
```
my-klaviyo-project/
├── src/
│ ├── klaviyo/
│ │ ├── client.ts # ApiKeySession + API class singletons
│ │ ├── profiles.ts # Profile operations
│ │ ├── events.ts # Event tracking
│ │ └── lists.ts # List management
│ └── index.ts
├── tests/
│ ├── unit/
│ │ └── profiles.test.ts # Mocked SDK tests
│ └── integration/
│ └── klaviyo.test.ts # Live API tests (CI only)
├── .env.local # Local secrets (git-ignored)
├── .env.example # Template for team
├── .env.test # Test environment (sandbox key)
└── package.json
```
### Step 2: Environment Configuration
```bash
# .env.example (commit this)
KLAVIYO_PRIVATE_KEY=pk_your_test_key_here
KLAVIYO_PUBLIC_KEY=YourPublicKey
NODE_ENV=development
# .env.local (git-ignored, actual secrets)
KLAVIYO_PRIVATE_KEY=pk_********************************
```
```json
// package.json scripts
{
"scripts": {
"dev": "tsx watch src/index.ts",
"test": "vitest",
"test:watch": "vitest --watch",
"test:integration": "KLAVIYO_TEST=1 vitest --config vitest.integration.config.ts",
"typecheck": "tsc --noEmit"
}
}
```
### Step 3: SDK Client Singleton
```typescript
// src/klaviyo/client.ts
import {
ApiKeySession,
ProfilesApi,
EventsApi,
ListsApi,
SegmentsApi,
CampaignsApi,
MetricsApi,
} from 'klaviyo-api';
let session: ApiKeySession | null = null;
function getSession(): ApiKeySession {
if (!session) {
const key = process.env.KLAVIYO_PRIVATE_KEY;
if (!key) throw new Error('KLAVIYO_PRIVATE_KEY not set');
session = new ApiKeySession(key);
}
return session;
}
// Lazy singletons -- only instantiate what you use
export const profiles = () => new ProfilesApi(getSession());
export const events = () => new EventsApi(getSession());
export const lists = () => new ListsApi(getSession());
export const segments = () => new SegmentsApi(getSession());
export const campaigns = () => new CampaignsApi(getSession());
export const metrics = () => new MetricsApi(getSession());
```
### Step 4: Unit Testing with Mocks
```typescript
// tests/unit/profiles.test.ts
import { describe, it, expect, vi, beforeEach } from 'vitest';
// Mock the entire klaviyo-api module
vi.mock('klaviyo-api', () => ({
ApiKeySession: vi.fn(),
ProfilesApi: vi.fn().mockImplementation(() => ({
createProfile: vi.fn().mockResolvedValue({
body: {
data: {
id: '01JMOCKPROFILEID',
type: 'profile',
attributes: { email: 'test@example.com', firstName: 'Test' },
},
},
}),
getProfiles: vi.fn().mockResolvedValue({
body: {
data: [{ id: '01JMOCKPROFILEID', attributes: { email: 'test@example.com' } }],
links: { next: null },
},
}),
})),
ProfileEnum: { Profile: 'profile' },
}));
import { ProfilesApi, ApiKeySession } from 'klaviyo-api';
describe('Profile operations', () => {
let profilesApi: ProfilesApi;
beforeEach(() => {
const session = new ApiKeySession('pk_test_key');
profilesApi = new ProfilesApi(session);
});
it('creates a profile with email', async () => {
const result = await profilesApi.createProfile({
data: {
type: 'profile' as any,
attributes: { email: 'test@example.com', firstName: 'Test' },
},
});
expect(result.body.data.id).toBe('01JMOCKPROFILEID');
});
});
```
### Step 5: Integration Test (runs against live API)
```typescript
// tests/integration/klaviyo.test.ts
import { describe, it, expect } from 'vitest';
import { ApiKeySession, ProfilesApi, AccountsApi } from 'klaviyo-api';
const SKIP = !process.env.KLAVIYO_TEST;
describe.skipIf(SKIP)('Klaviyo Integration', () => {
const session = new ApiKeySession(process.env.KLAVIYO_PRIVATE_KEY!);
it('connects to Klaviyo account', async () => {
const accountsApi = new AccountsApi(session);
const result = await accountsApi.getAccounts();
expect(result.body.data).toHaveLength(1);
expect(result.body.data[0].id).toBeTruthy();
});
it('creates and retrieves a test profile', async () => {
const profilesApi = new ProfilesApi(session);
const testEmail = `test-${Date.now()}@example.com`;
await profilesApi.createProfile({
data: {
type: 'profile' as any,
attributes: { email: testEmail, firstName: 'IntegrationTest' },
},
});
const profiles = await profilesApi.getProfiles({
filter: `equals(email,"${testEmail}")`,
});
expect(profiles.body.data[0].attributes.firstName).toBe('IntegrationTest');
});
});
```
### Step 6: Hot Reload Development
```bash
# Start dev server with file watching
npm run dev
# In another terminal, run tests on change
npm run test:watch
```
## Output
- Working dev environment with hot reload via `tsx watch`
- Unit tests with mocked `klaviyo-api` SDK
- Integration tests gated behind `KLAVIYO_TEST=1`
- Client singleton pattern for consistent SDK usage
## Error Handling
| Error | Cause | Solution |
|-------|-------|----------|
| `KLAVIYO_PRIVATE_KEY not set` | Missing .env.local | Copy from .env.example |
| Mock type errors | SDK type mismatches | Use `as any` for mock enum values |
| Integration test 429 | Rate limited in CI | Add delays between tests or use test key |
| `tsx` not found | Missing dependency | `npm install -D tsx` |
## Resources
- [klaviyo-api-node SDK](https://github.com/klaviyo/klaviyo-api-node)
- [Vitest Documentation](https://vitest.dev/)
- [tsx (TypeScript Execute)](https://github.com/privatenumber/tsx)
## Next Steps
See `klaviyo-sdk-patterns` for production-ready code patterns.Related Skills
workhuman-local-dev-loop
Workhuman local dev loop for employee recognition and rewards API. Use when integrating Workhuman Social Recognition, or building recognition workflows with HRIS systems. Trigger: "workhuman local dev loop".
wispr-local-dev-loop
Wispr Flow local dev loop for voice-to-text API integration. Use when integrating Wispr Flow dictation, WebSocket streaming, or building voice-powered applications. Trigger: "wispr local dev loop".
windsurf-local-dev-loop
Configure Windsurf local development workflow with Cascade, Previews, and terminal integration. Use when setting up a development environment, configuring Turbo mode, or establishing a fast iteration cycle with Windsurf AI. Trigger with phrases like "windsurf dev setup", "windsurf local development", "windsurf dev environment", "windsurf workflow", "develop with windsurf".
webflow-local-dev-loop
Configure a Webflow local development workflow with TypeScript, hot reload, mocked API tests, and webhook tunneling via ngrok. Use when setting up a development environment, configuring test workflows, or establishing a fast iteration cycle with the Webflow Data API. Trigger with phrases like "webflow dev setup", "webflow local development", "webflow dev environment", "develop with webflow".
vercel-local-dev-loop
Configure Vercel local development with vercel dev, environment variables, and hot reload. Use when setting up a development environment, testing serverless functions locally, or establishing a fast iteration cycle with Vercel. Trigger with phrases like "vercel dev setup", "vercel local development", "vercel dev environment", "develop with vercel locally".
veeva-local-dev-loop
Veeva Vault local dev loop for REST API and clinical operations. Use when working with Veeva Vault document management and CRM. Trigger: "veeva local dev loop".
vastai-local-dev-loop
Configure Vast.ai local development with testing and fast iteration. Use when setting up a development environment, testing instance provisioning, or building a fast iteration cycle for GPU workloads. Trigger with phrases like "vastai dev setup", "vastai local development", "vastai dev environment", "develop with vastai".
twinmind-local-dev-loop
Set up local development workflow with TwinMind API integration. Use when building applications that integrate TwinMind transcription, testing API calls locally, or developing meeting automation tools. Trigger with phrases like "twinmind dev setup", "twinmind local development", "twinmind API testing", "build with twinmind".
together-local-dev-loop
Together AI local dev loop for inference, fine-tuning, and model deployment. Use when working with Together AI's OpenAI-compatible API. Trigger: "together local dev loop".
techsmith-local-dev-loop
TechSmith local dev loop for Snagit COM API and Camtasia automation. Use when working with TechSmith screen capture and video editing automation. Trigger: "techsmith local dev loop".
supabase-local-dev-loop
Configure Supabase local development with the CLI, Docker, and migration workflow. Use when initializing a Supabase project locally, starting the local stack, writing migrations, seeding data, or iterating on schema changes. Trigger with phrases like "supabase local dev", "supabase start", "supabase init", "supabase db reset", "supabase local setup".
stackblitz-local-dev-loop
Configure local development for WebContainer applications with hot reload and testing. Use when building browser-based IDEs, testing WebContainer file operations, or setting up development workflows for WebContainer projects. Trigger: "stackblitz dev setup", "webcontainer local", "test webcontainers locally".