
Feishu Doc Optimizer
- 41 installs
- 82 repo stars
- Updated August 2, 2026
- aaaaqwq/claude-code-skills
feishu-doc-optimizer is a Claude Code skill that reads Feishu cloud documents and rewrites their structure, formatting, and layout for readability.
About
feishu-doc-optimizer is a Claude Code skill that improves the structure, formatting, and readability of Feishu cloud documents. It reads a document by token via the Feishu API, restructures the content, and replaces it using Playwright browser automation because the API cannot delete document blocks directly. A developer or writer uses it to clean up and standardize Feishu doc layout. It applies a defined convention of section numbering, emoji markers, separators, and aligned tables.
- Reads, restructures, and reformats Feishu cloud documents
- Uses the Feishu API to read and Playwright browser automation to replace content
- Ships an emoji, separator, and table formatting convention
Feishu Doc Optimizer by the numbers
- 41 all-time installs (skills.sh)
- Ranked #389 of 687 Office & Documents skills by installs in the Skillselion catalog
- Data as of Aug 3, 2026 (Skillselion catalog sync)
feishu-doc-optimizer capabilities & compatibility
Free skill; requires Feishu app credentials with docx scopes and a logged-in browser.
- Capabilities
- document formatting · content restructure · doc optimization · browser automation
- Works with
- playwright
- Use cases
- documentation
- Pricing
- Bring your own API key
What feishu-doc-optimizer says it does
飞书云文档内容优化与格式美化。当用户需要优化飞书文档的排版、结构、格式、美观度时使用此技能。
飞书 API 不支持直接删除文档块
npx skills add https://github.com/aaaaqwq/claude-code-skills --skill feishu-doc-optimizerAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 41 |
|---|---|
| repo stars | ★ 82 |
| Last updated | August 2, 2026 |
| Repository | aaaaqwq/claude-code-skills ↗ |
What it does
A writer optimizes Feishu document structure and formatting by reading via API and replacing content through browser automation.
Who is it for?
Writers standardizing Feishu doc layout with consistent numbering, emoji markers, and tables.
Skip if: Editing that must go purely through the API, since the Feishu API cannot delete document blocks and browser automation is used instead.
When should I use this skill?
When a user wants to optimize, beautify, or reformat a Feishu document's layout and structure.
What you get
A restructured, consistently formatted Feishu document with clear hierarchy, emoji markers, and aligned tables.
- Reformatted Feishu document
By the numbers
- 12-row emoji usage convention table
- 2 documented Feishu tenant configurations
Files
飞书云文档优化器
优化飞书云文档的内容结构、排版格式和视觉美观度。
工作流程
1. 读取文档内容
使用飞书 API 读取文档原始内容:
python3 scripts/feishu_doc_reader.py <doc_token>文档 token 从 URL 提取:https://xxx.feishu.cn/docx/<doc_token>
2. 分析并优化内容
优化原则:
- 结构清晰:使用标准章节编号(1. 2. 3.)
- 层次分明:一级标题、二级标题、正文层次清晰
- 内容精炼:删除冗余,保留核心信息
- 视觉美观:使用 emoji 标记、分隔线、表格对齐
3. 替换文档内容
通过 Playwright 浏览器自动化:
python3 scripts/feishu_doc_editor.py <doc_token> <content_file>流程: 1. 连接已登录的浏览器 2. 打开文档进入编辑模式 3. 循环 Ctrl+A + Backspace 清空内容 4. 逐行输入新内容
飞书 API 配置
租户配置
| 租户 | App ID | 用途 |
|---|---|---|
| hanxing | REDACTED_FEISHU_HANXING_APP_ID | 汉兴企业(默认) |
| personal | REDACTED_FEISHU_PERSONAL_APP_ID | 个人应用 |
API 权限
需要的权限范围:
docx:document:readonly- 读取文档docx:document- 编辑文档(API 方式)
优化模板
项目文档模板
# [项目名称]
> [一句话描述]
> 📅 版本:vX.X | 更新日期:YYYY-MM-DD
---
## 📋 目录
1. 项目背景 2. 系统架构 3. 核心功能 ...
---
## 1. 项目背景
### 1.1 痛点分析
🔴 痛点1 - 描述 ⭐⭐⭐⭐⭐
🔴 痛点2 - 描述 ⭐⭐⭐⭐
### 1.2 解决方案
方案描述...
---
## 2. 核心功能
### 2.1 功能名称 ✅
**功能**:功能描述
**流程**:步骤1 ➜ 步骤2 ➜ 步骤3
---
## N. 项目价值
### N.1 投入成本
| 项目 | 成本 | 说明 |
|------|------|------|
| 项目1 | ¥0 | 说明 |
### N.2 产出价值
⏱️ 指标1:描述
💰 指标2:描述
---
💡 如有改进建议,欢迎提出!格式规范
Emoji 使用
| 场景 | Emoji |
|---|---|
| 目录/导航 | 📋 |
| 日期/版本 | 📅 |
| 痛点/问题 | 🔴 |
| 已完成 | ✅ |
| 进行中 | 🔄 |
| 待办 | ⏳ |
| 重要提示 | ⚠️ 💡 |
| 数据采集 | 📥 |
| 数据处理 | ⚙️ |
| 数据展示 | 📊 |
| 时间 | ⏱️ |
| 成本 | 💰 |
| 增长 | 📈 |
分隔符
- 章节分隔:
---(三个短横线) - 流程箭头:
➜ - 星级评分:
⭐⭐⭐⭐⭐
表格格式
| 列1 | 列2 | 列3 |
|:---:|------|:---:|
| 居中 | 左对齐 | 居中 |注意事项
1. 登录状态:浏览器编辑需要已登录飞书 2. API 限制:飞书 API 不支持直接删除文档块 3. 编辑模式:确保文档处于"编辑"模式而非"阅读"模式 4. 保存确认:编辑后等待"已保存到云端"提示
相关文件
scripts/feishu_doc_reader.py- 读取文档内容scripts/feishu_doc_editor.py- 编辑文档内容references/optimization-examples.md- 优化案例参考
飞书文档优化案例
案例1:OpenHR 项目文档
优化前问题
- 章节编号混乱(功能1、功能2...)
- 缺少目录导航
- 表格格式不统一
- 代码块过多,影响阅读
- 缺少视觉层次
优化后改进
- 统一章节编号(1. 2. 3.)
- 添加目录概览
- 使用 emoji 标记增强视觉
- 精简代码块,保留关键信息
- 添加分隔线区分章节
优化对比
优化前:
功能1:主动筛选沟通牛人 ✅
功能描述:自动筛选符合条件的候选人并发送首次沟通消息
工作流程图:
[大段代码块]优化后:
3.1 主动筛选沟通 ✅
功能:自动筛选符合条件的候选人并发送首次沟通消息
流程:定时触发(每天10点) ➜ 影刀RPA启动 ➜ 筛选候选人 ➜ 发送沟通 ➜ 记录缓存
配置:沟通上限80次/轮 | 最低学历本科 | 最低年限3年---
案例2:技术方案文档
优化原则
1. 开门见山:第一段说明文档目的 2. 结构清晰:问题 → 方案 → 实施 → 效果 3. 数据支撑:用数字说话 4. 行动导向:明确下一步
模板结构
# [方案名称]
> 一句话说明方案目标
## 📋 背景
- 当前问题
- 影响范围
- 紧迫程度
## 💡 方案
### 核心思路
### 技术选型
### 实施步骤
## 📊 预期效果
| 指标 | 当前 | 目标 | 提升 |
|------|------|------|------|
## ⏰ 时间计划
- [ ] 阶段1
- [ ] 阶段2
## 🔗 相关资源---
案例3:会议纪要
优化原则
1. 结论先行:决议放最前面 2. 责任明确:每项有负责人和截止日期 3. 简洁扼要:删除无关讨论
模板结构
# [会议主题] - YYYY-MM-DD
## ✅ 决议事项
1. [决议1] - @负责人 - 截止日期
2. [决议2] - @负责人 - 截止日期
## 📝 讨论要点
- 要点1
- 要点2
## ⏳ 待跟进
- [ ] 事项1
- [ ] 事项2
## 👥 参会人员
@人员1 @人员2 @人员3---
通用优化技巧
1. 标题层次
- 一级标题:文档主题
- 二级标题:主要章节(1. 2. 3.)
- 三级标题:子章节(1.1 1.2)
- 四级标题:细分内容
2. 信息密度
- 每段不超过3-4行
- 使用列表替代长段落
- 表格呈现对比信息
3. 视觉引导
- emoji 标记重点
- 分隔线区分章节
- 代码块高亮关键配置
4. 行动导向
- 明确责任人
- 设定截止日期
- 提供下一步指引
#!/usr/bin/env python3
"""
飞书文档编辑器
通过 Playwright 浏览器自动化编辑飞书文档
"""
import sys
import asyncio
from playwright.async_api import async_playwright
async def clear_document(page):
"""清空文档内容"""
print("🗑️ 清空文档内容...")
# 点击内容区域
try:
await page.click('[data-block-id]', timeout=5000)
except:
pass
await page.wait_for_timeout(300)
# 循环删除直到内容清空
for i in range(50):
try:
await page.click('[data-block-id]', timeout=2000)
except:
pass
await page.wait_for_timeout(100)
await page.keyboard.press("Control+a")
await page.wait_for_timeout(100)
await page.keyboard.press("Backspace")
await page.wait_for_timeout(100)
if i % 10 == 0:
print(f" 已执行 {i+1} 次删除...")
print("✅ 清空完成")
async def input_content(page, content_lines):
"""输入新内容"""
print("📝 输入新内容...")
# 点击内容区域
try:
await page.click('[data-block-id]', timeout=5000)
except:
pass
await page.wait_for_timeout(300)
for i, line in enumerate(content_lines):
if line.strip():
await page.keyboard.type(line, delay=3)
await page.keyboard.press("Enter")
await page.wait_for_timeout(50)
if i % 20 == 0:
print(f" 已输入 {i+1}/{len(content_lines)} 行...")
print("✅ 输入完成")
async def edit_document(doc_token, content_file):
"""编辑文档"""
# 读取新内容
with open(content_file, 'r', encoding='utf-8') as f:
content = f.read()
content_lines = content.split('\n')
async with async_playwright() as p:
# 连接到已有的浏览器
try:
browser = await p.chromium.connect_over_cdp("http://127.0.0.1:18800")
except Exception as e:
print(f"❌ 无法连接浏览器: {e}")
print("请确保 OpenClaw 浏览器已启动")
return False
# 查找文档页面
page = None
for ctx in browser.contexts:
for pg in ctx.pages:
if doc_token in pg.url:
page = pg
break
if not page:
# 打开新页面
print(f"📄 打开文档...")
ctx = browser.contexts[0] if browser.contexts else await browser.new_context()
page = await ctx.new_page()
await page.goto(f"https://opencaio.feishu.cn/docx/{doc_token}")
await page.wait_for_timeout(3000)
print(f"✅ 找到页面: {page.url}")
# 检查是否需要登录
content = await page.content()
if '扫码登录' in content or '登录' in content:
print("❌ 需要登录飞书,请先在浏览器中登录")
return False
# 进入编辑模式
try:
await page.click('text="编辑"', timeout=3000)
await page.wait_for_timeout(500)
# 点击编辑选项
await page.click('text="可编辑文档"', timeout=3000)
await page.wait_for_timeout(500)
except:
print("⚠️ 可能已在编辑模式")
# 清空文档
await clear_document(page)
# 输入新内容
await input_content(page, content_lines)
# 等待保存
await page.wait_for_timeout(2000)
print("✅ 文档编辑完成!")
return True
def main():
if len(sys.argv) < 3:
print("用法: python feishu_doc_editor.py <doc_token> <content_file>")
print("示例: python feishu_doc_editor.py JM3WdqG2bolLsNxlVnJcTdMjnce optimized.md")
sys.exit(1)
doc_token = sys.argv[1]
content_file = sys.argv[2]
success = asyncio.run(edit_document(doc_token, content_file))
sys.exit(0 if success else 1)
if __name__ == "__main__":
main()
#!/usr/bin/env python3
"""
飞书文档读取器
读取飞书云文档的原始内容
"""
import sys
import requests
import json
# 租户配置
TENANTS = {
"hanxing": {
"app_id": "REDACTED_FEISHU_HANXING_APP_ID",
"app_secret": "REDACTED_FEISHU_HANXING_SECRET",
},
"personal": {
"app_id": "REDACTED_FEISHU_PERSONAL_APP_ID",
"app_secret": "REDACTED_FEISHU_PERSONAL_SECRET",
}
}
def get_token(tenant="hanxing"):
"""获取 tenant_access_token"""
config = TENANTS.get(tenant, TENANTS["hanxing"])
resp = requests.post(
"https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal",
json={"app_id": config["app_id"], "app_secret": config["app_secret"]},
timeout=10
)
return resp.json().get("tenant_access_token")
def read_document(doc_token, tenant="hanxing"):
"""读取文档原始内容"""
token = get_token(tenant)
headers = {"Authorization": f"Bearer {token}"}
# 获取原始内容
resp = requests.get(
f"https://open.feishu.cn/open-apis/docx/v1/documents/{doc_token}/raw_content",
headers=headers,
timeout=30
)
result = resp.json()
if result.get('code') == 0:
return result.get('data', {}).get('content', '')
else:
print(f"错误: {result.get('msg')}", file=sys.stderr)
return None
def get_document_info(doc_token, tenant="hanxing"):
"""获取文档基本信息"""
token = get_token(tenant)
headers = {"Authorization": f"Bearer {token}"}
resp = requests.get(
f"https://open.feishu.cn/open-apis/docx/v1/documents/{doc_token}",
headers=headers,
timeout=30
)
result = resp.json()
if result.get('code') == 0:
doc = result.get('data', {}).get('document', {})
return {
"title": doc.get('title'),
"document_id": doc.get('document_id'),
"revision_id": doc.get('revision_id')
}
return None
def main():
if len(sys.argv) < 2:
print("用法: python feishu_doc_reader.py <doc_token> [tenant]")
print("示例: python feishu_doc_reader.py JM3WdqG2bolLsNxlVnJcTdMjnce hanxing")
sys.exit(1)
doc_token = sys.argv[1]
tenant = sys.argv[2] if len(sys.argv) > 2 else "hanxing"
# 获取文档信息
info = get_document_info(doc_token, tenant)
if info:
print(f"📄 文档标题: {info['title']}")
print(f"📝 文档ID: {info['document_id']}")
print(f"🔄 版本: {info['revision_id']}")
print("=" * 50)
# 读取内容
content = read_document(doc_token, tenant)
if content:
print(content)
else:
sys.exit(1)
if __name__ == "__main__":
main()
Related skills
FAQ
How does it replace content?
It connects a logged-in browser with Playwright, opens the doc in edit mode, clears content, and types the new content because the API cannot delete blocks.
What permissions does it need?
docx:document:readonly to read and docx:document to edit via the API.