Loading...
Loading...
Write content to Feishu Docs, create new documents, and create blank documents. Supports advanced operations such as automatic conversion of Mermaid/PlantUML diagrams to boards, Callouts, and batch block updates. Use this when users request "create document", "new document", "write a document", "write", "update document", "edit document", or "add content". It is recommended to use Mermaid for diagramming.
npx skill4agent add riba2534/feishu-cli feishu-cli-writePrerequisite: Complete authentication before use:(OAuth login, it is recommended to include thefeishu-cli auth loginscope to obtain a 30-day valid Refresh Token).offline_access
feishu-cli doc create --title "Document Title" --output jsonfull_accessfeishu-cli perm add <document_id> --doc-type docx --member-type email --member-id user@example.com --perm full_access --notificationfeishu-cli perm transfer-owner <document_id> --doc-type docx --member-type email --member-id user@example.com --notification/tmpCRITICAL: Full overwrite of existing documents is PROHIBITEDAbsolutely forbidden to useto fully overwrite existing documents! This will:doc import --document-id <id>
- Lose all inline comments
- Break board/whiteboard references (become empty placeholder blocks)
- Lose manually edited formats and content from users
Incremental updates must be used for updating existing documents:(append),doc add(modify blocks),doc update(delete blocks).doc deleteis only allowed when the user explicitly requests full replacement.doc import --document-id
# Create new document
/feishu-write "Document Title"
# Update existing document
/feishu-write <document_id>/tmp/feishu_write_<timestamp>.mdfeishu-cli doc import /tmp/feishu_write_<timestamp>.md --title "Document Title"full_accessfeishu-cli perm add <document_id> --doc-type docx --member-type email --member-id user@example.com --perm full_accessdoc add# 1. Prepare the content to append (only write the new part, do not include existing content)
cat > /tmp/feishu_append.md << 'EOF'
## New Section Title
New content...
EOF
# 2. Append to the end of the document
feishu-cli doc add <document_id> /tmp/feishu_append.md --content-type markdown# 1. Get the document block structure and find the insertion point
feishu-cli doc blocks <document_id>
# 2. Insert at the specified position under the parent block
feishu-cli doc add <document_id> /tmp/feishu_insert.md \
--content-type markdown \
--block-id <parent_block_id> \
--index <position># 1. Get the document block structure and find the block_id to modify
feishu-cli doc blocks <document_id>
# 2. Update the specified block
feishu-cli doc update <document_id> <block_id> \
--content '{"update_text_elements":{"elements":[{"text_run":{"content":"Updated text"}}]}}'# Delete child blocks from index 2~4 under the parent block
feishu-cli doc delete <document_id> <parent_block_id> --start 2 --end 5
# Delete all child blocks under the parent block
feishu-cli doc delete <document_id> <parent_block_id> --all# 1. Get the block structure and locate the block range of the section
feishu-cli doc blocks <document_id>
# 2. Delete the old section (assuming it is at indexes 5~8 under the parent block)
feishu-cli doc delete <document_id> <parent_block_id> --start 5 --end 9 -f
# 3. Insert new content at the same position
feishu-cli doc add <document_id> /tmp/feishu_new_section.md \
--content-type markdown \
--block-id <parent_block_id> \
--index 5When is full overwrite allowed: Only when the user explicitly says "rewrite the entire document" or "full replacement", canbe used. Incremental updates are required by default.feishu-cli doc import /tmp/file.md --document-id <id>
| Syntax | Feishu Block Type | Description |
|---|---|---|
| Heading1-6 | |
| Text | |
| Bullet | Supports indentation nesting |
| Ordered | Supports indentation nesting |
| Todo | |
| Code | |
| Board | Recommended |
| Board | PlantUML diagrams |
| QuoteContainer | Supports nested quotes |
| Callout | 6 types |
| Divider | |
| Bold style | |
| Italic style | |
| Strikethrough style | |
| Underline style | |
| Inline code style | |
| Inline Formula | Supports multiple formulas in one paragraph |
| Block Formula | Independent formula line |
| Link | |
| ` | Table | ` |
{}{version}par...and...endparNote over X: Execute in parallel...```mermaid
flowchart TD
A[Start] --> B{Decision}
B -->|Yes| C[Process]
B -->|No| D[End]
``````plantuml
@startuml
Alice -> Bob: Hello
Bob --> Alice: Hi
@enduml
```> [!NOTE]
> Tip information.
> [!WARNING]
> Warning information.
> [!TIP]
> Tip information.
> [!CAUTION]
> Warning information.
> [!IMPORTANT]
> Important information.
> [!SUCCESS]
> Success information.Inline formula: Area of a circle $S = \pi r^2$, circumference $C = 2\pi r$.
Block formula:
$$\int_{0}^{\infty} e^{-x^2} dx = \frac{\sqrt{\pi}}{2}$$# Add a board to the end of the document
feishu-cli doc add-board <document_id>
# Add a board at a specified position
feishu-cli doc add-board <document_id> --parent-id <block_id> --index 0# Add an info-type Callout
feishu-cli doc add-callout <document_id> "Tip content" --callout-type info
# Add a warning-type Callout
feishu-cli doc add-callout <document_id> "Warning content" --callout-type warning
# Add at a specified position
feishu-cli doc add-callout <document_id> "Content" --callout-type error --parent-id <block_id> --index 0doc import[!TYPE]doc add-callout --callout-type| Color | Background Color Value | Markdown Syntax | CLI |
|---|---|---|---|
| Blue | 6 | | |
| Red | 2 | | |
| Orange | 3 | | — |
| Yellow | 4 | | |
| Green | 5 | | |
| Purple | 7 | | — |
When orange (CAUTION) or purple (IMPORTANT) is needed, please use the Markdown import method (ordoc import).doc add --content-type markdown
# Batch update from JSON file
feishu-cli doc batch-update <document_id> --source-type content --file updates.json[
{
"block_id": "block_xxx",
"block_type": 2,
"content": "Updated text content"
}
]https://feishu.cn/docx/<document_id># Create new meeting minutes
/feishu-write "2024-01-21 Weekly Meeting Minutes"
# Update existing document
/feishu-write <document_id>| Problem | Cause and Solution |
|---|---|
| Mermaid diagram import failed | The diagram will be automatically downgraded to a code block for display, and content will not be lost. Check if unsupported syntax such as |
| Permission addition failed | Check if the App in the Feishu Open Platform has been configured with the |
| Authentication expired (401 error) | Re-execute |
| Document created successfully but cannot be accessed | Confirm that |
| Table content is not fully displayed | The Feishu API limits a single table to 9 rows and 9 columns, and excess parts will be automatically split into multiple tables, which is normal behavior |