An agentic Slack CLI with structured JSON output and 200+ API methods — purpose-built for AI agents, LLMs, and DevOps automation.
Send messages, manage channels, search, upload files, and automate Slack from your terminal or agent toolchain. Ships as a single static binary (<15 MB) with structured { ok, data, meta } JSON envelope, non-interactive execution, idempotent writes, and slk schema for runtime tool discovery.
# Homebrew (macOS/Linux)
brew install osodevops/tap/slk
# Shell installer (macOS/Linux)
curl -fsSL https://raw.githubusercontent.com/osodevops/slack-cli/main/install.sh | sh
# PowerShell (Windows)
irm https://raw.githubusercontent.com/osodevops/slack-cli/main/install.ps1 | iex
# Pre-built binaries — download from GitHub Releases
# https://github.com/osodevops/slack-cli/releases
# Docker
docker run --rm -e SLK_TOKEN ghcr.io/osodevops/slk channel list
# From source
cargo install --git https://github.com/osodevops/slack-cliStore a bot token (from your Slack app settings):
slk auth add myworkspace --token xoxb-your-bot-token
# Credentials stored in OS keychain
# You're ready to go! Try: slk channel listOr set it as an environment variable:
export SLK_TOKEN=xoxb-your-bot-tokenFor cookie-based auth (xoxc + xoxd), extract directly from the Slack desktop app:
slk auth extract
# Reads token from Slack's LevelDB and decrypts cookies from Chromium DB# Send a message
slk msg send C123 "Hello from slk!" --yes
# List channels
slk channel list -o json
# Get channel history
slk msg history C123 -n 20 --fields ts,text,user
# Reply in a thread
slk msg reply C123 1234567890.123456 "Thread reply" --yes
# Search messages
slk search messages "deploy failure" --from U456
# React to a message
slk react add C123 1234567890.123456 thumbsup --yes
# Get user info
slk user info U456 -o json --fields id,real_name,email
# Upload a file
slk file upload report.pdf --channels C123 --title "Q4 Report" --yes# Plain text
slk msg send C123 "Hello world" --yes
# Block Kit templates (deploy, incident, approval, pr)
slk msg send C123 "Deploy" --template deploy --var app=api --var env=prod --yes
# Block Kit JSON from file
slk msg send C123 "Custom blocks" --blocks-file blocks.json --yes
# Edit a message
slk msg edit C123 1234567890.123456 "Updated text" --yes
# Delete a message
slk msg delete C123 1234567890.123456 --yes
# Schedule a message
slk msg schedule send C123 "Good morning" --post-at 1700000000 --yes
# Ephemeral message (visible to one user)
slk msg ephemeral C123 U456 "Only you can see this" --yes
# Get a permalink
slk msg permalink C123 1234567890.123456
# Save a draft (requires cookie auth)
slk msg draft C123 "WIP message" --yes# Export full channel history to NDJSON
slk msg export C123
# With thread replies and human-like pacing
slk msg export C123 --threads --pace slow -f backup.ndjson
# JSON array format
slk msg export C123 --format json -f archive.json
# Resume an interrupted export
slk msg export C123 --resume
# Export with stealth pacing (2-8s random delays)
slk msg export C123 --threads --pace stealth# List all channels
slk ch list -o json --fields id,name,num_members
# Filter by type
slk ch list --types public_channel,private_channel
# Create a channel
slk ch create my-project --yes
# Set topic and purpose
slk ch topic C123 "Sprint 42 discussion" --yes
slk ch purpose C123 "Coordinate sprint work" --yes
# Manage members
slk ch members C123 -n 500 -o json
slk ch invite C123 --users U456,U789 --yes
slk ch kick C123 U456 --yes# Search messages
slk search messages "budget" --after 2025-01-01 --sort timestamp
# Search with sender filter
slk search messages "deploy" --from U456 -o json
# Search files
slk search files "report" --in-channel C123
# Search users and channels
slk search users "alice"
slk search channels "engineering"# Upload with comment
slk file upload screenshot.png --channels C123 --comment "Bug screenshot" --yes
# List files in a channel
slk file list --channel C123 -n 10 -o json
# Download a file
slk file download F456 -o ./downloads/
# Delete a file
slk file delete F456 --yes# Extract tokens from a browser DevTools curl command
slk auth parse-curl --from-clipboard --login
# Pipe from clipboard
pbpaste | slk auth parse-curl --login --workspace mycompany
# Pass directly
slk auth parse-curl "curl 'https://myco.slack.com/api/...' -H 'Cookie: d=xoxd-...' --data 'token=xoxc-...'" --login# Listen for real-time events
slk events listen --app-token xapp-your-app-token
# Filter by event type
slk ev listen --app-token xapp-... --types message,reaction_added
# Filter by channel
slk ev listen --app-token xapp-... --channels C123,C456
# Pipe to a processor
slk ev listen --app-token xapp-... | jq '.event'# Full command tree as JSON (for agent tool discovery)
slk schema
# Single command details
slk schema --command msg.send
# API method registry with rate limit tiers
slk schema --methods# Add random delays between API calls
slk msg history C123 --pace stealth # 2-8s random delays
slk ch list --pace normal # 0.5-2s delays
slk msg export C123 --pace slow # 1-4s delays
# Custom delay range
slk ch list --pace-min-ms 1000 --pace-max-ms 5000slk is purpose-built for AI agents that need to interact with Slack. Every command outputs structured JSON, requires no interactive prompts, and supports safe-by-default write protection — making it ideal for autonomous agent workflows.
# Agent reads channel history, processes it, and responds
slk msg history C123 -n 10 -o json --fields ts,text,user | agent-process
slk msg send C123 "$(agent-generate-response)" --yes --idempotency-key $(uuidgen)
# Agent discovers available commands at runtime
slk schema # Full command tree as JSON
slk schema --methods # API method → CLI mapping with rate tiers
# Agent monitors events in real time
slk ev listen --app-token xapp-... --types message | agent-event-handler
# Agent exports channel for analysis with human-like pacing
slk msg export C123 --threads --pace stealth -f data.ndjson
# Dry-run to validate before executing
slk msg send C123 "Deploy notification" --dry-runWhy slk for agents:
- Structured output — JSON envelope with
{ ok, data, meta }on stdout, logs on stderr - Non-interactive — all input via args, env vars, or stdin — no prompts
- Safe by default — writes require
--yesorSLK_ALLOW_WRITE=true - Idempotent —
--idempotency-keyfor safe retries on write operations - Introspectable —
slk schemaemits full JSON command tree for tool discovery - Context-efficient —
--fieldsprojection reduces token usage for LLM context - Exit codes — deterministic codes (0-7) for programmatic error handling
# Post deploy notifications with Block Kit
slk msg send C123 --template deploy --var app=api --var version=v1.2.3 --var env=prod --yes
# Incident alerts
slk msg send C123 --template incident --var title="DB outage" --var severity=high --yes
# Notify on PR merge
slk msg send C123 --template pr --var title="Add caching" --var repo=myapp --yes
# Scheduled reminders
slk msg schedule send C123 "Deploy window closes in 1 hour" --post-at 1700000000 --yes# Export full channel history for compliance
slk msg export C123 --threads --pace slow -f compliance-export.ndjson
# Export with date range
slk msg export C123 --oldest 1700000000 --latest 1710000000 -f q4-archive.ndjson
# Resume interrupted exports
slk msg export C123 --resume# Audit channel membership
slk ch members C123 -n 1000 -o json | jq '.[].id'
# Bulk user lookup
slk user list --include-bots -o json --fields id,real_name,is_bot
# Manage user groups
slk usergroup members S0614TZR7 -o json
slk usergroup members-set S0614TZR7 --users U1,U2,U3 --yes- 200+ Slack API methods — messages, channels, files, reactions, search, users, pins, stars, bookmarks, reminders, status, DND, user groups, canvases
- Built for AI agents — structured JSON, non-interactive, idempotent, safe-by-default, introspectable via
slk schema - Human-like pacing — configurable random delays between API calls (none/fast/normal/slow/stealth)
- Channel export — stream full channel history to NDJSON/JSON with thread fetching and resume
- Block Kit templates — deploy, incident, approval, and PR notification templates built in
- Five auth methods — app extraction, browser login, parse-curl, OAuth PKCE, direct token
- Socket Mode — real-time event streaming via WebSocket
- Dry-run mode — preview API calls without executing
- Multiple output formats —
json(default),yaml,text,table,ndjson - Field projection —
--fields ts,text,userto select only needed data - Rate limit handling — automatic retry with exponential backoff on 429
- Multi-workspace — named profiles with credential storage in OS keychain
- Schema introspection —
slk schemaemits full JSON command tree for agent tool discovery - Shell completions — bash, zsh, fish, PowerShell
- Man pages —
slk docs --man-pages ./man/generates 111 man pages - Cross-platform — macOS (Apple Silicon + Intel), Linux (x86_64 + ARM64), Windows
- Zero runtime dependencies — single statically-linked binary (<15 MB)
slk supports five authentication methods. Credentials are resolved in priority order:
- CLI flags (
--token/--cookie) or env vars (SLK_TOKEN/SLK_COOKIE) - Stored credentials for the active workspace (OS keychain)
export SLK_TOKEN=xoxb-your-bot-token
# Or store persistently
slk auth add myworkspace --token xoxb-your-bot-token
# Read from a secret manager
vault read -field=token secret/slack | slk auth add myworkspace --token-stdinslk auth extract # From Slack app (default)
slk auth extract --source chrome # From Chrome
slk auth extract --source firefox # From Firefox
slk auth extract --list # Show available workspacesReads the xoxc- token from Slack's LevelDB and decrypts the xoxd- cookie from the Chromium cookie database using the OS keychain password (macOS Keychain / GNOME Keyring).
slk auth parse-curl --from-clipboard --loginCopy a Slack API request as cURL from browser DevTools, then paste. Extracts xoxc- token and xoxd- cookie automatically.
slk auth login myworkspace.slack.com
slk auth login myworkspace --headlessOpens a Chromium window via CDP. Supports SSO, SAML, and 2FA.
slk auth oauth --client-id 12345.67890 --scopes chat:write,channels:readslk auth list # List configured workspaces
slk auth status # Validate current credentials
slk auth switch production # Switch active workspace
slk auth logout old-workspace # Remove credentials| Feature | macOS | Linux | Windows |
|---|---|---|---|
| Slack app extraction | Yes | Yes | Yes |
| Cookie decryption | Yes (Keychain) | Yes (GNOME Keyring) | Not yet (DPAPI) |
| Chrome/Edge extraction | Yes | Yes | Not yet |
| Firefox extraction | Yes | Yes | Not yet |
| Browser login (CDP) | Yes | Yes | Yes |
| OAuth 2.0 PKCE | Yes | Yes | Yes |
| Bot/user token | Yes | Yes | Yes |
| Keyring storage | Keychain | Secret Service | Credential Manager |
~/.config/slk/config.toml:
[default]
workspace = "myworkspace"
output = "json"
default_pace = "normal"
user_agent = "Mozilla/5.0 ..."
[workspaces.myworkspace]
token_type = "bot"
team_id = "T12345"| Variable | Description |
|---|---|
SLK_TOKEN |
Slack API token (xoxb-, xoxp-, xoxc-) |
SLK_COOKIE |
Cookie value (xoxd-) for xoxc- token auth |
SLK_WORKSPACE |
Default workspace name |
SLK_OUTPUT |
Default output format (json, yaml, text, table, ndjson) |
SLK_ALLOW_WRITE |
Set to true to enable writes without --yes |
SLK_CONFIG_DIR |
Custom config directory (default: ~/.config/slk/) |
SLK_API_BASE_URL |
Override Slack API base URL (for testing) |
SLK_APP_TOKEN |
App-level token (xapp-) for Socket Mode |
Every command returns a structured envelope on stdout:
{
"ok": true,
"data": { "channel": "C123", "ts": "1234567890.123456" },
"meta": { "method": "chat.postMessage", "workspace": "myworkspace" }
}# JSON (default, best for agents)
slk ch list -o json
# YAML
slk ch list -o yaml
# ASCII table (human-friendly)
slk ch list -o table
# Plain text
slk user info U456 -o text
# NDJSON (one JSON object per line, good for streaming)
slk ch list -o ndjson
# Raw Slack API response (no envelope)
slk ch list --raw
# Field projection
slk ch list -o json --fields id,name,num_members| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Slack API error (check .data.error) |
| 2 | Authentication error |
| 3 | Rate limited (retry with backoff) |
| 4 | Network / WebSocket error |
| 5 | Configuration error |
| 6 | Write denied (missing --yes or SLK_ALLOW_WRITE) |
| 7 | Validation error (bad arguments) |
| 130 | Interrupted (SIGINT) |
slk [OPTIONS] <COMMAND>
Commands:
auth Authentication management (extract, login, add, oauth, parse-curl)
message Send, reply, edit, delete, schedule, export messages [alias: msg]
channel List, create, archive, rename, manage channels [alias: ch]
file Upload, download, list, delete files
reaction Add, remove, list emoji reactions [alias: react]
search Search messages, files, users, channels
user User info, list, presence, lookup
pin Pin and unpin messages
star Star and unstar items
bookmark Manage channel bookmarks
reminder Create and manage reminders
status Set and manage user status
dnd Do Not Disturb settings
usergroup Manage user groups and memberships
canvas Create and manage canvases
api Call any Slack API method directly
schema Introspect CLI commands and API methods (JSON)
events Real-time event streaming via Socket Mode [alias: ev]
completions Generate shell completions (bash/zsh/fish/powershell)
docs Generate man pages and documentation
Global Options:
-w, --workspace <NAME> Target workspace (overrides SLK_WORKSPACE)
-o, --output <FORMAT> Output format: json, yaml, text, table, ndjson
--raw Raw API response without envelope
--fields <FIELDS> Comma-separated fields to include
-q, --quiet Suppress output except errors
-v, --verbose Enable debug logging (to stderr)
--yes Skip confirmation prompts (required for writes)
--dry-run Show what would happen without executing
Auth Options:
--token <TOKEN> Slack API token (xoxb-, xoxp-, xoxc-)
--cookie <COOKIE> Cookie (xoxd-) for xoxc- token auth
Retry Options:
--retry <N> Max retry attempts [default: 3]
--no-retry Disable automatic retries
--timeout <SECS> Request timeout in seconds [default: 30]
--idempotency-key <K> Idempotency key for write operations
Pacing Options:
--pace <PROFILE> none, fast, normal, slow, stealth
--pace-min-ms <MS> Custom minimum delay (overrides profile)
--pace-max-ms <MS> Custom maximum delay (overrides profile)
--user-agent <STRING> Custom User-Agent header
git clone https://github.com/osodevops/slack-cli
cd slack-cli
cargo build --release
# Binary at target/release/slkRequirements: Rust 1.75+
# Run tests
cargo test
# Lint
cargo clippy --all-targets -- -D warnings
# Generate man pages
cargo run -- docs --man-pages docs/man
# Generate shell completions
cargo run -- completions zsh > ~/.zfunc/_slk- Phase 1: Core — CLI scaffold, HTTP client, auth system (5 methods), output formatting, rate limiting
- Phase 2: Essential — messages, channels, files, reactions, search, users
- Phase 3: Extended — pins, stars, bookmarks, reminders, status, DND, user groups, canvases
- Phase 4: Advanced — Socket Mode events, Block Kit templates, schema introspection
- Phase 5: Polish — integration tests (63), cross-platform builds (5 targets), Docker, Homebrew, release workflow
- Phase 6: Human-Like — pacing system, channel export, parse-curl auth, message drafts, man pages, agent-optimized help