Clipboard Patch System

A clipboard-driven code editing toolkit for working with AI assistants without IDE integration. Copy structured output, type a short alias, and edits apply with backups and syntax checking.

PowerShell 7 — Quick Install
PS> irm https://tools.2k09labs.com/downloads/install.ps1 | iex
PowerShell 7 AutoHotkey v2 AI-Optimized Workflow

How It Works

The AI formats edits in a structured clipboard format. You copy, press a hotkey, and the system applies them.

🤖
AI Generates Edit
Structured batch format
with file headers
📋
Copy to Clipboard
Select the code block
and copy
⌨️
Press Hotkey
Win+Shift+Enter
or type alias
Applied + Verified
Auto-backup, syntax check,
results to clipboard

Edit Commands

Each command reads structured content from your clipboard and applies it to files.

batch primary
Apply multiple edit operations in one clipboard paste. This is the main entry point — everything goes through batch.
Format:
#-# file
# path/newfile.ext
<full file content>
#-# fold
# existing.ext
<<<
old lines
>>>
new lines
file write
Write an entire file (new or complete rewrite). Auto-backs up existing files before overwriting.
Format:
# path/filename.ext
full file content here...
fold edit
Replace a section of a file using old/new blocks. Matches by trimmed content, auto-shifts indentation.
Format:
# filename.ext
<<<
old line 1
old line 2
>>>
new line 1
new line 2
drop edit
Replace a single function by matching its signature. Prompts on mismatch: Replace, Append, or Skip.
Format:
# filename.ext
def process_data(df):
# new function body...
ins edit
Insert content at a specific line number, or append to end of file.
Format:
# filename.ext 42
content to insert...
# filename.ext end
content to append...
nix delete
Remove lines from a file by line range or anchor strings. No clipboard needed.
Usage:
PS> nix file.ts 10 25
PS> nix file.ts -StartAnchor "# START" -EndAnchor "# END"
run execute
Execute commands inline within a batch. Strips ! prefixes (Claude-style shell commands).
Format (inside batch):
#-# run
! pip install requests
! python -m pytest
probe execute
Execute clipboard as code. Auto-detects Python vs PowerShell. Output captured to clipboard for pasting back to AI.
Usage:
PS> probe # auto-detect
PS> probe python # force Python
PS> probe pwsh # force PowerShell

Inspection Commands

Read code and copy structured output to clipboard — for feeding context back to the AI.

snap read
Copy files or functions to clipboard, formatted for AI consumption.
PS> snap app.py
PS> snap FuncName utils.py
PS> snap file1.ts file2.ts
context read
Show lines around a pattern match or line number with configurable radius.
PS> context app.ts "handleClick":5
PS> context app.ts 200:10
outline read
Show the structural skeleton of a file — functions, classes, exports with line numbers.
PS> outline renderer.ts
renderer.ts (342 lines)
12: export function init() {
45: export function render() {
180: export class Canvas {
rev safety
Restore files from timestamped backups. Supports per-file, Nth revision, or time-based bulk restore.
PS> rev app.py # restore latest
PS> rev app.py ? # list backups
PS> rev "14:30" # bulk restore

Hotkeys

AutoHotkey v2 bindings for instant execution. No terminal typing needed.

HotkeyActionDetails
Win + Shift + Enter Execute clipboard Auto-detects: batch (#-#), inspect (snap/context/outline), shell (!), or raw PowerShell
Win + Shift + C Clipboard ↔ Sublime Text Opens clipboard in Sublime with bidirectional sync — edits save back to clipboard
Win + Shift + P Python probe Run clipboard as Python script in the configured probe directory
Win + Shift + D Set probe directory Input dialog to set the working directory for probe runs
Win + Shift + R Copy rules Copy the AI rules template to clipboard for pasting into a chat session
Win + Shift + U Open as URL Opens clipboard as URL, auto-prepends https://, or falls back to Google search
Win + Shift + B Browse to path Opens clipboard path in Explorer — reveals files, opens folders
Win + Shift + A Tile terminals Arrange all Windows Terminal windows in a grid
Win + Shift + / Toggle server Show/hide the background PowerShell server window

Live Demos

Watch simulated terminal sessions showing the system in action.

PowerShell 7 — Hotkey Server
Click a demo above to see it in action.

Downloads

All files are portable — no hardcoded paths. See the setup guide below for installation.

📦
profile_clipboard_helpers.ps1
The core system — all edit commands (file, drop, fold, ins, nix, batch), inspection commands (snap, context, outline, peek), backup/restore (rev, diff), and syntax checking.
⬇ Download
clipboard_to_pwsh.ahk
AutoHotkey v2 hotkey script. Provides Win+Shift+Enter execution, clipboard-Sublime bridge, URL opener, path browser, and more.
⬇ Download
profile_hotkey_server.ps1
Persistent background PowerShell process that executes commands from AutoHotkey. Stays running with your full $PROFILE loaded.
⬇ Download
🚀
profile_hotkey_launcher.ps1
Launcher script that loads your PowerShell profile and starts the hotkey server. Called automatically by the AHK script.
⬇ Download
👁
clip_watcher.ps1
File watcher that syncs saves back to clipboard. Powers the Win+Shift+C bidirectional Sublime Text bridge.
⬇ Download
🔗
profile_set_shortcut.ps1
Dynamic shortcut system. Create persistent aliases with set name path that survive profile reloads.
⬇ Download
📜
rules_template.txt
AI rules template. Paste this into your AI chat to teach it the clipboard patch format. Customize paths for your environment.
⬇ Download

Setup Guide

Get everything running in about 5 minutes.

1

Prerequisites

Install these if you don't have them:

PowerShell 7+ https://aka.ms/powershell AutoHotkey v2 https://www.autohotkey.com/ Sublime Text https://www.sublimetext.com/ (optional, for clipboard bridge)
2

Create directory structure

Put the scripts where your PowerShell profile can find them:

$scripts = "$env:USERPROFILE\Scripts" New-Item -ItemType Directory -Force -Path "$scripts\profile" New-Item -ItemType Directory -Force -Path "$scripts\autohotkey" New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\pocket" New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\backups"
3

Place the files

Move downloaded files to their locations:

Scripts\profile\profile_clipboard_helpers.ps1 Scripts\profile\profile_set_shortcut.ps1 Scripts\autohotkey\clipboard_to_pwsh.ahk Scripts\autohotkey\profile_hotkey_server.ps1 Scripts\autohotkey\profile_hotkey_launcher.ps1 Scripts\autohotkey\clip_watcher.ps1 pocket\rules_template.txt (rename to rules.txt and customize)
4

Update your PowerShell profile

Add these lines to your $PROFILE:

$scripts = "$env:USERPROFILE\Scripts" # Clipboard patch system $ProfileScriptsRoot = Join-Path $scripts 'profile' . (Join-Path $ProfileScriptsRoot 'profile_clipboard_helpers.ps1') . (Join-Path $ProfileScriptsRoot 'profile_set_shortcut.ps1') # Load dynamic shortcuts $DynamicShortcutsFile = Join-Path $ProfileScriptsRoot 'profile_dynamic_shortcuts.ps1' if (Test-Path $DynamicShortcutsFile) { . $DynamicShortcutsFile } # Aliases Set-Alias file Write-FromClipboard -Scope Global -Force Set-Alias drop Apply-ClipboardFunctionPatch -Scope Global -Force Set-Alias fold Apply-ClipboardFoldPatch -Scope Global -Force Set-Alias ins Insert-ClipboardAtLine -Scope Global -Force Set-Alias nix Remove-FileSection -Scope Global -Force Set-Alias batch Invoke-ClipboardBatch -Scope Global -Force Set-Alias probe Invoke-ClipboardProbe -Scope Global -Force if (Test-Path Alias:diff) { Remove-Item Alias:diff -Force } Set-Alias diff Compare-WithBackup -Scope Global -Force Set-Alias rev Restore-LastBackup -Scope Global -Force
5

Launch AutoHotkey

Double-click clipboard_to_pwsh.ahk to start the hotkey system. It will auto-launch the background PowerShell server. Add it to your startup folder if you want it on every boot.

$ahk = "$env:USERPROFILE\Scripts\autohotkey\clipboard_to_pwsh.ahk" $startup = [Environment]::GetFolderPath("Startup") Copy-Item $ahk $startup # auto-start on login
6

Start coding with AI

Open any AI chat, paste your rules file (Win+Shift+R), and start coding. The AI will format edits as batch blocks that you can apply with Win+Shift+Enter.