lark-wiki
open.feishu.cn
Manage Lark Wiki spaces, members, and document nodes via CLI
What is lark-wiki?
lark-wiki is a skill for coding agents that provides structured access to Lark (Feishu) Wiki APIs via lark-cli. It covers creating and querying knowledge spaces, managing space members (users, groups, apps), and organizing node hierarchies including moves, copies, and deletions. It does not handle file uploads, document content editing, or spreadsheet/Base operations—those belong to separate skills.
- Create and list Lark Wiki knowledge spaces
- Get node details by node token, object token, or Lark/Doubao wiki URL
- Add, list, and remove space members (users, groups, departments, apps)
- Create, copy, move, and delete wiki nodes
- List child nodes under a space or parent node with pagination
- Resolve wiki URLs (including doubao.com /wiki/ paths) to space_id and node metadata
How to install lark-wiki
npx skills add null --skill lark-wiki- lark-cli must be installed and available in PATH
- lark-shared SKILL.md must be read first for authentication and permission setup
- Caller must have appropriate Lark app credentials (user or bot identity configured)
- For department member operations, user identity (--as user) is required; bot identity does not support opendepartmentid
How to use lark-wiki
- 1.Install the skill: npx skills add null --skill lark-wiki
- 2.Read lark-shared/SKILL.md to configure authentication before any API calls
- 3.Use --as user for personal wiki spaces (default auto often resolves to bot, which lists app-owned spaces instead)
- 4.List spaces: lark-cli wiki +space-list --as user
- 5.Get node info from a URL: lark-cli wiki +node-get --url <wiki_url>
- 6.Add a member: resolve the member's open_id first via lark-cli contact +search-user, then run lark-cli wiki +member-add
- 7.Create a node: lark-cli wiki +node-create with resolved space_id and optional parent node token
- 8.For file uploads or document content edits, switch to lark-drive or lark-doc skills respectively
Use cases
- Browse or audit the structure of a team's knowledge space
- Add a user or group as a member or admin of a wiki space
- Move or copy a document node into a different wiki space or parent
- Create a new wiki node under a specific space or parent node
- Resolve a wiki URL to its space_id before performing member management
- Developers automating Lark Wiki administration via coding agents
- Team leads organizing shared knowledge spaces and controlling access
- Agents handling wiki-related tasks triggered by Lark or Doubao wiki URLs
- Engineers building workflows that create or restructure wiki node hierarchies
lark-wiki FAQ
Yes. Route based on the /wiki/ URL path pattern and token, not the domain. Use lark-cli wiki spaces get_node with the token extracted from the URL.
The CLI default identity (auto) often resolves to bot. Explicitly pass --as user to list spaces owned by the authenticated user.
No. The Lark API does not support adding departments via opendepartmentid under bot (tenant_access_token). You must use --as user for department member operations.
Run lark-cli wiki spaces list --format json and paginate to find an exact name match, then present the candidate (name, space_id, description) to the user for confirmation before executing +delete-space --yes.
File uploads to wiki nodes (use lark-drive), editing document/spreadsheet/Base content (use lark-doc, lark-sheets, or lark-base), and file search or comment/permission management (use lark-drive).
Full instructions (SKILL.md)
Source of truth, from open.feishu.cn.
name: lark-wiki version: 1.0.1 description: "飞书知识库:管理知识空间、空间成员和文档节点。创建和查询知识空间、查看和管理空间成员、管理节点层级结构、在知识库中组织文档和快捷方式。当用户需要在知识库中查找或创建文档、浏览知识空间结构、查看或管理空间成员、移动或复制节点时使用。当用户给出 doubao.com 的 /wiki/ URL/token 时,也应直接使用本 skill,不要因为域名不是飞书而回退到 WebFetch;路由依据是 URL 路径模式和 token,而不是域名。不负责:上传文件到知识库节点下(走 lark-drive)、编辑文档/表格/Base 内容(走 lark-doc / lark-sheets / lark-base)。" metadata: requires: bins: ["lark-cli"] cliHelp: "lark-cli wiki --help"
wiki (v2)
CRITICAL — 开始前 MUST 先用 Read 工具读取 ../lark-shared/SKILL.md,其中包含认证、权限处理
成员管理硬限制:
- 如果目标是“部门”,先判断身份,再决定是否继续。
--as bot对应tenant_access_token。官方限制:这种身份下不能使用部门 ID (opendepartmentid) 添加知识空间成员。- 遇到“部门 + --as bot”时,禁止先调用
lark-cli wiki +member-add试错;直接说明该路径不可行。- 如果用户明确要求“以 bot 身份运行”,且目标是部门,必须停下说明 bot 路径无法完成,不要静默切到
--as user。
身份选择:优先使用 user 身份
知识空间和节点都是用户的个人资源,策略上应优先显式使用 --as user(CLI 的 --as 默认值为 auto,不带 --as 时常被解析成 bot,列出的是应用所属空间而非用户的)。仅当用户明确要求“应用 / bot 视角”时才用 --as bot(仍受上面的成员管理硬限制约束)。
快速决策
- 用户要整理 / 盘点 / 归类 / 重构知识库、个人文档库、文档库目录或 Wiki 节点结构,或要生成整理方案、目标目录树、移动计划时,不要只使用 Wiki 节点 API。必须先阅读
../lark-drive/references/lark-drive-workflow-knowledge-organize.md,该 workflow 负责 Drive / Wiki / 个人文档库的统一入口解析、资源盘点、分类计划、写前确认和结果验证。 - 用户给的是知识库 URL(
.../wiki/<token>),且后续要查成员/加成员/删成员:先调用lark-cli wiki spaces get_node --params '{"token":"<wiki_token>"}'获取space_id,后续成员接口统一使用space_id。 - 用户要删除知识空间(
wiki +delete-space)但只给了名称或 URL:不能把名称 / URL 原样传给--space-id,必须先解析出真实space_id。解析方式:- URL(
.../wiki/<token>):lark-cli wiki spaces get_node --params '{"token":"<wiki_token>"}' --format json,读data.node.space_id。 - 只知名称:
lark-cli wiki spaces list --format json,边翻页边收集 items 并按name精确匹配;一旦任一页累计到至少 1 条精确匹配就停止翻页。只有当翻完所有页(has_more=false)仍无精确匹配时,才对已收集的全量 items 做宽松匹配(nametrim 空格、大小写不敏感、子串包含)。 - 关键安全约束:无论精确还是模糊,无论命中 1 条还是多条,发起删除前都必须把候选(
name+space_id+description+space_type)列给用户,由用户明确选定一个space_id再执行。不要因为"只命中一条"就自动执行删除。 - 命中 0 条:停下来问用户是名称拼错了还是调用方无权限;不要自行改名字重试。
- 用户明确选定后再执行
lark-cli wiki +delete-space --space-id <ID> --yes(高风险写操作,必须显式--yes)。 - 反例:不要把 wiki URL / 名称直接当
--space-id(如--space-id "https://.../wiki/<wiki_token>");务必先用wiki spaces get_node解析出data.node.space_id再传。
- URL(
- 用户要在知识库中创建新节点,优先使用
lark-cli wiki +node-create。 - 用户说“给知识库添加成员/管理员”:先把目标解析成“用户 / 群 / 部门 / 应用”四类之一,再决定
--member-type,不要先调wiki +member-add再根据报错反推类型。 - 用户说“部门 + bot”:这是已知不支持路径。不要继续尝试
wiki +member-add --as bot;直接提示必须改成--as user,或明确告知当前要求无法完成。 - 用户说“用户 / 群 / 应用 + 添加成员”:先解析对应 ID,再执行
wiki +member-add。 - 用户说“查看 / 列出空间成员”:用
wiki +member-list;该 shortcut 默认只取一页,多成员场景显式加--page-all。 - 用户说“移除 / 删除空间成员”:用
wiki +member-remove,必须传齐原始授予时的--member-type和--member-role(不知道就先wiki +member-list查一下)。
Shortcuts(推荐优先使用)
Shortcut 是对常用操作的高级封装(lark-cli wiki +<verb> [flags])。有 Shortcut 的操作优先使用。
| Shortcut | 说明 |
|---|---|
+move | Move a wiki node, or move a Drive document into Wiki |
+node-create | Create a wiki node with automatic space resolution |
+delete-space | Delete a wiki space, polling the async delete task when needed |
+space-list | List all wiki spaces accessible to the caller |
+space-create | Create a wiki space (user identity only) |
+node-list | List wiki nodes in a space or under a parent node (supports pagination) |
+node-copy | Copy a wiki node to a target space or parent node |
+node-get | Get a wiki node's details by node_token / obj_token / Lark URL |
+node-delete | Delete a wiki node, polling the async delete task when needed |
+member-add | Add a member to a wiki space |
+member-remove | Remove a member from a wiki space |
+member-list | List members of a wiki space (supports pagination) |
成员添加流程
- 调用
lark-cli wiki +member-add前,先把自然语言里的“人 / 群 / 部门 / 应用”解析成正确的--member-id,不要猜格式。 - 用户场景默认优先
--member-type=openid:用lark-cli contact +search-user --query "<姓名/邮箱/手机号>" --format json获取open_id。 - 群组场景使用
--member-type=openchat:用lark-cli im +chat-search --query "<群名关键词>" --format json获取chat_id。 - 应用场景使用
--member-type=appid:--member-id传应用 ID,格式通常为cli_xxx。 userid/unionid只在下游明确要求时才使用;先拿到open_id,再调用lark-cli api GET /open-apis/contact/v3/users/<open_id> --params '{"user_id_type":"open_id"}' --format json读取user_id/union_id。- 部门场景使用
--member-type=opendepartmentid:当前 CLI 没有 shortcut,需调用lark-cli api POST /open-apis/contact/v3/departments/search --as user --params '{"department_id_type":"open_department_id"}' --data '{"query":"<部门名>"}'获取open_department_id。 - 只有在目标类型和身份都已确认可行后,才调用
lark-cli wiki +member-add。对于部门场景,这意味着必须是--as user。
目标语义约束
我的文档库/My Document Library/我的知识库/个人知识库/my_library都应视为 Wiki personal library,不是 Drive 根目录- 处理这类目标时,先解析
my_library对应的真实space_id,再执行wiki +move、wiki +node-create或其他 Wiki 写操作 - 不要因为缺少显式
space_id就退化成drive +move - 如果用户明确说的是 Drive 文件夹、云空间(云盘/云存储)根目录、
我的空间,才进入 Drive 域处理
API Resources
lark-cli schema wiki.<resource>.<method> # 调用原生 API 前必须先查看 --data / --params 参数结构,不要猜测字段格式
lark-cli wiki <resource> <method> [flags] # 调用 API
spaces
create— 创建知识空间get— 获取知识空间信息get_node— 获取知识空间节点信息list— 获取知识空间列表
members
create— 添加知识空间成员delete— 删除知识空间成员list— 获取知识空间成员列表
nodes
copy— 创建知识空间节点副本create— 创建知识空间节点list— 获取知识空间子节点列表
不在本 skill 范围
- 上传 / 下载文件到知识库节点下 →
lark-drive(drive +upload --wiki-token) - 编辑文档正文内容 →
lark-doc - 表格 / 多维表格数据操作 →
lark-sheets/lark-base - 按名称搜索文档 / Wiki / 表格文件、评论与权限管理 →
lark-drive
Related skills
More from open.feishu.cn and the wider catalog.
lark-approval
飞书审批:查询和处理审批待办/已办/实例,搜索可发起审批定义、查看定义详情并发起原生审批实例。当用户要处理审批任务、查看审批实例、搜索或发起审批时使用。审批待办不是飞书任务;非审批类待办走 lark-task。不负责创建审批定义;三方审批定义不走原生提单。
lark-doc
飞书云文档(Docx / Wiki 文档):读取和编辑飞书文档内容。当用户给出文档 URL 或 token,或需要查看、创建、编辑文档、插入或下载文档图片附件时使用。文档中嵌入的电子表格、多维表格、画板,先用本 skill 提取 token 再切到对应 skill。当用户给出 doubao.com 的 /docx/ 或 /wiki/ URL/token 时,也应直接使用本 skill;路由依据是 URL 路径模式和 token,而不是域名。不负责文档评论管理,也不负责表格或 Base 的数据操作。
lark-base
飞书多维表格(Base)操作:建表、字段、记录、视图、统计、公式/lookup、表单、仪表盘、workflow、角色权限;遇到 Base/多维表格/bitable 或 /base/ 链接时使用。文件导入转 lark-drive,认证/授权转 lark-shared。
lark-calendar
飞书日历:管理日历日程和会议室。查看/搜索日程、创建/更新日程、管理参会人、查询忙闲和推荐时段、预定会议室。当用户需要查看日程安排、创建/修改会议、查询/预定会议室时使用。不负责:查询过去的视频会议记录(走 lark-vc)、待办任务(走 lark-task)。
lark-drive
飞书云空间(云盘/云存储):管理 Drive 文件和文件夹,包含上传/下载、创建文件夹、复制/移动/删除、查看元数据、评论/权限/订阅、标题、版本和本地文件导入。用户需要整理云盘目录、处理云空间资源 URL/token,或导入 Word/Markdown/Excel/CSV/PPTX/.base 为 docx/sheet/bitable/slides 时使用;doubao.com 云空间 URL/token 也按资源路径和 token 路由,不回退 WebFetch。不负责:文档内容编辑(走 lark-doc)、表格/Base 表内数据操作(走 lark-sheets/lark-base)、知识空间节点/成员管理(走 lark-wiki)、原生 Markdown 文件读写/patch/diff(走 lark-markdown)。
lark-contact
飞书 / Lark 通讯录:按姓名 / 邮箱解析成 open_id,或按 open_id 反查姓名 / 部门 / 邮箱 / 联系方式 / 个人状态 / 签名。当用户提到某人姓名要下一步发消息 / 排日程,或拿到 open_id 想查具体信息时使用。不负责部门树遍历、按部门列员工、组织架构图,这类需求走原生 OpenAPI。