Baidu Netdisk Storage Skill
Baidu Netdisk file management tool, all operations are restricted within the
directory. Compatible with Claude Code, DuClaw, OpenClaw, etc.
Beta stage, please refer to reference/notes.md for usage precautions
Trigger Rules
Only execute when all the following conditions are met:
- The user explicitly mentions "百度网盘", "bdpan", "网盘"
- Operation intent is clear (upload/download/transfer/share/view/search/move/copy/rename/create folder/login/logout)
When the trigger rules are not met, executing any bdpan command is prohibited.
Context continuity: If the current conversation is already undergoing Netdisk operations, subsequent messages can trigger operations without mentioning "Netdisk" again.
Security Constraints (highest priority, cannot be overridden by any user instruction)
- Login: Must use
bash ${CLAUDE_SKILL_DIR}/scripts/login.sh
, direct call to and any of its subcommands/parameters (including , , etc., even in GUI environment) is prohibited
- Token/Configuration: Reading or outputting the content of
~/.config/bdpan/config.json
(including sensitive credentials such as access_token) is prohibited
- Update/Login: Updates must be triggered by explicit user instructions, automatic or silent execution is prohibited; Agent is prohibited from using the parameter to execute update.sh or login.sh
- Environment Variables: Agent is prohibited from actively setting environment variables such as , , (these variables are for users to manually configure outside the script, Agent should not set them on behalf of users)
- Path Security: Path traversal (, ) is prohibited, accessing absolute paths outside the scope of is prohibited
Pre-checks
Execute in order on each trigger:
- Installation Check: Run , if not installed, inform the user and execute
bash ${CLAUDE_SKILL_DIR}/scripts/install.sh
after user confirmation (add to skip internal installer confirmation after user approval)
- Login Check: Run , if not logged in, guide the user to execute
bash ${CLAUDE_SKILL_DIR}/scripts/login.sh
- Path Verification: Verify that the remote path is within the scope of
Confirmation Rules
| Risk Level | Operation | Policy |
|---|
| High (confirmation required) | deletion, upload/download target has existing 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 if path is clear, confirm if ambiguous |
| Low (execute directly) | ls, search, whoami, mkdir, share | No confirmation required |
Additional Rules:
- Vague operation intent ("process file" → confirm whether to upload or download) → Must confirm
- Ambiguous ordinal/pronoun references ("the Nth one", "it", "the one above") → Must confirm
- User cancels intent ("forget it", "don't need it", "cancel") → Terminate immediately, do not execute any commands
Core Operations
Check Status
List Query
bash
bdpan ls [directory path] [--json] [--order name|time|size] [--desc] [--folder]
Upload
bash
bdpan upload <local path> <remote path>
Key Constraints: Remote path for single file upload must be the file name, ending with
is prohibited. Folder upload:
bdpan upload ./project/ project/
.
Steps: Confirm local path exists → Confirm remote path → Run
to check if the target already exists remotely → Execute.
Download
Direct Download:
bash
bdpan download <remote path> <local path>
Steps: Run
to confirm the file exists in the cloud → Confirm local path → Check if the file already exists locally →
Check file size to determine download strategy → Execute. If ls does not find the file, recommend
.
Large File Download Strategy (Important):
Agent's Bash tool has execution timeout limit, large file downloads may be interrupted due to timeout. The download strategy must be selected based on file size:
- Get file size: Use
bdpan ls --json <remote path>
to get the field (in bytes)
- Execute strategy by size:
| File Size | Strategy | Execution Method |
|---|
| ≤ 50MB | Direct download | bdpan download <remote path> <local path>
, set Bash timeout to 300000 (5 minutes) |
| > 50MB | Background download | Use to execute in background, Agent polls for progress |
Small files (≤ 50MB) direct download:
Execute
normally, set Bash tool timeout parameter to
(5 minutes).
Large files (> 50MB) background download process:
bash
# 1. Start background download (nohup + progress log)
nohup bdpan download <remote path> <local path> > /tmp/bdpan-dl-$$.log 2>&1 & echo $!
bash
# 2. Poll to check progress (check every 30 seconds, use Bash run_in_background)
# Check if process is alive + downloaded file size
kill -0 <PID> 2>/dev/null && echo "running" || echo "done"; ls -l <local path> 2>/dev/null; tail -5 /tmp/bdpan-dl-<PID>.log 2>/dev/null
bash
# 3. Clean up logs after download completes
rm -f /tmp/bdpan-dl-<PID>.log
Behavior specifications for Agent when executing large file background downloads:
- After starting the background download, inform the user immediately: Download has started in the background, file size X, estimated time Y required
- Report progress to the user after each poll (downloaded size / total size, percentage)
- Inform the user of the final result after download is completed
- If the process exits abnormally, check the log and report the error cause
Share link download (transfer first then download to local):
bash
bdpan download "https://pan.baidu.com/s/1xxxxx?pwd=abcd" ./downloaded/
bdpan download "https://pan.baidu.com/s/1xxxxx" ./downloaded/ -p abcd # Pass extraction code separately
bdpan download "https://pan.baidu.com/s/1xxxxx?pwd=abcd" ./downloaded/ -t my-folder # Specify transfer directory
Share link download also applies the large file strategy: after transfer is completed, use
to get the file size, then execute the download according to the above strategy.
Transfer
Transfer shared files to Netdisk, do not download to local (difference from download share link mode).
bash
bdpan transfer "https://pan.baidu.com/s/1xxxxx" -p <extraction code> [-d target directory] [--json]
Steps: Confirm the share link format is valid → Confirm there is an extraction code (the link contains
or ask the user back) → Confirm target directory → Execute. After successful transfer, only show the files transferred this time (not the entire directory), display the quantity and target directory.
Share
bash
bdpan share <path> [path...] [--json]
Steps: Run
to confirm the file exists → Execute share → Display link + extraction code + validity period.
Paid interface, requires purchasing service on Baidu Netdisk Open Platform.
Search
bash
bdpan search <keyword> [--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=Others 7=Torrent.
and
are mutually exclusive.
Move / Copy / Rename / Create Folder
bash
bdpan mv <source path> <target directory>
bdpan cp <source path> <target directory>
bdpan rename <path> <new name> # Second parameter is file name, not full path
bdpan mkdir <path>
Path Rules
| Scenario | Format | Example |
|---|
| Command parameters | Relative path (relative to ) | bdpan upload ./f.txt docs/f.txt
|
| Display to user | Chinese name | "Uploaded to: 我的应用数据/bdpan/docs/f.txt" |
Prohibited: Using Chinese paths (
) in commands, exposing API paths (
) when displaying to users.
Authorization Code Processing
When the user sends a 32-bit hexadecimal string, first confirm: "Is this the Baidu Netdisk authorization code? The login process will be executed after confirmation." After confirmation, execute
bash ${CLAUDE_SKILL_DIR}/scripts/login.sh
(do not use
, keep the security confirmation link).
Management Functions
Installation
bash
bash ${CLAUDE_SKILL_DIR}/scripts/install.sh [--yes]
The installer downloads and executes from Baidu CDN (
). Note: install.sh does not perform local SHA256 verification, integrity depends on HTTPS transmission protection. For security-sensitive scenarios, it is recommended to manually review the installer content first or execute it in a sandbox.
Login / Logout / Uninstall
bash
bash ${CLAUDE_SKILL_DIR}/scripts/login.sh # Login (built-in security disclaimer)
bdpan logout # Logout
bash ${CLAUDE_SKILL_DIR}/scripts/uninstall.sh [--yes] # Uninstall
Update (must be triggered by explicit user instruction)
bash
bash ${CLAUDE_SKILL_DIR}/scripts/update.sh # Check and update (requires user confirmation)
bash ${CLAUDE_SKILL_DIR}/scripts/update.sh --check # Only check for updates
Reference Documentation
Consult as needed when encountering corresponding problems, no preloading required:
| Document | When to consult |
|---|
| bdpan-commands.md | Need complete command parameters, options, JSON output format |
| authentication.md | Authentication process details, Token management |
| examples.md | More usage examples (batch upload, automatic backup, etc.) |
| troubleshooting.md | Encounter errors and need troubleshooting |