Clip — Clean & Copy the Last Claude Message
Grabs the most recent prior assistant message in the current conversation,
runs it through the bundled reformatter (dist/clip/cli.js), and replaces the
macOS clipboard with the cleaned text in the requested format.
Designed for the case where the user wants to paste Claude's output somewhere
else (doc, email, Slack, Linear, a blog post) without the ⏺ bullet and
2-space indent that Claude Code applies to its rendered output.
Adapted from octavehq/claude-clip (MIT), reimplemented in TypeScript.
Modes
| Mode | What it does | Typical destination |
|---------|------------------------------------------------------------------------------|------------------------------|
| md | (default) Strip ⏺/indent, unwrap paragraphs, keep Markdown as-is | Linear, GitHub, Notion, docs |
| slack | Convert Markdown → Slack mrkdwn (**bold**→*bold*, headers→bold, tables→aligned code blocks) | Slack messages, threads |
| plain | Strip all Markdown syntax, keep the pure prose; links become label (url) | Email, SMS, plain-text notes |
| html | Convert Markdown → HTML (paragraphs, lists, headers, tables, inline formatting) | CMS, blog editors, email HTML |
How to interpret user intent:
/clipor/clip md→md/clip slackor "copy that for Slack" or "Slack mrkdwn" →slack/clip plainor/clip emailor "plain text" or "strip formatting" →plain/clip htmlor "HTML version" →html
What "the last message" means
"The last message" = the most recent assistant (Claude) message in the
conversation immediately before the user invoked /clip. Not the user's
message. Not an earlier assistant message. The single most recent assistant
turn's full prose content.
If /clip is invoked as the very first turn (no prior assistant message
exists), tell the user there's nothing to clip and stop.
Requirements
- Platform: macOS (uses
pbcopy). On Linux/Windows the pipe target would need to change (e.g.xclip -selection clipboard). - Node.js on
PATHand the plugin built (dist/clip/cli.jsexists).
How to Execute
Pipe the prior message through the reformatter into the clipboard using a
single Bash call with a quoted heredoc so the message text is passed
verbatim without shell expansion. Pass the mode via -m:
cat <<'CLIP_EOF' | node {pluginDir}/dist/clip/cli.js -m <MODE> | pbcopy
<paste the full text of your previous assistant message here, verbatim>
CLIP_EOF
Replace <MODE> with md, slack, plain, or html. If the user didn't
specify, use md.
Rules:
- Use the quoted heredoc form (
<<'CLIP_EOF') so$, backticks, and backslashes in the message stay literal. - If
CLIP_EOFappears inside the message body, pick a different unique delimiter (e.g.CLIP_EOF_7F3A). - Pass the message verbatim. Do not trim, summarize, rewrite, or otherwise modify the content — the CLI handles all whitespace and formatting normalization.
Then confirm with a single short line that includes the mode:
Clipped (slack). Paste with ⌘V.
Nothing more. Do not echo the cleaned output back to the chat unless the user explicitly asks to see it.
What NOT to do
- Do not summarize or paraphrase the previous message.
- Do not edit the previous message before piping it.
- Do not attempt to do the Markdown→Slack/HTML/plain conversion in your head — always pipe through the CLI. The CLI is deterministic; ad-hoc LLM conversion is not.
- Do not include tool-call blocks, tool results,
<system-reminder>content, or user messages in the clipped text. - Do not re-print the cleaned result to the chat by default.
What the reformatter does
dist/clip/cli.js reads stdin and writes stdout (src/clip/reformat.ts):
- Normalize CRLF → LF
- Strip any leading
⏺marker from lines - Parse into typed blocks: paragraphs, fenced code, separators
- Dedent fenced code blocks by the fence's own indent (so Claude's 2-sp indent is removed from code)
- Unwrap soft-wrapped paragraph lines (join with spaces, but start a new logical line on list items, headers, table rows, blockquotes, and
**Label:**patterns) - Apply the mode-specific renderer (
md,slack,plain,html)
Example
User's prior assistant turn was:
⏺ What Else
# Key insight
The **qual-doctor** skill has a [hidden](https://x.com) duplicate of the
ads-resonance prediction card system, and neither one knows about the
other yet.
- First item that wraps across
multiple lines
- Second item
User: /clip slack
Skill runs:
cat <<'CLIP_EOF' | node {pluginDir}/dist/clip/cli.js -m slack | pbcopy
⏺ What Else
# Key insight
The **qual-doctor** skill has a [hidden](https://x.com) duplicate of the
ads-resonance prediction card system, and neither one knows about the
other yet.
- First item that wraps across
multiple lines
- Second item
CLIP_EOF
Skill replies: Clipped (slack). Paste with ⌘V.