Feishu Doc Editing
by @guoqunabc
Performance-optimized strategies for editing Feishu (Lark) documents via OpenClaw's feishu_doc tool. Use when: (1) modifying existing Feishu documents, (2) i...
clawhub install feishu-doc-editingπ About This Skill
name: feishu-doc-editing description: | Performance-optimized strategies for editing Feishu (Lark) documents via OpenClaw's feishu_doc tool. Use when: (1) modifying existing Feishu documents, (2) inserting images at specific positions, (3) writing tables or structured content, (4) any multi-block document editing task, (5) writing long documents that may hit API size limits. Provides concrete patterns to minimize API calls and maximize editing speed while preserving existing formatting. Covers: parallel operations, positioned image insertion, large document chunking, rate-limit handling, rich-text preservation, and conflict avoidance. Complements the built-in feishu-doc skill (API reference) with operational best practices.
Feishu Document Editing β Performance Best Practices
Core Principle: Minimum Change
Never use write (full document replace) for partial edits β it destroys existing rich-text formatting (colors, highlights, inline styles). Always use targeted block-level operations.
> Full decision tree (when to use update_block vs delete+insert vs append, with protection mechanisms) is in ~/self-improving/domains/feishu.md under "ζε°ζΉε¨εε".
Strategy 1: Scan Once, Act in Parallel
Pattern: One list_blocks β plan all changes β fire independent operations together.
1. feishu_doc(action: "list_blocks", doc_token: "xxx")
β Full block tree with IDs, types, content2. Identify which blocks need update/delete/insert
3. Issue all independent operations in one tool-call batch:
- update_block(block_id: "A", content: "new text")
- update_block(block_id: "B", content: "new text")
- delete_block(block_id: "C")
- insert(after_block_id: "D", content: "...")
Why: update_block on different blocks has zero dependency. OpenClaw executes independent tool calls within a single response concurrently (other AI frameworks may vary β verify before assuming).
Result: 10 serial updates (3β5 s) β 10 concurrent updates (~0.3β1 s).
Cache the block tree: Reuse list_blocks throughout the session. Re-fetch only after inserts/deletes that shift the structure.
Strategy 2: Back-to-Front for Insert/Delete
When mixing insert and delete, operate from the document's end toward the beginning.
Why: Inserting or deleting a block shifts indices of all subsequent siblings. Back-to-front keeps earlier indices stable β no need to re-query after each op.
Example: Delete blocks at indices 5, 12, 20 β delete 20 first, then 12, then 5.
Strategy 3: Merge Adjacent Inserts
Combine consecutive inserts into one call:
{
"action": "insert",
"doc_token": "xxx",
"after_block_id": "target_block",
"content": "## New Section\n\nParagraph one.\n\nParagraph two.\n\n!caption"
}
Images as !alt inside insert/append are auto-positioned inline β no separate upload_image needed when the URL is public.
Strategy 4: Positioned Image Insertion
| Method | When to use |
|--------|------------|
| insert with  markdown | Public URL, image goes with surrounding text |
| upload_image + parent_block_id + index | Local file / base64, precise position needed |
upload_image with position:
{
"action": "upload_image",
"doc_token": "xxx",
"file_path": "/tmp/chart.png",
"parent_block_id": "doc_root_or_parent_id",
"index": 5
}
Finding the index: From list_blocks, locate the target in its parent's children array. Use that index to insert before, or index+1 to insert after.
Strategy 5: Table Performance
Docx tables are the slowest β each cell needs separate clear + convert + insert API calls.
create_table_with_values (one-step).Strategy 6: Large Document Chunking
The Feishu document.convert API and documentBlockChildren.create have per-request size limits. For long content:
# or ##) β keeps each chunk semantically coherent.append/insert auto-chunk internally, but feeding smaller pieces reduces conversion failures.Strategy 7: Rate-Limit & Retry
Feishu API returns 429 when request frequency is too high. Handle it:
children beats N separate requests.OpenClaw's built-in tool handles basic retries, but be aware when orchestrating many operations in rapid succession.
Strategy 8: Rich-Text Preservation
update_block replaces the entire text element array β all inline styles (bold, italic, color, links) are lost. To preserve formatting:
get_block to inspect existing text_element_style fields.color_text action instead of update_block.delete_block + insert with markdown that re-expresses the formatting, rather than update_block which strips styles.Strategy 9: Conflict Avoidance
When multiple agents or users may edit the same document simultaneously:
revision_id from read action before making changes. If the revision has advanced since your list_blocks, re-fetch before editing.Anti-Patterns
| Don't | Do instead |
|-------|-----------|
| write to change a few paragraphs | update_block on specific blocks |
| Serial update_block one-by-one | Batch independent ops in one tool-call |
| upload_image without position params | Pass parent_block_id + index, or use insert with  |
| Parallel upload_image with after_block_id to different positions | Serial: append text β upload_image β append text β upload_image (API ignores after_block_id in parallel) |
| Re-fetch list_blocks after every edit | Cache and reuse; re-fetch only after structural changes |
| Insert top-to-bottom when mixing insert/delete | Back-to-front to avoid index drift |
| Append 2000-line markdown in one call | Chunk at ~300β600 lines per append |
| Ignore 429 rate limits | Exponential backoff, limit concurrency to ~5 |
| update_block on formatted text blindly | Check existing styles; use color_text for style-only edits |
Compatibility
feishu_doc tool β no code changes neededfeishu-doc skill (API reference) and feishu-readability skill (formatting rules)