slack-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSlack CLI
Slack CLI
Use the Slack CLI to create, run, and manage Slack apps — including calling Web API methods directly and searching Slack developer documentation from the terminal.
For initial setup (sandbox creation, project scaffolding from templates), use the skill instead.
slack:create-slack-app使用Slack CLI从终端创建、运行和管理Slack应用——包括直接调用Web API方法,以及从终端搜索Slack开发者文档。
如果是初始设置(创建沙箱、从模板搭建项目),请使用技能。
slack:create-slack-appStep 1: Detect the Slack CLI
步骤1:检测Slack CLI
Resolve the path to the public Slack CLI before running any other command. We refer to the resolved value as — substitute it everywhere below. Try 1a → 1b → 1c in order; do not skip ahead.
SLACK_CMD在运行任何其他命令之前,先确定公开版Slack CLI的路径。我们将确定后的路径称为——请在下文所有位置替换为实际路径。按顺序尝试1a → 1b → 1c,不要跳过。
SLACK_CMD1a. Standard install path (preferred — no verification needed)
1a. 标准安装路径(首选——无需验证)
The official install scripts place the binary at a fixed per-user path. If the file exists, use it directly: only the install script writes to that path.
- macOS / Linux:
~/.slack/bin/slack - Windows: (or
%USERPROFILE%\AppData\Local\slack-cli\bin\slack.exeas a fallback)%USERPROFILE%\.slack-cli\bin\slack.exe
POSIX shell:
bash
[ -x "$HOME/.slack/bin/slack" ] && echo "$HOME/.slack/bin/slack"PowerShell:
powershell
$p = "$env:USERPROFILE\AppData\Local\slack-cli\bin\slack.exe"
if (Test-Path $p) { $p } elseif (Test-Path "$env:USERPROFILE\.slack-cli\bin\slack.exe") { "$env:USERPROFILE\.slack-cli\bin\slack.exe" }If a path is returned, set to that absolute path and proceed to Step 2. Do not also run .
SLACK_CMD_fingerprint官方安装脚本会将二进制文件放在固定的用户专属路径。如果文件存在,可直接使用:只有安装脚本会写入该路径。
- macOS / Linux:
~/.slack/bin/slack - Windows:(备用路径为
%USERPROFILE%\AppData\Local\slack-cli\bin\slack.exe)%USERPROFILE%\.slack-cli\bin\slack.exe
POSIX shell命令:
bash
[ -x "$HOME/.slack/bin/slack" ] && echo "$HOME/.slack/bin/slack"PowerShell命令:
powershell
$p = "$env:USERPROFILE\AppData\Local\slack-cli\bin\slack.exe"
if (Test-Path $p) { $p } elseif (Test-Path "$env:USERPROFILE\.slack-cli\bin\slack.exe") { "$env:USERPROFILE\.slack-cli\bin\slack.exe" }如果返回路径,请将设置为该绝对路径,然后进入步骤2。无需运行。
SLACK_CMD_fingerprint1b. slack
on PATH (verify with fingerprint)
slack1b. PATH中的slack
命令(通过指纹验证)
slackIf 1a found nothing, try on PATH:
slackbash
slack _fingerprint 2>/dev/nullIf it outputs , set and proceed.
d41d8cd98f00b204e9800998ecf8427eSLACK_CMD=slack如果1a未找到任何结果,尝试PATH中的命令:
slackbash
slack _fingerprint 2>/dev/null如果输出为,设置并继续。
d41d8cd98f00b204e9800998ecf8427eSLACK_CMD=slack1c. Ask about an alias, or install
1c. 询问别名或进行安装
If 1b fails or returns a different value, ask the developer using AskUserQuestion:
-
"Thecommand on your system doesn't appear to be the public Slack CLI. Do you have it installed under a different name or alias?"
slack -
Options: "Yes, it's aliased as..." (let them provide the alias), "No, I need to install it"
-
If they provide an alias, verify it withand set
<alias> _fingerprint 2>/dev/null.SLACK_CMD=<alias> -
If they need to install it, run:text
curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bashThen re-run 1a — the install script will have written.~/.slack/bin/slack
Common mistakes: Don't use to discover the binary — resolves any shell alias and defeats the point of 1a. In Git Bash on Windows, use the POSIX probe form, not PowerShell.
which slackwhich如果1b失败或返回不同值,请使用AskUserQuestion询问开发者:
-
"你系统中的命令似乎不是公开版Slack CLI。你是否使用其他名称或别名安装了它?"
slack -
选项:"是的,它的别名是..."(让开发者提供别名),"没有,我需要安装它"
-
如果开发者提供别名,使用验证,然后设置
<alias> _fingerprint 2>/dev/null。SLACK_CMD=<alias> -
如果需要安装,运行:text
curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash然后重新运行1a——安装脚本会将文件写入。~/.slack/bin/slack
常见错误:不要使用查找二进制文件——会解析任何shell别名,导致1a的验证失效。在Windows的Git Bash中,请使用POSIX探测格式,而非PowerShell。
which slackwhichStep 2: Command Discovery via Help
步骤2:通过帮助文档发现命令
Always run before constructing a command you have not used in the current session. Do not guess at flags — the help output is the source of truth.
SLACK_CMD <command> --help- — lists all available command groups
SLACK_CMD help - — shows subcommands, flags, and usage examples
SLACK_CMD <command> --help
**在当前会话中构建未使用过的命令之前,务必先运行。**不要猜测参数——帮助输出是权威来源。
SLACK_CMD <command> --help- ——列出所有可用命令组
SLACK_CMD help - ——显示子命令、参数和使用示例
SLACK_CMD <command> --help
Resolving --app
and --team
values
--app--team解析--app
和--team
参数值
--app--teamWhen a command requires or :
--app--team- App ID: Run from the project directory to see installed apps and their IDs.
SLACK_CMD app list - Team ID: Run to see authenticated workspaces and their team IDs.
SLACK_CMD auth list
当命令需要或时:
--app--team- 应用ID:从项目目录运行,查看已安装的应用及其ID。
SLACK_CMD app list - 团队ID:运行,查看已验证的工作区及其团队ID。
SLACK_CMD auth list
Step 3: Searching Documentation (slack docs search
)
slack docs search步骤3:搜索文档(slack docs search
)
slack docs searchSearch Slack's developer documentation directly from the terminal.
bash
SLACK_CMD docs search "<query>" --output=text --limit=5Use for concise terminal-readable results. Use this when you are already running CLI commands and want to:
--output=text- Check a Slack feature before implementing it
- Verify API behavior or required scopes
- Look up Block Kit elements, event types, or method parameters
直接从终端搜索Slack开发者文档。
bash
SLACK_CMD docs search "<query>" --output=text --limit=5使用获取适合终端阅读的简洁结果。当你正在运行CLI命令,且需要以下操作时使用该命令:
--output=text- 在实现前检查Slack功能
- 验证API行为或所需权限
- 查询Block Kit元素、事件类型或方法参数
Step 4: Calling Web API Methods (slack api
)
slack api步骤4:调用Web API方法(slack api
)
slack apiCall any Slack Web API method directly. Run for full details and examples.
SLACK_CMD api --helpParameters are passed as positional pairs (NOT flags):
key=value--key=valuebash
SLACK_CMD api chat.postMessage channel=C0123456789 text="Hello from the CLI"Important distinction: , , , and are meta-flags (prefixed with ). API method parameters use positional syntax without dashes.
--team--token--json--data--key=valueReference: Full method list at https://docs.slack.dev/reference/methods.md.
直接调用任何Slack Web API方法。运行获取完整详情和示例。
SLACK_CMD api --help参数以位置参数的形式传递(不是参数):
key=value--key=valuebash
SLACK_CMD api chat.postMessage channel=C0123456789 text="Hello from the CLI"重要区别:、、和是元参数(以开头)。API方法参数使用不带短横线的位置语法。
--team--token--json--data--key=value参考:完整方法列表见https://docs.slack.dev/reference/methods.md。
Step 5: Authentication (slack auth
)
slack auth步骤5:身份验证(slack auth
)
slack authWhen to run this flow
何时运行此流程
Slack auth is per-team, not a single boolean. Run the seamless login flow below whenever any of these is true:
- The developer is not authenticated to any team yet.
- The developer wants to add a new team / workspace / sandbox, even if already shows other teams.
SLACK_CMD auth list - The developer asks to log in, switch teams, or re-authenticate.
SLACK_CMD auth listSlack身份验证是按团队划分的,不是单一的布尔状态。当出现以下任一情况时,运行下方的无缝登录流程:
- 开发者尚未验证任何团队。
- 开发者想要添加新团队/工作区/沙箱,即使已显示其他团队。
SLACK_CMD auth list - 开发者要求登录、切换团队或重新验证。
SLACK_CMD auth listInspect existing auth (optional)
检查现有身份验证(可选)
bash
SLACK_CMD auth listUse this to show the developer which teams are already authenticated, or to confirm a successful login. Do not treat a non-empty list as "auth complete" when the developer asked to log in to a new team.
bash
SLACK_CMD auth list使用此命令向开发者展示已验证的团队,或确认登录成功。当开发者要求登录新团队时,不要将非空列表视为“身份验证完成”。
Run the seamless login flow
运行无缝登录流程
The agent drives this end-to-end — no separate terminal window, no browser confirmation.
SLACK_CMD login --no-prompt/slackauthticket1. Start login and capture the ticket
bash
SLACK_CMD login --no-promptThe CLI prints a slash command and exits. Capture the ticket — you will need it in step 4. Sample output:
/slackauthticket <ticket>text
📋 Run the following slash command from any Slack channel in the workspace
you'd like to authenticate
/slackauthticket eyJ0eXAiOiJKV1QiLCJh…
? Slack will then show you a challenge code. Submit it via:
slack login --ticket <ticket> --challenge <code>2. Hand the slash command to the developer
Show the full line and ask the developer to paste it into the message box of the Slack workspace they want to authenticate, then send it. Slack responds with a modal containing a short challenge code (e.g. ).
/slackauthticket …JDt1IK7X3. Collect the challenge code
Use to ask the developer for the challenge code shown in the Slack modal. Wait for their answer — do not guess or default.
AskUserQuestion4. Complete login
bash
SLACK_CMD login --ticket <ticket> --challenge <code>On success the CLI returns the team name and ID. Verify with and report the team back to the developer.
SLACK_CMD auth listTroubleshooting: tickets are single-use and time-limited. If step 4 fails with an invalid/expired ticket or wrong challenge, restart from step 1 with a fresh — do not retry the same ticket.
SLACK_CMD login --no-promptUse on individual commands to target a specific workspace without switching globally.
--team <team_id>由Agent全程驱动此流程——无需单独的终端窗口,无需浏览器确认。
SLACK_CMD login --no-prompt/slackauthticket1. 启动登录并捕获凭证
bash
SLACK_CMD login --no-promptCLI会打印斜杠命令并退出。捕获凭证——步骤4需要用到。示例输出:
/slackauthticket <ticket>text
📋 在你想要验证的工作区的任意Slack频道中运行以下斜杠命令
/slackauthticket eyJ0eXAiOiJKV1QiLCJh…
? Slack随后会向你展示验证码。通过以下命令提交:
slack login --ticket <ticket> --challenge <code>2. 将斜杠命令交给开发者
完整展示一行,并要求开发者将其粘贴到想要验证的Slack工作区的消息框中发送。Slack会回复一个包含短验证码的模态框(例如)。
/slackauthticket …JDt1IK7X3. 收集验证码
使用询问开发者Slack模态框中显示的验证码。等待开发者回复——不要猜测或使用默认值。
AskUserQuestion4. 完成登录
bash
SLACK_CMD login --ticket <ticket> --challenge <code>成功后,CLI会返回团队名称和ID。使用验证,并将团队信息反馈给开发者。
SLACK_CMD auth list故障排除:凭证是一次性的且有时间限制。如果步骤4因凭证无效/过期或验证码错误而失败,请重新从步骤1开始,运行新的——不要重试同一凭证。
SLACK_CMD login --no-prompt在单个命令上使用可指定目标工作区,无需全局切换。
--team <team_id>Red flags — STOP
危险信号——立即停止
If you catch yourself thinking any of these, you are about to regress to the old broken flow:
| Rationalization | Reality |
|---|---|
" | Auth is per-team. The developer asked for a new team — drive the flow. |
" | False with |
"I should tell the developer to run | Never. Step 5 is the agent's job from start to finish. |
All of these mean: run yourself and follow the four numbered steps above.
SLACK_CMD login --no-prompt如果你有以下想法,说明你即将退回到旧的失效流程:
| 错误想法 | 实际情况 |
|---|---|
" | 身份验证按团队划分。开发者要求登录_新_团队——请驱动流程。 |
" | 使用 |
"我应该让开发者在单独的终端窗口中运行 | 绝对不要这样做。步骤5全程由Agent负责。 |
出现以上任何情况时:自行运行,并按照上述四个编号步骤操作。
SLACK_CMD login --no-promptStep 6: Running an App Locally (slack run
)
slack run步骤6:本地运行应用(slack run
)
slack runRun for all available flags.
SLACK_CMD run --help运行查看所有可用参数。
SLACK_CMD run --helpResolve the app or team target
确定应用或团队目标
Run from the project directory to check for installed apps:
SLACK_CMD app list- If an app exists: Use in the run command.
--app=<app_id> - If no apps are listed: Use instead (get the team ID from
--team=<team_id>).SLACK_CMD auth list
从项目目录运行检查已安装的应用:
SLACK_CMD app list- 如果存在应用:在运行命令中使用。
--app=<app_id> - 如果未列出应用:改用(从
--team=<team_id>获取团队ID)。SLACK_CMD auth list
Start the dev server in the background
在后台启动开发服务器
Run this command as a background process so the developer can continue working:
If an app ID was found:
bash
cd <project-dir> && SLACK_CMD run --org-workspace-grant=all --app=<app_id>If no apps — use the team ID:
bash
cd <project-dir> && SLACK_CMD run --org-workspace-grant=all --team=<team_id>Tell the developer the app is running in the background. They can ask:
- "What's the status of the dev server?" — to check on it
- "Show me the output from slack run" — to see activity logs
- "Stop the dev server" — to terminate the process
将此命令作为后台进程运行,以便开发者可以继续工作:
如果找到应用ID:
bash
cd <project-dir> && SLACK_CMD run --org-workspace-grant=all --app=<app_id>如果没有应用——使用团队ID:
bash
cd <project-dir> && SLACK_CMD run --org-workspace-grant=all --team=<team_id>告知开发者应用正在后台运行。他们可能会询问:
- "开发服务器的状态如何?" ——检查服务器状态
- "显示的输出" ——查看活动日志
slack run - "停止开发服务器" ——终止进程
Step 7: Managing the Manifest
步骤7:管理Manifest
Run for subcommands (, ) and the flag.
SLACK_CMD manifest --helpvalidateinfo--source local|remoteUse before deploying or when something seems wrong with the app configuration.
SLACK_CMD manifest validate运行查看子命令(、)和参数。
SLACK_CMD manifest --helpvalidateinfo--source local|remote在部署前或应用配置出现问题时,使用。
SLACK_CMD manifest validateStep 8: Other Commands
步骤8:其他命令
For any other command group (e.g., , , , , , ), run to discover subcommands and flags. Run to see all available command groups.
triggerdatastoreenvcollaboratorexternal-authdeploySLACK_CMD <command> --helpSLACK_CMD help对于任何其他命令组(如、、、、、),运行发现子命令和参数。运行查看所有可用命令组。
triggerdatastoreenvcollaboratorexternal-authdeploySLACK_CMD <command> --helpSLACK_CMD helpNotes
注意事项
- is a placeholder — always substitute the actual command name resolved in Step 1.
SLACK_CMD - Always run before constructing a command you have not used in the current session.
--help - Interactive commands (e.g., without
slack trigger create) cannot be run in the background. Tell the developer to run these in a new terminal window.--trigger-defis not in this category — drive it inline using theslack login/--no-prompt/--ticketflow in Step 5.--challenge - runs locally for development.
slack rundeploys to Slack's hosted infrastructure. These are different operations — do not confuse them.slack deploy
- 是占位符——请始终替换为步骤1中确定的实际命令名称。
SLACK_CMD - 务必先运行,再构建当前会话中未使用过的命令。
--help - 交互式命令(如不带的
--trigger-def)无法在后台运行。请告知开发者在新终端窗口中运行这些命令。slack trigger create不属于此类命令——请使用步骤5中的slack login/--no-prompt/--ticket流程全程驱动。--challenge - 用于本地开发。
slack run用于部署到Slack的托管基础设施。这是两种不同的操作——不要混淆。slack deploy