Klaviyo Local Dev Loop
SkillDev tools'Configure Klaviyo local development with hot reload, mocking, and testing.
Use Klaviyo Local Dev Loop in Claude, ChatGPT or Ahel Desktop
Free. Sign in, add Klaviyo Local Dev Loop and connect your AI. About a minute.
Also: Claude Code · Cursor · Codex
Then ask your AI: use the Klaviyo Local Dev Loop skill
Details
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; Ahel provides instructions and does not run this skill.
No other account needed.
Add Ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.
What this skill tells your AI
The instructions your AI receives, as published by jeremylongshore/tons-of-skills-marketplace in skills/.curated/klaviyo-local-dev-loop/SKILL.md and read by Ahel’s review.
Overview
Set up a fast, reproducible local development workflow for Klaviyo integrations with hot reload, SDK mocking, and integration tests. The loop keeps three concerns separate: a lazily-instantiated SDK client singleton, mocked unit tests that never hit the network, and live integration tests gated behind an opt-in flag so they only run in CI.
Prerequisites
- Completed
klaviyo-install-authsetup (provides your private API key) - Node.js 18+ with
npmorpnpmon the PATH klaviyo-apipackage installed as a project dependencytsxandvitestinstalled as dev dependencies for hot reload and tests
Instructions
Follow six steps to stand up the loop. The full file contents for each step —
project layout, .env templates, package.json scripts, and the client
singleton — live in full walkthrough. The
complete test files live in test examples.
-
Project structure — create
src/klaviyo/for SDK modules andtests/{unit,integration}/. Keep secrets in a git-ignored.env.local, ship a committed.env.example. -
Environment configuration — define
KLAVIYO_PRIVATE_KEY/KLAVIYO_PUBLIC_KEYand wire thedev,test,test:watch,test:integration, andtypecheckscripts. -
SDK client singleton — read the key once, cache the
ApiKeySession, and export lazy per-API accessors so you only instantiate what you use:// src/klaviyo/client.ts import { ApiKeySession, ProfilesApi } 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; } export const profiles = () => new ProfilesApi(getSession()); -
Unit testing with mocks —
vi.mock('klaviyo-api', ...)the whole SDK so unit tests are deterministic and offline. See test examples. -
Integration test — a
describe.skipIf(!process.env.KLAVIYO_TEST)suite that exercises the live account. See test examples. -
Hot reload development — run
npm run dev(tsx watch) in one terminal andnpm run test:watchin another for a tight edit-test cycle.
Output
- Working dev environment with hot reload via
tsx watch - Unit tests with mocked
klaviyo-apiSDK - 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 |
Examples
A minimal mocked unit test — no network, fully deterministic. The full unit and integration suites are in test examples.
// tests/unit/profiles.test.ts
import { describe, it, expect, vi } from 'vitest';
vi.mock('klaviyo-api', () => ({
ApiKeySession: vi.fn(),
ProfilesApi: vi.fn().mockImplementation(() => ({
createProfile: vi.fn().mockResolvedValue({
body: { data: { id: '01JMOCKPROFILEID', attributes: { email: 'test@example.com' } } },
}),
})),
}));
import { ProfilesApi, ApiKeySession } from 'klaviyo-api';
describe('Profile operations', () => {
it('creates a profile with email', async () => {
const api = new ProfilesApi(new ApiKeySession('pk_test_key'));
const result = await api.createProfile({
data: { type: 'profile' as any, attributes: { email: 'test@example.com' } },
});
expect(result.body.data.id).toBe('01JMOCKPROFILEID');
});
});
Run it with npm run test, or npm run test:watch for the hot loop. To exercise
the live API instead, set KLAVIYO_TEST=1 and run npm run test:integration.
Resources
- klaviyo-api-node SDK
- Vitest Documentation
- tsx (TypeScript Execute)
- Full implementation walkthrough
- Complete test examples
Next Steps
See klaviyo-sdk-patterns for production-ready code patterns, and
klaviyo-install-auth if you still need to provision an API key. Once the loop
is green locally, wire npm run test:integration into CI behind the
KLAVIYO_TEST gate so live checks run only where a sandbox key is available.
Signals
- GitHub stars
- 3k
- Forks
- 415
- Last commit
- Oct 2026
Ahel review
K1binfo
installs-packages
Automated review, not a security audit. Ruleset v1+k2.
Advanced
- Item type
- skill
- Key
klaviyo-local-dev-loop- Source
- github.com/jeremylongshore/tons-of-skills-marketplace
github.com/jeremylongshore/tons-of-skills-marketplace
Related picks
Skill · thedaviddias
The pick for JavaScriptmodern-javascript-patterns
Skill · wshobson
The pick for JavaScriptsetup-ts-deep-modules
Skill · mattpocock
The pick for TypeScripttypescript-pro
Skill · jeffallan
The pick for TypeScriptnodejs-backend-patterns
Skill · wshobson
The pick for Noderun-node-tests
Skill · hiroro-work
The pick for Node