cloudshare
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesecloudshare
cloudshare
Share a local file (HTML, image, PDF, or directory) as a token-gated URL on
the user's personal Cloudflare Pages subdomain.
将本地文件(HTML、图片、PDF或目录)以令牌 gated 的URL形式分享至用户的个人Cloudflare Pages子域名。
When to use this skill
何时使用此技能
- User asks to share a local file or directory
- User wants a private link with token gating
- User mentions "Cloudflare Pages", "shareable URL", or "publish this"
- User asks to manage past shares: list, delete, rotate token
- 用户请求分享本地文件或目录
- 用户需要带令牌验证的私有链接
- 用户提及“Cloudflare Pages”“可分享URL”或“发布此内容”
- 用户要求管理过往分享内容:列出、删除、轮换令牌
Architecture (one-liner)
架构(一句话概括)
One Cloudflare Pages project per user (chosen at first-run setup). Each share
lands at under that project, with its own random token stored in
the project's env var. Middleware validates the token
before serving any path under .
/r/<slug>/SHARE_TOKENS_JSON/r/每个用户对应一个Cloudflare Pages项目(首次运行设置时选定)。每个分享内容会存放在该项目下的路径,其专属随机令牌存储在项目的环境变量中。中间件会在提供下的任何路径前验证令牌。
/r/<slug>/SHARE_TOKENS_JSON/r/Companion scripts (in this skill's resources/
dir)
resources/配套脚本(位于此技能的resources/
目录)
resources/- — share a file or directory
resources/deploy.sh - — list past shares
resources/list.sh - — delete one share
resources/delete.sh - — rotate token on one share
resources/rotate.sh - — helpers
resources/lib/{auth,tokens,clipboard}.sh - — reference templates (already copied into user's mirror at setup time)
resources/template/
When invoking these scripts, use the absolute path of the skill directory.
Different agents place skills in different locations — locate this SKILL.md
file and resolve relative paths from its directory.
- — 分享文件或目录
resources/deploy.sh - — 列出过往分享内容
resources/list.sh - — 删除某一项分享
resources/delete.sh - — 轮换某一项分享的令牌
resources/rotate.sh - — 辅助脚本
resources/lib/{auth,tokens,clipboard}.sh - — 参考模板(设置时已复制到用户本地镜像)
resources/template/
调用这些脚本时,请使用技能目录的绝对路径。不同Agent存放技能的位置不同——找到此SKILL.md文件,从其目录解析相对路径。
First-run setup is run by the user, not the agent
首次运行设置需由用户自行完成,而非Agent
The setup wizard is interactive (token paste, account selection, project
name pick) and lives at the repo root, decoupled from the skill install
path. Do not try to run it from inside the agent — it requires a real TTY.
If does not exist (the share scripts will
return exit code 2 with a clear message), tell the user to paste this into
their terminal:
~/.config/cloudshare/config.envcurl -fsSL https://raw.githubusercontent.com/alanho/cloudshare-skills/main/setup.sh | bashThe setup script will:
- Prompt for a Cloudflare API token (custom token with +
Account: Cloudflare Pages: Edit).Account: Account Settings: Read - Detect the account (or prompt to pick if multiple).
- Suggest a friendly subdomain (e.g. ); user can accept or override.
purple-tiger-42 - Create the Cloudflare Pages project, initialize the local mirror at , and set
~/.config/cloudshare/projects/<name>/.SHARE_TOKENS_JSON='{}' - Save credentials to (chmod 600).
~/.config/cloudshare/config.env
After setup, all shares from any agent (Claude Code, Codex, OpenCode, etc.)
read the same and target the same project.
~/.config/cloudshare/config.env设置向导为交互式(粘贴令牌、选择账号、选择项目名称),位于仓库根目录,与技能安装路径解耦。请勿尝试在Agent内部运行该向导——它需要真实的TTY环境。
如果不存在(分享脚本会返回退出码2并给出明确提示),请告知用户将以下命令粘贴至终端:
~/.config/cloudshare/config.envcurl -fsSL https://raw.githubusercontent.com/alanho/cloudshare-skills/main/setup.sh | bash设置脚本将执行以下操作:
- 提示输入Cloudflare API令牌(需包含+
Account: Cloudflare Pages: Edit权限的自定义令牌)。Account: Account Settings: Read - 检测账号(若存在多个账号则提示选择)。
- 建议一个友好的子域名(例如:);用户可接受或自定义。
purple-tiger-42 - 创建Cloudflare Pages项目,在初始化本地镜像,并设置
~/.config/cloudshare/projects/<name>/。SHARE_TOKENS_JSON='{}' - 将凭据保存至(设置权限为chmod 600)。
~/.config/cloudshare/config.env
设置完成后,所有Agent(Claude Code、Codex、OpenCode等)的分享操作都会读取同一个,并指向同一个项目。
~/.config/cloudshare/config.envPrerequisites check
前置检查
Before invoking any share script, optionally verify:
bash
command -v openssl >/dev/null || { echo "openssl required"; exit 1; }
command -v node >/dev/null || { echo "node required (https://nodejs.org/)"; exit 1; }
command -v curl >/dev/null || { echo "curl required"; exit 1; }wranglernpx wrangler@latest调用任何分享脚本前,可选择性验证以下依赖:
bash
command -v openssl >/dev/null || { echo "openssl required"; exit 1; }
command -v node >/dev/null || { echo "node required (https://nodejs.org/)"; exit 1; }
command -v curl >/dev/null || { echo "curl required"; exit 1; }wranglernpx wrangler@latestShare workflow
分享流程
bash
bash <SKILL_DIR>/resources/deploy.sh <absolute-path-to-file-or-dir>The script:
- Loads config from .
~/.config/cloudshare/config.env - If config missing, exits 2 with a setup instruction. Relay the setup command verbatim to the user.
- Generates a slug from the filename (e.g. ).
trip-options-9f3a - Generates a 32-hex-char token.
- Stages content into the local mirror.
- Updates via the Cloudflare API.
SHARE_TOKENS_JSON - Redeploys via .
npx wrangler@latest pages deploy - Prints the canonical URL on a single line starting with :
URL:URL: https://<project>.pages.dev/r/<slug>/?token=<hex> - Copies URL to clipboard.
- Appends to .
~/.config/cloudshare/shares.log
After running, present the URL prominently. Mention the clipboard copy. Note
that anyone with the URL has access — treat it like a password.
bash
bash <SKILL_DIR>/resources/deploy.sh <absolute-path-to-file-or-dir>该脚本执行以下步骤:
- 从加载配置。
~/.config/cloudshare/config.env - 若配置缺失,以退出码2退出并给出设置说明。请将设置命令原封不动传达给用户。
- 根据文件名生成slug(例如:)。
trip-options-9f3a - 生成一个32位十六进制字符的令牌。
- 将内容暂存至本地镜像。
- 通过Cloudflare API更新。
SHARE_TOKENS_JSON - 通过重新部署。
npx wrangler@latest pages deploy - 在单独一行以开头打印标准URL:
URL:URL: https://<project>.pages.dev/r/<slug>/?token=<hex> - 将URL复制到剪贴板。
- 将记录追加至。
~/.config/cloudshare/shares.log
运行完成后,请突出显示URL。提及已复制到剪贴板。注意任何拥有该URL的人都可访问——请将其视为密码妥善保管。
Subcommands
子命令
bash
bash <SKILL_DIR>/resources/list.sh # list past shares
bash <SKILL_DIR>/resources/delete.sh <slug> # revoke + delete a share
bash <SKILL_DIR>/resources/rotate.sh <slug> # rotate token; old → 401All three exit 2 with the same setup instruction if config is missing.
bash
bash <SKILL_DIR>/resources/list.sh # 列出过往分享内容
bash <SKILL_DIR>/resources/delete.sh <slug> # 撤销并删除某一项分享
bash <SKILL_DIR>/resources/rotate.sh <slug> # 轮换令牌;旧令牌会返回401若配置缺失,这三个命令都会以退出码2退出并给出相同的设置说明。
Output format
输出格式
Lead with the URL on its own line, then a short success block. Example:
https://purple-tiger-42.pages.dev/r/trip-options-9f3a/?token=4b7c8d2e1a9f1234
✓ Shared `trip-options.html` (copied to clipboard).首先单独一行显示URL,然后是简短的成功提示块。示例:
https://purple-tiger-42.pages.dev/r/trip-options-9f3a/?token=4b7c8d2e1a9f1234
✓ 已分享`trip-options.html`(已复制到剪贴板)。Limits and security
限制与安全
- Cloudflare Pages free tier: 500 deploys / month, 25 MB / file, 100 MB / deploy total.
- Each share is gated by a unique random token in the URL query string.
- is set, so most browsers won't leak the token via Referer.
Referrer-Policy: no-referrer - Whoever has the URL has access. The link is the credential.
- To revoke: (URL → 404) or
delete.sh <slug>(URL → 401, new URL printed).rotate.sh <slug>
- Cloudflare Pages免费套餐:每月500次部署,单文件最大25MB,单次部署总大小最大100MB。
- 每个分享内容由URL查询字符串中的唯一随机令牌保护。
- 设置了,因此大多数浏览器不会通过Referer泄露令牌。
Referrer-Policy: no-referrer - 拥有URL即拥有访问权限。链接本身就是凭据。
- 如需撤销权限:使用(URL会返回404)或
delete.sh <slug>(旧URL返回401,同时打印新URL)。rotate.sh <slug>
Common failure modes
常见失败场景
- Scripts exit 2 with "not set up yet" → user has not run the curl-pipe setup. Ask them to.
- Token verification fails during setup → user pasted a token without correct scopes; instruct them to recreate at https://dash.cloudflare.com/profile/api-tokens.
- Project name taken → wizard loops, ask user for a different name.
- Source > 90 MB → Cloudflare's per-deploy limit. Ask user to slim the input.
- env var update returns 5xx → Cloudflare API hiccup; retry once before surfacing.
SHARE_TOKENS_JSON - fails → check that the API token has
wrangler pages deploy, not just Read.Cloudflare Pages: Edit
- 脚本以退出码2提示“尚未设置” → 用户未运行curl管道设置命令。请让用户执行该命令。
- 设置期间令牌验证失败 → 用户粘贴的令牌权限不足;指导用户前往https://dash.cloudflare.com/profile/api-tokens重新创建。
- 项目名称已被占用 → 向导会循环提示,请让用户更换名称。
- 源文件大小超过90MB → 达到Cloudflare单次部署限制。请让用户缩减文件大小。
- 环境变量更新返回5xx错误 → Cloudflare API故障;重试一次后再告知用户。
SHARE_TOKENS_JSON - 失败 → 检查API令牌是否拥有
wrangler pages deploy权限,而非仅Read权限。Cloudflare Pages: Edit