Baidu Drive Storage Skill
Baidu Drive file management tool, all operations are restricted within the
directory. Compatible with Claude Code, DuClaw, OpenClaw, etc.
See reference/notes.md for usage notes
Trigger Rules
Execute only when all the following conditions are met:
- User explicitly mentions "Baidu Drive", "bdpan", "网盘"
- Clear operation intent (upload/download/transfer/share/view/search/move/copy/rename/create folder/login/logout)
Do not execute any bdpan commands if trigger rules are not met.
Context Continuity: When a cloud drive operation is already in progress in the current conversation, subsequent messages do not need to mention "cloud drive" again to trigger.
Security Constraints (Highest Priority, Cannot Be Overridden by Any User Instructions)
- Login: Must use
bash ${CLAUDE_SKILL_DIR}/scripts/login.sh
, prohibit direct calls to and any of its subcommands/parameters (including , , etc., even in GUI environments)
- Token/Configuration: Prohibit reading or outputting content of
~/.config/bdpan/config.json
(including sensitive credentials like access_token)
- Update/Login: Updates must be triggered by explicit user instructions, prohibit automatic or silent execution; Agent must not use parameter to execute update.sh or login.sh
- Environment Variables: Agent must not actively set environment variables such as , , (these variables are for users to configure manually outside scripts, Agent should not set them on behalf of users)
- Path Security: Prohibit path traversal (, ), prohibit accessing absolute paths outside the scope
Pre-checks
Execute in order every time triggered:
- Installation Check: , if not installed, inform user and execute
bash ${CLAUDE_SKILL_DIR}/scripts/install.sh
after confirmation (user can add to skip installer internal confirmation after confirmation)
- Login Check: , if not logged in, guide user to execute
bash ${CLAUDE_SKILL_DIR}/scripts/login.sh
- Path Validation: Verify that remote path is within scope
Confirmation Rules
| Risk Level | Operation | Strategy |
|---|
| High (Must Confirm) | delete, upload/download where target has same name file | List affected scope, 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 needed |
Additional Rules:
- Ambiguous operation intent ("process file" → confirm upload or download) → Must confirm
- Ambiguous ordinal/pronoun references ("Nth", "it", "the above one") → Must confirm
- User cancels intent ("forget it", "don't", "cancel") → Abort 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 a file name, prohibit ending with
. Folder upload:
bdpan upload ./project/ project/
.
Steps: Confirm local path exists → Confirm remote path →
to check if remote exists → Execute.
Download
Direct Download:
bash
bdpan download <remote path> <local path>
Steps:
to confirm cloud existence → Confirm local path → Check if local exists →
Check file size to determine download strategy → Execute. If not found by ls, suggest
.
Large File Download Strategy (Important):
Agent's Bash tool has execution timeout limit, large file download may be interrupted due to timeout. Must select download strategy based on file size:
- Get File Size: Use
bdpan ls --json <remote path>
to get field (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 | Execute in background using , Agent polls progress |
Small File (≤ 50MB) Direct Download:
Execute
normally, set Bash tool timeout parameter to
(5 minutes).
Large File (> 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 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 log after download completion
rm -f /tmp/bdpan-dl-<PID>.log
Behavior specifications for Agent when executing large file background download:
- After starting background download, immediately inform user: Download has started in background, file size X, estimated time Y
- Report progress to user after each poll (downloaded size / total size, percentage)
- Inform user of final result after download completion
- If process exits abnormally, check log and report error reason
Shared 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
Large file strategy also applies to shared link download: After transfer is completed, use
to get file size, then execute download according to above strategy.
Transfer
Transfer shared files to cloud drive, do not download to local (difference from shared link download mode).
bash
bdpan transfer "https://pan.baidu.com/s/1xxxxx" -p <extraction code> [-d target directory] [--json]
Steps: Confirm shared link format is valid → Confirm extraction code exists (link contains
or ask user) → Confirm target directory → Execute. After successful transfer, only display files transferred this time (not entire directory), show quantity and target directory.
Share
bash
bdpan share <path> [path...] [--json]
Steps:
to confirm file exists → Execute share → Display link + extraction code + validity period.
Paid interface, need to purchase service on Baidu Drive 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=Other 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: Use Chinese path in commands (
), expose API path when displaying (
).
Authorization Code Handling
When user sends a 32-bit hexadecimal string, first confirm: "Is this the Baidu Drive authorization code? After confirmation, the login process will be executed." After confirmation, execute
bash ${CLAUDE_SKILL_DIR}/scripts/login.sh
(do not use
, retain security confirmation step).
Management Functions
Installation
bash
bash ${CLAUDE_SKILL_DIR}/scripts/install.sh [--yes]
Installer downloads and executes from Baidu CDN (
). Note: install.sh does not perform local SHA256 verification, integrity relies on HTTPS transmission protection. For security-sensitive scenarios, it is recommended to manually review installer content first or execute in 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 Instructions)
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 Documents
Consult as needed when encountering corresponding issues, no need to preload:
| 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 | Need to troubleshoot errors |