Pp klaviyo

From mvanhorn/printing-press-library · View interactive version

Pp klaviyo is an AI agent skill from the GitHub repository mvanhorn/printing-press-library. Klaviyo from the shell, with local customer-behavior analytics layered on top. Trigger phrases: `inspect a Klaviyo profile`, `deploy a Klaviyo campaign`, `check Klaviyo flow decay`, `reconcile Klaviyo campaign revenue`.

How to use this skill

Skill file

<!-- GENERATED FILE — DO NOT EDIT.

This file is a verbatim mirror of library/marketing/klaviyo/SKILL.md,

regenerated post-merge by tools/generate-skills/. Hand-edits here are

silently overwritten on the next regen. Edit the library/ source instead.

See the repository agent guide, section "Generated artifacts: registry.json, cli-skills/". -->

Klaviyo - Printing Press CLI

Prerequisites: Install the CLI

This skill drives the klaviyo-pp-cli binary. You must verify the CLI is installed before invoking any command from this skill. If it is missing, install it first:

  1. Install via the Printing Press installer. It defaults binaries to $HOME/.local/bin on macOS/Linux and %LOCALAPPDATA%\Programs\PrintingPress\bin on Windows:

```bash

npx -y @mvanhorn/printing-press-library install klaviyo --cli-only

```

  1. Verify: klaviyo-pp-cli --version
  2. Ensure the reported install directory is on $PATH for the agent/runtime that will invoke this skill.

If the npx install fails (no Node, offline, etc.), fall back to a direct Go install (requires Go 1.26.6 or newer):

go install github.com/mvanhorn/printing-press-library/library/marketing/klaviyo/cmd/klaviyo-pp-cli@latest

If --version reports "command not found" after install, the runtime cannot see the binary directory on $PATH. Do not proceed with skill commands until verification succeeds.

When to Use This CLI

Use this CLI when an agent needs to inspect or operate Klaviyo without the web UI, especially for profiles, events, campaigns, flows, segments, templates, metrics, and compound growth workflows.

Generated with Printing Press 4.35.4 against Klaviyo API revision 2026-10-15. Every request sends revision: 2026-10-15.

At this revision, a campaign is a container. Messages carry status and send time; campaign-audiences carry included and excluded lists and segments; variations carry channel, template, subject, and sender. IDs issued before 2026-10-15 are now message IDs. Campaign workflows accept either a container ID or a historical campaign/message ID and resolve its audiences and variations. The raw campaigns get-id read expects a container ID and explains historical IDs on a 404.

Default local databases and response caches are scoped by a non-secret API-key fingerprint and honor XDG paths. Use an explicit --db only when intentionally selecting a tenant-specific store.

Unique Capabilities

These capabilities aren't available in any other tool for this API.

Campaign operations

Repeat --list-id and --segment-id to include audiences; repeat --exclude for excluded list or segment IDs. --preview-text, --reply-to, and --send-timezone set the email preview, reply address, and timezone. The reply address defaults to the sender and the timezone defaults to the account timezone. Use --template-file for an HTML file or --template-html for inline HTML. Deployment never schedules or sends the campaign.

```bash

klaviyo-pp-cli campaigns deploy --template-file ./email.html --campaign-name "Acme offer" \

--list-id LIST_ID --list-id SECOND_LIST_ID --segment-id SEGMENT_ID --exclude EXCLUDED_ID \

--subject "Acme offer" --preview-text "This week's offer" --from-email marketing@example.com \

--from-label "Acme" --reply-to replies@example.com --send-timezone America/Chicago --json

```

Repeat --to or use comma-separated addresses; without --to, recipients come from KLAVIYO_TEST_SEND_TO. --variation-id limits preview sends to one email variation while QA still checks the campaign. --dry-run runs QA and shows planned sends without sending. Preview POSTs are never retried; an ambiguous result says "unknown, check the inbox".

--brand reads Klaviyo's brand kit (brand colors, logos, buttons, email defaults), warns on off-brand colors and old logos, and fails on a missing footer. Add --brand-strict-neutrals to flag grays that are not in the palette.

```bash

klaviyo-pp-cli campaigns test-send --campaign-id CAMPAIGN_ID --to qa@example.com --json

```

_Agents can make safe creative swaps without rebuilding a whole campaign._

```bash

klaviyo-pp-cli campaigns image-swap --campaign-id CAMPAIGN_ID --old-url https://cdn.example.com/old.jpg --new-url https://cdn.example.com/new.jpg --json

```

Repeat --subject for each new variation. Preview text is copied from A unless --preview-text is repeated once per new subject. Empty subjects, duplicate subjects, scheduled messages and existing tests are refused. --campaign-id accepts a container with exactly one email message or a message ID; containers with several messages list the IDs to choose from.

--winner-metric accepts clicks (default), opens or orders. --test-percent defaults to 20 and accepts 1 to 100; this share is split evenly across all variations, and the remaining share receives the winner. --wait-hours defaults to 4 and accepts 1 to 264. Apple Mail Privacy Protection inflates opens, so clicks or orders pick a truer winner.

--dry-run reads current state and prints the plan without writing. Creates are attempted once; a failed create or settings update triggers best-effort deletion of this run's known new variations. An ambiguous create can leave an unconfirmed variation and reports that uncertainty. A successful command re-reads subjects, settings, draft status and send time. It never schedules or sends. Run campaigns test-send --campaign-id acme-message-id afterward to preview every variation.

```bash

klaviyo-pp-cli campaigns ab-test create --campaign-id acme-message-id \

--subject "Acme: a new way to start" --subject "Start with Acme today" \

--preview-text "Your next step" --preview-text "See what's new" \

--winner-metric clicks --test-percent 20 --wait-hours 4 --dry-run --json

```

--metric accepts clicks, opens or orders; it defaults to the test's winner metric, then clicks. The rate leader must beat every other variation in a two-sided pooled two-proportion z-test with p < 0.05 for clear_winner; otherwise the verdict is no_clear_winner. P-values, an opens privacy note and small-sample notes (fewer than 100 selected metric events) accompany the result. When the winner audience share is positive, the most-mailed variation is labelled as a Klaviyo winner inferred from recipient counts.

Reports use the day before the send date through now in KLAVIYO_TIMEZONE (default UTC), capped to the provider's 364-day window. --conversion-metric-id overrides the default Shopify Placed Order auto-resolution. If auto-resolution cannot find a usable order metric, clicks and opens use Received Email for reporting; orders, revenue and revenue per recipient are unavailable (null in JSON), with a note. Comparing orders requires a usable order metric. JSON includes message ID, A/B settings, timeframe, variations, verdict, leader, p-values and notes.

```bash

klaviyo-pp-cli campaigns ab-test results --campaign-id acme-message-id --metric clicks --json

```

Flow and form operations

--after identifies the existing action. --link selects next, next_if_true, next_if_false, or a multi-branch branch ID. Unsupported step types are refused, and timing or logic steps in a live flow require --allow-live-action.

```bash

klaviyo-pp-cli flows insert-step FLOW_ID --after ACTION_ID --step-file ./step.json --json

```

```bash

klaviyo-pp-cli forms publish FORM_ID --apply --json

```

```bash

klaviyo-pp-cli forms unpublish FORM_ID --apply --json

```

Both form commands refuse a draft A/B test. --dry-run always previews, even with --apply; ambiguous publish or unpublish requests are never retried.

Behavior graph analytics

_Agents can spot lifecycle automations that need refresh before revenue falls further._

```bash

klaviyo-pp-cli flow-decay --days 90 --threshold 0.15 --json

```

_Agents can answer which acquisition cohorts keep buying without exporting CSVs._

```bash

klaviyo-pp-cli cohort --metric "Placed Order" --interval month --json --select cohort,profiles,retained

```

_Agents can explain which automation or campaign generated revenue using local event evidence._

```bash

klaviyo-pp-cli attribution --metric "Placed Order" --group-by flow --since 2026-01-01 --json

```

Reporting

Missing or stale estimates are refreshed with estimation jobs by default. --wait bounds that work (default two minutes); --no-refresh uses GET requests only.

```bash

klaviyo-pp-cli send-budget --no-refresh --json

```

```bash

klaviyo-pp-cli campaign-values-reports --timeframe last_12_months --statistics recipients,opens,clicks,conversion_value --agent

```

```bash

klaviyo-pp-cli report targeting --timeframe last_12_months --agent

```

Data hygiene

```bash

klaviyo-pp-cli list-quality-score --json --no-cache

```

```bash

klaviyo-pp-cli segments get --all --with-counts --json --no-cache

```

_Agents can flag customer records that split behavior and revenue history across identities._

```bash

klaviyo-pp-cli dedup --by email,phone --json

```

_Agents can check whether campaign performance agrees with order evidence before reporting numbers._

```bash

klaviyo-pp-cli reconcile --campaign-id CAMPAIGN_ID --since 2026-01-01 --json

```

Growth planning

_Agents can convert strategy notes into a concrete Klaviyo execution plan._

```bash

klaviyo-pp-cli plan brief-to-strategy --brief ./brief.md --json

```

_Agents can block risky campaign launches with explicit findings instead of vague review notes._

```bash

klaviyo-pp-cli plan qa-gate --campaign-id CAMPAIGN_ID --html ./email.html --json

```

--brand reads Klaviyo's brand kit (brand colors, logos, buttons, email defaults), warns on off-brand colors and old logos, and fails on a missing footer. Add --brand-strict-neutrals to flag grays that are not in the palette.

Command Reference

accounts - accounts

back-in-stock-subscriptions - Manage back in stock subscriptions

campaign-clone - Manage campaign clone

campaign-message-assign-template - Manage campaign message assign template

campaign-messages - Manage campaign messages

campaign-recipient-estimation-jobs - Manage campaign recipient estimation jobs

campaign-recipient-estimations - Manage campaign recipient estimations

campaign-send-jobs - Manage campaign send jobs

campaign-values-reports - Manage campaign values reports

campaigns - campaigns

Use campaigns deploy for an unscheduled email draft and campaigns test-send for QA followed by inbox previews. Use campaigns ab-test create for subject-line alternatives and campaigns ab-test results to compare their performance.

campaigns create translates legacy --data-attributes-name and --data-attributes-campaign-messages into the new definition, messages, and variations; a legacy audience object becomes one inline audience. --stdin bodies pass through unchanged and must already use the new model. The flags --data-attributes-send-options, --data-attributes-send-strategy, and --data-attributes-tracking-options were removed: put campaign send_settings in --data-attributes-definition and supported message settings (is_add_utm, throttling_type) in --data-attributes-messages.

catalog-categories - Manage catalog categories

catalog-category-bulk-create-jobs - Manage catalog category bulk create jobs

catalog-category-bulk-delete-jobs - Manage catalog category bulk delete jobs

catalog-category-bulk-update-jobs - Manage catalog category bulk update jobs

catalog-item-bulk-create-jobs - Manage catalog item bulk create jobs

catalog-item-bulk-delete-jobs - Manage catalog item bulk delete jobs

catalog-item-bulk-update-jobs - Manage catalog item bulk update jobs

catalog-items - Manage catalog items

catalog-variant-bulk-create-jobs - Manage catalog variant bulk create jobs

catalog-variant-bulk-delete-jobs - Manage catalog variant bulk delete jobs

catalog-variant-bulk-update-jobs - Manage catalog variant bulk update jobs

catalog-variants - Manage catalog variants

client - client

conversation-messages - Manage conversation messages

coupon-code-bulk-create-jobs - Manage coupon code bulk create jobs

coupon-codes - Manage coupon codes

coupons - coupons

custom-metrics - Manage custom metrics

data-privacy-deletion-jobs - Manage data privacy deletion jobs

data-source-record-bulk-create-jobs - Manage data source record bulk create jobs

data-source-record-create-jobs - Manage data source record create jobs

data-sources - Manage data sources

event-bulk-create-jobs - Manage event bulk create jobs

events - events

flow-actions - Manage flow actions

flow-messages - Manage flow messages

flow-series-reports - Manage flow series reports

flow-values-reports - Manage flow values reports

flows - flows

form-series-reports - Manage form series reports

form-values-reports - Manage form values reports

form-versions - Manage form versions

forms - forms

image-upload - Manage image upload

images - images

lists - lists

mapped-metrics - Manage mapped metrics

metric-aggregates - Manage metric aggregates

metric-properties - Manage metric properties

metrics - metrics

profile-bulk-import-jobs - Manage profile bulk import jobs

profile-import - Manage profile import

profile-merge - Manage profile merge

profile-subscription-bulk-create-jobs - Manage profile subscription bulk create jobs

profile-subscription-bulk-delete-jobs - Manage profile subscription bulk delete jobs

profile-suppression-bulk-create-jobs - Manage profile suppression bulk create jobs

profile-suppression-bulk-delete-jobs - Manage profile suppression bulk delete jobs

profiles - profiles

push-tokens - Manage push tokens

reviews - reviews

segment-series-reports - Manage segment series reports

segment-values-reports - Manage segment values reports

segments - segments

tag-groups - Manage tag groups

tags - tags

template-clone - Manage template clone

template-render - Manage template render

template-universal-content - Manage template universal content

templates - templates

tracking-settings - tracking settings

web-feeds - web feeds

webhook-topics - Manage webhook topics

webhooks - webhooks

Finding the right command

When you know what you want to do but not which command does it, ask the CLI directly:

klaviyo-pp-cli which "<capability in your own words>"

which resolves a natural-language capability query to the best matching command from this CLI's curated feature index. Exit code 0 means at least one match; exit code 2 means no confident match - fall back to --help or use a narrower query.

Recipes

Inspect a profile compactly

klaviyo-pp-cli profiles get --page-size 1 --json --select data.id,data.email,data.first_name

Fetch one profile and select only the fields an agent needs.

Find a revenue metric

klaviyo-pp-cli metrics list --json --select data.id,data.name | jq '.data[] | select(.name=="Placed Order")'

Locate the Placed Order metric before attribution or cohort work.

Run a launch QA gate

klaviyo-pp-cli plan qa-gate --campaign-id CAMPAIGN_ID --html ./email.html --json

Review offer, link, unsubscribe, compliance, date, and deliverability findings before launch. Missing or broken unsubscribe tags fail the gate. A fail verdict exits nonzero after printing JSON. With --campaign-id and no --html, the command fetches every email variation's assigned template HTML; SMS and push variations do not use email checks. Use {% unsubscribe %} as standalone text or {% unsubscribe_link %} inside the Unsubscribe anchor's href; use {% manage_preferences_link %} inside the Manage Preferences anchor's href. Kit {{ unsubscribe_url }} and {{ manage_preferences_url }} tags fail even when mixed with a valid Klaviyo link. campaigns deploy, campaign-message-assign-template, and campaign-send-jobs send-campaign block before writing when the check fails. templates create, templates update, and template-clone allow the write with a stderr and JSON warning for flow and transactional templates.

⚠️ Pitfall: Configuration Conflict - Client Profile vs Env Var

If a client profile is selected and KLAVIYO_API_KEY is present without an

env:KLAVIYO_API_KEY reference in that profile, the CLI refuses with:

Error: configuration conflict: KLAVIYO_API_KEY cannot override a selected client profile

Unset an unrelated legacy key, or explicitly bind it to the selected profile:

klaviyo-pp-cli client source set acme --credential-ref env:KLAVIYO_API_KEY --expected-account-id 'trusted-account-id' --expected-org-name 'Acme'
klaviyo-pp-cli --client-profile acme campaigns get --agent

Provider data commands are tenant-gated, so omitting the client profile is not

a supported workaround. If the key exists only as a legacy environment value,

bind an exact credential reference with client source set (or create the

profile with client add) before running data commands.

Run klaviyo-pp-cli client list --agent to see which profiles are configured.

Auth Setup

Use a tenant-gated client profile for every data command:

teach, recall, learnings, and playbook also run through the selected profile's live tenant gate and use that profile's database and learning journal. Learned IDs, queries, and playbooks do not cross clients; a saved --profile of command flags is separate from the --client-profile tenant selector.

klaviyo-pp-cli client add acme --credential-ref 'op://Example/Klaviyo/private-api-key' --expected-account-id 'trusted-account-id' --expected-org-name 'Acme'
klaviyo-pp-cli client validate acme
klaviyo-pp-cli --client-profile acme whoami --no-cache

On hosts without 1Password, use --credential-ref env:KLAVIYO_API_KEY with the

same expected identity flags. --username-ref and named

--additional-credential-ref values also accept env:NAME. The variable must be

set and non-empty at use time; every reference still runs the live tenant gate.

Profiles, receipts, and command output retain references or safe metadata only.

Keep raw values out of run profiles, receipts, logs, and argv.

Agent Mode

Add --agent to any command. Expands to: --json --compact --no-input --no-color --yes.

```bash

klaviyo-pp-cli accounts get --agent --select id,name,status

```

Response envelope

Commands that read from the local store or the API wrap output in a provenance envelope:

{
  "meta": {"source": "live" | "local", "synced_at": "...", "reason": "..."},
  "results": <data>
}

Parse .results for data and .meta.source to know whether it's live or local. A human-readable N results (live) summary is printed to stderr only when stdout is a terminal - piped/agent consumers get pure JSON on stdout.

Agent Feedback

When you (or the agent) notice something off about this CLI, record it:

klaviyo-pp-cli feedback "the --since flag is inclusive but docs say exclusive"
klaviyo-pp-cli feedback --stdin < notes.txt
klaviyo-pp-cli feedback list --json --limit 10

Entries are stored locally at ~/.klaviyo-pp-cli/feedback.jsonl. They are never POSTed unless KLAVIYO_FEEDBACK_ENDPOINT is set AND either --send is passed or KLAVIYO_FEEDBACK_AUTO_SEND=true. Default behavior is local-only.

Write what surprised you, not a bug report. Short, specific, one line: that is the part that compounds.

Output Delivery

Every command accepts --deliver <sink>. The output goes to the named sink in addition to (or instead of) stdout, so agents can route command results without hand-piping. Three sinks are supported:

| Sink | Effect |

|------|--------|

| stdout | Default; write to stdout only |

| file:<path> | Atomically write output to <path> (tmp + rename) |

| webhook:<url> | POST the output body to the URL (application/json or application/x-ndjson when --compact) |

Unknown schemes are refused with a structured error naming the supported set. Webhook failures return non-zero and log the URL + HTTP status on stderr.

Named Profiles

A profile is a saved set of flag values, reused across invocations. Use it when a scheduled agent calls the same command every run with the same configuration - HeyGen's "Beacon" pattern.

klaviyo-pp-cli profile save briefing --json
klaviyo-pp-cli --profile briefing accounts get
klaviyo-pp-cli profile list --json
klaviyo-pp-cli profile show briefing
klaviyo-pp-cli profile delete briefing --yes

Explicit flags always win over profile values; profile values win over defaults. agent-context lists all available profiles under available_profiles so introspecting agents discover them at runtime.

Exit Codes

| Code | Meaning |

|------|---------|

| 0 | Success |

| 2 | Usage error (wrong arguments) |

| 3 | Resource not found |

| 4 | Authentication required |

| 5 | API error (upstream issue) |

| 7 | Rate limited (wait and retry) |

| 10 | Config error |

Argument Parsing

Parse $ARGUMENTS:

  1. Empty, help, or --help → show klaviyo-pp-cli --help output
  2. Starts with install → ends with mcp → MCP installation; otherwise → see Prerequisites above
  3. Anything else → Direct Use (execute as CLI command with --agent)

MCP Server Installation

The server uses the generator's code-orchestration surface: klaviyo_search discovers endpoints, klaviyo_get returns GET endpoint metadata without an API call, klaviyo_read runs read-only requests, and klaviyo_execute handles mutations. Local search, read-only sql, context, and the hand-written command tools are also available; there is no separate tool for each endpoint.

klaviyo_execute returns a preview until confirm is boolean true; the string "true" does not confirm a write. Confirmed campaign sends and template assignments run the same unsubscribe checks as the CLI. Set PRINTING_PRESS_CLIENT_PROFILE to an already configured profile such as acme in the MCP server's environment; the server and its learning commands stay bound to that profile.

  1. Install the MCP server:

```bash

go install github.com/mvanhorn/printing-press-library/library/marketing/klaviyo/cmd/klaviyo-pp-mcp@latest

```

  1. Register with Claude Code:

```bash

claude mcp add klaviyo-pp-mcp -- klaviyo-pp-mcp

```

  1. Verify: claude mcp list

Direct Use

  1. Check if installed: which klaviyo-pp-cli

If not found, offer to install (see Prerequisites at the top of this skill).

  1. Match the user query to the best command from the Unique Capabilities and Command Reference above.
  2. Execute with the --agent flag:

```bash

klaviyo-pp-cli <command> [subcommand] [args] --agent

```

  1. If ambiguous, drill into subcommand help: klaviyo-pp-cli <command> --help.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.