agentleFS
therain2020therain2020/therain2020-agent/.claude/skills/push-docs-to-feishu/SKILL.md

push-docs-to-feishu

Skill0 starsChanged 6 months agoMITView on GitHub

Push local project Markdown documents to Feishu Wiki using lark-cli. Handles creation (docs +create v2), wiki move, UTF-8 encoding, rate limiting, and CLAUDE.md reference updates. Two-step pipeline: create docx + move to wiki.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Check which ones already exist in the wiki (optional — use wiki +space-list and wiki +node-list to check)

    line 43
  2. Distinctive:

    Use this PowerShell pattern.

    line 48
  3. Distinctive:

    After successful upload, update CLAUDE.md to add the new docs to the Design Reference or Project Docs table.

    line 86

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “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

Push Docs to Feishu Wiki Skill

Push local Markdown files to a Feishu Wiki space using lark-cli.

Prerequisites

  • lark-cli.exe at D:\GitHub\larksuite-cli\lark-cli.exe
  • Authenticated (lark-cli wiki +space-list returns "ok": true)
  • Target wiki space ID: 7644823612574141651 (Agent 设计文档)

The Pipeline

Each document goes through a two-step pipeline:

1. docs +create --api-version v2 --content @file --doc-format markdown --title "..."
   → returns document_id
2. wiki +move --obj-type docx --obj-token <doc_id> --target-space-id <space_id>
   → moves into wiki space

Phase 1: Assess

  1. List local docs to push: Get-ChildItem <dir> -Filter "*.md"
  2. Check which ones already exist in the wiki (optional — use wiki +space-list and wiki +node-list to check)
  3. Report: "Found N docs. M new, K already in wiki."

Phase 2: Push

Use this PowerShell pattern. Critical rules:

  • UTF-8 no BOM: [System.Text.UTF8Encoding]::new($false) — never use Out-File -Encoding utf8
  • Relative paths: Set-Location to lark-cli directory before each call
  • Rate limit: Start-Sleep -Seconds 2 between each doc
  • Shell CWD: lark-cli resets working directory after each call; always Set-Location before calling
$cli = "D:\GitHub\larksuite-cli\lark-cli.exe"
$spaceId = "7644823612574141651"
$tmpDir = "D:\GitHub\larksuite-cli"

foreach ($f in Get-ChildItem $sourceDir -Filter "*.md" | Sort-Object Name) {
    $title = $f.BaseName -replace '-', ' '
    if ($title.Length -gt 60) { $title = $title.Substring(0, 60) }
    $content = [System.IO.File]::ReadAllText($f.FullName, [System.Text.UTF8Encoding]::new($false))
    [System.IO.File]::WriteAllText("$tmpDir\tmp-md.txt", $content, [System.Text.UTF8Encoding]::new($false))
    
    # Step 1: Create docx
    Set-Location $tmpDir
    $raw = & $cli docs +create --api-version v2 --content "@tmp-md.txt" --doc-format markdown --title "$title" 2>&1 | Out-String
    Set-Location "D:\GitHub\therain2020-agent"
    
    if ($raw -match '"document_id":\s*"([^"]+)"') {
        $docId = $matches[1]
        # Step 2: Move to wiki
        Set-Location $tmpDir
        $moveResult = & $cli wiki +move --obj-type docx --obj-token $docId --target-space-id $spaceId 2>&1 | Out-String
        Set-Location "D:\GitHub\therain2020-agent"
        if ($moveResult -match '"ok":\s*true') { Write-Host "  OK: $title" } else { Write-Host "  MOVE FAIL: $title" }
    } else { Write-Host "  CREATE FAIL: $title" }
    Start-Sleep -Seconds 2
}
Remove-Item "$tmpDir\tmp-md.txt" -ErrorAction SilentlyContinue

Phase 3: Update References

After successful upload, update CLAUDE.md to add the new docs to the Design Reference or Project Docs table.

The wiki space URL is: https://ycn21rm70xup.feishu.cn/wiki/space/7644823612574141651

Common Pitfalls

SymptomCauseFix
--data invalid JSON formatFile has UTF-8 BOM from Out-File -Encoding utf8Use [System.Text.UTF8Encoding]::new($false)
cannot read file "tmp-md.txt"CWD was reset by previous lark-cli callSet-Location $tmpDir before every CLI call
--content is requiredUsing v1 syntax (--markdown) with v2 APIUse --content @file --doc-format markdown
First 18 docs OK, rest failRate limitingStart-Sleep -Seconds 2 minimum
unknown flag: --wiki-spacev2 API removed this flagTwo-step: create + wiki move

Target Directories

Local pathContent typeWiki section
D:\GitHub\agent-design\temp\设计文档 (30篇)Root of wiki space
D:\GitHub\therain2020-agent\docs\项目文档 (5篇)Root of wiki space

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.