agentleFS
Light-hdzLight-hdz/claude-skills/feishu-doc/SKILL.md

feishu-doc

Skill0 starsChanged 7 months agoApache-2.0View on GitHub

Create and publish online documents in Feishu (Lark) cloud workspace from markdown or text content. Use this skill when the user wants to "create a Feishu doc", "make an online document in Feishu", "upload to Feishu docs", "published in Feishu", "create a Lark document", "make a Feishu page", or any request to turn content into a Feishu/Lark online document. Also use when converting markdown files to Feishu docx format, or when the user mentions words like "飞书文档", "飞书在线文档", "云文档", "创建文档". Covers uploading content via API, converting files to online documents via browser automation, and handling the Feishu docx conversion workflow. Do NOT use for editing existing documents, managing Feishu permissions, or general Feishu administration tasks unrelated to document creation.

9 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use deep-research and skill-creator.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • NVIDIASkill

    deep-research

    Queue deep, multi-step research and analysis tasks to the DeepAgents worker. Supports execution depth presets, request-specific rubrics, SubAgent delegation, and RubricMiddleware cross-validation.

    Also in 3 projects that use this

  • SentrySkill

    skill-creator

    Create new agent skills following the Agent Skills specification. Use when asked to "create a skill", "add a new skill", "write a skill", "make a skill", "build a skill", or scaffold a new skill with SKILL.md. Guides through requirements, writing, registration, and verification.

    Also in 4 projects that use this

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 4 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before starting, gather these from the user if not already known:

    line 36
  2. Very specific:

    Write content as markdown.

    line 67
  3. Very specific:

    Use the drive/v1/files/upload_all endpoint with parent_type=explorer.

    line 85
  4. Distinctive:

    Wait for the page to redirect away from the login URL (poll every 2 seconds).

    line 139
  5. Very specific:

    But note: If using the browser_tabs tool pattern, use action: "select" and index: 1 to switch to the new tab.

    line 163
  6. Distinctive:

    If no content needs to be pre-filled, create a blank online document directly in the browser:

    line 177
  7. Distinctive:

    Use JavaScript to click the menu item because Playwright locators may be blocked by overlays:

    line 182

“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Feishu Document Creator

Overview

Creates Feishu (Lark) online documents from markdown or text content. Uses a two-phase strategy: upload content via API, then convert to editable online document via Playwright browser automation. This hybrid approach works because Feishu's drive:drive API scope handles file uploads, while the "convert to online doc" step requires browser interaction (the docx:document API scope is separate and often unavailable).

Quick Reference

TaskMethod
Upload .md file to Feishu Drivedrive/v1/files/upload_all API
Convert file to online docxPlaywright → click "转为在线文档"
Create empty documentPlaywright → "新建" → "文档"
Get tenant access tokenauth/v3/tenant_access_token/internal API

Prerequisites

Before starting, gather these from the user if not already known:

ItemWhere to find
App IDFeishu Open Platform → app credentials
App SecretFeishu Open Platform → app credentials
Feishu tenant URLUsually {subdomain}.feishu.cn
Root folder tokendrive/explorer/v2/root_folder/meta API

The app must have at minimum the drive:drive permission scope configured and published in the Feishu Open Platform.


Phase 1: Upload Content to Feishu Drive

Step 1.1: Get Tenant Access Token

import requests

resp = requests.post(
    'https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal',
    json={'app_id': 'YOUR_APP_ID', 'app_secret': 'YOUR_APP_SECRET'}
)
token = resp.json()['tenant_access_token']

The token is valid for ~2 hours. If permissions change, get a new token — the old one caches the previous permission set.

Step 1.2: Prepare Content

Write content as markdown. Use proper headings (#, ##), lists (-, 1.), tables, and code blocks. Feishu renders these faithfully.

Save content to a temporary .md file:

content = """# Document Title

## Section One

Your content here...
"""
temp_path = '/tmp/feishu_doc.md'
with open(temp_path, 'w', encoding='utf-8') as f:
    f.write(content)

Step 1.3: Upload via API

Use the drive/v1/files/upload_all endpoint with parent_type=explorer. Leave parent_node empty to upload to the tenant root.

file_size = len(content.encode('utf-8'))

resp = requests.post(
    'https://open.feishu.cn/open-apis/drive/v1/files/upload_all',
    headers={'Authorization': f'Bearer {token}'},
    files={'file': ('document.md', content.encode('utf-8'), 'text/markdown')},
    data={
        'file_name': 'document.md',
        'parent_type': 'explorer',
        'parent_node': '',
        'size': str(file_size),
    }
)
result = resp.json()
if result['code'] == 0:
    file_token = result['data']['file_token']
    file_url = f'https://{tenant_domain}/file/{file_token}'

Important: Files uploaded via tenant_access_token are owned by the app, not the user. They appear in the tenant's shared space but not in the user's personal "My Drive." This is expected — the browser phase handles the conversion to a user-owned document.

Common Upload Errors

Error CodeMeaningFix
99991672Missing API scopeGrant drive:drive in Feishu Open Platform, publish version
99991663Token expired/invalidatedGet a fresh token (permissions changed)
1061002Parameter errorCheck parent_type is explorer, size matches

Phase 2: Convert to Online Document (Playwright)

Step 2.1: Open Browser to File

Navigate the Playwright browser directly to the uploaded file URL:

// The file URL pattern is: https://{tenant}.feishu.cn/file/{file_token}
await page.goto(file_url);

Step 2.2: Handle Login

Feishu requires authentication. The login page shows a QR code. Take a screenshot and ask the user to scan it with their Feishu mobile app:

await page.screenshot({ path: 'login_qr.png' });
// Show this to the user — they scan to log in

Wait for the page to redirect away from the login URL (poll every 2 seconds). Once the URL changes to the file page, login is complete.

Step 2.3: Convert to Online Document

On the file view page, there is a button labeled "转为在线文档" (Convert to Online Document). Click it:

await page.getByText('转为在线文档').click();

This creates a new docx document in a new browser tab. The original .md file remains as-is.

Step 2.4: Capture the Document URL

Switch to the newly opened tab and extract the URL:

const tabs = await context.pages();
// The new tab is the last one
const docTab = tabs[tabs.length - 1];
const docUrl = docTab.url();
// Pattern: https://{tenant}.feishu.cn/docx/{doc_token}

But note: If using the browser_tabs tool pattern, use action: "select" and index: 1 to switch to the new tab.

Step 2.5: Verify

Take a screenshot of the document to confirm the content rendered correctly:

await page.screenshot({ path: 'feishu_doc_result.png' });

Alternative Path: Create Empty Document via Playwright

If no content needs to be pre-filled, create a blank online document directly in the browser:

  1. Navigate to https://{tenant}.feishu.cn/drive/home/
  2. Handle QR code login (same as above)
  3. Click "新建" (New) → find "文档" (Document) in the dropdown menu
  4. Use JavaScript to click the menu item because Playwright locators may be blocked by overlays:
await page.evaluate(() => {
    const spans = document.querySelectorAll('span');
    for (const span of spans) {
        if (span.textContent === '文档') {
            let parent = span.parentElement;
            while (parent && parent.tagName !== 'BODY') {
                if (parent.classList.contains('menu-item')) {
                    parent.click();
                    return;
                }
                parent = parent.parentElement;
            }
        }
    }
});
  1. A new blank document tab opens — capture the URL as above.

Complete Example

User request: "帮我把这个总结发布到飞书上"

# Phase 1: Upload
import requests

token = get_tenant_token(app_id, app_secret)
content = generate_markdown_content()  # your content here

resp = requests.post(
    'https://open.feishu.cn/open-apis/drive/v1/files/upload_all',
    headers={'Authorization': f'Bearer {token}'},
    files={'file': ('summary.md', content.encode(), 'text/markdown')},
    data={
        'file_name': 'summary.md',
        'parent_type': 'explorer',
        'parent_node': '',
        'size': str(len(content.encode())),
    }
)
file_token = resp.json()['data']['file_token']
file_url = f'https://{tenant}.feishu.cn/file/{file_token}'

# Phase 2: Convert via Playwright
# (Use playwright skill to navigate to file_url, click "转为在线文档")
# Result: https://{tenant}.feishu.cn/docx/{new_doc_token}

Error Recovery

ProblemRecovery Strategy
QR code not scannedRe-take screenshot, tell user explicitly "请用飞书手机端扫描二维码"
"转为在线文档" button not foundWait longer for page to load, or refresh. If still missing, the file type may not be convertible — try parent_type variants
Dropdown menu blocks clickPress Escape to dismiss menu, then retry
File not visible in DriveNavigate directly to file/{file_token} URL instead of browsing
API upload fails with 1061002Remove parent_node parameter or use empty string — root folder token may be rejected
Token returns old permissionsGet a new token; Feishu caches permissions in existing tokens

Key Constraints

  1. API vs Browser: API can upload files but cannot convert them to online documents without docx:document scope. Browser automation is the reliable conversion path.
  2. File Ownership: API-uploaded files are owned by the app. After browser conversion to docx, the new document is owned by the logged-in user.
  3. QR Code Login: Required for browser automation. There is no way to bypass this — Feishu web requires interactive authentication.
  4. Rate Limits: The drive/v1/files/upload_all API has rate limits. For bulk operations, space out calls.
  5. File Size: Maximum 20MB per file upload.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.