CRITICAL — Before starting, you MUST first use the Read tool to read ../lark-shared/SKILL.md, which contains authentication and permission handling
Hard limits on member management:
- If the target is a "department", first determine the identity, then decide whether to continue.
--as botcorresponds totenant_access_token. Official limitation: under this identity, a department ID (opendepartmentid) cannot be used to add wiki space members.- When encountering "department + --as bot", it is forbidden to first call
lark-cli wiki +member-addfor trial and error; directly state that this path is not feasible.- If the user explicitly requests "run as bot" and the target is a department, you must stop and explain that the bot path cannot complete it; do not silently switch to
--as user。
Identity selection: Prefer using the user identity
Knowledge spaces and nodes are both personal resources of the user.As a policy, you should preferentially explicitly use --as user(the CLI's --as default is auto); without --as , it is often parsed as bot, and what is listed is the spaces belonging to the app rather than the user's. Only use --as botwhen the user explicitly requests the "app / bot perspective" (still subject to the hard limits on member management above).
Quick decisions
- The user wants tosearch for materials by a specific topic / keyword / content clue and collect them into a wiki node or under a newly created wiki node, you must first read
../lark-drive/references/lark-drive-workflow.md, then follow theWorkflow Registryin it to enter thetopic_move_collectorworkflow. This workflow uses a full Drive search for recall, then resolves, confirms, and moves according to the Wiki target; do not use only the Wiki node list for local traversal. - The user wants toorganize / inventory / categorize / restructure the wiki, personal document library, document library directory, or Wiki node structure, or wants to generate an organization plan, target directory tree, or move plan, do not use only the Wiki node API. You must first read
../lark-drive/references/lark-drive-workflow.md, then follow theWorkflow Registryin it to enter theknowledge_organizeworkflow; this workflow is responsible for the unified entry resolution, resource inventory, classification plan, pre-write confirmation, and result verification for Drive / Wiki / personal document library. - The user wants tomove an existing Wiki node out of the wiki and place it in a Drive folder or the root directory of "My Space": use
wiki +move-to-drive, do not usewiki +moveordrive +move. This is a write operation that changes node ownership and permission inheritance; confirm the source node and target location before execution. - The user provides a wiki URL (
.../wiki/<token>), and subsequently wants to query members/add members/remove members: first determine the identity for downstream member operations (defaultuser; usebotwhen the user explicitly requests the app / bot perspective), then calllark-cli wiki +node-get --node-token '<wiki_url>' --as user --format json, obtain the space ID fromdata.space_id; when using bot downstream, change the identity in the example to--as bot. Node resolution and subsequent member operations must use the same identity. - The user wants todeletea knowledge space (
wiki +delete-space) but only a name or URL is given:must notpass the name / URL as-is to--space-id; the realspace_idmust be resolved first. Resolution method:- URL(
.../wiki/<token>): first determine the identity of the subsequentwiki +delete-space(defaultuser; when the bot perspective is explicitly required, usebot), then calllark-cli wiki +node-get --node-token '<wiki_url>' --as user --format json, readdata.space_id; when downstream uses bot, change the identity in the example to--as bot. Resolution and deletion must use the same identity. - Only know the name:
lark-cli wiki spaces list --format json, page through while collecting items and match exactly byname;once any page accumulates at least 1 exact match, stop paging. Only when all pages have been paged through (has_more=false) and there is still no exact match, perform loose matching on all collected items (nametrim spaces, case-insensitive, substring containment). - Key security constraint: whether exact or fuzzy,whether 1 or multiple hits, before initiating deletion you must list the candidates (
name+space_id+description+space_type) to the user, and the user must explicitly select onespace_idbefore executing. Do not automatically execute deletion just because "only one hit". - 0 hits: stop and ask the user whether the name was misspelled or the caller lacks permission;do notchange the name yourself and retry.
- After the user has explicitly selected, execute
lark-cli wiki +delete-space --space-id <ID> --yes(high-risk write operation, must be explicitly--yes)。 - Counterexample: do not treat a wiki URL / name directly as
--space-id(e.g.--space-id "https://.../wiki/<wiki_token>"); be sure to first usewiki +node-getto resolvedata.space_idbefore passing it.
- URL(
- The user wants to create a new node in the knowledge base; prefer using
lark-cli wiki +node-create。 - The user wants torename a Wiki node in place / modify the node title: use
lark-cli drive +update-title --url '<wiki_url>' --title '<new_title>'. This command keeps the samenode_token, and based on the API response gives the exact missing scope and authorization hints; do not explore thewiki.nodesof the rawupdate_titleendpoint, and do not implement renaming by copying or creating a second node. - The user wants to list Wiki nodes: first use
wiki +space-list --as userto get the numericspace_id, then usewiki +node-list --space-id <space_id>. Do not treat a wiki URL, node token, doc token, or name directly as--space-id. When drilling into child nodes,--parent-node-tokenmust be a wiki node token; if the user gives a docx/sheet/base URL, first usewiki +node-get --node-token <url>to resolvenode_token。 wiki +node-listhitsinvalid_parameters、not_found、permission_denied, do not repeatedly call with the same parameters; fixspace_id/parent_node_token/ permissions according to the hint. Onlyrate_limitshould be retried with backoff.- The user says "add a member/admin to the knowledge base": first resolve the target into one of the four categories "user / group / department / app", then decide
--member-type; do not callwiki +member-addfirst and then infer the type from the error. - The user says "department + bot": this is a known unsupported path. Do not keep trying
wiki +member-add --as bot; directly prompt that it must be changed to--as user, or clearly inform that the current request cannot be completed. - User says "user / group / app + add member": first resolve the corresponding ID, then execute
wiki +member-add。 - User says "view / list space members": use
wiki +member-list; this shortcut only fetches one page by default, for multi-member scenarios explicitly add--page-all。 - User says "remove / delete space member": use
wiki +member-remove, must pass the complete original grant--member-typeand--member-role(if unknown, firstwiki +member-listlook it up).
Shortcuts (prefer using these first)
Shortcut is a high-level wrapper for common operations (lark-cli wiki +<verb> [flags]). For operations with a Shortcut, prefer using it.
Always use wiki +node-getto get or resolve Wiki nodes, including intermediate steps only for getting space_id、node_token、obj_token or obj_type .
| Shortcut | Description |
|---|---|
+move |
Move a wiki node, or move a Drive document into Wiki |
+move-to-drive |
Move a wiki node to a Drive folder and poll the async task |
+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) |
Member addition process
- Before calling
lark-cli wiki +member-add, first resolve the "person / group / department / app" in natural language into the correct--member-id, do not guess the format. - For user scenarios, default to prioritizing
--member-type=openid: uselark-cli contact +search-user --query "<姓名/邮箱/手机号>" --format jsonto getopen_id。 - For group scenarios use
--member-type=openchat: uselark-cli im +chat-search --query "<群名关键词>" --format jsonto getchat_id。 - For app scenarios use
--member-type=appid:--member-idto pass the app ID, the format is usuallycli_xxx。 userid/unionidUse only when explicitly required by downstream; first getopen_id, then calllark-cli api GET /open-apis/contact/v3/users/<open_id> --params '{"user_id_type":"open_id"}' --format jsonto readuser_id/union_id。- For department scenarios use
--member-type=opendepartmentid: the current CLI has no shortcut, need to calllark-cli api POST /open-apis/contact/v3/departments/search --as user --params '{"department_id_type":"open_department_id"}' --data '{"query":"<部门名>"}'to getopen_department_id。 - Only after the target type and identity are both confirmed feasible, call
lark-cli wiki +member-add. For department scenarios, this means it must be--as user。
Target semantic constraints
我的文档库/My Document Library/我的知识库/个人知识库/my_libraryshould all be treated as Wiki personal library, not the Drive root directory- When handling such targets, first resolve
my_libraryto the corresponding realspace_id, then executewiki +move、wiki +node-createor other Wiki write operations - Do not degrade to
space_idjust because an explicitdrive +move - If the user explicitly says Drive folder, cloud space (cloud disk/cloud storage) root directory,
我的空间, then branch by source object: when the source object is a Wiki node usewiki +move-to-drive, when the source object is already in Drive usedrive +move
API Resources
lark-cli schema wiki.<resource>.<method> # 调用原生 API 前必须先查看 --data / --params 参数结构,不要猜测字段格式
lark-cli wiki <resource> <method> [flags] # 调用 API
spaces
create— Create knowledge spaceget— Get knowledge space infolist— Get knowledge space list
members
create— Add knowledge space memberdelete— Delete knowledge space memberlist— Get knowledge space member list
nodes
copy— Create knowledge space node copycreate— Create knowledge space nodelist— Get knowledge space child node list
Not in this skill's scope
- Upload file to knowledge base node →
lark-drive(drive +upload --wiki-token) - Download the file corresponding to a Wiki node (underlying
obj_typeisfile)→lark-drive:drive +download --wiki-token <node_token>ordrive +download --url <wiki_url>(the CLI will first resolve the Wiki node to the underlying file before downloading); when the underlying isdocx/sheet/bitable/slidesand other online documents, usedrive +export - Edit document body content →
lark-doc - Table / Bitable data operations →
lark-sheets/lark-base - Search documents / Wiki / table files by name, comments and permission management →
lark-drive