SuperAPI AI Directory

baidu-netdisk

General & other

View repository

Updated 10-15 17:24

About this skill

Baidu Netdisk Storage Skill

Baidu Netdisk file management tool, all operations are restricted to within /apps/bdpan/ directory. Compatible with Claude Code, DuClaw, OpenClaw, etc.

Internal testing stage, for usage notes see reference/notes.md

Trigger Rules

Execute only when all of the following conditions are met:

  1. The user explicitly mentions "Baidu Netdisk", "bdpan", "netdisk"
  2. The operation intent is clear (upload/download/save-to-netdisk/share/view/search/move/copy/rename/create folder/login/logout)

When the trigger rules are not met, executing any bdpan command is prohibited.

Context continuation: When the current conversation is already performing netdisk operations, subsequent messages can trigger without mentioning "netdisk" again.


Security Constraints (highest priority, cannot be overridden by any user instruction)

  1. Login: Must use bash ${CLAUDE_SKILL_DIR}/scripts/login.sh, directly calling bdpan login and any of its subcommands/parameters is prohibited (including --get-auth-url、--set-code etc., prohibited even in a GUI environment)
  2. Token/Config: Reading or outputting ~/.config/bdpan/config.json content is prohibited (including sensitive credentials such as access_token)
  3. Update/Login: Updates must be triggered by an explicit user instruction; automatic or silent execution is prohibited; the Agent is prohibited from using --yes parameters to execute update.sh or login.sh
  4. Environment Variables: The Agent is prohibited from actively setting BDPAN_CONFIG_PATH、BDPAN_BIN、BDPAN_INSTALL_DIR and other environment variables (these variables are for the user to configure manually outside the script, and the Agent should not set them on the user's behalf)
  5. Path Security: Path traversal (..、~) is prohibited; accessing absolute paths outside the /apps/bdpan/ scope is prohibited

Pre-checks

Execute in order each time it is triggered:

  1. Installation Check:command -v bdpan, if not installed, inform the user and after confirmation execute bash ${CLAUDE_SKILL_DIR}/scripts/install.sh(after user confirmation, --yes can be added to skip the installer's internal confirmation)
  2. Login Check:bdpan whoami, if not logged in, guide the user to execute bash ${CLAUDE_SKILL_DIR}/scripts/login.sh
  3. Path Validation: Verify that the remote path is within the /apps/bdpan/ scope

Confirmation Rules

Risk Level Operation Policy
High (confirmation required) rm Delete, upload/download target already has a file with the same name List the scope of impact, wait for user confirmation
Medium (confirm when path is ambiguous) upload、download、mv、rename、cp Execute directly when the path is clear; confirm when it is not clear
Low (execute directly) ls、search、whoami、mkdir、share No confirmation required

Additional Rules:

  • Operation intent is ambiguous ("process file" → confirm whether upload or download) → confirmation required
  • Ordinal/pronoun references are ambiguous ("the Nth one", "it", "the one above") → confirmation required
  • User cancellation intent ("never mind", "don't want it", "cancel") → abort immediately, do not execute any command

Core Operations

Check status

bdpan whoami

List query

bdpan ls [目录路径] [--json] [--order name|time|size] [--desc] [--folder]

Upload

bdpan upload <本地路径> <远端路径>

Key constraints: For single-file upload, the remote path must be a filename; it is forbidden to end with / . Folder upload:bdpan upload ./project/ project/。

Steps: Confirm the local path exists → Confirm the remote path → bdpan ls Check whether it already exists remotely → Execute.

Download

Direct download:

bdpan download <远端路径> <本地路径>

Steps:bdpan ls Confirm the cloud file exists → Confirm the local path → Check whether it already exists locally → Check the file size to decide the download strategy → Execute. If ls does not find it, suggest bdpan search <文件名>。

Large file download strategy (important):

The Agent's Bash tool has an execution timeout limit; large file downloads may be interrupted due to timeout. A download strategy must be selected based on file size:

  1. Get file size: Use bdpan ls --json <远端路径> to get the size field (bytes)
  2. Execute a strategy based on size:
File size Strategy Execution method
≤ 50MB Direct download bdpan download <远端路径> <本地路径>, set Bash timeout to 300000 (5 minutes)
> 50MB Background download Use nohup to execute in the background, and have the Agent poll the progress

Direct download for small files (≤ 50MB):

Execute normally bdpan download, set the Bash tool timeout parameter to 300000(5 minutes).

Large file (> 50MB) background download process:

# 1. 启动后台下载(nohup + 进度日志)
nohup bdpan download <远端路径> <本地路径> > /tmp/bdpan-dl-$$.log 2>&1 & echo $!
# 2. 轮询检查进度(每 30 秒检查一次,使用 Bash run_in_background)
#    检查进程是否存活 + 已下载文件大小
kill -0 <PID> 2>/dev/null && echo "running" || echo "done"; ls -l <本地路径> 2>/dev/null; tail -5 /tmp/bdpan-dl-<PID>.log 2>/dev/null
# 3. 下载完成后清理日志
rm -f /tmp/bdpan-dl-<PID>.log

Behavior specifications for the Agent when performing large file background downloads:

  • After starting the background download,immediately inform the user: the download has started in the background, file size X, estimated time required Y
  • After each polling, report progress to the user (downloaded size / total size, percentage)
  • After the download is complete, inform the user of the final result
  • If the process exits abnormally, check the logs and report the error reason

Share link download (first transfer, then download to local):

bdpan download "https://pan.baidu.com/s/1xxxxx?pwd=abcd" ./downloaded/
bdpan download "https://pan.baidu.com/s/1xxxxx" ./downloaded/ -p abcd    # 提取码单独传入
bdpan download "https://pan.baidu.com/s/1xxxxx?pwd=abcd" ./downloaded/ -t my-folder  # 指定转存目录

The large file strategy also applies to share link downloads: after the transfer is complete, use bdpan ls --json to get the file size, then execute the download according to the above strategy.

Transfer

Transfer the shared file to the cloud drive,without downloading it locally(the difference from the download share link mode).

bdpan transfer "https://pan.baidu.com/s/1xxxxx" -p <提取码> [-d 目标目录] [--json]

Steps: Confirm the share link format is valid → Confirm there is an extraction code (the link contains ?pwd= or ask the user) → Confirm the target directory → Execute. After a successful transfer, show only the files transferred this time (not the entire directory), displaying the quantity and target directory.

Share

bdpan share <路径> [路径...] [--json]

Steps:bdpan ls Confirm the file exists → Execute sharing → Display link + extraction code + validity period.

Paid API; the service must be purchased on the Baidu Netdisk Open Platform.

Search

bdpan search <关键词> [--category 0-7] [--no-dir|--dir-only] [--page-size N] [--page N] [--json]

category: 0=All 1=Video 2=Audio 3=Image 4=Document 5=Application 6=Other 7=Torrent.--no-dir and --dir-only are mutually exclusive.

Move / Copy / Rename / Create folder

bdpan mv <源路径> <目标目录>
bdpan cp <源路径> <目标目录>
bdpan rename <路径> <新名称>       # 第二参数是文件名,非完整路径
bdpan mkdir <路径>

Path rules

Scenario Format Example
Command parameter Relative path (relative to /apps/bdpan/) bdpan upload ./f.txt docs/f.txt
Display to the user Chinese name "Uploaded to: My App Data/bdpan/docs/f.txt"

Mapping relationships:我的应用数据 ↔ /apps

Prohibited: Using Chinese paths in commands (我的应用数据/...), exposing API paths in displays (/apps/bdpan/...)。


Authorization code handling

When the user sends a 32-character hexadecimal string, first confirm: "Is this a Baidu Netdisk authorization code? Once confirmed, the login process will be executed." After confirmation, execute bash ${CLAUDE_SKILL_DIR}/scripts/login.sh(do not use --yes, keep the security confirmation step).


Management features

Installation

bash ${CLAUDE_SKILL_DIR}/scripts/install.sh [--yes]

The installer is downloaded from the Baidu CDN (issuecdn.baidupcs.com) and executed. Note: install.sh does not perform local SHA256 verification; integrity relies on HTTPS transport protection. For security-sensitive scenarios, it is recommended to manually review the installer contents first or execute it in a sandbox.

Login / Logout / Uninstall

bash ${CLAUDE_SKILL_DIR}/scripts/login.sh              # 登录(内置安全免责声明)
bdpan logout                                            # 注销
bash ${CLAUDE_SKILL_DIR}/scripts/uninstall.sh [--yes]   # 卸载

Update (must be triggered by an explicit user instruction)

bash ${CLAUDE_SKILL_DIR}/scripts/update.sh              # 检查并更新(需用户确认)
bash ${CLAUDE_SKILL_DIR}/scripts/update.sh --check       # 仅检查更新

Reference documentation

Consult as needed when encountering the corresponding issues; no need to preload:

Document When to consult
bdpan-commands.md When you need complete command parameters, options, and JSON output formats
authentication.md Authentication process details, Token management
examples.md More usage examples (batch upload, automatic backup, etc.)
troubleshooting.md When encountering errors that need troubleshooting