clipaste
AGENTS.md60 starsChanged 3 months agoMITView on GitHub
Instructions for coding agents working with clipaste — both installing it for a user and contributing to this repository. clipaste is a clipboard daemon that makes screenshot paste work in terminal AI tools (Claude Code, Codex CLI, Cursor CLI), locally on macOS/Windows and across SSH/WSL2 boundaries. Graphical Linux hosts provide read-only PNG clipboard capture for the SSH bridge. This is the entry point. It classifies the machine, runs the checks that are meaningful for that machine, and returns fix commands…
- Reads credentials
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository3 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- docs/llms-full.txtllms.txt
- docs/llms.txtllms.txt
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
22 rules. About 0 are common, 3 are distinctive, and 19 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
19
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 23
Do not guess at the state of a clipaste install — ask doctor.
- Distinctive: line 109
Do not reclassify those consumers as hosts.
- Very specific: line 146
Ensure the appropriate binary directory (~/.local/bin for the extracted archive or normally ~/.cargo/bin for Cargo) is on PATH.
- Very specific: line 168
All Wayland clipboard accesses use wl-paste --watch in bounded one-shot mode, which refuses popup fallback and verifies actual compiled-in …
- Very specific: line 177
Run host diagnostics as the same desktop user and in the same session.
- Very specific: line 182
No display produces actionable guidance to start from a graphical desktop or configure a consumer.
- Very specific: line 197
Keep cache directories 0700 and files 0600, with no automatic expiry.
- Very specific: line 204
Run this on the local macOS, Windows, or graphical Linux clipboard host, not on the remote consumer.
- Very specific: line 223
Run this inside the WSL2 distro, with clipaste.exe already running on Windows:
- Very specific: line 256
Never tell a user to press Cmd+V in an SSH session: that sends the *local* file path as text, which the remote agent cannot open.
- Very specific: line 276
Verify with clipaste doctor --json: the daemon check detail contains server-only.
- Very specific: line 284
Do not install a Linux systemd service automatically or present it as a fix for missing desktop access.
- Very specific: line 288
Do not classify all Linux machines as hosts or as unsupported-host: actual SSH sessions and configured headless consumers retain ssh-remote …
- Very specific: line 290
Do not bind the daemon to 0.0.0.0 or add firewall exceptions to "fix" connectivity.
- Very specific: line 293
Do not write shims by hand.
- Very specific: line 295
Do not kill -9 the daemon to restart it.
- Very specific: line 298
Do not report success without a passing clipaste doctor.
- Very specific: line 365
Generated shell must be syntax-checked in tests: Every shim and setup script is asserted against bash -n.
- Distinctive: line 368
No silent fallbacks: When detection fails, list what was tried and why, and say what the user should do.
- Distinctive: line 379
Run the Release workflow manually on the release commit to validate packaging without publishing.
- Very specific: line 383
After validation, tag vX.Y.Z and push.
- Very specific: line 385
Update the Homebrew formula in hqhq1025/homebrew-clipaste.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Instructions for coding agents working with clipaste — both installing it for a user and contributing to this repository.
clipaste is a clipboard daemon that makes screenshot paste work in terminal AI tools (Claude Code, Codex CLI, Cursor CLI), locally on macOS/Windows and across SSH/WSL2 boundaries. Graphical Linux hosts provide read-only PNG clipboard capture for the SSH bridge.
Part 1 — Installing clipaste for a user
The one command that tells you what to do
clipaste doctor --jsonThis is the entry point. It classifies the machine, runs the checks that are
meaningful for that machine, and returns fix commands or guidance where available.
Do not guess at the state of a clipaste install — ask doctor.
{
"version": "2.4.1",
"os": "macos",
"role": "clipboard-host",
"status": "warn",
"checks": [
{
"name": "daemon",
"status": "ok",
"detail": "daemon responding on 127.0.0.1:18340",
"fix": null
},
{
"name": "clipboard",
"status": "warn",
"detail": "no image staged yet — take a screenshot, then re-run doctor",
"fix": null
}
]
}| Field | Contract |
role | clipboard-host / ssh-remote / wsl2 / unsupported-host decides which checks apply |
status | worst of all checks: ok, warn, fail |
checks[].status | ok / warn / fail |
checks[].fix | a remediation command or guidance, or null when no single command applies |
| exit code | 0 usable (ok or warn), 1 broken, 2 bad arguments |
A warn is not a failure. "No screenshot on the clipboard yet" is the normal
state of a freshly installed machine — do not report it to the user as a
problem, and do not try to fix it.
Consumers of the JSON output must accept unsupported-host for platforms
without a backend. Do not apply it to Linux as a whole: Linux host diagnostics
must distinguish missing tools, missing session access, and missing compositor
data-control from consumer helper or bridge failures.
Decide where you are before installing anything
clipaste has two sides and they install differently. Getting this wrong is the single most common mistake.
| OS / context | Local clipboard-host daemon | Consumer of another host's clipboard |
| macOS | Supported | SSH remote via clipaste-paste |
| Windows | Supported | Via WSL2 |
| Native Linux desktop | Read-only image/png via Wayland data-control or X11/XWayland | Supported over SSH via shims / clipaste-paste |
| Headless Linux | No display; host startup fails with guidance | Supported with configured helpers / SSH |
| WSL2 | No; the Windows daemon is required | Supported via wsl-setup |
Clipboard host Consumer
macOS / Windows / graphical Linux
PNG cache -> loopback HTTP -> SSH tunnel -> SSH remote
run ssh-setup on this host shims / clipaste-paste
Windows -> HTTP over WSL networking -------> WSL2
Windows daemon run wsl-setup inside the distro
Local macOS / Windows: existing clipboard normalization and paste
(skipped with CLIPASTE_SERVER_ONLY=1; HTTP serving remains)
Local Linux: read-only PNG capture, no added text-path pasteclipaste doctor --json reports which side you are on as role. Trust it over
uname: an SSH session into a Mac is ssh-remote, not clipboard-host.
The role contract applies in this order:
- WSL context:
wsl2, even if SSH environment variables are also present. - An actual SSH session:
ssh-remote, including SSH into macOS. - A local macOS or Windows machine, or graphical local Linux session:
clipboard-host. Linux backend access still needs validation. - A headless Linux machine with a configured consumer helper:
ssh-remote, even without SSH environment variables; keep checking its helper and bridge. - Linux without a display or consumer indicators:
clipboard-hostwith a failingbackendcheck and actionable graphical-session guidance. Other platforms without a backend or consumer indicators retainunsupported-host.
WSL remains a Windows consumer even when WSLg supplies display variables. SSH session detection takes precedence over a Linux desktop's display variables. Do not reclassify those consumers as hosts.
Install on the clipboard host
macOS:
brew install hqhq1025/clipaste/clipaste
brew services start clipaste
clipaste doctor --jsonWindows (PowerShell, no admin needed):
irm https://raw.githubusercontent.com/hqhq1025/clipaste/main/install.ps1 | iex
clipaste doctor --jsonLinux desktop (Ubuntu package example):
sudo apt install wl-clipboard xclip curlReleases since v2.5.0 include static Linux archives for x86_64-unknown-linux-musl
and aarch64-unknown-linux-musl. Download the matching architecture, verify
against the release's SHA256SUMS, extract it, then:
install -Dm755 clipaste "$HOME/.local/bin/clipaste"
export PATH="$HOME/.local/bin:$PATH"
clipasteSource installation with Rust/Cargo is also supported:
cargo install --git https://github.com/hqhq1025/clipaste --tag v2.6.0 --locked.
Ensure the appropriate binary directory (~/.local/bin for the extracted
archive or normally ~/.cargo/bin for Cargo) is on PATH. Start
clipaste as the desktop user in a graphical-session terminal and leave it
running. No Linux service or auto-start entry is installed. In a separate
terminal from that same session, run:
clipaste doctor --json
clipaste ssh-setup user@hostFor development, cargo build --release works from the checkout. Linux retains
doctor and consumer setup, including wsl-setup; do not add a blanket
compile_error! gate that blocks consumer machines.
Linux backend and verification contract
CLIPASTE_BACKEND=autois the default. Prefer real systemwl-pastewith usable data-control access; otherwise warn and use systemxclipthrough an accessibleDISPLAY, or fail with actionable guidance if unavailable. HTTP consumer shims do not count as system clipboard tools.- Native Wayland requires
wl-clipboard >=2.2for empty-selection watch events. All Wayland clipboard accesses usewl-paste --watchin bounded one-shot mode, which refuses popup fallback and verifies actual compiled-in data-control support. Ext-only compositors needwl-clipboard >=2.3built withext-data-controlsupport;wlr-data-controlworks with compatible 2.2+ builds. Version 2.1.x triggers theautoXWayland fallback or fails withoutDISPLAY; a version number alone does not establish protocol support. CLIPASTE_BACKEND=waylandrequires native data-control access and fails instead of falling back.CLIPASTE_BACKEND=x11requiresxclipand an accessibleDISPLAY. Use the same override for the daemon anddoctor.- Run host diagnostics as the same desktop user and in the same session.
Wayland needs
WAYLAND_DISPLAYandXDG_RUNTIME_DIR; X11/XWayland needsDISPLAYand display authorization. SSH,sudo, stale tmux environments, and services can lack that context. Setting a variable alone does not establish display access. - No display produces actionable guidance to start from a graphical desktop or
configure a consumer. Wayland-only sessions without data-control must fail
with guidance to use XWayland (
xclip+DISPLAY) or an X11 session. Never use focus-stealing windows or arbitrary forced-focus Wayland polling. - GNOME Wayland may require its XWayland clipboard bridge. Require reporters
to copy a screenshot from a native Wayland app, re-run
doctor, then verify the image fetched on the remote withclipaste-paste. An X11-only test is insufficient, and a backend probe is not universal compatibility evidence. - Linux polls every 300 ms and reads
image/pngwithout modifying the clipboard. It saves to the private stable PNG cache, then serves through existing loopback HTTP and SSH shims /clipaste-paste. It does not add file URLs or text, and does not promise local terminal text-path paste. Image file-copy offering only a URI is not supported yet. - Clipboard clears, non-image content, and recognized private markers clear
the staged image. Historical cache paths remain; this is not cache erasure.
Keep cache directories
0700and files0600, with no automatic expiry. - Preserve existing macOS/Windows clipboard normalization and paste workflows. Linux tests do not establish macOS/Windows regression coverage or universal desktop compatibility; report exactly which platforms were verified.
Wire up an SSH remote
Run this on the local macOS, Windows, or graphical Linux clipboard host, not on
the remote consumer. It needs the local daemon running, and it edits the local
~/.ssh/config.
clipaste ssh-setup user@host # non-interactive; idempotent
clipaste ssh-setup user@host -p 22222 # custom SSH portIt detects the remote OS itself and installs the right helpers. Then the user
must open a new SSH session — the RemoteForward tunnel only exists in
sessions started after the config change. Verify from inside that new session:
clipaste doctor --json # role should be "ssh-remote", status "ok"Wire up WSL2
Run this inside the WSL2 distro, with clipaste.exe already running on Windows:
clipaste wsl-setup # probes for the Windows host address
clipaste wsl-setup --host 127.0.0.1 # skip probing, use this addressBoth networkingMode=mirrored and the default NAT mode are handled. If setup
reports that nothing answered, read its output — it lists every address it tried
and why, and states plainly that NAT-mode WSL cannot reach a loopback-bound
daemon.
Tell the user the right paste gesture
This differs per tool and per location, and telling a user the wrong one wastes their time:
| Where | Claude Code / Cursor CLI | Codex CLI |
| Local terminal (macOS / Windows) | Cmd+V (macOS) / Ctrl+V | Cmd+V (macOS) / Ctrl+V |
| SSH into Linux | Ctrl+V | clipaste-paste, then paste the printed path |
| SSH into macOS | clipaste-paste | clipaste-paste |
| WSL2 | Ctrl+V | clipaste-paste, then paste the printed path |
Codex CLI reads the clipboard in-process (via arboard) and never shells out to
xclip, so it cannot use the shim. clipaste-paste writes the image to a real
file on the current host and prints the path — hand that path to the tool.
The local shortcut row does not apply to Linux hosts. Linux serves clipboard PNG images to remote consumers without inserting a local text path. It also does not apply to a macOS/Windows daemon in server-only mode (below).
Never tell a user to press Cmd+V in an SSH session: that sends the local
file path as text, which the remote agent cannot open.
Server-only mode
The macOS/Windows daemon adds a file path to the local clipboard after each
screenshot. Offer CLIPASTE_SERVER_ONLY=1 when the user only pastes into
agents over SSH or WSL2, or reports that GUI apps paste a path instead of the
image (on Windows the rewrite drops the bitmap). The daemon then leaves the
clipboard as copied and still serves images to remote consumers. Do not enable
it for a user who pastes screenshots into local terminals: those rely on the path.
- Windows:
setx CLIPASTE_SERVER_ONLY 1, set$env:CLIPASTE_SERVER_ONLY = "1"in the same PowerShell, then stop and restartclipaste.exefrom it. The Run entry and reinstalls keep the setting. - macOS:
brew servicescannot pass environment variables. Replace it with a LaunchAgent that setsEnvironmentVariables, following the README recipe, and restart that agent withlaunchctl kickstart -k, notbrew services restart. - Linux never modifies the clipboard; the variable changes nothing there.
Verify with clipaste doctor --json: the daemon check detail contains
server-only. If it does not, the running daemon did not receive the variable
or predates the mode (v2.5.0 and earlier ignore it). Values other than 1 and
0 stop the daemon at startup. In this mode, no path on the local clipboard is
expected; do not report it as a fault.
Things not to do
- Do not install a Linux systemd service automatically or present it as a fix
for missing desktop access. Follow the reported tool/session/data-control
guidance. For a consumer, run
ssh-setupon its clipboard host and reconnect; WSL2 still requires the Windows daemon andwsl-setupinside the distro. - Do not classify all Linux machines as hosts or as
unsupported-host: actual SSH sessions and configured headless consumers retainssh-remotediagnostics. - Do not bind the daemon to
0.0.0.0or add firewall exceptions to "fix" connectivity. It listens on loopback deliberately; the image bytes on that port are the user's screen contents. - Do not write shims by hand.
ssh-setup/wsl-setupgenerate them with the correct URL baked in; a hand-written one drifts silently. - Do not
kill -9the daemon to restart it. Usebrew services restart clipaste(macOS), stopclipaste.exenormally (Windows), or Ctrl+C in its graphical terminal (Linux). - Do not report success without a passing
clipaste doctor. "The install command exited 0" is not the same as "paste works". On Linux, also verify a real screenshot end to end, especially when XWayland fallback is reported.
Part 2 — Contributing to this repository
Layout
src/
├── main.rs CLI entry + argument parsing (one parser per subcommand)
├── common.rs version, port, temp-file handling, image conversion, http_get
├── server.rs HTTP server on 127.0.0.1:18340 (/health, /clipboard/type, /clipboard/image)
├── doctor.rs environment classification + checks + human/JSON rendering
├── ssh_setup.rs shim templates, ssh-setup, wsl-setup, host detection
├── linux.rs read-only PNG polling via system wl-paste / xclip (cfg linux)
├── macos.rs NSPasteboard watcher (cfg macos)
└── windows.rs clipboard-format listener (cfg windows)Build and test
cargo build
cargo test # must stay green; no network access required
cargo clippy --all-targetsThe default cargo test suite runs without a daemon, without a network, and
without touching the real $HOME. Keep that default isolated; anything that
needs a home directory must take one via an env override, as
remote_script_run_installs_into_empty_home does.
Opt-in Linux desktop integration tests use real clipboard tools in isolated
Xvfb and headless Sway sessions, with temporary HOME/cache/runtime directories.
They do not use the real user's clipboard. From the repository root on Linux,
with Rust/Cargo, Clippy, and loopback port 18340 free:
sudo apt install xvfb xclip sway wl-clipboard dbus-x11 python3-pil curl
bash tests/linux/run.shThe Sway tests require wl-clipboard >=2.2; upgrade older distro packages first.
The runner executes unit tests, strict Clippy, and clipboard/HTTP smoke tests.
Alternatively, the existing container recipe builds wl-clipboard 2.3.0; run it
without mounting desktop sockets or the user's home:
docker build -f tests/linux/Dockerfile -t clipaste-linux-test .
docker run --rm clipaste-linux-testIsolated Xvfb/Sway coverage does not establish compatibility with GNOME, ext-only compositors, or the reporter's native application.
Conventions this codebase holds to
- No new dependencies without a strong reason. The point of clipaste is that
it stays lightweight. Linux uses distro clipboard tools with 300 ms polling;
do not apply macOS/Windows idle measurements to it. HTTP is
curl; JSON output is hand-rolled incommon::json_escape. If you need serde, justify it. - Pure functions for anything with logic. Parsing, ordering, config
rewriting, and rendering are all separated from I/O so they can be tested
directly — see
wsl_host_candidates,build_ssh_config,render_json. - Generated shell must be syntax-checked in tests. Every shim and setup
script is asserted against
bash -n; a typo there would only ever fail on a user's remote host. - No silent fallbacks. When detection fails, list what was tried and why, and say what the user should do. A green tick that hides a broken tunnel is worse than a red one.
- Comments explain why, not what. Assume the reader can read Rust.
Releasing
- Bump
versioninCargo.tomlandVERSIONinsrc/common.rs— they must match;doctorcompares the running daemon's reported version against the binary's and warns on skew. cargo test && cargo clippy --all-targets- Run the Release workflow manually on the release commit to validate packaging without publishing. It builds macOS (aarch64 + x86_64), Windows x86_64, and static Linux musl (aarch64 + x86_64) artifacts. Linux release binaries run through the isolated Xvfb/Sway smoke tests on native architecture runners.
- After validation, tag
vX.Y.Zand push. The same workflow builds and publishes the artifacts withSHA256SUMS. Never rewrite an existing release tag. - Update the Homebrew formula in
hqhq1025/homebrew-clipaste.
When fixing a reported issue
Reproduce the failure shape in a test before fixing it. The WSL mirrored-mode bug (#7) is the model: the fix is a handful of lines, but the tests encode every networking mode so the next change cannot silently break the others.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

