ShellBot Website
Build and deploy micro apps and websites on Cloudflare Workers with production-grade design.
Arguments
- - Command:
$0 (create | deploy | domain | provision | secrets | status | teardown) - Arg 1:
$1 (template name, resource type, domain, etc.) - Arg 2+:
$2, $3, etc. - All args: INLINECODE11
| Command | Script | Example |
|---|
| INLINECODE12 | INLINECODE13 | INLINECODE14 |
| INLINECODE15 |
scripts/deploy.sh |
/shellbot-website deploy --env production |
|
domain |
scripts/setup-domain.sh |
/shellbot-website domain my-worker example.com |
|
provision |
scripts/provision-*.sh |
/shellbot-website provision d1 my-db |
|
secrets |
scripts/manage-secrets.sh |
/shellbot-website secrets put API_KEY |
|
status |
scripts/status.sh |
/shellbot-website status --resources |
|
teardown |
scripts/teardown.sh |
/shellbot-website teardown my-worker |
Authentication
Two authentication methods, checked in this order:
Method 1: API Token (recommended, required for agents/CI)
Set CLOUDFLARE_API_TOKEN environment variable. This is the primary method — it takes precedence over OAuth if both are present.
If any command fails with authentication errors, tell user:
CODEBLOCK0
Method 2: OAuth via wrangler login (fallback for local use)
If CLOUDFLARE_API_TOKEN is not set, attempt OAuth login:
CODEBLOCK1
This opens a browser for Cloudflare OAuth. When running in an agent context:
- 1. Run
wrangler login — it will print an authorization URL to stdout - Show the URL to the user and ask them to open it in their browser
- The user authorizes in the browser, which redirects to INLINECODE37
- Wrangler receives the callback and stores OAuth tokens in INLINECODE38
Limitation: This only works when the agent runs on the user's local machine (the OAuth callback must reach localhost:8976). It will NOT work in remote/CI environments — use API token there.
After login, verify with:
CODEBLOCK2
Auth check order in scripts
All scripts check CLOUDFLARE_API_TOKEN first. If not set, they check if wrangler whoami succeeds (meaning OAuth tokens exist in ~/.wrangler/config/default.toml). If neither works, they error with instructions for both methods.
Optional: Account ID
INLINECODE43 — auto-detected by wrangler. Set it to skip the account selection prompt when multiple accounts exist.
CODEBLOCK3
Prerequisites
- - Node.js v20+
- Wrangler:
npm install -g wrangler or use INLINECODE45
Verify setup:
CODEBLOCK4
Non-Interactive Design
All scripts run fully non-interactively — no prompts, no user input required. This makes them safe for agent invocation. Destructive operations require explicit --force flags instead of confirmation prompts.
Quick Start
CODEBLOCK5
Project Scaffolding
Default Templates
| Short Name | Template | Best For |
|---|
| INLINECODE47 (default) | INLINECODE48 | Fullstack apps with React Router 7 + Hono API |
| INLINECODE49 |
next-starter-template | Next.js apps on CF Workers |
CODEBLOCK6
See references/cf-templates.md for the full catalog of 36+ templates.
Custom Template URL
CODEBLOCK7
Deployment
CODEBLOCK8
The deploy.sh script pre-checks that wrangler config exists and CLOUDFLARE_API_TOKEN is set before deploying.
Custom Domains
Three approaches to connect a custom domain to a CF Worker. See references/custom-domains.md for the full guide.
1. Automated Setup (Recommended)
CODEBLOCK9
2. Via wrangler.toml Routes
CODEBLOCK10
3. Via Cloudflare Dashboard
Workers & Pages → your worker → Settings → Domains & Routes → Add Custom Domain.
DNS Requirements
- - Domain must be in your Cloudflare account (orange-cloud proxied)
- SSL is automatic — no certificate management needed
- DNS propagation takes 1-5 minutes for proxied domains
Resource Provisioning
D1 (SQL Database)
CODEBLOCK11
Common D1 operations:
CODEBLOCK12
KV (Key-Value Store)
CODEBLOCK13
R2 (Object Storage)
CODEBLOCK14
Queues
CODEBLOCK15
Secrets Management
CODEBLOCK16
Configuration
Wrangler supports TOML and JSON/JSONC. If both exist, JSON takes precedence. Pick one.
Quick Reference (wrangler.toml)
CODEBLOCK17
See references/wrangler-config.md for the full reference including JSONC format, static assets, and all binding types.
Frontend Design
When building the frontend, apply these principles. Each links to a deep reference guide.
Typography
→
See references/typography.md
Choose distinctive fonts (not Inter/Roboto). Use a modular type scale with clamp() for headings. Pair a display font with a body font. Use font-display: swap and fallback metric matching to prevent layout shift.
Color & Theme
→
See references/color-and-contrast.md
Use OKLCH for perceptually uniform palettes. Tint neutrals toward your brand hue. Follow the 60-30-10 rule (neutrals / secondary / accent). Avoid pure black/white. Avoid the AI palette (cyan-on-dark, purple-blue gradients).
Layout & Space
→
See references/spatial-design.md
Use a 4pt spacing system. Create rhythm through varied spacing. Use auto-fit grids. Avoid wrapping everything in cards. Embrace asymmetry.
Motion
→
See references/motion-design.md
Only animate transform and opacity. Use exponential easing (quart/quint/expo). 100-150ms for feedback, 200-300ms for state changes, 300-500ms for layout. Always support prefers-reduced-motion.
Interaction
→
See references/interaction-design.md
Design all 8 states (default, hover, focus, active, disabled, loading, error, success). Use :focus-visible for keyboard-only focus rings. Prefer optimistic UI and undo over confirmation dialogs.
Responsive
→
See references/responsive-design.md
Mobile-first with min-width queries. Use container queries for components. Detect input method (pointer: fine/coarse), not just screen size. Handle safe areas.
UX Writing
→
See references/ux-writing.md
Specific verb + object for buttons. Every error message answers what/why/how-to-fix. Empty states are onboarding moments. Pick one term and stick with it.
The AI Slop Test
If someone sees this interface and immediately thinks "AI made this" — that's the problem. Avoid: cyan-on-dark, purple gradients, glassmorphism everywhere, identical card grids, gradient text, dark mode with glowing accents. Make unexpected, intentional design choices.
Context Gathering
Before doing design work, you MUST have confirmed design context:
- 1. Check loaded instructions for a Design Context section
- Check
.impeccable.md in project root - If neither exists, ask the user for: target audience, use cases, brand personality/tone
Troubleshooting
| Issue | Solution |
|---|
| "Not authenticated" | Set CLOUDFLARE_API_TOKEN env var or run INLINECODE64 |
| Node version error |
Requires Node.js v20+ |
| No config found | Run from project root with
wrangler.toml or
wrangler.jsonc |
| Config changes ignored | JSON takes precedence over TOML if both exist |
| Binding not found | Check wrangler config bindings match code references |
| Custom domain not working | Domain must be proxied (orange cloud) in CF DNS |
| SSL pending | Wait 1-5 min for automatic certificate provisioning |
Scripts & References
Scripts
| Script | Purpose |
|---|
| INLINECODE67 | Scaffold project from CF templates |
| INLINECODE68 |
Deploy worker with pre-checks |
|
scripts/setup-domain.sh | Configure custom domain via CF API |
|
scripts/provision-d1.sh | Create D1 database + binding snippet |
|
scripts/provision-kv.sh | Create KV namespace + binding snippet |
|
scripts/provision-r2.sh | Create R2 bucket + binding snippet |
|
scripts/provision-queue.sh | Create queue + binding snippet |
|
scripts/manage-secrets.sh | Add/list/delete/bulk secrets |
|
scripts/status.sh | Deployment status, resources, logs |
|
scripts/teardown.sh | Delete worker + resources |
References
Domain setup, DNS, routes, SSL |
|
references/wrangler-config.md | Full wrangler.toml/jsonc reference |
|
references/typography.md | Font selection, scales, loading |
|
references/color-and-contrast.md | OKLCH, palettes, dark mode |
|
references/spatial-design.md | Grids, spacing, hierarchy |
|
references/motion-design.md | Animation timing, easing |
|
references/interaction-design.md | States, forms, focus, loading |
|
references/responsive-design.md | Mobile-first, fluid, container queries |
|
references/ux-writing.md | Labels, errors, empty states |
External Resources
ShellBot 网站
在 Cloudflare Workers 上构建和部署具有生产级设计的微应用和网站。
参数
- - 命令: $0(create | deploy | domain | provision | secrets | status | teardown)
- 参数 1: $1(模板名称、资源类型、域名等)
- 参数 2+: $2、$3 等
- 所有参数: $ARGUMENTS
| 命令 | 脚本 | 示例 |
|---|
| create | scripts/create-project.sh | /shellbot-website create my-app --template react-hono |
| deploy |
scripts/deploy.sh | /shellbot-website deploy --env production |
| domain | scripts/setup-domain.sh | /shellbot-website domain my-worker example.com |
| provision | scripts/provision-*.sh | /shellbot-website provision d1 my-db |
| secrets | scripts/manage-secrets.sh | /shellbot-website secrets put API_KEY |
| status | scripts/status.sh | /shellbot-website status --resources |
| teardown | scripts/teardown.sh | /shellbot-website teardown my-worker |
身份验证
两种身份验证方法,按以下顺序检查:
方法 1:API 令牌(推荐,代理/CI 必需)
设置 CLOUDFLAREAPITOKEN 环境变量。这是主要方法——如果两者都存在,则优先于 OAuth。
如果任何命令因身份验证错误而失败,请告知用户:
从 https://dash.cloudflare.com/profile/api-tokens 获取 API 令牌
使用编辑 Cloudflare Workers模板,或创建自定义令牌,权限包括:
Workers 脚本:编辑
D1:编辑
Workers KV 存储:编辑
Workers R2 存储:编辑
区域 DNS:编辑(用于自定义域名)
然后:export CLOUDFLAREAPITOKEN=your-token-here
方法 2:通过 wrangler login 进行 OAuth(本地使用的备用方案)
如果未设置 CLOUDFLAREAPITOKEN,则尝试 OAuth 登录:
bash
wrangler login
这会打开浏览器进行 Cloudflare OAuth。在代理上下文中运行时:
- 1. 运行 wrangler login——它会将授权 URL 打印到标准输出
- 向用户显示该 URL,并要求他们在浏览器中打开
- 用户在浏览器中授权,浏览器重定向到 localhost:8976
- Wrangler 接收回调并将 OAuth 令牌存储在 ~/.wrangler/config/default.toml 中
限制:仅当代理在用户的本地机器上运行时才有效(OAuth 回调必须到达 localhost:8976)。在远程/CI 环境中无效——请在那里使用 API 令牌。
登录后,使用以下命令验证:
bash
wrangler whoami
脚本中的身份验证检查顺序
所有脚本首先检查 CLOUDFLAREAPITOKEN。如果未设置,则检查 wrangler whoami 是否成功(意味着 OAuth 令牌存在于 ~/.wrangler/config/default.toml 中)。如果两者都不起作用,则会报错并提供两种方法的说明。
可选:账户 ID
CLOUDFLAREACCOUNTID——由 wrangler 自动检测。设置它以在存在多个账户时跳过账户选择提示。
查找位置:仪表板 → 概览 → 右侧边栏 → 账户 ID
然后:export CLOUDFLAREACCOUNTID=your-account-id
前提条件
- - Node.js v20+
- Wrangler:npm install -g wrangler 或使用 npx wrangler
验证设置:
bash
wrangler whoami
非交互式设计
所有脚本完全以非交互方式运行——无提示,无需用户输入。这使得它们可以安全地由代理调用。破坏性操作需要显式的 --force 标志,而不是确认提示。
快速开始
bash
1. 从模板搭建项目(完全非交互,不部署,不初始化 git)
bash scripts/create-project.sh my-app
2. 本地开发
cd my-app && npm run dev
3. 部署到 Cloudflare
bash scripts/deploy.sh
4. 添加自定义域名
bash scripts/setup-domain.sh my-app example.com
5. 根据需要配置资源
bash scripts/provision-d1.sh my-db --binding DB
bash scripts/provision-kv.sh my-cache --binding CACHE
bash scripts/provision-r2.sh my-assets --binding ASSETS
项目搭建
默认模板
| 简称 | 模板 | 最佳用途 |
|---|
| react-hono(默认) | react-router-hono-fullstack-template | 使用 React Router 7 + Hono API 的全栈应用 |
| next |
next-starter-template | 在 CF Workers 上的 Next.js 应用 |
bash
主要默认模板(React Router + Hono)
bash scripts/create-project.sh my-app
改用 Next.js
bash scripts/create-project.sh my-app --template next
使用任何 CF 模板(按简称或全名)
bash scripts/create-project.sh my-app --template astro-blog
bash scripts/create-project.sh my-app --template remix
bash scripts/create-project.sh my-app --template vite-react
参见 references/cf-templates.md 获取包含 36+ 个模板的完整目录。
自定义模板 URL
bash
bash scripts/create-project.sh my-app --template-url https://github.com/user/repo
部署
bash
部署到生产环境
bash scripts/deploy.sh
部署到特定环境
bash scripts/deploy.sh --env staging
bash scripts/deploy.sh --env production
试运行(显示将要部署的内容)
bash scripts/deploy.sh --dry-run
查看部署
wrangler deployments list
回滚到之前的版本
wrangler rollback [version-id]
deploy.sh 脚本在部署前预先检查 wrangler 配置是否存在以及 CLOUDFLAREAPITOKEN 是否已设置。
自定义域名
将自定义域名连接到 CF Worker 的三种方法。参见 references/custom-domains.md 获取完整指南。
1. 自动设置(推荐)
bash
域名必须已在您的 CF 账户中
bash scripts/setup-domain.sh my-worker example.com
使用特定区域 ID(跳过查找)
bash scripts/setup-domain.sh my-worker example.com --zone-id abc123
子域名
bash scripts/setup-domain.sh my-worker app.example.com
2. 通过 wrangler.toml 路由
toml
[[routes]]
pattern = example.com/*
zone_id = your-zone-id
3. 通过 Cloudflare 仪表板
Workers & Pages → 您的 worker → 设置 → 域名和路由 → 添加自定义域名。
DNS 要求
- - 域名必须在您的 Cloudflare 账户中(橙色云代理)
- SSL 是自动的——无需证书管理
- 代理域名的 DNS 传播需要 1-5 分钟
资源配置
D1(SQL 数据库)
bash
bash scripts/provision-d1.sh my-db --binding DB
创建数据库,输出用于 wrangler.toml 的绑定代码片段
可选:--migration-file schema.sql(应用初始迁移)
常见的 D1 操作:
bash
wrangler d1 execute my-db --command SELECT * FROM users
wrangler d1 execute my-db --file schema.sql
wrangler d1 execute my-db --local --command ... # 本地开发
wrangler d1 migrations create my-db add-users
wrangler d1 migrations apply my-db
KV(键值存储)
bash
bash scripts/provision-kv.sh my-cache --binding CACHE
创建命名空间,输出绑定代码片段
R2(对象存储)
bash
bash scripts/provision-r2.sh my-assets --binding ASSETS
创建存储桶,输出绑定代码片段
队列
bash
bash scripts/provision-queue.sh my-queue --binding QUEUE --type producer
创建队列,输出生产者/消费者绑定代码片段
密钥管理
bash
添加密钥(非交互式)
bash scripts/manage-secrets.sh put API_KEY sk-...
列出