Skip to main content

npm version PyPI version

slack-cli

A Slack CLI designed for coding agents (Claude Code, Cursor, etc.) that provides structured JSON access to Slack workspaces via the Web API.

It works by extracting authentication tokens from your existing browser session — no Slack app or bot token required.

Install

npm:

npm install -g @alankyshum/slack-cli

pip:

pip install slack-cli-agent

Manual:

git clone https://github.com/alankyshum/slack-cli.git
chmod +x slack-cli/bin/slack-cli
ln -s "$(pwd)/slack-cli/bin/slack-cli" ~/.local/bin/slack-cli

Prerequisites

  • curl and jq (for all commands)
  • python3 (for URL encoding)
  • Node.js + Playwright (only for auth command)
npm install -g playwright
npx playwright install chromium

Quick Start

# 1. Authenticate (opens browser to extract tokens)
slack-cli auth --domain mycompany.slack.com

# 2. Search messages
slack-cli search "from:@alice in:#engineering deployment"

# 3. Read channel history
slack-cli read engineering 10

# 4. Draft a message (saved locally, not sent)
slack-cli draft general "Hey team, the fix for JIRA-123 is ready"

Commands

Command Description
auth --domain <dom> Extract tokens from browser session
whoami Show authenticated user
config Show current configuration
search <query> Search messages (full Slack query syntax)
read <channel> [count] Read channel messages
unreads Show recent activity
draft <channel> <msg> [--thread <ts>] [--file <path>] Save a server-side draft
draft-delete <draft_id> Delete a server-side draft
drafts List saved drafts
send <draft_id> Send a draft (with confirmation prompt)
post <channel> <msg> [--thread <ts>] [--file <path>] Send a message with mrkdwn formatting
channels List your channels
dms List recent DMs
userinfo <user> Look up user by ID, email, or name
status [emoji] [text] Get or set your Slack status (clear to remove)
`presence [user_id username

Search Modifiers

Slack's full search syntax is supported:

Modifier Example Description
from: from:@alice / from:me Messages from a person
in: in:#channel / in:@user Messages in channel or DM
before: before:2025-06-01 Before a date
after: after:2025-01-01 After a date
on: on:2025-03-15 On exact date
during: during:january During a month or year
has: has::eyes: / has:pin Has reaction or pin
is: is:saved / is:thread Saved or thread messages
"..." "exact phrase" Exact phrase match
- -word Exclude word
* deploy* Wildcard (min 3 chars)

Environment Variables

Variable Default Description
SLACK_CLI_HOME ~/.slack-cli Config directory
SLACK_CLI_CHROME_PROFILE ~/.slack-cli/chrome-profile Chrome profile for auth
SLACK_CLI_COUNT 20 Results per page
SLACK_CLI_SORT timestamp Sort: timestamp or score
SLACK_CLI_SORT_DIR desc Direction: asc or desc

How It Works

  1. auth opens a Chromium browser using your existing Chrome profile (via Playwright), navigates to your Slack workspace, and intercepts the xoxc- API token and xoxd- session cookie from live API requests.

  2. All other commands use direct Slack Web API calls via curl — no browser needed, making them fast and suitable for automation.

  3. Drafts are saved locally to ~/.slack-cli/drafts.json. The send command requires interactive confirmation before posting.

  4. All output is structured JSON, making it easy to parse with jq or consume from AI agents.

Security

  • Credentials are stored at ~/.slack-cli/credentials.json with 600 permissions
  • Tokens are xoxc- client tokens scoped to your user session
  • The send command requires explicit y confirmation
  • No data is sent to any third party

License

MIT

Metadata

Release files for slack-cli-agent 1.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for slack-cli-agent 1.4.1
File Size Uploaded Provenance
slack_cli_agent-1.4.1.tar.gz 15.8 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for slack-cli-agent 1.4.1
File Interpreter ABI Platform
slack_cli_agent-1.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 30.6 kB

Release files / slack_cli_agent-1.4.1.tar.gz

Download URL slack_cli_agent-1.4.1.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
afc1dea902baadf65d7d8816332ca8b3c17c17c34849acdb444bafb43f44dd3c
BLAKE2b-256 checksum
How to use checksums
e1b234316644cd477d34ea80774e04873aaf6dcffdca399e4b609eb83b74d0ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 8, 2026.

Transparency log

Release files / slack_cli_agent-1.4.1-py3-none-any.whl

Download URL slack_cli_agent-1.4.1-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
464125c3ebac4e464a6c6b1f7786c6b7e34d28fce16c3aaa9d43673a12d005e9
BLAKE2b-256 checksum
How to use checksums
19fe62da2bcb11c69c9ce71e68710a1841ec0712a4ca44ba7bd7047cbb8ce4a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 8, 2026.

Transparency log

Security for slack-cli-agent 1.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for slack_cli_agent-1.4.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page