Substack

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

Substack is an AI agent skill from the GitHub repository mvanhorn/printing-press-library. Run your Substack growth and authoring loop from the command line — publish rich drafts, manage a multi-publication portfolio, and measure what drives growth. Trigger phrases: `post a substack note`, `schedule a week of substack notes`, `find substack swap partners`, `which of my notes drove subs`,

How to use this skill

Skill file

Substack — Printing Press CLI

Prerequisites: Install the CLI

This skill drives the substack-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 substack --cli-only

```

  1. Verify: substack-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/media-and-entertainment/substack/cmd/substack-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

Reach for this CLI when an agent needs to operate a Substack publication end-to-end: posting Notes on a cadence, drafting and publishing long-form, engaging with niche writers, finding swap partners, and measuring which content actually drove subs. It is the right pick over WriteStack/StackSweller when you need agent-native plumbing (--json, --select, --dry-run, typed exit codes), offline-first analytics (every join runs locally over SQLite), or coverage of the writer surface those tools don't expose. Engage write actions (engage like, engage restack, engage restack-with-comment) print a curl-equivalent by default and only fire with --send; treat the print-curl output as a preflight, not a live action.

Unique Capabilities

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

Local state that compounds

_Pick this over a generic stats call when an agent needs to decide which Note formats to repeat next week._

```bash

substack-pp-cli growth attribution --days 30 --json --select rank,note_id,note_excerpt,subs_acquired,paid_subs_acquired

```

_Use when an agent is deciding whether to keep investing in a swap partner; surfaces relationships before they go stale._

```bash

substack-pp-cli engage reciprocity --days 30 --agent --select handle,outgoing,incoming,net,drift

```

Algorithm-aware automation

_Stops an agent from accidentally torching its own reach by dumping a queue all at once._

```bash

substack-pp-cli notes schedule --at 2026-05-10T13:00:00Z --body "hook line\n\nbody" --guard --json

```

_An agent picking when to schedule tomorrow's Notes can ask for the goal it's optimizing instead of guessing._

```bash

substack-pp-cli growth best-time --days 90 --for-goal subs --json --select day_of_week,hour,rate,sample_size

```

Pattern intelligence

_An agent drafting Notes can ask which hook shape currently outperforms in this niche before generating._

```bash

substack-pp-cli discover patterns --niche productivity --sort restacks --since 14d --agent --select pattern,sample_count,avg_restacks,avg_comments,top_example

```

_An agent drafting Notes for a ghostwriter client can verify the output stays inside the client's voice envelope._

```bash

substack-pp-cli voice fingerprint --handle maya --diff devon --json --select metric,self,other,delta

```

Network leverage

_An agent running a weekly cross-promo pass can rank candidates instead of pitching cold._

```bash

substack-pp-cli recs find-partners --my-pub on --top 20 --json --select rank,handle,pub,overlap_score,shared_followees

```

_An agent organizing a mutual-aid pod can see who's net-positive vs free-riding without a spreadsheet._

```bash

substack-pp-cli growth pod --members maya,devon,priya,jordan --days 30 --json

```

Authoring with rich field control

_Use when an agent is constructing a complete long-form post from structured data — research summary, translated copy, ghostwritten piece — and needs paywall, SEO, and section placement set in one command._

```bash

export SUBSTACK_PUBLICATION=mypub

substack-pp-cli drafts create --title "Why X matters" \

--body-file ./post.md --audience only_paid \

--seo-title "X explained" --seo-description "How X affects Y" \

--cover-image https://substackcdn.com/.../cover.jpg --json

```

Portfolio & analytics (local columnar store)

These commands read a local SQLite store populated by portfolio sync. The workflow is:

auth login --chrome  →  export SUBSTACK_PUBLICATION=<your-pub>  →  portfolio sync  →  portfolio / posts best / grep / subs churn / …

Custom-domain publications are supported: auth login --chrome captures the Creator-session cookie from the custom domain automatically.

```bash

export SUBSTACK_PUBLICATION=mypub

substack-pp-cli portfolio sync --json

```

```bash

substack-pp-cli portfolio --json

```

_Use when an agent is deciding which posts to twin into a new publication or surface in a weekly newsletter._

```bash

substack-pp-cli posts best --by restacks --window 30d --cross-pub --json

substack-pp-cli posts best --by views --limit 5 --publication mypub-en

```

```bash

substack-pp-cli posts twin my-en-slug --to mypub-de --dry-run --json

substack-pp-cli posts twin my-en-slug --to mypub-de

```

```bash

substack-pp-cli posts pair my-en-slug my-de-slug

substack-pp-cli posts pairs --missing --publication mypub-en --json

```

```bash

substack-pp-cli grep "yield curve" --json

substack-pp-cli grep "rate hike" --scope posts --publication mypub-en --since 2024-01-01

```

```bash

substack-pp-cli schedule board --days 30 --json

```

```bash

substack-pp-cli subs churn --snapshot

substack-pp-cli subs churn --since 7d --json --publication mypub-paid

```

```bash

substack-pp-cli subs cross-sell --json --limit 100

```

Command Reference

categories — Site-wide Substack category list — culture, technology, food, etc.

comments — Long-form post comments (distinct from Notes)

discover — Discovery surfaces — search publications, embed metadata

drafts — Drafts CRUD + publish + schedule

feed — RSS feed for a publication

images — Image upload (data-URI JSON, not multipart)

inbox — Authenticated reader feed (home feed) — Notes + posts surfaced for the current user

reader — Reader-side commands — subscriptions, following, and reading list

notes — Substack Notes — short-form posts (Substack treats Notes as comments internally)

grep — Full-text search across synced posts, notes, and comments

portfolio — Multi-publication status dashboard and data-population

posts — Long-form posts and archives on a specific publication

profiles — Substack profiles — your own and other writers'

recommendations — Substack Recommendations — outbound (publications I recommend)

sections — Sections of a publication (newsletters can have multiple)

settings — Account settings + connectivity probe (used by doctor)

schedule — Cross-publication editorial scheduling

subs — Subscriber count, churn diff, and cross-sell analytics

tags — Post tags

Freshness Contract

This printed CLI owns bounded freshness only for registered store-backed read command paths. In --data-source auto mode, those paths check sync_state and may run a bounded refresh before reading local data. --data-source local never refreshes. --data-source live reads the API and does not mutate the local store. Set SUBSTACK_NO_AUTO_REFRESH=1 to skip the freshness hook without changing source selection.

Covered paths:

When JSON output uses the generated provenance envelope, freshness metadata appears at meta.freshness. Treat it as current-cache freshness for the covered command path, not a guarantee of complete historical backfill or API-specific enrichment.

Finding the right command

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

substack-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

Daily growth-loop morning ritual

substack-pp-cli growth attribution --days 7 --agent --select rank,note_excerpt,subs_acquired

Surfaces yesterday's Note→sub winners. Pair with substack-pp-cli engage reciprocity --days 7 --agent to see whose engagement reciprocates yours, and substack-pp-cli sync --since 24h ahead of time to keep the local store fresh.

Schedule a Note with the cadence guard

substack-pp-cli notes schedule --at 2030-05-13T09:00:00Z --body 'Tuesday hook line' --guard --json

Queues the Note locally; --guard refuses scheduling if it lands within 30 min of an existing own-Note (typed exit 2 + JSON diagnosis). Drop --guard or add --send to fire immediately.

Find this week's swap partners

substack-pp-cli recs find-partners --my-pub on --top 5 --json --select rank,handle,pub,overlap_score

Ranks candidate publications by audience overlap; pipe to your draft-outreach tool of choice (substack-pp-cli does the ranking; outreach drafting is left to your agent's prompt).

Capture a writer's voice fingerprint as JSON

substack-pp-cli voice fingerprint --handle alice --diff bob --json

Mechanical voice metrics for the named handle, with a delta against another writer when --diff is set. Save the JSON yourself; agent generation prompts can ingest it.

Surface deeply nested Note metadata with --select

substack-pp-cli notes get c-12345 --agent --select id,body,attachments.url,attachments.image_url,attachments.published_bylines.name,attachments.published_bylines.handle,context.users.name

Notes responses are deeply nested (attachments, bylines, contextual users). Dotted --select narrows the payload so an agent doesn't burn context parsing 30KB of JSON it doesn't need.

Bootstrap the portfolio analytics store

substack-pp-cli auth login --chrome
export SUBSTACK_PUBLICATION=mypub
substack-pp-cli portfolio sync --json
substack-pp-cli portfolio --json

Run this once after login. Every cross-publication analytics command (posts best, grep, schedule board, subs churn, subs cross-sell) reads the local store that portfolio sync populates.

Publish a rich draft with SEO and cover image

export SUBSTACK_PUBLICATION=mypub
substack-pp-cli drafts create \
  --title "The case for X" \
  --subtitle "Three reasons it matters now" \
  --body-file ./post.md \
  --audience only_paid \
  --seo-title "Case for X" \
  --seo-description "Why X matters for Y" \
  --cover-image https://substackcdn.com/.../cover.jpg \
  --json

Converts the Markdown body to Substack's ProseMirror format automatically. The target publication is resolved from $SUBSTACK_PUBLICATION. Drop --audience only_paid for a public post.

Twin your best EN post into a DE publication

# Sync first so the local store has current posts
substack-pp-cli portfolio sync --json

# Find top post by restacks
substack-pp-cli posts best --by restacks --limit 1 --publication mypub-en --json

# Preview the twin operation, then create the draft
substack-pp-cli posts twin my-en-slug --to mypub-de --dry-run --json
substack-pp-cli posts twin my-en-slug --to mypub-de --json

Weekly subscriber churn digest

# Run this weekly (automate with a cron or agent schedule)
substack-pp-cli subs churn --since 7d --json --publication mypub-paid

First run ever needs a baseline: substack-pp-cli subs churn --snapshot. After that, --since 7d compares against the nearest snapshot within that window.

Full-text search across all your publications

substack-pp-cli grep "interest rates" --scope posts --json
substack-pp-cli grep "reader question" --scope notes --since 2025-01-01 --limit 20 --json

Auth Setup

Substack uses a session cookie (substack.sid). The only path today is auth login --chrome (also accepts --browser as an alias) — it reads the cookie from your logged-in Chrome via pycookiecheat / cookies / cookie-scoop-cli and stores it in the OS keyring. There is no password login and no manual cookie-paste subcommand. If your cookie expires, re-run auth login --chrome.

Run substack-pp-cli doctor to verify setup.

Agent Mode

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

```bash

substack-pp-cli categories list --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 AND no machine-format flag (--json, --csv, --compact, --quiet, --plain, --select) is set — piped/agent consumers and explicit-format runs get pure JSON on stdout.

Agent Feedback

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

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

Entries are stored locally at ~/.local/share/substack-pp-cli/feedback.jsonl. They are never POSTed unless SUBSTACK_FEEDBACK_ENDPOINT is set AND either --send is passed or SUBSTACK_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.

substack-pp-cli profile save briefing --json
substack-pp-cli --profile briefing categories list
substack-pp-cli profile list --json
substack-pp-cli profile show briefing
substack-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 substack-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

  1. Install the MCP server:

```bash

go install github.com/mvanhorn/printing-press-library/library/media-and-entertainment/substack/cmd/substack-pp-mcp@latest

```

  1. Register with Claude Code:

```bash

claude mcp add substack-pp-mcp -- substack-pp-mcp

```

  1. Verify: claude mcp list

Direct Use

  1. Check if installed: which substack-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

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

```

  1. If ambiguous, drill into subcommand help: substack-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.