lark-shared
SkillCommunityAudited: no issuesTranslated from ChineseThis skill provides essential guidelines for using lark-cli to manage Feishu resources, including configuration, authentication, and permission handling. It covers identity switching between user and bot roles, managing high-risk operations, and handling CLI updates.
npx skills add larksuite/cli/lark-sharedlark-cli sharing rules
This skill guides you on how to operate Lark resources using lark-cli and what precautions to take.
Configuration initialization
For the first use, you must run lark-cli config init to complete the application configuration.
When you help a user initialize the configuration, use the background method to initiate the configuration application process with the following command. After starting, read the output, extract the authorization link from it, and send it to the user.
URL forwarding rules: When the command output contains URL fields such as verification_url, verification_uri_complete, or console_url, you must forward the URL exactly as returned by the CLI to the user and treat it as an opaque string that cannot be modified. Do not perform URL encode/decode, do not add %20, spaces, or punctuation, do not reassemble the query, and do not rewrite it into Markdown link text. It is recommended to output it separately in a code block containing only the original URL.
# Initiate configuration (this command will block until the user opens the link and completes the operation or it expires)
lark-cli config init --new
Authentication
Identity types
There are two identity types, which can be switched via --as:
| Identity | Identifier | How to obtain | Applicable scenarios |
|---|---|---|---|
| user identity | --as user | lark-cli auth login etc. | Accessing the user's own resources (calendar, cloud drive, etc.) |
| bot identity | --as bot | Automatic, only appId + appSecret required | Application-level operations, accessing the bot's own resources |
Identity selection principles
The output [identity: bot/user] represents the current identity. The behavior of bot and user differs significantly, so you must confirm that the identity meets the target requirements:
- Bot cannot see user resources: Cannot access personal resources such as the user's calendar, cloud drive documents, or email. For example,
--as botto check the schedule returns the bot's own (empty) calendar. - Bot cannot act on behalf of the user: Messages are sent in the name of the application, and created documents belong to the bot.
- Bot permissions: Only need to enable scope in the Lark developer console, no
auth loginrequired. - User permissions: Enable scope in the console + user authorization via
auth login; both layers must be satisfied.
Handling insufficient permissions
When encountering permission-related errors, take different solutions based on the current identity type.
The error response contains key information:
permission_violations: Lists missing scopes (choose one of N).console_url: The permission configuration link in the Lark developer console.hint: Suggested repair command.
Bot identity (--as bot)
Provide the console_url from the error to the user as is, and guide them to the console to enable the scope. Do not perform auth login for the bot.
User identity (--as user)
lark-cli auth login --domain <domain> # Authorize by business domain
lark-cli auth login --scope "<missing_scope>" # Authorize by specific scope (recommended, follows the principle of least privilege)
Rule: auth login must specify a scope (--domain or --scope). Scopes from multiple logins will accumulate (incremental authorization).
Agent-initiated authentication (recommended)
When you as an AI agent need to help a user complete authentication, prioritize using split-flow to avoid blocking and waiting for user authorization in the same turn:
# Initiate authorization (immediately returns device_code and verification_url)
lark-cli auth login --scope "calendar:calendar:readonly" --no-wait --json
After obtaining the verification_url, send it to the user as the final message of the current turn as is, and end the turn/return control. Do not execute --device-code for blocking polling immediately after displaying the URL in the same turn; in an agent harness that does not pass through intermediate output, this will cause the user to never see the URL.
After the user replies that authorization is complete, execute the following in subsequent steps:
lark-cli auth login --device-code <device_code>
Update check
After a lark-cli command is executed, if a new version is detected, the JSON output will contain the _notice.update field (including message, command, etc.).
When you see _notice.update in the output, after completing the user's current request, proactively offer to help the user update:
- Inform the user of the current version and the latest version number.
- Propose to execute the update (updating both CLI and Skills):
lark-cli update - After the update is complete, remind the user: Exit and reopen the AI Agent to load the latest Skills.
Important: Always use lark-cli update to update, as it updates both the CLI and AI Skills simultaneously.
Rule: Do not silently ignore update prompts. Even if the current task is unrelated to the update, you should inform the user after completing their request.
Security rules
- Prohibit outputting secrets (appSecret, accessToken) to the terminal in plain text.
- Must confirm user intent before write/delete operations.
- Use
--dry-runto preview dangerous requests.
Approval protocol for high-risk operations (exit 10)
lark-cli has a mandatory confirmation gate for high-risk write operations (risk: "high-risk-write"). When you call such commands without --yes, the CLI will exit with code 10 and return the following structured envelope in stderr:
{
"ok": false,
"error": {
"type": "confirmation_required",
"message": "drive +delete requires confirmation",
"hint": "add --yes to confirm",
"risk": {
"level": "high-risk-write",
"action": "drive +delete"
}
}
}
When encountering this situation, do not give up as if it were a normal error. Handle it according to the following process:
- Identify: See that the child process exit code =
10anderror.type == "confirmation_required"in the stderr JSON. - Confirm with the user: Display
error.risk.actionand key parameters to the user, clearly state "This is a high-risk operation", and wait for the user's explicit consent. - User agrees → Retry by appending
--yesto the end of your original argv. - User refuses → Terminate the process; do not modify parameters or skip the gate without authorization.
Absolutely prohibited:
- Defaulting to adding
--yesand retrying silently when seeing exit 10 (this is equivalent to disabling the gate). - Treating
confirmation_requiredas a network error or permission error. - Appending
--yesand retrying without the user's explicit consent. - Using shell methods like
sh -cto concatenate commands for retries, use theexec.Command(argv...)parameter array form to avoid shell parsing treating user parameters as syntax.
Proactive prediction: If you want to let the user review the specific request for a dangerous operation first, add --dry-run when calling, it does not trigger the gate and will print full request details (URL / body / params). You can show this preview to the user before executing it for real.
How to identify if a command is high-risk
- Shortcut:
lark-cli <service> +<cmd> --helpwill displayRisk: high-risk-writeat the top. - Service command: The return value of
lark-cli schema <service>.<resource>.<method> --format jsonwill contain"risk": "high-risk-write".
lark-cli 共享规则
本技能指导你如何通过lark-cli操作飞书资源, 以及有哪些注意事项。
配置初始化
首次使用需运行 lark-cli config init 完成应用配置。
当你帮用户初始化配置时,使用background方式使用下面的命令发起配置应用流程,启动后读取输出,从中提取授权链接并发给用户。
URL 转发规则:当命令输出 verification_url、verification_uri_complete、console_url 等 URL 字段时,必须将 URL exactly as returned by the CLI 转发给用户,并把它视为不可修改的 opaque string;不要做 URL encode/decode,不要补 %20、空格或标点,不要重新拼接 query,不要改写成 Markdown link text,建议用只包含原始 URL 的代码块单独输出。
# 发起配置(该命令会阻塞直到用户打开链接并完成操作或过期)
lark-cli config init --new
认证
身份类型
两种身份类型,通过 --as 切换:
| 身份 | 标识 | 获取方式 | 适用场景 |
|---|---|---|---|
| user 用户身份 | --as user | lark-cli auth login 等 | 访问用户自己的资源(日历、云空间等) |
| bot 应用身份 | --as bot | 自动,只需 appId + appSecret | 应用级操作,访问bot自己的资源 |
身份选择原则
输出的 [identity: bot/user] 代表当前身份。bot 与 user 表现差异很大,需确认身份符合目标需求:
- Bot 看不到用户资源:无法访问用户的日历、云空间文档、邮箱等个人资源。例如
--as bot查日程返回 bot 自己的(空)日历 - Bot 无法代表用户操作:发消息以应用名义发送,创建文档归属 bot
- Bot 权限:只需在飞书开发者后台开通 scope,无需
auth login - User 权限:后台开通 scope + 用户通过
auth login授权,两层都要满足
权限不足处理
遇到权限相关错误时,根据当前身份类型采取不同解决方案。
错误响应中包含关键信息:
permission_violations:列出缺失的 scope (N选1)console_url:飞书开发者后台的权限配置链接hint:建议的修复命令
Bot 身份(--as bot)
将错误中的 console_url 原样提供给用户,引导去后台开通 scope。禁止对 bot 执行 auth login。
User 身份(--as user)
lark-cli auth login --domain <domain> # 按业务域授权
lark-cli auth login --scope "<missing_scope>" # 按具体 scope 授权(推荐,符合最小权限原则)
规则:auth login 必须指定范围(--domain 或 --scope)。多次 login 的 scope 会累积(增量授权)。
Agent 代理发起认证(推荐)
当你作为 AI agent 需要帮用户完成认证时,优先使用 split-flow,避免在同一轮对话中阻塞等待用户授权:
# 发起授权(立即返回 device_code 和 verification_url)
lark-cli auth login --scope "calendar:calendar:readonly" --no-wait --json
拿到 verification_url 后,将它原样作为本轮最终消息发给用户,并结束本轮/交还控制权。不要在同一轮中展示 URL 后立刻执行 --device-code 阻塞轮询;在不透传中间输出的 agent harness 里,这会导致用户永远看不到 URL。
用户回复已完成授权后,再在后续步骤执行:
lark-cli auth login --device-code <device_code>
更新检查
lark-cli 命令执行后,如果检测到新版本,JSON 输出中会包含 _notice.update 字段(含 message、command 等)。
当你在输出中看到 _notice.update 时,完成用户当前请求后,主动提议帮用户更新:
- 告知用户当前版本和最新版本号
- 提议执行更新(同时更新 CLI 和 Skills):
lark-cli update - 更新完成后提醒用户:退出并重新打开 AI Agent 以加载最新 Skills
重要:始终使用 lark-cli update 更新,它会同时更新 CLI 和 AI Skills。
规则:不要静默忽略更新提示。即使当前任务与更新无关,也应在完成用户请求后补充告知。
安全规则
- 禁止输出密钥(appSecret、accessToken)到终端明文。
- 写入/删除操作前必须确认用户意图。
- 用
--dry-run预览危险请求。
高风险操作的审批协议(exit 10)
lark-cli 对高风险写操作(risk: "high-risk-write")有强制确认门禁。当你不带 --yes 调用这类命令时,CLI 会退出码 10、并在 stderr 返回如下结构化 envelope:
{
"ok": false,
"error": {
"type": "confirmation_required",
"message": "drive +delete requires confirmation",
"hint": "add --yes to confirm",
"risk": {
"level": "high-risk-write",
"action": "drive +delete"
}
}
}
遇到这种情况,不要当普通错误放弃。 按以下流程处理:
- 识别:看到子进程 exit code =
10且 stderr JSON 里error.type == "confirmation_required" - 向用户确认:把
error.risk.action和关键参数展示给用户,明确告知"这是高风险操作",等待用户显式同意 - 用户同意 → 在你原始 argv 的末尾追加
--yes后重试 - 用户拒绝 → 终止流程,不要擅自改写参数或跳过门禁
绝对不允许:
- 看到 exit 10 就默认加
--yes静默重试(这等于禁用门禁) - 把
confirmation_required当网络错误/权限错误处理 - 在用户没明确同意的前提下追加
--yes重试 - 用
sh -c等 shell 方式拼接命令重试——用exec.Command(argv...)参数数组形式,避免 shell 解析把用户参数当作语法
提前预判:想先让用户 review 危险操作的具体请求,调用时加 --dry-run——它不触发门禁,会打印完整请求详情(URL / body / params),你可以把这个预览给用户看过再去真正执行。
如何识别一条命令是高风险
- shortcut:
lark-cli <service> +<cmd> --help顶部会显示Risk: high-risk-write - service 命令:
lark-cli schema <service>.<resource>.<method> --format json的返回值里"risk": "high-risk-write"
Installs
218,135First seen
Jun 10, 2026
Auto-fetched from GitHub .
Stats via skills.sh.
Skills similar to lark-shared:
Installs
Installs
Installs