Feature Request: Add /copy command to copy messages to clipboard
Open 💬 25 comments Opened Aug 10, 2025 by NightMachinery
Feature Request: /copy [N=1] slash command
Summary
Add a /copy slash command that copies the last N Claude Code messages as Markdown to the OS clipboard.
Proposed Usage
/copy # Copies the last message (Claude's response)
/copy 3 # Copies the last 3 messages (alternating user/Claude)
/copy 5 # Copies the last 5 messages
Expected Behavior
- Default N=1 (copies just Claude's last response)
- Messages should be copied as properly formatted Markdown
- Should include both user messages and Claude responses when N > 1
- Should integrate with OS clipboard (works with Cmd+V/Ctrl+V)
- Should preserve code blocks, formatting, and structure
Use Cases
- Quickly share Claude's responses in documentation
- Copy code snippets and explanations for use elsewhere
- Archive conversation snippets for later reference
- Share troubleshooting responses with team members
Implementation Notes
- Should work across platforms (macOS, Linux, Windows)
- Consider using a clipboard library like
pyperclipor similar - Messages should maintain original formatting and structure
- Could potentially support additional formats (plain text, HTML) as options
This would significantly improve the workflow when working with Claude Code responses that need to be shared or documented elsewhere.
25 Comments
Found 1 possible duplicate issue:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
need this
Need this too, would be nice if it was native but found this
https://github.com/Twizzes/copy-claude-response
need this
Please add this because a lot of times I want to copy the claude message to a colleague on slack.
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
This would be extremely helpful!
Fwiw a hack I use: if the message has some uniquely identifiable piece, you can grep for that in
~/.claude. Here's a one-liner to copy the markdown to clipboard:Another workaround is to create your own
/copycommand. I use the following that also also supports:**bold inline heading** - description textformat````
---
description: Copy last response to clipboard
allowed-tools: Bash
---
Copy the last assistant response to the clipboard.
Arguments
$ARGUMENTS
Instructions
**bold** - text→**bold:** text(replace dash separator with colon after bold terms)—) → Rewrite as two complete sentences, rephrasing if neededDefault Mode
Copy the content using
pbcopywith a heredoc. Use the exact text without any code block indentation or markdown fences.Slack Mode
Convert the content to HTML and copy using AppleScript so Slack's default editor accepts it:
# Headingor## Heading→<b>Heading</b><br>**text**→<b>text</b>- itemor• item→ list items, wrap in<ul><li>...</li></ul>, add single<br>after</ul>or</ol><br>)<br><br><br>``
bash
``html='[your HTML here]'
hex=$(echo -n "$html" | hexdump -ve '1/1 "%.2x"')
osascript -e "set the clipboard to {text:\" \", «class HTML»:«data HTML${hex}»}"
---
After copying, say "Done" - nothing more.
````
While waiting for native support, I made a minimal skill that adds
/yankfor clipboard access:https://github.com/joelev/yank
Install:
It's ~40 lines, cross-platform (macOS, Linux, Windows via WSL), and uses the platform info Claude Code already provides in context—no detection scripts. Claude will also offer to yank when generating prompts or snippets.
Not a replacement for a proper native command, but scratches the itch for now.
i am using
find session id with
/status, then e.g.ccopy 01ef658c-19ec-42b9-83f5-89a8c5c2f524or with text
ccopy ref typetakes the latest project and latest message and increases to later answers if not found
not perfect in any away, but improving.
Btw, I would also like to have just
/copy nto copy the last responses...+1 on this. I primarily use Claude Code through the VS Code extension, and the lack of any copy/share mechanism is a real pain point.
The web UI (claude.ai) has a simple copy button on each message - I'd love to see the same in the VS Code panel. Right-click → "Copy as Markdown" on individual messages, or a way to select a range of messages and copy them. The /copy N command proposed here would also work great in VS Code's input.
There's support for
/copysince https://github.com/anthropics/claude-code/releases/tag/v2.1.20, but no parameters yet, AFAICS.I can confirm that /copy is now supported from the latest version.
Yes, it was implemented. However, it has bugs: the
/copycommand sometimes hangs indefinitely, requiring you to press Ctrl + C to abort it and then retry. This might deserve a separate issue.Nice! Up until now i've just been telling Claude "pbcopy the last message". This consistently worked, but fewer characters to type makes me happy :).
Building on @pokey's one-liner and @MarkusJLechner's
ccopy, here's a version I've been using that adds a few things:-pproject filter with substring matching — e.g.-p dotfilesmatches the project dir-Users-me--dotfilesRequires:
rg,jq. Optional:fzf.Examples:
For browsing and searching sessions visually, claude-history is excellent — and there's a PR pending to add message copying there too. Even so, this function stays useful as a standalone alternative with no external dependencies beyond
rgandjq.Complements
/copynicely —/copygrabs from the current session,ccopysearches across all past conversations.+1 on this. This is especially painful when claude streams responses from subagents and main thread intermittently, in response to a single prompt. In that case, you only get the last section of the response from
/copy. Usingesc + escallows you to roll back between prompts, so it doesn't help to granulate the copy action.Example prompt
Outcome for
/copyWhichever activity completes first, the search or the edit, prints. When the next completes, it prints too.
/copyonly pasteboard-copies the latter.can we say that this is fixed with https://github.com/anthropics/claude-code/releases/tag/v2.1.77 ?
Why do I not see this available in the Claude extension panel if it is supported?
<img width="616" height="125" alt="Image" src="https://github.com/user-attachments/assets/953cddde-328a-4f4e-8ad4-75787e1aacf6" />
I also don't see it in the available slash commands menu:
<img width="616" height="398" alt="Image" src="https://github.com/user-attachments/assets/38046a73-fc44-46ef-884d-487d9e1b26f6" />
While native
/copyisn't available yet, you can get similar functionality with a custom skill + Bash:1. Create a
/copyskill:2. Or use a PostToolUse hook for automatic copying:
Save as
~/.claude/hooks/auto-copy-response.sh:3. Quickest workaround — just ask Claude:
Tell Claude: "Copy your last response to my clipboard" — it will use the Bash tool to
echo "..." | pbcopy(or equivalent).Not as clean as a native
/copy Ncommand, but functional today.They added it, but it works like crap: only copies one line in a multi-tool call agentic response.
Frustratingly bad experience. All other harnesses allow you to copy messages easily.
In VS Code you can use the following workaround, as long as
/copyis not available in claude code extension:/resumein terminal and choose the session from claude code extension/copyin terminalThe core ask is simple: use soft wrapping for code block content only — emit long lines without inserting hard \n
characters, and let the terminal emulator handle visual wrapping. The TUI chrome (spinners, separators, progress
bars) can keep using terminal width — only code block text needs to change.
Why this matters:
artifacts instead of a runnable one-liner
/copy works but requires an extra step every single time
not planned, same root cause)
The fix is surgical: don't call the hard-wrap renderer for fenced code block content. Emit the raw line and let the
terminal wrap it visually. This is standard behavior for every other terminal tool that outputs code.
It's very tedious and also if you forget to exit the resumed conversation from CLI and send a message in chat within the extension, you might corrupt your chat history and/or make it unfork'able/unrewind'able.
I don't understand how they still don't have copy UI when every single harness does. GHCP even allows to copy the entire conversation, even a very long one, in one click.