$npx -y skills add backblaze-labs/claude-skill-b2-cloud-storage --skill b2-cloud-storageManage Backblaze B2 cloud storage. List files, audit usage, estimate cost, clean up stale data, review security posture, and manage lifecycle rules. Use when the user mentions B2, Backblaze, object storage buckets, or storage cleanup.
| 1 | # B2 Cloud Storage Management |
| 2 | |
| 3 | Manage Backblaze B2 cloud storage: list files, audit usage, estimate cost, clean up stale data, and review security posture. |
| 4 | |
| 5 | ## Security Rules (MANDATORY) |
| 6 | |
| 7 | 1. **Never** run `b2 account get`, `b2 account clear`, or any `b2 key *` subcommand — these expose or mutate credentials. |
| 8 | 2. **Never** read `~/.b2_account_info` or any file matching `*b2_account_info*` — this is the B2 credential database (SQLite). |
| 9 | 3. **Always** run `b2 rm --dry-run` before any real deletion; show the user what would be deleted and require an explicit "yes" before executing. |
| 10 | 4. **Never** change a bucket to `allPublic` without first warning the user about the security implications and getting explicit confirmation. |
| 11 | 5. **Default to read-only** — only perform writes or deletes when the user explicitly requests them. |
| 12 | 6. **Never** store or write API keys, application keys, or account IDs to any file. |
| 13 | 7. If the user pastes key values into the chat instead of the terminal, warn them immediately and recommend rotating the key. Never echo, store, or reference key values that appear in conversation. |
| 14 | |
| 15 | ## First-Use Flow |
| 16 | |
| 17 | 1. Check the B2 CLI is installed: `b2 version`. If missing, ask the user to install the CLI outside the agent, then rerun `b2 version` - see `references/setup.md` for detail. |
| 18 | 2. Verify the CLI is authorized: `b2 ls`. If it fails with an auth error, walk the user through `references/setup.md`. |
| 19 | 3. Check for a per-project config at `.claude/b2-config.json` in the project root. If missing, ask the user for bucket + prefix and create one. |
| 20 | |
| 21 | ### Interactive auth note |
| 22 | |
| 23 | `b2 account authorize` (no args) reads keys from an interactive prompt, which agents cannot drive. The user has two options: |
| 24 | |
| 25 | - Run it themselves in the terminal — in Claude Code they can type `!b2 account authorize` to execute directly in the session. |
| 26 | - Pass the keyID and applicationKey as positional args: `b2 account authorize <keyID> <appKey>` (keys will appear in shell history — less safe). |
| 27 | - Or set `B2_APPLICATION_KEY_ID` and `B2_APPLICATION_KEY` env vars before running B2 commands (recommended for scripts and CI). |
| 28 | |
| 29 | ## Project-Level Config |
| 30 | |
| 31 | Per-project config at `.claude/b2-config.json`: |
| 32 | |
| 33 | ```json |
| 34 | { |
| 35 | "bucket": "my-project-bucket", |
| 36 | "prefix": "", |
| 37 | "accountInfoPath": "~/.b2_account_info" |
| 38 | } |
| 39 | ``` |
| 40 | |
| 41 | | Field | Purpose | |
| 42 | |-------|---------| |
| 43 | | `bucket` | Default bucket name for this project | |
| 44 | | `prefix` | Optional prefix to scope all operations (e.g. `data/models/`) | |
| 45 | | `accountInfoPath` | Path to B2 credential file — allows different keys per project | |
| 46 | |
| 47 | If `accountInfoPath` differs from the default, prepend `B2_ACCOUNT_INFO=<path>` when running b2 commands. This file stores bucket names and paths only — never API keys. |
| 48 | |
| 49 | ## Common Actions |
| 50 | |
| 51 | ### List & search |
| 52 | |
| 53 | ```bash |
| 54 | b2 ls b2://<bucket> # top-level |
| 55 | b2 ls -r b2://<bucket> # recursive |
| 56 | b2 ls -r --json b2://<bucket> # JSON for scripting |
| 57 | b2 ls --versions -r --json b2://<b> # include old versions + hide markers |
| 58 | b2 ls b2://<bucket>/<prefix> # prefix-scoped |
| 59 | ``` |
| 60 | |
| 61 | ### Inspect file |
| 62 | |
| 63 | ```bash |
| 64 | b2 file info b2id://<fileId> |
| 65 | ``` |
| 66 | |
| 67 | ### Storage audit (usage, stale, large, duplicates, cost) |
| 68 | |
| 69 | ```bash |
| 70 | python scripts/storage_audit.py <bucket> |
| 71 | python scripts/storage_audit.py <bucket> --json |
| 72 | python scripts/storage_audit.py <bucket> --stale-days 180 --large-mb 500 --prefix-depth 2 |
| 73 | ``` |
| 74 | |
| 75 | Reports live vs. billable storage, unfinished large files, old versions, hide markers, SHA1-based duplicates, and an estimated monthly cost. |
| 76 | |
| 77 | ### Cleanup (destructive) |
| 78 | |
| 79 | See `references/cleanup-playbook.md`. Never skip the dry-run step. |
| 80 | |
| 81 | ### Lifecycle rules |
| 82 | |
| 83 | ```bash |
| 84 | b2 bucket get <bucket> |
| 85 | b2 bucket update --lifecycle-rules '<json>' <bucket> allPrivate |
| 86 | ``` |
| 87 | |
| 88 | Lifecycle rule JSON format is in `references/b2-cli-reference.md`. |
| 89 | |
| 90 | ### Security review |
| 91 | |
| 92 | See `references/security-review.md` for the full checklist (bucket type, SSE, CORS, object lock, replication, lifecycle coverage). |
| 93 | |
| 94 | ## References |
| 95 | |
| 96 | - `references/setup.md` — first-use setup walk-through (install, app-key creation, authorization) |
| 97 | - `references/cleanup-playbook.md` — safe deletion procedure with dry-run |
| 98 | - `references/security-review.md` — per-bucket security audit checklist |
| 99 | - `references/b2-cli-reference.md` — CLI v4 command reference |