You are managing the Feishu document operations skill.
User data is stored in ~/.feishu-docs/。
First, locate the skill directory by finding this SKILL.md file:
- Use the Glob pattern
**/skills/**/feishu-docs/SKILL.mdto find its path, then derive the skill root directory from it. - Keep this path in mind as SKILL_DIR, to be used for all subsequent file references.
Command Parsing
From $ARGUMENTS , parse the user's intent and map it to one of the following subcommands:
| User says (example) | Subcommand |
|---|---|
setup, configure, 配置 |
setup |
create <title>, 创建文档 <title> |
create |
list, 列出文档 |
list |
read <docToken>, 读取文档 <docToken> |
read |
update <docToken> <content>, 更新文档 <docToken> |
update |
delete <docToken>, 删除文档 <docToken> |
delete |
Extract optional parameters.
Runtime Detection
Before executing any subcommand, detect which environment you are running in:
- Interactive skill host —
AskUserQuestiontool is available. Use it for the interactive setup wizard. - Non-interactive host —
AskUserQuestionis not available. Fall back to non-interactive guidance: explain the steps, showSKILL_DIR/config.env.example, and ask the user to manually create~/.feishu-docs/config.env。
You can test this by checking whether AskUserQuestion is in the list of available tools.
Configuration Check (applicable to create、list、read、update、delete)
Before running any subcommand other than setup , check whether ~/.feishu-docs/config.env exists:
- If it does not exist:
- In an interactive host: tell the user "Configuration not found" and automatically use AskUserQuestion to launch the
setupwizard. - In a non-interactive host: tell the user "Configuration not found. Please create
~/.feishu-docs/config.envaccording to the example:" then showSKILL_DIR/config.env.exampleand stop. Do not attempt to perform document operations.
- In an interactive host: tell the user "Configuration not found" and automatically use AskUserQuestion to launch the
- If it exists: Continue executing the requested subcommand.
Subcommands
setup
Run the interactive setup wizard. This subcommand requires AskUserQuestion. If it is unavailable, show SKILL_DIR/config.env.example with a field-by-field explanation, and guide the user to manually create the configuration file.
When AskUserQuestion is available,field by fieldcollect input. After each answer, confirm the value with the user (show only the last 4 characters of secrets), then proceed to the next question.
Step 1 — Configuration
Collect the following information:
- App ID - obtained from the Feishu Open Platform
- App Secret - obtained from the Feishu Open Platform
- Domain(optional) - default
https://open.feishu.cn, usehttps://open.larksuite.com - Default folder Token(optional) - the default location for document creation
Before asking for credentials, first read SKILL_DIR/references/setup-guide.md and show the relevant platform guidance to the user.
Step 2 — Write the configuration and verify
- Show the final summary table with all settings clearly displayed (show only the last 4 characters of secrets)
- Ask the user for confirmation before writing
- Use Bash to create the directory structure:
mkdir -p ~/.feishu-docs/{data,logs} - Use Write to create
~/.feishu-docs/config.env, with all settings in KEY=VALUE format - Use Bash to set permissions:
chmod 600 ~/.feishu-docs/config.env - Verify credentials:
- Use Write to create a temporary JSON file used only for the current verification, for example
~/.feishu-docs/data/auth-check.json - file contents include
app_idandapp_secret - Use Bash to call:
curl -s -X POST "${DOMAIN}/open-apis/auth/v3/tenant_access_token/internal" -H "Content-Type: application/json" --data-binary "@$HOME/.feishu-docs/data/auth-check.json" - Delete the temporary file immediately after verification
- Only report to the user
code/msg/ success or failure, never echo the request body, App ID, or App Secret
- Use Write to create a temporary JSON file used only for the current verification, for example
- Report the result with a summary table. If any verification fails, explain what might have gone wrong and how to fix it.
- On success, tell the user: "Setup complete! You can now use the Feishu document commands."
create <title> [content]
Create a new Feishu document.
- Extract the title and optional content from the parameters
- If no content is provided, prompt the user for input or read from the clipboard/current file
- Use Write to create a temporary parameter file (JSON), for example
~/.feishu-docs/data/create-args.json - Write
{ "command": "create", "title": "...", "content": "..." } - Call
node SKILL_DIR/scripts/feishu-docs.js --args-file "$HOME/.feishu-docs/data/create-args.json" - Delete the temporary parameter file after running
- Show the result to the user, including the document link
list
List recent Feishu documents.
Run:node SKILL_DIR/scripts/feishu-docs.js list
Display the document list, including titles, last modified times, and document links.
read <docToken>
Read Feishu document content.
- Use Write to create a temporary parameter file (JSON), for example
~/.feishu-docs/data/read-args.json - Write
{ "command": "read", "docToken": "..." } - Run:
node SKILL_DIR/scripts/feishu-docs.js --args-file "$HOME/.feishu-docs/data/read-args.json" - Delete the temporary parameter file after running
Display the document content. If the content is long, it can be displayed in sections.
update <docToken> <content>
Update Feishu document content.
- Use Write to create a temporary parameter file (JSON), for example
~/.feishu-docs/data/update-args.json - Write
{ "command": "update", "docToken": "...", "content": "..." } - Run:
node SKILL_DIR/scripts/feishu-docs.js --args-file "$HOME/.feishu-docs/data/update-args.json" - Delete the temporary parameter file after running
delete <docToken>
Delete a Feishu document.
- Confirm before deleting
- Use Write to create a temporary parameter file (JSON), for example
~/.feishu-docs/data/delete-args.json - Write
{ "command": "delete", "docToken": "..." } - Run:
node SKILL_DIR/scripts/feishu-docs.js --args-file "$HOME/.feishu-docs/data/delete-args.json" - Delete the temporary parameter file after running
- Clearly explain to the user that this operation will move the document to the recycle bin
Notes
- Always mask secrets in the output (show only the last 4 characters)
- The configuration file permissions should be 600
- Document operations require the corresponding Feishu API permissions
- Do not inline secrets, tokens, or user content directly into shell commands; prefer passing parameters via temporary files
- Error output should report only the necessary status information, and should not echo the raw request body or the complete exception object