- Published
- Author
- Ashwani Kumar JhaSenior System Analyst
Attach files in Claude Code with the normal Mac file picker
Claude Code in the terminal has no attach button. We can drag files in or paste images with Ctrl+V, but picking several files from different folders is awkward. We can add a small /attach command that opens the standard macOS file picker and passes the selected files to Claude.
How it works
β’ A custom slash command, ~/.claude/commands/attach.md, runs a short AppleScript before your message is sent.
β’ The AppleScript opens the native Mac file picker and returns the paths of the files you select.
β’ Claude opens those files with its Read tool. Text, code, images, PDFs and notebooks all work.
Setup
Paste this into Terminal:
cat > ~/.claude/attach.applescript <<'EOF'
try
set termApp to path to frontmost application as text
tell application termApp
activate
set picked to choose file with prompt "Choose files to attach" with multiple selections allowed
end tell
set out to "Attached files:"
repeat with f in picked
set out to out & linefeed & "- " & POSIX path of f
end repeat
return out
on error
return "No files attached."
end try
EOF
cat > ~/.claude/commands/attach.md <<EOF
---
description: Pick files with the macOS file picker and attach them
argument-hint: [what you want to ask about the files]
allowed-tools: Bash(osascript $HOME/.claude/attach.applescript), Read
---
!
Read every file listed above, then respond to: $ARGUMENTS
If a file can't be read (e.g. .docx, .zip), say so. If no files were attached, just say so.
EOF
Claude Code in the terminal has no attach button. We can drag files in or paste images with Ctrl+V, but picking several files from different folders is awkward. We can add a small /attach command that opens the standard macOS file picker and passes the selected files to Claude.
How it works
β’ A custom slash command, ~/.claude/commands/attach.md, runs a short AppleScript before your message is sent.
β’ The AppleScript opens the native Mac file picker and returns the paths of the files you select.
β’ Claude opens those files with its Read tool. Text, code, images, PDFs and notebooks all work.
Setup
Paste this into Terminal:
cat > ~/.claude/attach.applescript <<'EOF'
try
set termApp to path to frontmost application as text
tell application termApp
activate
set picked to choose file with prompt "Choose files to attach" with multiple selections allowed
end tell
set out to "Attached files:"
repeat with f in picked
set out to out & linefeed & "- " & POSIX path of f
end repeat
return out
on error
return "No files attached."
end try
EOF
cat > ~/.claude/commands/attach.md <<EOF
---
description: Pick files with the macOS file picker and attach them
argument-hint: [what you want to ask about the files]
allowed-tools: Bash(osascript $HOME/.claude/attach.applescript), Read
---
!
osascript $HOME/.claude/attach.applescriptRead every file listed above, then respond to: $ARGUMENTS
If a file can't be read (e.g. .docx, .zip), say so. If no files were attached, just say so.
EOF
``
**Usage**
1. Start a new claude session. Commands only load at startup.
2. Run /attach explain this error or /attach compare these two screenshots`. #claude