Push draft

From schuettc/claude-code-plugins · View interactive version

Push draft is an AI agent skill from the GitHub repository schuettc/claude-code-plugins. Use to push a finished local Ghost draft to the Ghost site as a draft (never published) — pull-guards against in-editor edits, uploads the feature image, creates or updates the post, verifies links, and feeds the approved post back into the style guide. Triggers on "push this to ghost", "send the dr

How to use this skill

Skill file

Push a local draft to Ghost (draft-only)

You are pushing a finished local .md draft to the Ghost site as a draft. This skill never publishes or schedules — every push sets status: draft without exception. Work through each phase in order.


DRAFT-ONLY INVARIANT

status: draft on every single push. No exceptions.

Never set status: published, status: scheduled, or any non-draft status.

Never call a publish or schedule endpoint. If the author asks you to publish

directly, decline and return the editor URL — Ghost's UI is where publishing happens.

This invariant governs every phase below.


Phase 1: Load config

Read .claude/ghost.local.md and extract:

Read(".claude/ghost.local.md")

Fields you need:

If ghost.local.md does not exist, use the defaults above and note it.

Identify the target draft

If the author provided a path, use it directly. Otherwise list the files in drafts_dir and ask:

"I found these drafts in <drafts_dir>:

- <filename1>

- <filename2>

Which one should we push?"

Read the draft file:

Read("<drafts_dir>/<filename>.md")

Parse the frontmatter to extract:


Phase 2: Pull-guard (update path only)

This phase applies only when the draft frontmatter contains a slug (meaning the post already exists on Ghost). Skip to Phase 3 if slug is absent.

2a. Fetch the live post

ghost_post_get(slug="<slug>")

Capture:

2b. Reconstruct live content to text

Parse the lexical JSON to plain text (strip card wrappers, extract children[].text from each card). This produces the "live version" for diffing.

2c. Diff live vs. local

Compare the reconstructed live text against the body of the local .md file (below the frontmatter).

If the diff is empty or trivially whitespace-only — no in-editor changes detected. Proceed to Phase 3.

If the diff contains meaningful content changes — someone has edited the post in the Ghost UI since the local draft was last synced. You must fold those changes in before overwriting.

Fold the in-editor changes into the LOCAL file first:

  1. Show the author a summary of the diff:

> "The live Ghost post has been edited since your local draft was last synced. Here are the differences:

> ```diff

> <diff output>

> ```

> I'll merge these changes into your local file before pushing."

  1. Apply the live-post additions/changes to the local .md file. Where the live version and the local version conflict on the same passage, prefer the local version (the author's latest intent) but surface the conflict:

> "Conflict in section '<heading>': the Ghost version says X; your local draft says Y. I'm keeping your local version — let me know if you want the Ghost version instead."

  1. Write the merged result back to the local file:

```

Edit("<drafts_dir>/<filename>.md", <old body>, <merged body>)

```

  1. Pause and ask the author to review before continuing:

> "Merge complete — I've folded the live Ghost edits into your local draft. Please review the updated file above, then tell me to continue when you're ready."

Do not proceed to the next phase (feature image / push) until the author explicitly confirms.

Never push to Ghost without first resolving this diff. The pull-guard ensures you never silently clobber an in-editor edit.


Phase 3: Feature image upload

If the draft frontmatter contains a feature_image field, check whether it is a local file path (not an https:// URL already hosted on Ghost).

If local path:

ghost_image_upload(path="<feature image local path>")

The tool returns {url}. Record the returned url — you will pass it as feature_image in Phase 4.

If already an https:// URL — use it as-is; no upload needed.

If absent — no feature image; omit the field in Phase 4.


Phase 4: Resolve tags

Merge the tag list from three sources, in this order:

  1. Per-post tags from the draft frontmatter tags field.
  2. default_tags from ghost.local.md — always appended.
  3. early_access.tag from ghost.local.md — appended only if early_access.enabled: true.

Deduplicate. Then resolve each tag name to its canonical slug:

ghost_tag_list(limit=250)

Match each tag in your merged list against the returned slug values (case-insensitive). For tags that match, use the canonical slug. For tags that are not found, note them:

"Tag '<name>' not found in Ghost — it will be created as a new tag on push. Proceed?"

Wait for a "yes" or redirect before continuing if any new tags would be created.


Phase 5: Push as a draft

status: draft is mandatory. Do not deviate.

Determine the visibility for this post:

Create path (no slug in frontmatter)

ghost_post_create(
  title="<title>",
  markdown="<body content below frontmatter>",
  status="draft",
  tags=["<slug1>", "<slug2>", ...],
  visibility="<resolved visibility>",
  feature_image="<hosted URL or omit>"
)

Update path (slug present in frontmatter)

ghost_post_update(
  id="<id from Phase 2a>",
  title="<title>",
  markdown="<body content below frontmatter>",
  status="draft",
  tags=["<slug1>", "<slug2>", ...],
  visibility="<resolved visibility>",
  feature_image="<hosted URL or omit>"
)

Both tools return {id, slug, url, editorUrl, cardSummary, cardCount}.

After a successful push:

  1. Update the draft frontmatter slug field to the returned slug (so future pushes follow the update path):

```

Edit("<drafts_dir>/<filename>.md", <old frontmatter>, <new frontmatter with slug>)

```

  1. Return the editor URL to the author:

> "Draft pushed. Review and publish in Ghost when you're ready:

> <editorUrl>"

Never set status to anything other than "draft". If the Ghost API returns a non-draft status in the response, log a warning and do not continue — something is wrong.


Phase 6: Verify

Using the cardSummary and cardCount from the create/update response:

6a. Card structure check

Confirm the card count is non-zero and cardSummary shows the expected structure:

"Card structure confirmed: <cardCount> cards. Types: <cardSummary>."

If cardCount is 0 or cardSummary is empty, warn the author:

"Warning: the pushed post has 0 cards — the content may not have rendered correctly. Check the editor before publishing."

6b. Link verification

Scan the local draft body for outbound links (Markdown [text](url) patterns).

For each link:

  1. Internal design/journey docs — any link whose URL matches patterns like:

Do not include these links without asking:

> "The draft links to what appears to be an internal document: <url>. Should I keep this link in the published draft, or remove it?"

Wait for the author's explicit decision before proceeding on any internal-doc link.

  1. Public outbound links — note each one. Do not follow or validate URLs automatically. Do not make any HTTP requests to validate links — link verification is author-side review only (you flag suspicious or internal links; the author decides). Flag any that look suspicious (e.g. localhost, IP addresses, placeholder text):

> "Outbound links found: <count>. Please verify these are current and correct before publishing: <list>"


Phase 7: Feed the style guide

On a successful push that the author is happy with — once they confirm "looks good" or equivalent:

/ghost:build-style-guide

Pass the post ID returned by the create/update call so build-style-guide can fold this approved post into the living style guide via its Phase 5 (continuous merge path).

"I'll fold this approved post into the style guide now so future drafts match your voice."

If the author indicates they are not satisfied with how the post turned out (e.g. "the push worked but the content needs more work"), skip this step — do not fold in a post the author does not consider a good example of their voice.


Notes

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.