skill
copy-to-clipboard-plugin
Claude Code plugin: copy queries, shell commands and config snippets from Claude's responses to your clipboard — macOS, Linux, Windows, and over SSH
Set up
Skills are installed by placing their folder where your agent loads skills.
The download comes from github.com/harleensahni/copy-to-clipboard-plugin itself, not from our server, so what you get is exactly what its author published.
Install instructions come from the README
README
synced Oct 22, 2026copy-to-clipboard
A Claude Code skill that copies useful output — queries, shell commands, config snippets, JavaScript for the browser console — straight to your clipboard.
Two reasons that beats selecting the text yourself. The obvious one is that you don't have to: no dragging across a wrapped block in scrollback, no clipping the last character, no reaching for the mouse at all. The less obvious one is that terminal selection is lossy — a long command that hard-wrapped at the window edge comes back with line breaks that were never in it, and you pick up leading indentation, gutter characters, and box-drawing from whatever framed the output. Paste that into a shell and it breaks, usually somewhere non-obvious. Multi-line content is where it hurts most: a wrapped curl, a SQL query, a YAML block, a JS snippet for the console.
Works on macOS, Linux and Windows, and over SSH, where it hands the text to your local terminal instead. Every platform is covered by a real copy-and-read-back test in CI, not just detection logic.
Two modes:
- Proactive — when Claude's response includes text you'll need to paste somewhere external (a Grafana query, a shell command to run yourself, a config snippet, a JS one-liner for the devtools console), it shows the text inline as usual and then asks whether to copy it to your clipboard.
- User-invoked — type
/clipboard:copyto copy the most recent copyable block from Claude's last response, or name a target:/clipboard:copy the sql query. No confirmation prompt in this mode.
It deliberately skips things that don't belong on the clipboard: code that lives in a diff/commit, file:line citations, and secrets you didn't explicitly ask to copy.
Requirements
Claude Code, plus a clipboard tool for your platform. scripts/copy.sh picks one automatically:
| Platform | Uses | Preinstalled? |
|---|---|---|
| macOS | pbcopy | Yes |
| Windows (WSL or Git Bash) | clip.exe | Yes |
| Windows (no Git for Windows) | PowerShell Set-Clipboard | Yes |
| Linux — Wayland | wl-copy | No — sudo apt install wl-clipboard |
| Linux — X11 | xclip or xsel | No — sudo apt install xclip |
Linux is the only case that usually needs an install. When nothing is available the skill reports the install command for your distro instead of silently doing nothing.
Over SSH
When Claude Code runs on a remote machine, that machine has no clipboard worth copying to — you want the text on the laptop in front of you. Setting CLIPBOARD_BACKEND=osc52 switches to an escape sequence your local terminal interprets, so the text lands on your real clipboard across the SSH connection:
CLIPBOARD_BACKEND=osc52 skills/copy/scripts/copy.sh < some-file
Works in iTerm2, kitty, WezTerm and Windows Terminal, and inside tmux (the sequence is wrapped in a DCS passthrough automatically). Apple's Terminal.app does not support it. Non-ASCII text survives the trip.
One caveat worth knowing: the terminal never reports back, so a copy that a terminal silently ignores looks identical to one that worked. That is why this is opt-in rather than an automatic fallback.
Install
/plugin marketplace add harleensahni/copy-to-clipboard-plugin
/plugin install clipboard@harleen-skills
Then restart Claude Code (or run /reload-plugins). Invoke with:
/clipboard:copy [optional target]
The proactive mode activates on its own whenever a response contains paste-elsewhere text.
Example
Proactive mode — you ask for something you'll paste elsewhere, and the skill offers the clipboard without you asking:
> what's the PromQL for p99 request latency by route?
histogram_quantile(0.99,
sum by (le, route) (rate(http_request_duration_seconds_bucket[5m]))
)
Paste that into Grafana Explore with the range set to at least 15m —
the 5m rate window needs a couple of scrapes to settle.
┌─ Copy PromQL p99 latency query to clipboard? ─┐
│ > Yes │
│ No thanks │
└───────────────────────────────────────────────┘
Copied.
User-invoked mode — nothing was offered, or you want an earlier block. Name the target, or leave it off to grab the most recent one:
> /clipboard:copy the migration command
Copied: the sqlx migrate run command.
Layout
.claude-plugin/
├── plugin.json plugin manifest
└── marketplace.json marketplace catalog (this repo doubles as its own marketplace)
skills/
└── copy/
├── SKILL.md the skill itself
└── scripts/
└── copy.sh platform detection + the actual copy
tests/
├── run-tests.sh the suite
├── with-display.sh starts headless X11 or Wayland, then runs the suite
├── run-in-container.sh runs the Linux half locally via podman/docker
└── Containerfile Debian + xclip, xsel, Xvfb, wl-clipboard, sway
Validated with claude plugin validate --strict.
Tests
tests/run-tests.sh # this machine's platform
tests/run-in-container.sh # Linux, against real X11 and Wayland servers
Detection tests are hermetic — each builds a throwaway PATH holding only the tools a given platform would have, so a simulated Wayland box can't accidentally find the host's pbcopy. That covers macOS, WSL (including WSLg, where the Windows clipboard must win over the Linux display vars), Git Bash, Wayland, X11, and the no-clipboard-installed case.
On top of that, every stack gets a real round-trip — copy, then read back — against an actual clipboard: pbcopy locally, xclip under Xvfb, wl-copy under headless sway, and clip.exe on Windows CI (including a non-ASCII payload, which is what the UTF-16LE conversion is for). The OSC 52 path is checked by allocating a pty and asserting the exact escape sequence, plain and tmux-wrapped.
CI runs the suite on Linux, macOS and Windows on every push.