@cli4ai/slack
Official @cli4ai package • https://cli4ai.com • Install cli4ai: npm i -g cli4ai
Full-featured Slack CLI. Uses channel/user names instead of IDs.
Setup
npm i -g cli4ai
cli4ai add -g slack
cli4ai secrets init slack
SLACK_BOT_TOKEN is required (xoxb-...). Create a Slack app, install it to your workspace, and grant the scopes listed below.
Commands
Channels
cli4ai run slack channels [limit]
cli4ai run slack info "#channel"
cli4ai run slack unread
Messages
cli4ai run slack history "#channel" [limit]
cli4ai run slack thread "#channel" <ts> [limit]
cli4ai run slack post "#channel" "message"
cli4ai run slack postas "#ch" "msg" "Name" "icon"
cli4ai run slack reply "#ch" <ts> "msg"
cli4ai run slack edit "#channel" <ts> "text"
cli4ai run slack delete "#channel" <ts>
Reactions
cli4ai run slack react "#channel" <ts> emoji
cli4ai run slack reactions "#channel" <ts>
Pins
cli4ai run slack pins "#channel"
cli4ai run slack pin "#channel" <ts>
cli4ai run slack unpin "#channel" <ts>
Users
cli4ai run slack users [limit]
cli4ai run slack user "@username"
cli4ai run slack dm "@username" "message"
cli4ai run slack status [emoji] [text]
Files
cli4ai run slack upload "#channel" ./file.pdf "comment"
Scheduling
cli4ai run slack schedule "#ch" "2025-12-14T09:00" "msg"
cli4ai run slack scheduled [channel]
cli4ai run slack unschedule "#channel" <id>
Monitoring
cli4ai run slack watch "#channel"
cli4ai run slack mentions
Output Flags
--raw, -r
--compact, -c
--broadcast, -b
--limit=N
--interval=N
Name Resolution
Use #channel-name instead of channel IDs:
cli4ai run slack post "#claude" "Hello!"
Use @username instead of user IDs:
cli4ai run slack dm "@adam" "Hey!"
cli4ai run slack user "@mail"
Custom Bot Identity
Post messages with a custom username and avatar:
cli4ai run slack postas "#claude" "Breaking news!" "News Bot" "newspaper"
cli4ai run slack postas "#claude" "Hello!" "Custom Bot" "https://example.com/avatar.png"
Slack mrkdwn Formatting
*bold* _italic_ ~strikethrough~
`code` ```code block``` > blockquote
<https://url|text> <@U123> :emoji:
Use \n for newlines:
cli4ai run slack post "#claude" "Line 1\nLine 2\n• Bullet"
Examples
cli4ai run slack history "#claude" 10 --compact
cli4ai run slack post "#claude" "*Important*: Check <https://example.com|this link>"
cli4ai run slack postas "#claude" ":rotating_light: Alert!" "Alert Bot" "warning"
cli4ai run slack reply "#claude" 1234567890.123 "On it!" --broadcast
cli4ai run slack reactions "#claude" 1234567890.123
cli4ai run slack pin "#claude" 1234567890.123
cli4ai run slack schedule "#general" "2025-12-25T09:00:00" ":christmas_tree: Merry Christmas!"
cli4ai run slack watch "#claude"
cli4ai run slack upload "#claude" ./report.pdf "Here's the report"
Project Structure
slack/
├── run.ts # CLI entry point
└── lib/
├── api.ts # Core API + name resolution
├── channels.ts # Channel operations
├── messages.ts # Messages, reactions, postAs
├── users.ts # User operations
├── files.ts # File uploads
├── pins.ts # Pin operations
├── schedule.ts # Scheduled messages
└── watch.ts # Watch + mentions
Required Bot Scopes
The bot needs these OAuth scopes:
channels:history, channels:read, channels:join, channels:manage
groups:history, groups:read
chat:write, chat:write.customize
reactions:read, reactions:write
pins:read, pins:write
files:read, files:write
users:read, users:read.email, users.profile:read
im:history, im:read, im:write
app_mentions:read
bookmarks:read, bookmarks:write