slack
Slack CLI tool for messages, channels, and users
v1.0.13 • by cliforai • Updated 1 day ago • BUSL-1.1 License
$ cli4ai add slack About
@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] # List channels (alias: ls)
cli4ai run slack info "#channel" # Get channel info
cli4ai run slack unread # Channels with unread messages
Messages
cli4ai run slack history "#channel" [limit] # Get messages (alias: read)
cli4ai run slack thread "#channel" <ts> [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" <ts> "msg" # Reply to thread (use --broadcast)
cli4ai run slack edit "#channel" <ts> "text" # Edit a message
cli4ai run slack delete "#channel" <ts> # Delete a message
Reactions
cli4ai run slack react "#channel" <ts> emoji # Add reaction
cli4ai run slack reactions "#channel" <ts> # See who reacted to a message
Pins
cli4ai run slack pins "#channel" # List pinned messages
cli4ai run slack pin "#channel" <ts> # Pin a message
cli4ai run slack unpin "#channel" <ts> # Unpin a message
Users
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)
Files
cli4ai run slack upload "#channel" ./file.pdf "comment"
Scheduling
cli4ai run slack schedule "#ch" "2025-12-14T09:00" "msg" # Schedule message
cli4ai run slack scheduled [channel] # List scheduled
cli4ai run slack unschedule "#channel" <id> # Delete scheduled
Monitoring
cli4ai run slack watch "#channel" # Live watch for new messages
cli4ai run slack mentions # Find recent mentions of you
Output Flags
--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:
cli4ai run slack post "#claude" "Hello!" # Instead of C093DN981RR
Use @username instead of user IDs:
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:
# 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
<https://url|text> <@U123> :emoji:
Use \n for newlines:
cli4ai run slack post "#claude" "Line 1\nLine 2\n• Bullet"
Examples
# Read recent messages (compact view)
cli4ai run slack history "#claude" 10 --compact
# Post with formatting
cli4ai run slack post "#claude" "*Important*: Check <https://example.com|this link>"
# 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!" --broadcast
# See who reacted to a message
cli4ai run slack reactions "#claude" 1234567890.123
# Pin an important message
cli4ai run slack pin "#claude" 1234567890.123
# Schedule 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:managegroups:history,groups:readchat:write,chat:write.customizereactions:read,reactions:writepins:read,pins:writefiles:read,files:writeusers:read,users:read.email,users.profile:readim:history,im:read,im:writeapp_mentions:readbookmarks:read,bookmarks:write
Keywords
Related Packages
gmail
v1.0.11 • by cliforai
Gmail CLI tool for messages, threads, and drafts
#gmail
#email
#google
0 downloads
v1.0.12 • by cliforai
LinkedIn tools - READ ONLY (15 req/hour, human-like delays)
#linkedin
#social
#professional
0 downloads
v1.0.13 • by cliforai
Twitter/X browser automation
#twitter
#x
#social
0 downloads