deft / guides

Compress a PDF from the command line

deft pdf compress makes a PDF smaller by re-encoding its images. Give it a level, or a size it must get under.

deft pdf compress scan.pdf --target-size 150KB -o small.pdf

Options

--level lossless|balanced|strong
How hard to compress. lossless only rewrites the file's structure; balanced (the default) re-encodes images as JPEG 75 at 150 dpi; strong as JPEG 55 at 100 dpi.
--target-size 2MB
Tries stronger settings until the output is at or under this size.
--grayscale
Turns the images grey, which saves more on colour scans.
--password TEXT
Opens an encrypted input.
-o FILE|DIR
Where to write. Without it, report.pdf becomes report.compressed.pdf; the input is never overwritten.

All options: deft pdf compress --help. Add --json for a structured result.

A real run

The released deft on a real file. This is exactly what it printed:

$ deft pdf compress scan.pdf --target-size 150KB -o small.pdf
ok pdf.compress scan.pdf -> small.pdf  1.8MB -> 113KB (-94%)  0.08s

Limits

What it saves an AI agent

Every task in the deft benchmark that uses this command, run by Claude Code (Opus 5.5, medium effort) once without deft and once with deft and its skill installed. The prompt never mentions deft. Each cell reads without → with deft; click a task for the agent's full trace. On 3 of the 7 tasks deft used more tokens: on a short job the agent reads deft's help first.

TaskSolvedTime New tokensFailed commands
Send a scan and its text to an accountantscan.pdf is going to our accountant. Keep it under 1MB, protect it with the password hunter2 and save it as for-accountant.pdf. Also put the text of the scan in for-accountant.txt so they can copy figures from it.yes → yes42 s → 53 s16.5k → 21.3k1 → 1
Assemble an application from mixed filesPut together one application.pdf for a portal: letter.docx first, then the photo DSCN0010.jpg, then fw9.pdf. Number the pages at the bottom. The portal rejects anything over 1MB.yes → yes95 s → 29 s30.3k → 14.6k1 → 0
Compress a folder of PDFsCompress every PDF in the reports folder and put the results in a folder called compressed, keeping the file names.yes → yes23 s → 13 s11.1k → 11.0k1 → 0
Compress a photo-heavy PDFReduce photos.pdf to less than half its size and save it as light.pdf.yes → yes14 s → 14 s9.7k → 11.0k1 → 0
Shrink a scan for emailscan.pdf is too big to email. Make a copy called small.pdf under 150KB that is still readable.yes → yes89 s → 20 s29.9k → 14.0k4 → 0
Shrink a scanned letter and mark it as a copyletter.pdf is a scan of an old handwritten letter. I want to email it to the family: get it under 500 KB and stamp COPY on every page so nobody takes it for the original. Save it as letter-copy.pdf.yes → yes119 s → 23 s31.8k → 14.4k5 → 0
Turn scanned pages upright, shrink and save the textturned.pdf is a scanned product sheet, but the pages went through the scanner in different directions. Turn every page so it reads the right way up, and keep the file under 150 KB for our website. Save it as sheet.pdf, and put its text in sheet.txt for the product page.no → yes600 s → 79 s25.1k → 25.3k1 → 4
All 7 tasks6 → 7982 s → 231 s154.4k → 111.7k14 → 5

One run per task and arm, on 2026-11-15. Deft was improved against these same tasks, so this is a development benchmark, not a held-out test. New tokens are input not served from the prompt cache, plus output. Failed commands are the agent's tool calls that returned an error: shell commands, and file reads and writes. All tasks: the benchmark.

Install

curl -fsSL https://deftcli.com/install.sh | sh

Or brew install firstprayer/tap/deft. One binary for macOS and Linux; the script also sets up the skill for Claude Code and Codex. Install guide.