CommunityImagegithub.com

yb2460/cli-anything-photoshop

A CLI harness for controlling Adobe Photoshop via COM automation. Supports project management, layer operations, selection control, text editing, image adjustments, and multi-format export.

What is cli-anything-photoshop?

This skill provides a command-line interface to automate Adobe Photoshop through its Windows COM interface, enabling both human users and AI agents to programmatically manipulate PSD projects. It includes comprehensive commands for creating, opening, and saving documents; managing layers (add, delete, duplicate, reorder, merge); controlling selections (all, none, invert, feather, expand, contract, border, rectangle); editing text; resizing and cropping canvases; and exporting to various formats. The `--json` flag outputs structured JSON (ideal for AI agents like Claude Code, Cursor, or Codex), and `--dry-run` allows previewing changes without saving. A REPL mode supports multi-step interactive workflows across Windows 10/11 with Adobe Photoshop 2023+ and Python 3.10+. The tool is built on a Click CLI, with a ComBridge singleton managing the Photoshop Application COM singleton to reduce process overhead.

Works with~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/yb2460/harness-anything/tree/master/photoshop-harness/skills/cli-anything-photoshop

Installed? Explore more Image skills: steipete/songsee, affaan-m/frontend-design, mattpocock/improve-codebase-architecture · View all 6 →

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

CLI-Anything Photoshop

A command-line tool for controlling Adobe Photoshop via the Windows COM automation interface.

Prerequisites

  • Windows 10/11
  • Adobe Photoshop 2023+ (COM interface must be registered)
  • Python 3.10+ and the pywin32 package

Installation

cd photoshop-harness/agent-harness
pip install -e .

After installation, you can use the cli-anything-photoshop command.

Command Structure

cli-anything-photoshop [--json] [--project <path>] [--dry-run] <command-group> <command> [options]

Global Options

OptionDescription
--jsonOutput in JSON format (for AI Agent parsing)
--project <path>Automatically open or create a PSD project file
--dry-runExecute the command without saving to disk

Command Groups

project — Project Management

CommandOptionsDescription
new <path>-w width, -h height, -r resolution, -m mode, -b bg-colorCreate a new PSD
open <path>Open a PSD file
save [path]Save the document
close--no-saveClose the document

document — Document Operations

CommandOptionsDescription
infoDocument info
resize-w width, -h height, -r resolutionResize dimensions
canvas-w width, -h height, -a anchorResize canvas
crop--left --top --right --bottomCrop
rotate-a angleRotate canvas
flip-d directionFlip canvas
mode-m modeChange color mode
trim-t typeTrim edges

layer — Layer Operations

CommandOptionsDescription
add-n name, -t type, -o opacity, -b blendAdd a layer
delete-n nameDelete a layer
duplicate-n name, --new-name nameDuplicate a layer
rename--old name, --new nameRename
show / hide-n nameShow/Hide
opacity-n name, -o opacitySet opacity
blend-n name, -m modeSet blend mode
listList all layers
reorder-n name, -p positionReorder
merge-n name, --with-layer nameMerge layers

selection — Selection Operations

CommandOptionsDescription
allSelect all
noneDeselect
invertInvert selection
feather-r radiusFeather
expand-p pixelsExpand
contract-p pixelsContract
border-w widthBorder selection
rect--left --top --right --bottomRectangular selection
fill-c color, -o opacityFill selection

text — Text Operations

CommandOptionsDescription
add-t text, -f font, -s size, -c colorAdd text
edit-n name, -t text, -f font, -s size, -c colorEdit text
info-n nameText info

export — Export

CommandOptionsDescription
save <path>-f format, -q quality, -w width, -h heightExport file

repl

CommandDescription
replStart interactive REPL mode

Usage Examples

AI Agent Usage (--json mode)

# Create a new project and get JSON output
cli-anything-photoshop --json project new -w 800 -h 600 poster.psd

# Add a text layer
cli-anything-photoshop --json --project poster.psd text add -t "Hello World" -f Arial -s 48 -c "#FF0000"

# List all layers (JSON format)
cli-anything-photoshop --json --project poster.psd layer list

# Export as PNG
cli-anything-photoshop --json --project poster.psd export save -f png output.png

# Preview (without saving)
cli-anything-photoshop --dry-run --project poster.psd layer add -n "draft" --type text

Human Usage

# Open a PSD, interactive editing
cli-anything-photoshop --project work.psd layer list

# Start REPL
cli-anything-photoshop repl

Agent Usage Guide

  1. Always use the --json flag for structured output
  2. Use --dry-run to preview before committing to a save
  3. Error handling: Check stderr for JSON error objects when exit code is non-zero
  4. Project state: Use --project to automatically manage file open/save
  5. REPL mode: Suitable for multi-step interactive operations, reducing Photoshop process startup overhead

Photoshop COM Architecture

CLI command → Click CLI → Core module → ComBridge (singleton) → Photoshop.Application COM → Photoshop engine

Photoshop exposes its full editing capabilities through the Windows COM interface. This harness wraps the most commonly used operations. To extend, refer to the Adobe Photoshop COM documentation and add new methods to utils/com_bridge.py.

Individual skills in this repo

This repo contains 1 individual skill — each has its own dedicated page.

Related Skills