baidu-drive

Original:🇨🇳 Chinese
Translated
4 scriptsChecked / no sensitive code detected

Baidu Drive File Management — Upload, download, transfer, share, search, move, copy, rename, create folders. TRIGGER: When user mentions "Baidu Drive/bdpan/网盘/云盘/baidu drive/Baidu Drive" and involves file operations. DO NOT TRIGGER: For non-file storage operations, or when using other cloud storage services.

26installs
Added on

NPX Install

npx skill4agent add baidu-netdisk/bdpan-storage baidu-drive

Tags

Translated version includes tags in frontmatter

SKILL.md Content (Chinese)

View Translation Comparison →

Baidu Drive Storage Skill

Baidu Drive file management tool, all operations are restricted within the
/apps/bdpan/
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:
  1. User explicitly mentions "Baidu Drive", "bdpan", "网盘"
  2. 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)

  1. Login: Must use
    bash ${CLAUDE_SKILL_DIR}/scripts/login.sh
    , prohibit direct calls to
    bdpan login
    and any of its subcommands/parameters (including
    --get-auth-url
    ,
    --set-code
    , etc., even in GUI environments)
  2. Token/Configuration: Prohibit reading or outputting content of
    ~/.config/bdpan/config.json
    (including sensitive credentials like access_token)
  3. Update/Login: Updates must be triggered by explicit user instructions, prohibit automatic or silent execution; Agent must not use
    --yes
    parameter to execute update.sh or login.sh
  4. Environment Variables: Agent must not actively set environment variables such as
    BDPAN_CONFIG_PATH
    ,
    BDPAN_BIN
    ,
    BDPAN_INSTALL_DIR
    (these variables are for users to configure manually outside scripts, Agent should not set them on behalf of users)
  5. Path Security: Prohibit path traversal (
    ..
    ,
    ~
    ), prohibit accessing absolute paths outside the
    /apps/bdpan/
    scope

Pre-checks

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

Confirmation Rules

Risk LevelOperationStrategy
High (Must Confirm)
rm
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, cpExecute directly if path is clear, confirm if ambiguous
Low (Execute Directly)ls, search, whoami, mkdir, shareNo 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

bash
bdpan whoami

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 →
bdpan ls
to check if remote exists → Execute.

Download

Direct Download:
bash
bdpan download <remote path> <local path>
Steps:
bdpan ls
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
bdpan search <file name>
.
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:
  1. Get File Size: Use
    bdpan ls --json <remote path>
    to get
    size
    field (bytes)
  2. Execute Strategy by Size:
File SizeStrategyExecution Method
≤ 50MBDirect Download
bdpan download <remote path> <local path>
, set Bash timeout to 300000 (5 minutes)
> 50MBBackground DownloadExecute in background using
nohup
, Agent polls progress
Small File (≤ 50MB) Direct Download:
Execute
bdpan download
normally, set Bash tool timeout parameter to
300000
(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
bdpan ls --json
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
?pwd=
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:
bdpan ls
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.
--no-dir
and
--dir-only
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

ScenarioFormatExample
Command ParametersRelative path (relative to
/apps/bdpan/
)
bdpan upload ./f.txt docs/f.txt
Display to UserChinese name"Uploaded to: 我的应用数据/bdpan/docs/f.txt"
Mapping relationship:
我的应用数据
↔
/apps
Prohibited: Use Chinese path in commands (
我的应用数据/...
), expose API path when displaying (
/apps/bdpan/...
).

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
--yes
, retain security confirmation step).

Management Functions

Installation

bash
bash ${CLAUDE_SKILL_DIR}/scripts/install.sh [--yes]
Installer downloads and executes from Baidu CDN (
issuecdn.baidupcs.com
). 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:
DocumentWhen to Consult
bdpan-commands.mdNeed complete command parameters, options, JSON output format
authentication.mdAuthentication process details, Token management
examples.mdMore usage examples (batch upload, automatic backup, etc.)
troubleshooting.mdNeed to troubleshoot errors