slk — Slack CLI
Session-based Slack CLI for macOS. Auto-authenticates from the Slack desktop app — no tokens, no OAuth, no app installs. Acts as your user (xoxc- session tokens).
Commands
CODEBLOCK0
Channel accepts name (general), ID (C08A8AQ2AFP), @username for DMs, or user ID (U07RQTFCLUC).
Auth
Automatic — extracts session token from Slack desktop app's LevelDB + decrypts cookie from macOS Keychain.
First run: macOS will show a Keychain dialog asking to allow access to "Slack Safe Storage":
- - Allow — one-time access, prompted again next time
- Always Allow — permanent, no future prompts (convenient but any process running as your user can extract credentials silently)
- Deny — blocks access, slk cannot authenticate
Token cache: ~/.local/slk/token-cache.json — auto-validated, auto-refreshed on invalid_auth.
If auth fails (token rotated, Slack logged out):
CODEBLOCK1
Slack desktop app must be installed and logged in. Does not need to be running if token is cached.
Reading Threads
Threads require a Slack timestamp. Use --ts to get it, then read the thread:
CODEBLOCK2
Agent Workflow Examples
- - Heartbeat/cron unread check —
slk unread → slk read <channel> for channels that need attention - Save & pick up — Human saves threads in Slack ("Save for later"). Agent runs
slk saved during heartbeat, reads full threads with slk thread, summarizes or extracts action items - Daily channel digest —
slk read <channel> 100 across key channels → compile decisions, open questions, action items → INLINECODE13 - Weekly DM summary —
slk read @boss 200 --from 2026-02-01 --threads → extract action items, decisions, context - Thread monitoring — Watch specific threads for new replies (incidents, PR reviews, decisions)
- Draft for human review —
slk draft <channel> "..." posts to Slack's editor UI for human to review before sending - Search-driven context —
slk search "deployment process" or slk pins <channel> to pull context before answering questions
Limitations
- - macOS only — uses Keychain + Electron storage paths
- Session-based — acts as your user, not a bot. Be mindful of what you send
- Draft drop may fail with
draft_has_conflict if Slack has that conversation open - Session token expires on logout — keep Slack app running or rely on cached token
Missing Features & Issues
Create PR or Report Issue at: https://github.com/therohitdas/slkcli
slk — Slack CLI
基于会话的macOS Slack CLI。从Slack桌面应用自动认证——无需令牌、无需OAuth、无需安装应用。以你的用户身份运行(使用xoxc-会话令牌)。
命令
bash
认证
slk auth # 测试认证,显示用户/团队
读取
slk channels # 列出频道(别名:ch)
slk dms # 列出带ID的私信对话(别名:dm)
slk read <频道> [数量] # 读取最近消息,默认20条(别名:r)
slk read @用户名 [数量] # 按用户名读取私信
slk read <频道> --threads # 自动展开所有线程
slk read <频道> --from 2026-02-01 # 日期范围筛选
slk thread <频道> <时间戳> [数量] # 读取线程回复,默认50条(别名:t)
slk search <查询> [数量] # 跨工作区搜索消息
slk users # 列出工作区用户(别名:u)
活动
slk activity # 所有有未读/提及计数的频道(别名:a)
slk unread # 仅未读消息,排除静音频道(别名:ur)
slk starred # VIP用户 + 星标项目(别名:star)
slk saved [数量] [--all] # 稍后阅读的已保存项目(别名:sv)
slk pins <频道> # 频道中的固定项目(别名:pin)
写入
slk send <频道> <消息> # 发送消息(别名:s)
slk react <频道> <时间戳> <表情> # 对消息做出反应
草稿(同步至Slack编辑器界面)
slk draft <频道> <消息> # 起草频道消息
slk draft thread <频道> <时间戳> <消息> # 起草线程回复
slk draft user <用户ID> <消息> # 起草私信
slk drafts # 列出活跃草稿
slk draft drop <草稿ID> # 删除草稿
频道接受名称(general)、ID(C08A8AQ2AFP)、私信的@用户名或用户ID(U07RQTFCLUC)。
认证
自动——从Slack桌面应用的LevelDB提取会话令牌,并从macOS钥匙串解密cookie。
首次运行: macOS会显示钥匙串对话框,询问是否允许访问Slack Safe Storage:
- - 允许 — 一次性访问,下次会再次提示
- 始终允许 — 永久授权,不再提示(方便,但任何以你的用户身份运行的进程都可以静默提取凭据)
- 拒绝 — 阻止访问,slk无法认证
令牌缓存: ~/.local/slk/token-cache.json — 自动验证,invalid_auth时自动刷新。
如果认证失败(令牌轮换、Slack登出):
bash
rm ~/.local/slk/token-cache.json
slk auth
必须安装并登录Slack桌面应用。如果令牌已缓存,则无需运行Slack。
读取线程
线程需要Slack时间戳。使用--ts获取时间戳,然后读取线程:
bash
slk read general 10 --ts
输出:[1/30/2026, 11:41 AM ts:1769753479.788949] User [3 replies]: ...
slk thread general 1769753479.788949
代理工作流示例
- - 心跳/定时未读检查 — slk unread → 对需要关注的频道执行slk read <频道>
- 保存并跟进 — 用户在Slack中保存线程(稍后阅读)。代理在心跳时运行slk saved,用slk thread读取完整线程,总结或提取行动项
- 每日频道摘要 — 在关键频道上执行slk read <频道> 100 → 整理决策、未解决问题、行动项 → slk send daily-digest 📋 ...
- 每周私信总结 — slk read @老板 200 --from 2026-02-01 --threads → 提取行动项、决策、上下文
- 线程监控 — 监控特定线程的新回复(事件、PR审查、决策)
- 草稿供人工审查 — slk draft <频道> ... 将内容发布到Slack编辑器界面,供发送前人工审查
- 搜索驱动上下文 — 在回答问题前,通过slk search 部署流程或slk pins <频道>获取上下文
限制
- - 仅macOS — 使用钥匙串和Electron存储路径
- 基于会话 — 以你的用户身份运行,而非机器人。注意发送的内容
- 如果Slack打开了该对话,删除草稿可能失败并显示drafthasconflict
- 会话令牌在登出后过期——保持Slack应用运行或依赖缓存的令牌
缺失功能与问题
创建PR或报告问题:https://github.com/therohitdas/slkcli