SuperAPI AI Directory

lark-drive

Office & productivity

View repository

Updated 10-13 21:26

About this skill

drive (v1)

CRITICAL — Before starting, you MUST first use the Read tool to read ../lark-shared/SKILL.md, which contains authentication and permission handling

Terminology note: Feishu Cloud Space is also often called "Cloud Drive", "Cloud Storage", "Netdisk", or "My Space". These terms usually refer to the same product, which is Feishu's official cloud file storage and management center.

Import routing rules: If the user wants to import a local Excel / CSV / .base snapshot into a Base / Bitable / bitable, you must prioritize using lark-cli drive +import --type bitable. Do not first switch to lark-base;lark-base is only responsible for in-table operations after the import is complete.

Copy routing rules: If the user wants to copy an online document, create a document copy, or copy a document to another folder, you must use lark-cli drive +copy. Do not use drive +export to download and then drive +import upload, and do not use docs +fetch + docs +create to rebuild the body; export/import is only for local file conversion or offline artifacts.

Quick decision

  • The user wants to move anexisting Wiki node out of the knowledge base and place it in a Drive folder or the root directory of "My Space": switch to lark-wiki, use lark-cli wiki +move-to-drive; do not hand the Wiki token directly to drive +move. This is a write operation that changes document ownership and permission inheritance. Confirm the source node and target location before executing.
  • The user wants tocopy a document / create a copy to Cloud Drive or a folder: when a directly usable URL or token is provided, use references/lark-drive-copy.md to use lark-cli drive +copy; when only a title is provided, first use references/lark-drive-search.md to use drive +search to uniquely locate the source resource, then copy according to the copy reference. If you want to copy a document / create a copy to the knowledge base, use wiki +node-copy(see lark-wiki-node-copy.md)。
  • The user wants toidentify the type and token of a Feishu / doubao cloud space URL: you can first make a lightweight judgment based on the URL path form; when the path already clearly points to resources such as docx / sheet / bitable / slides / file / folder, you can directly extract the corresponding token/type. When a wiki URL is passed in, the title or canonical URL needs to be identified, the URL/token is ambiguous, or subsequent operations depend on the underlying real resource, then use lark-cli drive +inspect --url '<url>' for identification; for specific usage, failure handling, and boundaries, see references/lark-drive-inspect.md。
  • High-risk write operations (deletion, public permission modification, owner transfer, version deletion/rollback, batch move/overwrite/sync) must satisfy three conditions at the same time before execution: the target has been resolved into an executable object that can be directly used by the operation, the execution details have been clarified to the point where the command can be directly called (for example, the file-token/type for deletion, the sharing scope for public permission modification, the target owner for owner transfer, the version id for version deletion/rollback, and the target location and conflict policy for move/overwrite/sync), and the user explicitly confirms in this round to execute these specific targets and execution details. If the user only says "delete useless files", "open/share with everyone", "change to open", "overwrite/move these", it only indicates the target state; first perform read-only discovery and list candidates, permission levels, or execution plans, then stop and wait for user confirmation.
  • The user wants tocheck / govern document permissions, public scope, link sharing, external access, copy and download permissions, classification labels, owner transfer, or wants "permission risk reports, tighten permissions, request view / edit permissions, transfer / batch transfer owner", you must first read references/lark-drive-workflow.md, then follow the Workflow Registry Enter permission_governance workflow。
  • When the user explicitly wants toremove the permissions of a single cloud document collaborator, use lark-cli drive +member-remove; first read references/lark-drive-member-remove.md. This is a high-risk write operation; actual execution must confirm the exact resource, member ID/type, and wiki permission scope, and explicitly pass --yes。
  • The user wants toset / modify the secure label for a specified Feishu document, or query the secure labels available to the current user, directly read references/lark-drive-secure-label.md; this is a Drive file governance capability.
  • The user wants tocheck / govern document permissions, public scope, link sharing, external access, copy and download permissions, secure labels, owner transfer, or wants a "permission risk report, tighten permissions, request view / edit permissions, transfer / batch transfer owner", you must first read references/lark-drive-workflow.md, then follow its Workflow Registry to enter permission_governance workflow。
  • The user wants toquery the public access, sharing, collaborator management, security, and comment permission settings of a file, folder, or cloud document itself, prefer to use lark-cli drive +permission-get-setting; it only reads the target's own settings and does not recursively audit the permissions of subdocuments in a folder. A bare token must be explicitly passed --type。
  • The user wants tosearch for materials across containers by a specific topic, keyword, or content clue, and collect them uniformly into a Drive folder or Wiki node, you must first read references/lark-drive-workflow.md, then follow its Workflow Registry to enter the topic_move_collector workflow. This workflow is responsible for search recall, content verification, relevance classification, move planning, pre-write confirmation, and result verification; it is forbidden to start directly from drive +search or drive +move .
  • The user wants toorganize cloud drive / folder / document library / knowledge base / personal document library, or wants to "inventory the directory structure, find unarchived/temporary/duplicate/empty directories, and generate an organization plan", you must first read references/lark-drive-workflow.md, then follow its Workflow Registry to enter the knowledge_organize workflow. By default, only generate a plan; creating directories, moving resources, and requesting permissions must all be confirmed separately.
  • For cross-scope search and centralized archiving by topic, enter topic_move_collector; for directory inventory and structural reorganization of a known folder, document library, or knowledge base, enter knowledge_organize; when moving only one already clearly identified resource, still use the atomic move command.
  • The user wants tosearch documents / Wiki / spreadsheets / Base / cloud space (cloud drive/cloud storage) objects, prefer to use lark-cli drive +search; when locating by title and handling duplicate candidates, follow references/lark-drive-search.md. In natural language, "recently edited by me", "created by me" (→ --created-by-me, original creator semantics), "owned by me/owner" (→ --mine, owner semantics), "the xxx I opened in the last week", "the docx owned by someone", etc. map directly to flat flags, avoiding handwritten nested JSON.
  • When the user wants todocument commentsperform any operation (add comment, list / batch query, reply, get / update / delete reply, resolve / restore, reaction), select the corresponding drive +<verb> comment command according to the Shortcuts table below, and read that command's ref before execution. To locate a document body position by comment, see references/lark-drive-comment-location.md。
  • When the user provides a cloud space resource URL/token for doubao.com, or explicitly mentions a file/folder/docx/sheet/bitable/wiki resource in Doubao, still route to this skill based on the resource type, URL path, and token; do not fall back to WebFetch just because the domain is not Feishu.
  • When the user wants to import a local .xlsx / .csv / .base into a Base / multi-dimensional table / bitable, the first step must use lark-cli drive +import --type bitable。
  • When the user wants to import a local .md / .docx / .doc / .txt / .html into an online document, use lark-cli drive +import --type docx。
  • When the user wants to import a local .pptx into Feishu Slides, use lark-cli drive +import --type slides; the current PPTX import limit is 500MB.
  • When executing drive +import in batch and the target is the same location (the same --folder-token, default root directory, or the same --target-token), execution must be serial; do not import concurrently to the same location, as the server may return a concurrent conflict error.
  • When the user wants to upload, create, read, partially patch, or overwrite-update in Drivenative .md files(not import into docx), switch to lark-markdown。
  • When the user wants to compare native .md files'historical version differences, or compare a remote Markdown with a local draft, switch to lark-markdown the lark-cli markdown +diff; when a version number is needed, first use drive +version-history。
  • When the user wants to view, download, roll back, or delete a file'shistorical versions, use drive +version-history、drive +version-get、drive +version-revert、drive +version-delete; this group of commands supports both --as user and --as botpreferred for automation scenarios --as bot。
  • When the user wants to import a local .xlsx / .xls / .csv into a spreadsheet, use lark-cli drive +import --type sheet。
  • When the user wants to create a new folder in cloud space (cloud drive/cloud storage), prefer using lark-cli drive +create-folder。
  • When the user wants to view or download file content, or view the available preview formats of a file and obtain converted preview outputs such as PDF / HTML / text / images, use lark-cli drive +preview。+preview and +download both support --file-token / --url / --wiki-token choose one of the three (Wiki will resolve to the underlying file); but the two only handle Drive files, if the target is an online document such as docx/sheet/bitable/slides, switch to drive +export。
  • When the user wants to obtain the cover image of a file, prefer using lark-cli drive +cover; first --list-only to check the specifications, then choose --spec to download.
  • When the user wants to export a cloud document, prefer using lark-cli drive +export --url '<文档 URL>' --file-extension <格式>; for detailed parameters, Wiki tokens, and error code handling, see references/lark-drive-export.md。
  • When the user wants to upload a local file to a certain wiki node in the knowledge base / document library, still use lark-cli drive +upload --wiki-token <wiki_token>; do not mistakenly switch to the wiki domain command.
  • lark-base early at the "local file -> Base" step lark-base。
  • When the user provides a wiki URL / token and the underlying resource type has not yet been clarified, first use lark-cli drive +inspect to unwrap;+inspect after a failure, do not automatically switch to another write API to keep trying; first handle the permission, scope, or link issue according to the error message.
  • drive +inspect / drive +upload When encountering not found、permission denied、missing scope , stop retrying by default; only rate limit or temporary network errors are suitable for limited retries.

Modify the title

Core Concepts

Document Types and Tokens

On the Feishu Open Platform, different document types have different URL formats and Token handling methods. When performing document operations (such as adding comments, downloading files, etc.), you must first obtain the correct file_token。

Document URL Formats and Token Handling

URL Format Example Token Type Handling Method
/docx/ https://example.larksuite.com/docx/doxcnxxxxxxxxx file_token The token in the URL path is used directly as file_token use
/doc/ https://example.larksuite.com/doc/doccnxxxxxxxxx file_token The token in the URL path is used directly as file_token use
/wiki/ https://example.larksuite.com/wiki/wikcnxxxxxxxxx wiki_token cannot be used directly as the underlying file_token; prefer using drive +inspect to unpack and obtain obj_token
/sheets/ https://example.larksuite.com/sheets/shtcnxxxxxxxxx file_token The token in the URL path is used directly as file_token use
/page/ https://example.feishu.cn/page/pagcnxxxxxxxx/ apps token The token in the URL path is used directly; the resource type is apps
/drive/folder/ https://example.larksuite.com/drive/folder/fldcnxxxx folder_token The token in the URL path is used as the folder token

Special Handling for Wiki Links

lark-cli drive +inspect --url 'https://xxx.feishu.cn/wiki/wikcnXXX'

Behind a knowledge base link may be different objects such as docx, sheet, bitable, slides, file, etc. When subsequently performing comments, downloads, exports, or content reading, prefer using drive +inspect to get type、token、title、url; for complete manual parsing and cross-skill routing, see the shared document lark-wiki-token-routing.md. Do not rely only on /wiki/<token> to guess the underlying type.

Token Requirements for Common Operations

Operation Required Token Description
Read document content file_token / handled automatically via docs +fetch auto-handling docs +fetch supports passing the URL directly
Download file file_token extracted directly from the file URL
Upload file folder_token / wiki_node_token token of the target location

Typical Errors and Solutions

Error Message Cause Solution
not exist The wrong token was used Check the token type; for wiki links, you must first query to obtain obj_token
permission denied No permission for the relevant operation Guide the user to check whether the current identity has the corresponding operation permission for the document/file; if needed, the corresponding permission can be granted
invalid file_type file_type parameter error Pass the correct file_type according to obj_type (docx/doc/sheet/slides/bitable/apps)
232140101 / 232140100 / 233523001(commonly seen in drive +import 's job_error_msg) Concurrent import / create operations exist in the same location When batch importing to the same folder, root directory, or the same --target-token , switch to serial execution; before each retry of each failed item, wait a few seconds, with a maximum of 3 retries in total; if it still fails, stop and report the conflict

Permission Capability Entry Points

  • When the user wants to manage Drive document/file collaborators, public permissions, authorize the current app to access a document, or handle permission.public.patch 's 91009 / 91010 / 91011 / 91012 error, first read lark-drive-permission-guide.md。
  • When the user wants to query the public access, sharing, collaborator management, security, and comment permission settings of a file, folder, or cloud document itself, use +permission-get-setting; if you want to recursively audit the permissions of subdocuments under a folder, then enter permission_governance workflow。
  • If the user simply does not have access permission and wants to request access from the owner, prefer using +apply-permission。
  • Ordinary scope, identity, or login issues are still handled according to lark-shared ; do not simply classify tenant security policies, external sharing, or classification interception as missing scope.

Out of scope for this skill

  • Reading, summarizing, creating, editing, inserting or downloading images/attachments in document body: use lark-doc。
  • In-sheet operations such as spreadsheet cells, filters, formulas, and styles: use lark-sheets。
  • Operations on tables, fields, records, views, dashboards, etc. inside Base / Bitable: use lark-base。
  • Knowledge space, Wiki node hierarchy, space member management: use lark-wiki; uploading local files to a wiki node still uses drive +upload --wiki-token。
  • Native Markdown file reading, writing, patch, diff: use lark-markdown; importing Markdown as an online docx uses drive +import --type docx。

Shortcuts (recommended to use first)

Shortcut is a high-level wrapper for common operations (lark-cli drive +<verb> [flags]). For operations that have a Shortcut, use it first.

Shortcut Description
+search Search cloud space objects such as documents, Wiki, sheets, and folders; supports flat flags such as --edited-since、--created-by-me、--mine、--doc-types ; distinguishes between original creator and owner semantics.
+upload Upload local files to a Drive folder or wiki node; when modifying/rewriting/updating an existing file, prefer overwrite upload rather than directly uploading a new file.
+create-folder Create a new Drive folder, supporting parent folders and automatic authorization after bot creation.
+download Download Drive files to local.
+preview View or download file content, or view available preview formats for a file and obtain converted preview outputs such as PDF / HTML / text / images.
+cover View or download file cover image specifications.
+status Compare differences between a local directory and a Drive folder; by default compares exactly by SHA-256,--quick uses approximate comparison by modification time.
+pull Pull files from Drive to a local directory, supporting duplicate remote path handling and incremental mode.
+sync Bidirectionally sync a local directory with a Drive folder: pull new_remote, push new_local,modified handled according to --on-conflict=remote-wins|local-wins|keep-both|ask ;--quick uses approximate comparison by modification time;--on-duplicate-remote supports fail / newest / oldest; only syncs type=file, skips online documents and shortcuts, and does not delete extra files on either side.
+push Push a local directory to a Drive folder, supporting skip / smart / overwrite and deleting remote files after confirmation.
+create-shortcut Create a shortcut to an existing Drive file in another folder.
+copy Copy resources to a target folder; if copying to a knowledge base, use wiki +node-copy;
+add-comment Add full-text/partial comments to doc/docx/file/sheet/slides/base(bitable); does not support Miaoda apps.
+list-comments Get a paginated list of comments.
+batch-query-comments Batch get comments by comment ID.
+resolve-comment Mark a comment as resolved (is_solved=true)。
+restore-comment Restore/reopen a resolved comment (is_solved=false)。
+add-reply Add a reply to an existing comment.
+list-replies Get a paginated list of replies under a comment.
+update-reply Replace the content of a reply entirely.
+delete-reply Delete a reply under a comment (high risk, requires --yes)。
+react-reply Add/remove emoji reactions to a reply.
+export Export doc/docx/sheet/bitable/slides as local files.
+export-download Download the file based on the file_token of the exported artifact.
+import Import a local file as a Feishu online document, spreadsheet, Base, or slides.
+version-history View the file's historical versions.
+version-get Download the specified historical version.
+version-revert Roll back to the specified historical version.
+version-delete Delete the specified historical version.
+move Move a Drive file or folder; for Wiki hierarchy moves, use lark-wiki。
+update-title Rename a file, folder, online document, or wiki.
+delete Delete a Drive file or folder; folder deletion will poll the asynchronous task.
+task_result Query the results of asynchronous tasks such as import/export/move/delete.
+inspect Inspect the URL's type, title, and canonical token; wiki URLs will be automatically unwrapped to the underlying document.
+apply-permission Request access permission from the document owner as a user.
+member-add Add one or up to 10 collaborators/authorized members to a Drive document, file, folder, or wiki node; wraps Drive permission member create/batch_create, actual write requires --yes。
+member-list Query the collaborator/authorized member list of a Drive document, file, folder, or wiki node.
+member-remove Remove a collaborator from a Drive document, file, folder, or wiki node; wraps Drive permission member delete, actual write requires --yes。
+permission-get-setting Query the public access, sharing, collaborator management, security, and comment permission settings of a file, folder, or cloud document itself; supports URL or bare token + --type; does not recursively read the permissions of subdocuments in a folder.
+secure-label-list List the classification labels available to the current user.
+secure-label-update Update the classification label of a Drive file or document.

API Resources

lark-cli schema drive.<resource>.<method>   # 调用 API 前必须先查看参数结构
lark-cli drive <resource> <method> [flags] # 调用 API

Important: When using the native API, you must first run schema to view the --data / --params parameter structure; do not guess the field format.

High-frequency native commands: When reading a Drive folder listing, use drive files list; before use, first read references/lark-drive-files-list.md, pass parameters via --params according to the template and handle pagination manually; do not pass the --page-all output directly to a JSON parsing script.

files

permission.members

  • auth —
  • create — Add collaborator permission
  • transfer_owner —

metas

  • batch_query — Get document metadata

user

  • remove_subscription — Unsubscribe from user- and app-dimension events
  • subscription — Subscribe to user- and app-dimension events (this release opens the comment-added event)
  • subscription_status — Query the subscription status of users and apps for specified events

file.statistics

  • get — Get file statistics
    • When getting docx / file statistics, it is recommended to prefer typed flags:lark-cli drive file.statistics get --file-token <token> --file-type <type> --format json;--params JSON is also supported, suitable for batch assembly or raw parameter scenarios.

file.view_records

  • list — Get the document's visitor records
    • When viewing recent docx access records, returning open_id, and limiting to at most N records, it is recommended to prefer typed flags:lark-cli drive file.view_records list --file-token <docx_token> --file-type docx --page-size <N> --viewer-id-type open_id --format json;--params JSON is also supported, suitable for batch assembly, paginated continuation, or raw parameter scenarios.

file.comment.reply.reactions

  • update_reaction — Add/remove reaction; prefer using drive +react-reply

quota_details

  • get — Get the current user's capacity information, including usage by business, whether the tenant quota is exceeded, user quota, and department quota
    • Only supports --as user, do not use the default bot identity
    • quota_detail_id pass the current user's user_id