feishu-update-doc

Original🇨🇳 Chinese
Translated

Update Feishu Cloud Docs. Supports 7 update modes: Append, Overwrite, Targeted Replacement, Full-text Replacement, Insert Before, Insert After, Delete.

14installs
Added on

NPX Install

npx skill4agent add larksuite/openclaw-lark feishu-update-doc

SKILL.md Content (Chinese)

View Translation Comparison →

feishu__update_doc

Update Feishu Cloud Docs content with support for 7 update modes. Prefer partial updates (replace_range/append/insert_before/insert_after), use overwrite with caution (it will clear and rewrite the document, which may cause loss of images, comments, etc.).

Positioning Methods

Positioning modes (replace_range/replace_all/insert_before/insert_after/delete_range) support two positioning methods, choose one:

selection_with_ellipsis - Content Positioning

Supports two formats:
  1. Range Matching:
    start content...end content
    • Matches all content from the start to the end (including intermediate content)
    • It is recommended to use 10-20 characters to ensure uniqueness
  2. Exact Matching:
    complete content
    (without
    ...
    )
    • Matches the exact text content
    • Suitable for replacing short text, keywords, etc.
Escape Instructions: If the content to be matched itself contains
...
, use
\\.\\.\\.
to represent the literal three dots.
Examples:
  • 你好...世界
    → Matches any content between "你好" and "世界"
  • 你好\\.\\.\\.世界
    → Matches the literal string "你好...世界"
Recommendation: If there are multiple
...
in the document, it is recommended to use longer context for precise positioning to avoid ambiguity.

selection_by_title - Title Positioning

Format:
## Chapter Title
(with or without the # prefix)
Automatically locates the entire chapter (from the title to before the next sibling or higher-level title).
Examples:
  • ## Feature Description
    → Locates the level 2 title "Feature Description" and all its content
  • Feature Description
    → Locates the "Feature Description" title of any level and its content

Optional Parameters

new_title

Update the document title. If this parameter is provided, the document title will be updated synchronously after updating the document content.
Features:
  • Only supports plain text, does not support rich text formatting
  • Length limit: 1-800 characters
  • Can be used with any mode
  • Title update is executed after content update

Return Values

Success

json
{
  "success": true,
  "doc_id": "Document ID",
  "mode": "Mode Used",
  "message": "Document updated successfully (xxx mode)",
  "warnings": ["Optional warning list"],
  "log_id": "Request Log ID"
}

Asynchronous Mode (Timeout for Large Documents)

json
{
  "task_id": "async_task_xxxx",
  "message": "Document update has been submitted for asynchronous processing, please use task_id to query status",
  "log_id": "Request Log ID"
}
Use the returned
task_id
to call update-doc again (only pass the task_id parameter) to query the status.

Error

json
{
  "error": "[Error Code] Error Message\n💡 Suggestion: Fix Suggestion\n📍 Context: Context Information",
  "log_id": "Request Log ID"
}

Usage Examples

append - Append to End

json
{
  "doc_id": "Document ID or URL",
  "mode": "append",
  "markdown": "## New Chapter\n\nAppended content..."
}

replace_range - Targeted Replacement

Using
selection_with_ellipsis
:
json
{
  "doc_id": "Document ID or URL",
  "mode": "replace_range",
  "selection_with_ellipsis": "## Old Chapter Title...Old Chapter End.",
  "markdown": "## New Chapter Title\n\nNew content..."
}
Using
selection_by_title
(replace entire chapter):
json
{
  "doc_id": "Document ID or URL",
  "mode": "replace_range",
  "selection_by_title": "## Feature Description",
  "markdown": "## Feature Description\n\nUpdated feature description content..."
}

replace_all - Full-text Replacement

Similar to replace_range, but supports simultaneous replacement in multiple locations (replace_range requires unique matches):
json
{
  "doc_id": "Document ID or URL",
  "mode": "replace_all",
  "selection_with_ellipsis": "张三",
  "markdown": "李四"
}
Return Value includes the
replace_count
field, indicating the number of replacements:
json
{
  "success": true,
  "replace_count": 4,
  "message": "Document updated successfully (replace_all mode, 4 replacements made)"
}
Notes:
  • Unlike
    replace_range
    ,
    replace_all
    allows multiple matches
  • If no matching content is found, an error will be returned
  • markdown
    can be an empty string, which means deleting all matching content

insert_before - Insert Before

json
{
  "doc_id": "Document ID or URL",
  "mode": "insert_before",
  "selection_with_ellipsis": "## Dangerous Operations...Risk of Data Loss.",
  "markdown": "> **Warning**: Please proceed with caution for the following operations!"
}

insert_after - Insert After

json
{
  "doc_id": "Document ID or URL",
  "mode": "insert_after",
  "selection_with_ellipsis": "```python...```",
  "markdown": "**Output Example**: \n```\nresult = 42\n```"
}

delete_range - Delete Content

Using
selection_with_ellipsis
:
json
{
  "doc_id": "Document ID or URL",
  "mode": "delete_range",
  "selection_with_ellipsis": "## Obsolete Chapter...Content No Longer Needed."
}
Using
selection_by_title
(delete entire chapter):
json
{
  "doc_id": "Document ID or URL",
  "mode": "delete_range",
  "selection_by_title": "## Obsolete Chapter"
}
Note: The delete_range mode does not require the markdown parameter.

Update Title and Content Simultaneously

You can add the
new_title
parameter to any update mode to update the document title at the same time:
json
{
  "doc_id": "Document ID or URL",
  "mode": "overwrite",
  "markdown": "# Project Document v2.0\n\nBrand new content...",
  "new_title": "Project Document v2.0"
}
json
{
  "doc_id": "Document ID or URL",
  "mode": "append",
  "markdown": "## Update Log\n\n2025-12-18: New features added...",
  "new_title": "Project Document (Updated)"
}

overwrite - Full Overwrite

⚠️ It will clear and rewrite the document, which may cause loss of images, comments, etc. Use only when you need to completely rebuild the document.
json
{
  "doc_id": "Document ID or URL",
  "mode": "overwrite",
  "markdown": "# New Document\n\nBrand new content..."
}

Best Practices

Granular Exact Replacement

When modifying document content, the smaller the positioning range, the safer it is. Especially for nested blocks such as tables and columns, you should precisely locate the text that needs to be modified to avoid affecting other content.
Example: A table cell contains images and text, only need to modify the text
  • ❌ Replace the entire table or entire row → May break image references
  • ✅ Only locate the text that needs to be modified → Images and other content remain unaffected

Protect Non-reconstructible Content

Content such as images, whiteboards, spreadsheets, base tables, and tasks are stored as tokens, which cannot be read and written back in their original form.
Protection Strategies:
  • Avoid areas containing such content when replacing
  • Precisely locate plain text parts for modification

Step-by-step Updates Are Better Than Full Overwrite

When modifying multiple parts of content:
  • ✅ Perform multiple small-range replacements and modify gradually
  • ⚠️ Use
    overwrite
    to rewrite the entire document with caution, unless you consider the risk completely controllable
Reason: Partial updates retain original media, comments, and collaboration history, making them safer and more reliable.

Pay Attention to Insertion Position When Expanding Positioning Range in Insert Mode

When using
insert_before
or
insert_after
, if the target content appears repeatedly, you need to expand the
selection_with_ellipsis
range to locate it uniquely.
Key: The insertion position is based on the boundary of the matching range:
  • insert_after
    → Insert after the end of the matching range
  • insert_before
    → Insert before the start of the matching range
When expanding the range, ensure the boundary is still the desired insertion point.

Fix Whiteboard Syntax Errors

When create-doc or update-doc returns a warning about whiteboard writing failure:
  1. The warning contains a whiteboard tag (e.g.,
    <whiteboard token="xxx"/>
    )
  2. Analyze the error message and correct the Mermaid/PlantUML syntax
  3. Use
    replace_range
    to replace:
    selection_with_ellipsis
    uses the whiteboard tag from the warning,
    markdown
    provides the corrected code block
  4. Resubmit for verification

Notes

  • Markdown Syntax: Supports Feishu extended syntax, see the create-doc tool documentation for details