Skip to content

Slack CLI - Command-line tool for interacting with Slack workspaces and channels. AI-friendly with structured output formats (JSON, table, text) designed for easy integration with AI tools and automation workflows.

License

Notifications You must be signed in to change notification settings

shaharia-lab/slackcli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SlackCLI

A fast, developer-friendly command-line interface tool for interacting with Slack workspaces. Built with TypeScript and Bun, it enables AI agents, automation tools, and developers to access Slack functionality directly from the terminal.

Features

  • πŸ” Dual Authentication Support: Standard Slack tokens (xoxb/xoxp) or browser tokens (xoxd/xoxc)
  • 🎯 Easy Token Extraction: Automatically parse tokens from browser cURL commands
  • 🏒 Multi-Workspace Management: Manage multiple Slack workspaces with ease
  • πŸ’¬ Conversation Management: List channels, read messages, send messages
  • πŸŽ‰ Message Reactions: Add emoji reactions to messages programmatically
  • πŸš€ Fast & Lightweight: Built with Bun for blazing fast performance
  • πŸ”„ Auto-Update: Built-in self-update mechanism
  • 🎨 Beautiful Output: Colorful, user-friendly terminal output

Installation

Pre-built Binaries

Linux

curl -L https://github.com/shaharia-lab/slackcli/releases/latest/download/slackcli-linux -o slackcli
chmod +x slackcli
mkdir -p ~/.local/bin && mv slackcli ~/.local/bin/

macOS (Intel)

curl -L https://github.com/shaharia-lab/slackcli/releases/latest/download/slackcli-macos -o slackcli
chmod +x slackcli
mkdir -p ~/.local/bin && mv slackcli ~/.local/bin/

macOS (Apple Silicon)

curl -L https://github.com/shaharia-lab/slackcli/releases/latest/download/slackcli-macos-arm64 -o slackcli
chmod +x slackcli
mkdir -p ~/.local/bin && mv slackcli ~/.local/bin/

Windows

Download slackcli-windows.exe from the latest release and add it to your PATH.

From Source

# Clone the repository
git clone https://github.com/shaharia-lab/slackcli.git
cd slackcli

# Install dependencies
bun install

# Build binary
bun run build

Authentication

SlackCLI supports two authentication methods:

1. Standard Slack App Tokens (Recommended for Production)

Create a Slack app at api.slack.com/apps and obtain a bot token (xoxb-) or user token (xoxp-).

slackcli auth login --token=xoxb-YOUR-TOKEN --workspace-name="My Team"

2. Browser Session Tokens (Quick Setup)

Extract tokens from your browser session. No Slack app creation required!

# Step 1: Get extraction guide
slackcli auth extract-tokens

# Step 2: Login with extracted tokens
slackcli auth login-browser \
  --xoxd=xoxd-YOUR-TOKEN \
  --xoxc=xoxc-YOUR-TOKEN \
  --workspace-url=https://yourteam.slack.com

How to Extract Browser Tokens:

  1. Open your Slack workspace in a web browser
  2. Open Developer Tools (F12)
  3. Go to Network tab
  4. Send a message or refresh
  5. Find a Slack API request
  6. Extract:
    • xoxd token from Cookie header (d=xoxd-...)
    • xoxc token from request payload ("token":"xoxc-...")

3. Easy Method: Parse cURL Command (Recommended for Browser Tokens)

The easiest way to extract browser tokens is to copy a Slack API request as cURL and let SlackCLI parse it automatically!

# Step 1: In browser DevTools, right-click any Slack API request
#         β†’ Copy β†’ Copy as cURL

# Step 2: Interactive mode (recommended) - just paste and press Enter twice
slackcli auth parse-curl --login

# Alternative: Read directly from clipboard
slackcli auth parse-curl --from-clipboard --login

# Alternative: Pipe from clipboard or file
pbpaste | slackcli auth parse-curl --login
cat curl-command.txt | slackcli auth parse-curl --login

This automatically extracts:

  • Workspace URL and name
  • xoxd token from cookies
  • xoxc token from request data

Usage

Authentication Commands

# List all authenticated workspaces
slackcli auth list

# Set default workspace
slackcli auth set-default T1234567

# Remove a workspace
slackcli auth remove T1234567

# Logout from all workspaces
slackcli auth logout

Conversation Commands

# List all conversations
slackcli conversations list

# List only public channels
slackcli conversations list --types=public_channel

# List DMs
slackcli conversations list --types=im

# Read recent messages from a channel
slackcli conversations read C1234567890

# Read a specific thread
slackcli conversations read C1234567890 --thread-ts=1234567890.123456

# Read with custom limit
slackcli conversations read C1234567890 --limit=50

# Get JSON output (includes ts and thread_ts for replies)
slackcli conversations read C1234567890 --json

Message Commands

# Send message to a channel
slackcli messages send --recipient-id=C1234567890 --message="Hello team!"

# Send DM to a user
slackcli messages send --recipient-id=U9876543210 --message="Hey there!"

# Reply to a thread
slackcli messages send --recipient-id=C1234567890 --thread-ts=1234567890.123456 --message="Great idea!"

# Add emoji reaction to a message
slackcli messages react --channel-id=C1234567890 --timestamp=1234567890.123456 --emoji=+1

# More reaction examples
slackcli messages react --channel-id=C1234567890 --timestamp=1234567890.123456 --emoji=heart
slackcli messages react --channel-id=C1234567890 --timestamp=1234567890.123456 --emoji=fire
slackcli messages react --channel-id=C1234567890 --timestamp=1234567890.123456 --emoji=eyes

Common emoji names:

  • +1 or thumbsup - πŸ‘
  • heart - ❀️
  • fire - πŸ”₯
  • eyes - πŸ‘€
  • tada - πŸŽ‰
  • rocket - πŸš€

Update Commands

# Check for updates
slackcli update check

# Update to latest version
slackcli update

Multi-Workspace Usage

# Use specific workspace by ID
slackcli conversations list --workspace=T1234567

# Use specific workspace by name
slackcli conversations list --workspace="My Team"

Configuration

Configuration is stored in ~/.config/slackcli/:

  • workspaces.json - Workspace credentials
  • config.json - User preferences (future)

Development

Prerequisites

  • Bun v1.0+
  • TypeScript 5.x+

Setup

# Install dependencies
bun install

# Run in development mode
bun run dev --help

# Build binary
bun run build

# Build for all platforms
bun run build:all

# Type check
bun run type-check

Project Structure

slackcli/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ index.ts              # CLI entry point
β”‚   β”œβ”€β”€ commands/             # Command implementations
β”‚   β”‚   β”œβ”€β”€ auth.ts
β”‚   β”‚   β”œβ”€β”€ conversations.ts
β”‚   β”‚   β”œβ”€β”€ messages.ts
β”‚   β”‚   └── update.ts
β”‚   β”œβ”€β”€ lib/                  # Core library
β”‚   β”‚   β”œβ”€β”€ auth.ts
β”‚   β”‚   β”œβ”€β”€ workspaces.ts
β”‚   β”‚   β”œβ”€β”€ slack-client.ts
β”‚   β”‚   β”œβ”€β”€ formatter.ts
β”‚   β”‚   └── updater.ts
β”‚   └── types/                # Type definitions
β”‚       └── index.ts
β”œβ”€β”€ .github/workflows/        # CI/CD
└── dist/                     # Build output

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Troubleshooting

Authentication Issues

Standard Tokens:

  • Ensure your token has the required OAuth scopes
  • Check token validity in your Slack app settings

Browser Tokens:

  • Tokens expire with your browser session
  • Extract fresh tokens if authentication fails
  • Verify workspace URL format (https://yourteam.slack.com)

Permission Errors

If you get permission errors when accessing conversations or sending messages:

  • Verify your bot/user has been added to the channel
  • Check OAuth scopes include required permissions
  • For browser tokens, ensure you have access in the web UI

Update Issues

If slackcli update fails:

  • Ensure you have write permissions to the binary location
  • Try running with sudo if installed system-wide
  • Consider installing to user directory (~/.local/bin) instead

License

MIT License - see LICENSE file for details

Support

Acknowledgments


Made with ❀️ by Shaharia Lab

About

Slack CLI - Command-line tool for interacting with Slack workspaces and channels. AI-friendly with structured output formats (JSON, table, text) designed for easy integration with AI tools and automation workflows.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Contributors