skills/feishu-cli-profile/SKILL.md
feishu-cli 多 App 配置切换。profile add/list/remove/rename/use/current/migrate 管理 ~/.feishu-cli/profiles/<name>/{config,token}.json 多套 App ID + Token 配置。 active-profile 指针记录当前激活 profile。向后兼容旧版无 profile 时直接读 ~/.feishu-cli/{config,token}.json。 当用户在多个飞书租户 / 多个 App ID 间切换时使用,避免反复重新登录。
npx skillsauth add riba2534/feishu-cli feishu-cli-profileInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
feishu-cli profile 让一台机器在多个飞书账号 / 应用之间快速切换,免去手动备份 / 恢复 ~/.feishu-cli/{config.yaml,token.json} 的麻烦。常见场景:work / personal 双账号、feishu.cn / larksuite.com 双端、多个 tenant 协同测试。
feishu-cli:如尚未安装,请前往 riba2534/feishu-cli 获取安装方式。
~/.feishu-cli/
config.yaml # 旧布局:profile 系统未启用时仍读这里(无感升级)
token.json # 旧布局
active-profile # 一行文本:当前 profile 名
previous-profile # 一行文本:上一个 profile 名(支持 use -)
profiles/
work/
config.yaml # 该 profile 自己的 app_id / app_secret / base_url
token.json # 该 profile 的 User Access Token + Refresh Token
user_profile.json # 缓存的当前登录用户信息
personal/
...
由 internal/profile.ActiveDir() 决定,所有 feishu-cli 命令(auth login / doc import / msg send 等)自动从这里读 config + token,无需任何额外参数:
FEISHU_PROFILE=<name>(强制覆盖,不写指针文件;profile 必须已存在,否则报错)~/.feishu-cli/active-profile 指针文件指向的 profileprofiles/ 下字典序第一个profiles/ 不存在) → 返回旧布局 ~/.feishu-cli/,老用户零感知internal/config 和 internal/auth 仍走旧路径 ~/.feishu-cli/{config.yaml,token.json}profile add 不会自动迁移旧文件——避免静默丢数据config.yaml + token.json 接入 profile 系统,必须显式 profile migrate# 新建
feishu-cli profile add <name> [--app-id ... --app-secret ... --base-url ... --use] [--json]
# 列表(标注 active)
feishu-cli profile list [--json] # alias: ls
# 切换 active
feishu-cli profile use <name> [--json] # alias: switch / checkout
feishu-cli profile use - # 切回上一个 profile
# 显示当前 active
feishu-cli profile current
# 重命名(自动同步 active / previous 指针)
feishu-cli profile rename <old> <new> [--json] # alias: mv
# 删除(默认二次确认)
feishu-cli profile remove <name> [--force] [--json] # alias: rm / delete
# 把旧布局迁移到 profile 系统(不可逆见下方踩坑)
feishu-cli profile migrate [--name <target>] [--force] [--json]
profile add创建 ~/.feishu-cli/profiles/<name>/ 目录并写入初始 config.yaml。不会自动迁移旧布局——如需迁移用 profile migrate。
| 参数 | 默认 | 说明 |
|------|------|------|
| --app-id | "" | 飞书应用 app_id,可后续手动写 config.yaml |
| --app-secret | "" | 飞书应用 app_secret |
| --base-url | https://open.feishu.cn | 飞书 OpenAPI base URL(larksuite 用 https://open.larksuite.com) |
| --use | false | 创建后立即切换为 active profile |
| --json | false | JSON 输出,适合脚本 / AI Agent |
feishu-cli profile add work --app-id cli_xxx --app-secret secret_xxx --use
feishu-cli profile add personal --base-url https://open.larksuite.com
feishu-cli profile add temp # 留空待手动填
profile listfeishu-cli profile list
# ACTIVE NAME CONFIG TOKEN PATH
# * work yes yes /Users/me/.feishu-cli/profiles/work
# personal yes no /Users/me/.feishu-cli/profiles/personal
ACTIVE 列星号 * 标当前激活CONFIG / TOKEN 表示该 profile 是否已有 config.yaml / token.json(用来判断是否已 auth login)--json 返回 {"active": "work", "profiles": [{"name":..., "path":..., "active":..., "has_config":..., "has_token":...}]}profile use切换 active,把 ~/.feishu-cli/active-profile 指针写为 <name>。
previous-profile,支持 use - toggle 切回ErrNotFoundfeishu-cli profile use personal
feishu-cli profile use - # 切回上一个
profile current显示当前激活 profile 名 + 目录(制表符分隔)。未启用 profile 系统时输出 (未启用 profile 系统,使用旧布局 ~/.feishu-cli/)。
profile rename把 profiles/<old>/ 整目录 rename 到 profiles/<new>/,自动同步 active-profile / previous-profile 指针文件。
profile remove删除 profiles/<name>/ 整个目录(含 config / token / 用户信息缓存)。
--force 跳过提示active-profile 指针被清空,下次访问回退到字典序第一个 profileprofile migrate把旧布局 ~/.feishu-cli/{config.yaml,token.json,user_profile.json} 拷贝到 profiles/<target>/,并把 active 指针指向 target。
| 参数 | 默认 | 说明 |
|------|------|------|
| --name | default | 迁移目标 profile 名 |
| --force | false | 目标 profile 已存在时覆盖 |
| --json | false | JSON 输出 |
原文件不会被删除——用户自己确认无误后可手动 rm ~/.feishu-cli/{config.yaml,token.json,user_profile.json}。
FEISHU_PROFILE 环境变量临时覆盖当前 active profile,不修改指针文件,适合 CI / 一次性切换:
FEISHU_PROFILE=work feishu-cli msg send ... # 仅本次命令用 work
FEISHU_PROFILE=personal feishu-cli auth status # 检查 personal 的登录态
ErrNotFound/ .. 等)时报错 ErrInvalidName仅允许 [A-Za-z0-9_-]{1,64}:
. / .. / / 等路径注入字符profiles / cache 不可作为 profile 名非法名直接报 ErrInvalidName,所有命令在动手前会先校验。
# 已经有 ~/.feishu-cli/config.yaml + token.json
feishu-cli profile migrate # → profiles/default/,指针指 default
feishu-cli profile list # 确认 default 已是 active
feishu-cli profile add personal --use --app-id cli_yyy # 新建 personal 并切过去
feishu-cli auth login # 给 personal 做 OAuth
feishu-cli profile use - # 切回 default
feishu-cli profile add work --app-id cli_work --app-secret secret_xxx --use
feishu-cli auth login # work 登录
feishu-cli profile add personal --base-url https://open.larksuite.com
feishu-cli profile use personal
feishu-cli auth login # personal 登录
feishu-cli profile list # 看双账号状态
FEISHU_PROFILE=ci-bot feishu-cli msg send --chat-id oc_xxx --text "build done"
# 不动 active-profile 指针,下次普通命令仍用之前的 profile
profile migrate 不可逆,但原文件不删config.yaml / token.json / user_profile.json 被复制到 profiles/<target>/,并写入 active 指针profiles/ 目录存在且至少一个子目录),所有命令都走 ActiveDir() 解析,不再读旧路径profile remove <target> 删干净所有 profile 让 profiles/ 空 → 回退到旧布局;要么手动 cp 把 profile 目录内容拷回 ~/.feishu-cli/ 顶层profile current + 跑一条业务命令(如 auth status)确认无误,再考虑 rm ~/.feishu-cli/{config.yaml,token.json,user_profile.json}sync.Mutex 仅进程内并发,不跨进程锁internal/profile.writeMu 是 Go 进程内 mutex,串行化同一进程内的 Create / Remove / Rename / Use / MigrateLegacyfeishu-cli 进程同时改 active-profile 指针文件——指针写入用了 .tmp + rename 原子替换,但两个进程 race 可能造成"最后一个赢"的不一致profile use a & profile use b),结果不可预期& 后台并行);自动化场景一律单进程依次跑profile use 不会自动登录切换到一个还没 auth login 过的 profile,后续命令会按需提示「未登录飞书」。需要先:
feishu-cli profile use newone
feishu-cli auth login # 这次的 token 落到 profiles/newone/token.json
active-profile 指针指向不存在的 profile不会报错,会自动回退到字典序第一个 profile。如果想精确控制,请显式 profile use <name> 修正指针。
profile remove 删的是当前 active 时,指针被清空,下次命令会回退到字典序第一个 profile(如果还有的话)。profile list 会提示「当前无激活 profile」。
profiles/ 是否存在子目录HasProfiles() 检查 ~/.feishu-cli/profiles/ 下是否有至少一个合法名字的子目录。空目录 / 全是非法名(如 .tmp)的子目录会被忽略,仍走旧布局。所以单纯 mkdir ~/.feishu-cli/profiles/ 不会改变 CLI 行为。
feishu-cli config create-app --save + feishu-cli auth login,走 feishu-cli-authfeishu-cli-authconfig.yaml 字段说明 / config create-app 一键创建应用 → feishu-cli-auth 的「创建飞书应用」节cp ~/.feishu-cli/profiles/work/token.json ~/.feishu-cli/profiles/personal/,CLI 没提供专门命令所有写操作(add / use / rename / remove / migrate)和 list 都支持 --json,返回结构化输出:
$ feishu-cli profile add work --app-id cli_xxx --use --json
{"active":true,"dir":"/Users/me/.feishu-cli/profiles/work","name":"work","ok":true}
$ feishu-cli profile list --json
{"active":"work","profiles":[{"name":"work","path":"...","active":true,"has_config":true,"has_token":true}]}
$ feishu-cli profile use personal --json
{"active":"personal","dir":"...","ok":true,"previous":"work"}
$ feishu-cli profile current
work /Users/me/.feishu-cli/profiles/work
AI Agent 优先 --json 解析,避免依赖人类可读输出的格式稳定性。
tools
往飞书文档里插入/更新/读取/删除「妙笔BOX」HTML 小组件块——飞书文档里**唯一能跑动画和可交互内容**的载体。 把一整页 HTML(CSS/JS)塞进块,在 iframe 沙箱里真实执行:CSS @keyframes 动画、ECharts/Three.js 图表、 Canvas、可拖拽力导向图、Dashboard、打字机/进度条/状态机动画等都能动。 当用户请求"飞书文档里做动画/能动的图/可交互图表/数据大屏/Dashboard/真实地图/地理飞线/3D 图表(map3D、3D 曲面、Three.js)/在飞书文档里放 ECharts 可视化/批量做一套图表演示"、"妙笔BOX"、"HTML 小组件"、 "在飞书文档里跑 ECharts/CSS 动画/JavaScript"、"嵌入网页/HTML 到飞书文档"、"飞书文档里的图怎么动起来"时使用。 注意:要"动"必须用本技能(妙笔BOX);画板(feishu-cli-board)的 SVG 节点会被服务端栅格化成静态图,不会动。
tools
飞书 OpenAPI 裸调。api GET/POST/PUT/DELETE/PATCH <path> 直接调用任意飞书 OpenAPI 接口, 覆盖 feishu-cli 尚未封装的接口(对齐 lark-cli 的 api 能力)。支持 --params(query)/--data(body JSON)/--data-file(从文件读 body)/ --as auto|user|bot 身份/--dry-run 预览/-o 二进制下载/--format/--jq。 当用户请求"调用 X API"、"裸调飞书接口"、"feishu-cli 没封装的接口怎么调"、"raw api"、 "用 api 命令发请求"、"下载飞书媒体/文件 binary"时使用。 不适用:仅查 schema 不调用(用 feishu-cli schema);已有专用命令的高频场景(用对应 feishu-cli <模块>)。
tools
飞书电子表格高级能力(筛选视图 + 筛选条件 + 下拉单元格 + 浮动图片 + 批量样式)。 filter-view CRUD 管理筛选视图,filter-view condition CRUD 写筛选条件(V3 API); dropdown set/get/update/delete 管理单元格下拉框(V2 dataValidation); image get/update/media-upload/write-image 操作浮动图片与单元格写图; batch-set-style 批量设置多范围单元格样式。 基础读写(read/write/style/add-rows/add-sheet)仍在 feishu-cli 主命令 sheet/bitable, 本 skill 专注高级能力。 当用户请求"筛选视图"、"筛选条件"、"加下拉框"、"数据验证"、"列下拉"、"浮动图片"、"插入图片"、"批量样式"时使用。
tools
飞书 OpenAPI 方法本地浏览 + 通用 API 透传调用。schema `service.resource.method` 三段式查路径/参数/scope(无需联网); `feishu-cli api <method> <path>` 直接调任意端点(v1.29+,覆盖 2500+ 未封装 API)。 当用户请求"飞书有没有 XX API"、"X API 的参数是什么"、"X 方法需要什么 scope"、 "OpenAPI 方法浏览"、"看 SDK 怎么调用"、"调一个没封装的飞书 API"时使用。 不适用:查在线最新 schema(请用 OpenAPI Explorer,本地元数据可能落后于飞书开放平台)。