Skip to content

Felipevieiraemp/claude-code-paste-image

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

claude-code-paste-image

Paste clipboard screenshots directly into Claude Code on Windows with a single /paste command.

Platform Shell License


The problem

Claude Code's terminal accepts images by drag-and-drop from a folder, but Ctrl+V doesn't paste screenshots from the Windows clipboard. So whenever you Win+Shift+S or PrtScn something, you have to:

  1. Open Paint or a screenshot tool
  2. Save the image as a file
  3. Drag the file into the terminal

Three steps for something that should take zero. This package fixes that.

The fix

A custom /paste slash command. The flow becomes:

1. Take screenshot          →  PrtScn  or  Win+Shift+S
2. In Claude Code, type     →  /paste
3. Claude sees the image    →  done.

Under the hood, a tiny PowerShell script reads the bitmap from the Windows clipboard, saves it as a timestamped PNG in ~/.claude/clipboard-images/, and Claude reads the file — the image becomes a real visual attachment, identical to drag-and-drop.

Install

One-liner (recommended)

In any PowerShell window:

irm https://raw.githubusercontent.com/Felipevieiraemp/claude-code-paste-image/main/install.ps1 | iex

Then restart Claude Code so it picks up the new slash command.

Manual install

  1. Clone this repo (or download the ZIP).

  2. Copy the two files into your Claude config:

    Copy-Item commands\paste.md                  $env:USERPROFILE\.claude\commands\paste.md
    Copy-Item scripts\paste-clipboard-image.ps1  $env:USERPROFILE\.claude\scripts\paste-clipboard-image.ps1

    Create the commands\ and scripts\ folders first if they don't exist.

  3. Restart Claude Code.

Usage

[take screenshot with PrtScn or Win+Shift+S]

> /paste

Claude will:

  1. Run the PowerShell extractor
  2. Save the clipboard image as ~/.claude/clipboard-images/screenshot-<timestamp>.png
  3. Load the PNG as a visible attachment
  4. Briefly describe what was pasted (so you know it landed correctly)
  5. Wait for your next instruction

You can also pass arguments after /paste and they'll be appended to the prompt — for example:

> /paste explain what this error means

How it works

  • commands/paste.md — a Claude Code custom slash command. When you type /paste, this prompt template tells Claude exactly what to do: run the script, parse the output, and load the file with the Read tool.
  • scripts/paste-clipboard-image.ps1 — uses System.Windows.Forms.Clipboard.GetImage() to grab the bitmap, then Image.Save(..., ImageFormat.Png) to encode it. Outputs the file path on stdout, or ERROR: <reason> on failure.

That's the whole project. Two files, no dependencies, no daemons, no installers — just plumbing that should have been there to begin with.

Requirements

  • Windows 10 or 11 (uses Windows Forms clipboard APIs)
  • PowerShell 5.1+ — built into Windows, nothing to install
  • Claude Code — any recent version that supports custom slash commands in ~/.claude/commands/

Not on Windows? The same idea works on macOS (pngpaste + a wrapper script) and Linux (xclip -selection clipboard -t image/png -o). PRs welcome.

File layout after install

~/.claude/
├── commands/
│   └── paste.md                       ← the slash command
├── scripts/
│   └── paste-clipboard-image.ps1      ← the clipboard extractor
└── clipboard-images/                  ← saved PNGs (created on first paste)
    └── screenshot-20260509-143022-123.png
    └── screenshot-20260509-143108-456.png
    └── ...

The clipboard-images/ folder is never auto-cleaned — every paste leaves a file. Sweep it manually when it gets big:

Remove-Item $env:USERPROFILE\.claude\clipboard-images\*.png

Troubleshooting

/paste doesn't appear in the autocomplete list Restart Claude Code. Custom slash commands in ~/.claude/commands/ are loaded only at startup.

ERROR: no image in clipboard You haven't copied an image yet. Take a screenshot first (PrtScn or Win+Shift+S), or copy an image from any app, then run /paste again.

ERROR: failed to save PNG: Access to the path ... is denied The folder ~/.claude/clipboard-images/ isn't writable. Check your Claude config directory permissions.

Execution policy error The installer uses -ExecutionPolicy Bypass for that single invocation, so it should never trigger. If it does:

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned

The image looks wrong / has weird colors Some apps put non-bitmap formats on the clipboard (e.g. metafiles). The script only handles raster images. Copy the screenshot through Win+Shift+S (which always produces a PNG-compatible bitmap) and try again.

Uninstall

Remove-Item $env:USERPROFILE\.claude\commands\paste.md
Remove-Item $env:USERPROFILE\.claude\scripts\paste-clipboard-image.ps1
Remove-Item $env:USERPROFILE\.claude\clipboard-images\ -Recurse -Force

Restart Claude Code.

Contributing

Bugs, ideas, and PRs welcome — especially:

  • macOS port (pngpaste)
  • Linux port (xclip / wl-paste)
  • Auto-cleanup of old PNGs
  • Multiple-image clipboard handling

Open an issue or send a PR.

License

MIT — do whatever you want, no warranty.

About

Paste clipboard screenshots directly into Claude Code on Windows with a /paste slash command.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors