slackctl
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSlack automation with slackctl
slackctl借助slackctl
实现Slack自动化
slackctlslackctl$PATHslackctl user get @aliceslackctl$PATHslackctl user get @aliceInstallation
安装
If is not found on , install it:
slackctl$PATH- (macOS/Linux, recommended)
brew tap cluas/tap && brew install slackctl - (requires Go)
go install github.com/cluas/slackctl/cmd/slackctl@latest
如果中未找到,请按以下方式安装:
$PATHslackctl- (macOS/Linux,推荐方式)
brew tap cluas/tap && brew install slackctl - (需要安装Go环境)
go install github.com/cluas/slackctl/cmd/slackctl@latest
CRITICAL: Bash command formatting rules
重要提示:Bash命令格式规则
Claude Code's permission checker has security heuristics that force manual approval prompts. Avoid these patterns to keep commands auto-allowed.
- No anywhere in the command string. Use bare channel names (
#notgeneral).#general - No (consecutive single quotes) or
''(consecutive double quotes). Triggers "potential obfuscation" check."" - Only for filtering — no python3, no other commands.
| jqwith single-quote-only expressions (nojqinside) is safe:"- RIGHT:
slackctl search messages "query" | jq '.messages[] | .ts'
- RIGHT:
- No or
||chains. Run multiple slackctl commands as separate Bash tool calls.&& - No file redirects (,
>). Process JSON output directly, don't write to files.>>
Claude Code的权限检查器带有安全启发式规则,会触发手动审批提示。请避免以下模式,确保命令可自动通过审批。
- 命令字符串中不得包含。请使用纯频道名称(如
#而非general)。#general - 不得包含连续单引号或连续双引号
''。这会触发“潜在混淆”检查。"" - 仅允许使用进行过滤——禁止使用python3或其他命令。仅使用单引号表达式的
| jq是安全的:jq- 正确示例:
slackctl search messages "query" | jq '.messages[] | .ts'
- 正确示例:
- 不得使用或
||链式命令。请将多个slackctl命令作为独立的Bash工具调用执行。&& - 不得使用文件重定向符或
>。请直接处理JSON输出,不要写入文件。>>
Quick start (auth)
快速开始(认证)
Authentication is automatic on macOS (Slack Desktop first, then Chrome/Firefox fallbacks).
If credentials aren't available, run one of:
- Slack Desktop import (macOS):
bash
slackctl auth import-desktop
slackctl auth test- Firefox fallback:
bash
slackctl auth import-firefox
slackctl auth test- Chrome fallback:
bash
slackctl auth import-chrome
slackctl auth test- Or set env vars:
bash
export SLACK_TOKEN="xoxc-..."
export SLACK_COOKIE_D="xoxd-..."
export SLACK_WORKSPACE_URL="https://myteam.slack.com"
slackctl auth test- Or add manually:
bash
slackctl auth add --workspace-url https://myteam.slack.com --xoxc xoxc-... --xoxd xoxd-...
slackctl auth testCheck configured workspaces:
bash
slackctl auth whoami在macOS上认证是自动完成的(优先使用Slack Desktop,其次是Chrome/Firefox作为备选)。
如果无法获取凭证,请运行以下其中一种方式:
- 从Slack Desktop导入(macOS):
bash
slackctl auth import-desktop
slackctl auth test- Firefox备选方案:
bash
slackctl auth import-firefox
slackctl auth test- Chrome备选方案:
bash
slackctl auth import-chrome
slackctl auth test- 或设置环境变量:
bash
export SLACK_TOKEN="xoxc-..."
export SLACK_COOKIE_D="xoxd-..."
export SLACK_WORKSPACE_URL="https://myteam.slack.com"
slackctl auth test- 或手动添加:
bash
slackctl auth add --workspace-url https://myteam.slack.com --xoxc xoxc-... --xoxd xoxd-...
slackctl auth test查看已配置的工作区:
bash
slackctl auth whoamiCanonical workflow (given a Slack message URL)
标准工作流(给定Slack消息URL)
- Fetch a single message:
bash
slackctl message get "https://workspace.slack.com/archives/C123/p1700000000000000"- If you need the full thread:
bash
slackctl message list "https://workspace.slack.com/archives/C123/p1700000000000000" --thread-ts 1700000000.000000- 获取单条消息:
bash
slackctl message get "https://workspace.slack.com/archives/C123/p1700000000000000"- 如果需要完整线程:
bash
slackctl message list "https://workspace.slack.com/archives/C123/p1700000000000000" --thread-ts 1700000000.000000Browse recent channel messages
浏览频道近期消息
bash
slackctl message list "general" --limit 20
slackctl message list "C0123ABC" --limit 10bash
slackctl message list "general" --limit 20
slackctl message list "C0123ABC" --limit 10Get unread messages
获取未读消息
List all channels with unread messages:
bash
slackctl message unread --limit 20Also fetch the actual unread message content:
bash
slackctl message unread --fetch --max-per-channel 5Note: For Enterprise Grid, use with the enterprise URL for unread counts:
--workspacebash
slackctl message unread --workspace longbridge-group --fetch列出包含未读消息的所有频道:
bash
slackctl message unread --limit 20同时获取实际未读消息内容:
bash
slackctl message unread --fetch --max-per-channel 5注意:对于Enterprise Grid,需使用参数指定企业URL以获取未读计数:
--workspacebash
slackctl message unread --workspace longbridge-group --fetchSend, edit, delete, or react
发送、编辑、删除消息或添加/移除反应
bash
slackctl message send "general" "here is the report"
slackctl message send U01AAAA "hello via DM"
slackctl message send "general" "threaded reply" --thread-ts 1700000000.000000
slackctl message edit "general" 1700000000.000000 "updated text"
slackctl message delete "general" 1700000000.000000
slackctl message react add "general" 1700000000.000000 "eyes"
slackctl message react remove "general" 1700000000.000000 "eyes"Send to a user ID opens a DM automatically.
bash
slackctl message send "general" "here is the report"
slackctl message send U01AAAA "hello via DM"
slackctl message send "general" "threaded reply" --thread-ts 1700000000.000000
slackctl message edit "general" 1700000000.000000 "updated text"
slackctl message delete "general" 1700000000.000000
slackctl message react add "general" 1700000000.000000 "eyes"
slackctl message react remove "general" 1700000000.000000 "eyes"向用户ID发送消息会自动打开私信。
List channels + create/invite
列出频道 + 创建/邀请用户
bash
slackctl channel list
slackctl channel list --limit 50
slackctl channel new "incident-war-room"
slackctl channel new "incident-leads" --private
slackctl channel invite "incident-war-room" "U01AAAA,U02BBBB"bash
slackctl channel list
slackctl channel list --limit 50
slackctl channel new "incident-war-room"
slackctl channel new "incident-leads" --private
slackctl channel invite "incident-war-room" "U01AAAA,U02BBBB"Search (messages + files)
搜索(消息+文件)
bash
slackctl search messages "deploy failed" --limit 10
slackctl search files "report" --limit 5bash
slackctl search messages "deploy failed" --limit 10
slackctl search files "report" --limit 5Mark as read
标记为已读
bash
slackctl channel mark "general" 1700000000.000000bash
slackctl channel mark "general" 1700000000.000000Canvas
Canvas功能
Fetch a Slack canvas and convert to Markdown:
bash
slackctl canvas get "https://workspace.slack.com/docs/T123/F456"
slackctl canvas get F0123ABCDEF获取Slack canvas并转换为Markdown格式:
bash
slackctl canvas get "https://workspace.slack.com/docs/T123/F456"
slackctl canvas get F0123ABCDEFUsers
用户管理
bash
slackctl user list --limit 100
slackctl user get "@alice"
slackctl user get U01AAAAbash
slackctl user list --limit 100
slackctl user get "@alice"
slackctl user get U01AAAAMulti-workspace
多工作区支持
If you have multiple workspaces, pass to disambiguate:
--workspacebash
slackctl message list "general" --workspace "myteam" --limit 10
slackctl auth set-default https://myteam.slack.com如果您有多个工作区,请传递参数以明确指定:
--workspacebash
slackctl message list "general" --workspace "myteam" --limit 10
slackctl auth set-default https://myteam.slack.comAll output is JSON
所有输出均为JSON格式
All commands output JSON to stdout. Use for filtering:
| jqbash
slackctl user get U01AAAA | jq '.email'
slackctl message list "general" --limit 5 | jq '.[].text'所有命令均向标准输出(stdout)输出JSON。可使用进行过滤:
| jqbash
slackctl user get U01AAAA | jq '.email'
slackctl message list "general" --limit 5 | jq '.[].text'References
参考文档
- references/commands.md: full command map + all flags
- references/targets.md: URL vs channel targeting rules
- references/output.md: JSON output shapes
- references/commands.md:完整命令映射及所有参数
- references/targets.md:URL与频道定位规则
- references/output.md:JSON输出结构