# Copy Paste Via File

> Whenever the assistant needs the user to copy-paste a command, code snippet, prompt, or any text where chat-rendered formatting could mangle line wrapping, regex literals, or string contents (e.g. DevTools console one-liners, terminal commands with quoted JSON, long URLs, multi-line prompts), write the exact text to a file and open it so the user can copy it clean. Use whenever the assistant is about to say "paste this command into..." or similar, especially for browser DevTools console pastes, complex shell commands, or anything containing regex literals, escaped quotes, or backticks.

- Skill: `cobuchan/copy-paste-via-file` (Agent Skill)
- Install (CLI): `npx skillmds@latest add cobuchan/copy-paste-via-file`
- Raw SKILL.md: https://api.skillmd.com/api/skills/cobuchan/copy-paste-via-file/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: cobuchan (https://skillmd.com/u/cobuchan)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/cobuchan/copy-paste-via-file

---


# Copy-Paste Via File

Chat-rendered code blocks can hard-wrap inside string literals and regex bodies when copied, producing `SyntaxError: Invalid or unexpected token` or silent corruption. Especially common when pasting into a browser DevTools Console, an SSH terminal, or a form field that doesn't normalize whitespace.

## When to Use

Trigger this skill whenever the assistant is about to ask the user to copy-paste any of:

- A DevTools Console one-liner (especially with regex literals like `/\s+/g`).
- A multi-quote, multi-escape shell command.
- A long URL with query parameters that may wrap.
- A multi-paragraph prompt body (system prompt, debate brief, email draft) where chat may add hanging indents.
- Any JSON literal embedded in a JS expression.

Skip when the snippet is short, single-token, and contains no escapes (e.g. a single CLI flag, a path, a 2-3 word answer). Trust the user's chat copy for those.

## How to Apply

1. Pick a stable, descriptive file path under the active project's working area, e.g. `~/projects/<project>/scratch/<short-name>.<ext>`. Reuse an existing path if the same kind of probe is being repeated.
2. Use the file extension that matches the destination (`.js` for DevTools, `.sh` for shell, `.txt` for prompts, `.sql` for queries).
3. Write the content with the `Write` tool. **Do not** add wrapping fences, language tags, or "copy this:" preamble. The file content is exactly what gets pasted.
4. Open the file in a plain-text editor via the shell (e.g. `open -a TextEdit <path>` on macOS) so the user can select-all / copy cleanly.
5. Tell the user the file path (one line), that the open command was run (one line), and what to do with the copied text (one line). No more.

## Example

User says: "I need to inspect every input on this signup page."

Assistant action:
1. `Write(~/projects/my-app/scratch/devtools-form-audit-probe.js, <one-line JS>)`
2. `Bash(open -a TextEdit <path>)`
3. Reply: "Saved to `<path>`. Opened in TextEdit. Select all, copy, paste into the DevTools Console, Enter."

## Why

- **No mangling.** A plain-text editor preserves exact bytes; chat copy can fold lines.
- **Auditable.** The exact pasted command stays on disk for replay or to share with another agent.
- **Faster on retries.** If the first paste fails, the user doesn't re-format from chat — they re-copy from the same file.

## Standing Authorization

Once you've validated this pattern works for your own workflow, treat it as standing permission — don't re-ask each time. Just do it whenever the trigger conditions match.

