cloudflare-r2:multipart-init

cloudflare-r2:multipart-init is a command for Claude Code from secondsky/claude-skills. It costs 19 tokens per session (1,925 once invoked), scanned A, original, MIT.

A setup guide for multipart uploads, which split a large file into smaller pieces and upload them separately.

In plain words
What is it for?
It chooses a part size, generates upload and retry code, and handles completion or cancellation for files over 100 MB.
Why use it?
It helps large uploads recover from failed pieces and show progress instead of restarting the entire file.

Command for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the cloudflare-r2 plugin — 1 skill, 4 commands, 5 agents shipped together

Good fit It chooses a part size, generates upload and retry code, and handles…

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/secondsky/claude-skills/r2-multipart-init
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/secondsky/claude-skills

Made for: Claude Code.

Or install cloudflare-r2, the plugin that ships this one along with the rest of its 1 skill, 4 commands, 5 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cloudflare-r2:multipart-init

README.md
[![agentmods](https://agentmods.dev/badge/commands/secondsky/claude-skills/r2-multipart-init.svg)](https://agentmods.dev/commands/secondsky/claude-skills/r2-multipart-init)
Your own site
<a href="https://agentmods.dev/commands/secondsky/claude-skills/r2-multipart-init"><img src="https://agentmods.dev/badge/commands/secondsky/claude-skills/r2-multipart-init.svg" alt="Measured on agentmods" height="20"></a>
Per session 19 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,925 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00019 $0.01925
Opus 5 $0.00010 $0.00962
Sonnet 5 $0.00004 $0.00385
Haiku 4.5 $0.00002 $0.00193

Measured 3d ago against content hash 6c02d14f6d8e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

cloudflare-r2:multipart-init scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/cloudflare-r2/commands/r2-multipart-init.md · 281 lines

How it starts

The opening of the file, as written. The whole thing — 281 lines — stays where its author put it; the contents beside it link to each section on GitHub.

R2 Multipart Upload Setup

Initialize and implement multipart upload workflow for handling large files (>100MB) with chunking, error recovery, and progress tracking.

Required Information

  1. File size (in MB): {{file_size}}
  2. Object key (destination path): {{key}}
  3. Part size (5-100 MB, recommended 10MB): {{part_size}}
  4. Content type: {{content_type}}

What This Command Does

  1. Calculates optimal part size based on file size
  2. Shows createMultipartUpload code for initialization
  3. Generates part upload loop with retry logic
  4. Provides completion/abort handlers
  5. Adds progress tracking for user feedback

Multipart Upload Constraints

  • Minimum part size: 5 MB (except last part)
  • Maximum part size: 100 MB
  • Maximum parts: 10,000 parts per upload
  • Part numbers: 1 to 10,000 (1-based indexing)

Part Size Calculator

function calculatePartSize(fileSizeMB: number): number {
  const MIN_PART_SIZE = 5 * 1024 * 1024;  // 5MB
  const MAX_PART_SIZE = 100 * 1024 * 1024; // 100MB
  const MAX_PARTS = 10000;

  const fileSize = fileSizeMB * 1024 * 1024;
  const recommendedSize = Math.ceil(fileSize / MAX_PARTS);

  if (recommendedSize < MIN_PART_SIZE) {
    return MIN_PART_SIZE;
  } else if (recommendedSize > MAX_PART_SIZE) {
    return MAX_PART_SIZE;
  } else {
    return recommendedSize;
  }
}

// Example: 500MB file = 10MB parts (50 parts)
// Example: 50GB file = 10MB parts (5000 parts)

Complete Implementation

import { Hono } from 'hono';

type Bindings = {
  MY_BUCKET: R2Bucket;
};

const app = new Hono<{ Bindings: Bindings }>();

// Step 1: Initialize multipart upload
app.post('/multipart/create', async (c) => {
  const { key, contentType } = await c.req.json();

  const multipart = await c.env.MY_BUCKET.createMultipartUpload(key, {
    httpMetadata: {
      contentType: contentType || 'application/octet-stream',
    },
    customMetadata: {
      uploadedAt: new Date().toISOString(),
    },
  });

  return c.json({
    uploadId: multipart.uploadId,
    key: multipart.key,
  });
});

// Step 2: Upload individual parts
app.put('/multipart/upload-part', async (c) => {
  const { uploadId, key, partNumber } = await c.req.json();
  const data = await c.req.arrayBuffer();

  // Validate part number (1-10000)
  if (partNumber < 1 || partNumber > 10000) {
    return c.json({ error: 'Invalid part number' }, 400);
  }

  const multipart = c.env.MY_BUCKET.resumeMultipartUpload(key, uploadId);
  const uploadedPart = await multipart.uploadPart(partNumber, data);

  return c.json({
    partNumber,
    etag: uploadedPart.etag,
  });
});

// Step 3: Complete multipart upload
app.post('/multipart/complete', async (c) => {
  const { uploadId, key, parts } = await c.req.json();

  const multipart = c.env.MY_BUCKET.resumeMultipartUpload(key, uploadId);

  // parts = [{ partNumber: 1, etag: 'abc' }, { partNumber: 2, etag: 'def' }, ...]
  const object = await multipart.complete(parts);

  return c.json({
    success: true,
    key: object.key,
    size: object.size,
    etag: object.httpEtag,
  });
});

// Step 4: Abort multipart upload (cleanup)
app.delete('/multipart/abort', async (c) => {
  const { uploadId, key } = await c.req.json();

  const multipart = c.env.MY_BUCKET.resumeMultipartUpload(key, uploadId);
  await multipart.abort();

  return c.json({ success: true, message: 'Upload aborted' });
});

export default app;

Read the full file on GitHub · 281 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 281 lines · 19 tokens per session scan A 6c02d14f6d8e

Subscribe to this mod's changes

cloudflare-r2:multipart-init is a command published in the GitHub repository secondsky/claude-skills (214 stars, last pushed 3d ago), licensed MIT. It adds 19 tokens to every session and 1,925 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.