Feishu Markdown Exporter
Use this skill to export Feishu/Lark documents to Markdown. It supports the two common personal workflows:
- Export one Feishu/Lark document URL to
.md. - Recursively export a Feishu/Lark Drive folder tree to local
.mdfiles.
The implementation uses official Feishu Open Platform APIs:
- OAuth user authorization to obtain
user_access_token. - Drive folder listing API for folder recursion.
- Docx document metadata and blocks APIs to read document content.
- Local conversion from Feishu block JSON to Markdown.
It does not crack private documents or bypass view permissions. The user must have view access, and the app must have the required API scopes. It can still export Markdown when the UI disables copy/export, because reading document blocks and official file export are separate permission surfaces.
Script
Run the bundled script:
python /Users/weijian/.agents/skills/feishu-md-exporter/scripts/export_feishu_md.py <feishu-url> --output <output-dir>
For a single document:
python /Users/weijian/.agents/skills/feishu-md-exporter/scripts/export_feishu_md.py \
"https://example.feishu.cn/docx/xxxxx" \
--output ./feishu_md_exports
For a folder:
python /Users/weijian/.agents/skills/feishu-md-exporter/scripts/export_feishu_md.py \
"https://example.feishu.cn/drive/folder/xxxxx" \
--output ./feishu_md_exports
Credentials
Prefer environment variables:
export FEISHU_APP_ID="cli_xxx"
export FEISHU_APP_SECRET="xxx"
Or pass them explicitly:
python scripts/export_feishu_md.py <url> --app-id cli_xxx --app-secret xxx
Or store them in:
~/.feishu-md-exporter/config.json
Format:
{
"app_id": "cli_xxx",
"app_secret": "xxx"
}
The OAuth token cache is stored at:
~/.feishu-md-exporter/token_cache.json
Required Feishu App Setup
In the Feishu/Lark developer console:
- Add redirect URL exactly:
http://localhost:9876/callback
- Enable and publish the relevant scopes:
docx:document:readonly
wiki:wiki:readonly
drive:drive:readonly
drive:file:readonly
drive:export:readonly is not required for Markdown block export, but it is harmless if already enabled.
- On first run, complete the OAuth page in the browser.
Workflow
- Identify whether the URL is a single document, wiki node, or Drive folder.
- If credentials are missing, ask for
app_idandapp_secret, or ask the user to create~/.feishu-md-exporter/config.json. - Run the script with a clear output directory.
- If OAuth opens in the browser, tell the user to approve it. If the page says redirect URL error, tell them to add
http://localhost:9876/callbackunder Security Settings -> Redirect URL. - After export, report:
- Output directory or file path.
- Number of Markdown files exported.
- Any failed or skipped items.
Common Errors
redirect URL error/ code20029: the app did not configurehttp://localhost:9876/callbackas a redirect URL.no permission/403: the user or app lacks view/API permission for the document or folder.scopeor authorization error: add and publish the required scopes, then delete~/.feishu-md-exporter/token_cache.jsonand retry.- Folder export returns no docs: verify the URL is a Drive folder URL and the user has view access to the folder contents.
Output Behavior
- Folder export preserves the Feishu folder tree locally.
- Unsupported path characters such as
/are replaced with_. - Duplicate names receive suffixes like
_2. - Images and files may be represented as placeholders if the Blocks API returns only tokens and the script does not download binary assets.
Keep the user-facing response short: say whether it worked, where the files are, and the counts.