
- Installs
- 112
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/alextangson/feishu_skills --skill feishu-doc-writer- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads feishu-doc-writer automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
飞书文档写入
通过 Docx API 写入内容到飞书云文档。飞书文档使用 Block 树模型,不接受原始 Markdown。
Base URL: https://open.feishu.cn/open-apis/docx/v1
认证与 Token 获取
从 feishu_skills 根目录执行共享脚本:
TOKEN="$(./scripts/get_feishu_token.sh)"
请求头统一使用 Authorization: Bearer ${TOKEN}。
如果业务接口返回 token 无效、过期或 401,强制刷新后仅重试一次原请求:
TOKEN="$(./scripts/get_feishu_token.sh --force-refresh)"
环境变量:
FEISHU_APP_IDFEISHU_APP_SECRET
本地缓存: ./.feishu_token_cache.json(未过期直接复用,默认提前 5 分钟刷新)
推荐方式:转换 API
飞书提供官方 Markdown → Blocks 转换端点:
POST /documents/{document_id}/convert
{
"content": "# 标题\n\n正文\n\n- 列表项",
"content_type": "markdown"
}
✅ 无需手动构建 Block JSON,支持标准 Markdown ⚠️ 不支持飞书特有块(Callout 等)— 需手动创建
Block 类型
| block_type | 名称 | JSON Key | 说明 |
|---|---|---|---|
| 1 | 页面 | page | 文档根节点 |
| 2 | 文本 | text | 段落 |
| 3-11 | 标题1-9 | heading1-heading9 | - |
| 12 | 无序列表 | bullet | 每项单独一个 block |
| 13 | 有序列表 | ordered | - |
| 14 | 代码块 | code | 需指定 style.language |
| 15 | 引用 | quote | - |
| 17 | 待办 | todo | 带 style.done |
| 19 | 高亮块 | callout | 飞书特有,容器块 |
| 22 | 分割线 | divider | - |
| 27 | 图片 | image | 两步:创建占位 + 上传 |
| 31 | 表格 | table | - |
创建 Blocks
POST /documents/{document_id}/blocks/{block_id}/children?document_revision_id=-1
{
"children": [...],
"index": 0
}
block_id: 父块 ID(根节点用document_id)index: 插入位置(0=开头,-1=末尾)
删除 Blocks
删除父块下指定范围的子块:
DELETE /documents/{document_id}/blocks/{block_id}/children/batch_delete?document_revision_id=-1
{
"start_index": 3,
"end_index": 4
}
block_id: 要操作的父块 IDstart_index: 起始子块下标(包含)end_index: 结束子块下标(不包含)- ⚠️ 该接口是
DELETE,不是POST
Block 示例
文本:
{"block_type": 2, "text": {"elements": [{"text_run": {"content": "段落"}}]}}
标题:
{"block_type": 3, "heading1": {"elements": [{"text_run": {"content": "标题"}}]}}
代码块:
{
"block_type": 14,
"code": {
"style": {"language": 1},
"elements": [{"text_run": {"content": "console.log('hello')"}}]
}
}
Mermaid 绘图块(插件块):
{
"block_type": 40,
"add_ons": {
"component_type_id": "blk_631fefbbae02400430b8f9f4",
"record": "{\"data\":\"flowchart TD\\nA-->B\",\"theme\":\"default\",\"view\":\"codeChart\"}"
}
}
block_type = 40表示插件块component_type_id = blk_631fefbbae02400430b8f9f4可用于 Mermaid 绘图record是字符串化 JSON,目前验证过的字段:data: Mermaid 源码theme: 通常用defaultview: 通常用codeChart
- 如果文档里已经有人手动插入过“本文绘图”格式的 Mermaid,优先先读取该块,再复用它的
component_type_id/theme/view
高亮块(Callout):
{
"block_type": 19,
"callout": {
"background_color": 1,
"border_color": 1,
"emoji_id": "bulb"
},
"children": [
{"block_type": 2, "text": {"elements": [{"text_run": {"content": "提示内容"}}]}}
]
}
图片(两步):
- 创建占位:
{"block_type": 27, "image": {}} - 上传:
PUT /documents/{document_id}/blocks/{block_id}/image
文本样式
{
"text_run": {
"content": "样式文本",
"text_element_style": {
"bold": true,
"italic": true,
"strikethrough": true,
"underline": true,
"inline_code": true,
"background_color": 1,
"text_color": 1
}
}
}
并发处理
飞书文档支持多人协作,需处理并发:
- 获取最新 revision:
GET /documents/{document_id} - 带 revision 写入:
?document_revision_id={revision} - 冲突时重试(HTTP 409)
Mermaid 推荐流程
当用户要求“按本文绘图格式统一 Mermaid”时,不要直接写普通文本块或代码块里的 ```mermaid。
推荐顺序:
- 先读取目标文档所有块,确认是否已存在人工调整好的 Mermaid 绘图块
- 如果存在,读取该块的:
block_typeadd_ons.component_type_idadd_ons.record
- 复用同样的绘图块结构创建新图,而不是继续写
code块 - 新图创建成功后,再删除旧的 Mermaid 代码块,避免文档里同时保留两套内容
适用场景:
- 用户已经把某一张 Mermaid 图手动改成了理想样式,要求“其他图也改成这种格式”
- 需要让多张流程图在同一篇 Docx 中保持一致视觉效果
实战建议
- 普通结构优先用文本块/标题块
- 代码展示用
block_type = 14 - 流程图展示优先用 Mermaid 插件块,不要把 ```mermaid 当最终呈现形式
- 替换旧图时,先插入新块,再删除旧块,避免内容丢失
- 涉及批量替换时,先读取父块 children 顺序,再按 index 精确删除
最佳实践
- 优先用转换 API(简化开发)
- 批量创建 blocks(减少 API 调用)
- 处理并发冲突(带 revision 参数)
- 图片分两步(占位 + 上传)
- Mermaid 图优先复用现有插件块格式
FAQ
What does the feishu-doc-writer skill do?
飞书文档写入。Markdown 转 Block、创建文档块、处理并发,支持 Mermaid 绘图块。
How do I install feishu-doc-writer?
Run npx skills add https://github.com/alextangson/feishu_skills --skill feishu-doc-writer in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/feishu-doc-writer/ (personal) or .claude/skills/feishu-doc-writer/ (project).
Which AI agents can use feishu-doc-writer?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is feishu-doc-writer safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains feishu-doc-writer?
It is published by alextangson in alextangson/feishu_skills. It has 112 recorded installs.
More from alextangson/feishu_skills
feishu-bitable
alextangson/feishu_skills
飞书多维表格操作。记录 CRUD、字段管理、视图、权限、公式、关联。
feishu-card
alextangson/feishu_skills
Open the skill to read its SKILL.md instructions.
feishu-im
alextangson/feishu_skills
飞书消息与群管理。发送消息、建群、置顶、加急、撤回、群菜单/Tab/公告。
feishu-task
alextangson/feishu_skills
Open the skill to read its SKILL.md instructions.
Popular docs & writing skills
grill-with-docs
mattpocock/skills
A relentless interview to sharpen a plan or design, which also creates docs (ADR's and glossary) as we go.
lark-markdown
open.feishu.cn
飞书 Markdown:查看、创建、上传、编辑和比较飞书中的原生 Markdown 文件。当用户要操作飞书 Markdown 文件,或比较其远端版本及本地草稿时使用。纯本地 Markdown 文件操作不触发本 skill。不负责将 Markdown 导入为飞书在线文档,也不负责文件搜索、权限、评论、移动、删除等云空间管理操作。
writing-beats
mattpocock/skills
Writing, exploit; assemble raw material into a journey of beats, grounding each term before a beat leans on it.
writing-shape
mattpocock/skills
Writing, exploit: shape raw material into an article, paragraph by paragraph.
writing-fragments
mattpocock/skills
Writing, explore: mine raw fragments, no structure yet.
writing-for-agents
mattpocock/skills
Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.