Slack CLI tool for messages, channels, and users
npm install @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.
``bash`
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.
bash
cli4ai run slack channels [limit] # List channels (alias: ls)
cli4ai run slack info "#channel" # Get channel info
cli4ai run slack unread # Channels with unread messages
`$3
`bash
cli4ai run slack history "#channel" [limit] # Get messages (alias: read)
cli4ai run slack thread "#channel" [limit] # Get thread replies
cli4ai run slack post "#channel" "message" # Post message (alias: msg, send)
cli4ai run slack postas "#ch" "msg" "Name" "icon" # Post as custom user
cli4ai run slack reply "#ch" "msg" # Reply to thread (use --broadcast)
cli4ai run slack edit "#channel" "text" # Edit a message
cli4ai run slack delete "#channel" # Delete a message
`$3
`bash
cli4ai run slack react "#channel" emoji # Add reaction
cli4ai run slack reactions "#channel" # See who reacted to a message
`$3
`bash
cli4ai run slack pins "#channel" # List pinned messages
cli4ai run slack pin "#channel" # Pin a message
cli4ai run slack unpin "#channel" # Unpin a message
`$3
`bash
cli4ai run slack users [limit] # List users
cli4ai run slack user "@username" # Get user info
cli4ai run slack dm "@username" "message" # Send direct message
cli4ai run slack status [emoji] [text] # Get/set status (use "clear" to clear)
`$3
`bash
cli4ai run slack upload "#channel" ./file.pdf "comment"
`$3
`bash
cli4ai run slack schedule "#ch" "2025-12-14T09:00" "msg" # Schedule message
cli4ai run slack scheduled [channel] # List scheduled
cli4ai run slack unschedule "#channel" # Delete scheduled
`$3
`bash
cli4ai run slack watch "#channel" # Live watch for new messages
cli4ai run slack mentions # Find recent mentions of you
`Output Flags
`bash
--raw, -r # Full JSON output
--compact, -c # One line per message
--broadcast, -b # Broadcast thread reply to channel
--limit=N # Override default limit
--interval=N # Watch poll interval (seconds)
`Name Resolution
Use
#channel-name instead of channel IDs:
`bash
cli4ai run slack post "#claude" "Hello!" # Instead of C093DN981RR
`Use
@username instead of user IDs:
`bash
cli4ai run slack dm "@adam" "Hey!" # Instead of U02JCQC0SLB
cli4ai run slack user "@mail" # Lookup by name or email
`Custom Bot Identity
Post messages with a custom username and avatar:
`bash
Using emoji as icon
cli4ai run slack postas "#claude" "Breaking news!" "News Bot" "newspaper"Using URL as icon
cli4ai run slack postas "#claude" "Hello!" "Custom Bot" "https://example.com/avatar.png"
`Slack mrkdwn Formatting
`
bold _italic_ ~strikethrough~
code `code block` > blockquote
<@U123> :emoji:
`Use
\n for newlines:
`bash
cli4ai run slack post "#claude" "Line 1\nLine 2\n• Bullet"
`Examples
`bash
Read recent messages (compact view)
cli4ai run slack history "#claude" 10 --compactPost with formatting
cli4ai run slack post "#claude" "Important: Check "Post as a custom bot
cli4ai run slack postas "#claude" ":rotating_light: Alert!" "Alert Bot" "warning"Reply and broadcast to channel
cli4ai run slack reply "#claude" 1234567890.123 "On it!" --broadcastSee who reacted to a message
cli4ai run slack reactions "#claude" 1234567890.123Pin an important message
cli4ai run slack pin "#claude" 1234567890.123Schedule a message
cli4ai run slack schedule "#general" "2025-12-25T09:00:00" ":christmas_tree: Merry Christmas!"Watch for new messages
cli4ai run slack watch "#claude"Upload a file
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`