agentleFS
bighadj22bighadj22/codflow/.agents/skills/storefront-vercel/SKILL.md

storefront-vercel

Skill338 starsChanged 2 months agoApache-2.0View on GitHub

Deploy or redeploy the CodFlow storefront (cod-astro/theme01) to Vercel — an AI agent following it configures the Vercel project with DEPLOY_TARGET=vercel, binds environment variables (COD_SERVER_URL, STORE_API_KEY, MEDIA_DOMAIN), builds and deploys using the Vercel CLI or Git integration, and verifies storefront functionality. Use when a developer wants to deploy the storefront to Vercel, switch from Cloudflare Workers to Vercel, or troubleshoot Vercel storefront deployments.

  • Reads credentials
  • Installs packages

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 7 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Automatic Preview Deployments: Every Git branch/PR can have its own preview URL for testing theme changes.

    line 22
  2. Distinctive:

    Before deploying, collect these values:

    line 28
  3. Very specific:

    Ensure Vercel CLI is accessible via npx vercel (or installed globally).

    line 51
  4. Distinctive:

    If not logged in:

    line 56
  5. Very specific:

    If a browser is available: npx vercel login

    line 57
  6. Very specific:

    If headless/CI: Set VERCEL_TOKEN in the environment (export VERCEL_TOKEN="<token>").

    line 58
  7. Distinctive:

    Follow the interactive prompts (or provide flags in non-interactive sessions):

    line 70
  8. Distinctive:

    Add the required production environment variables using the CLI:

    line 76
  9. Distinctive:

    Use this method when connecting a GitHub / GitLab / Bitbucket repository:

    line 108
  10. Very specific:

    Output Directory: Leave default (.vercel/output).

    line 123
  11. Very specific:

    Install Command: Leave default (npm install / root workspace install).

    line 124
  12. Distinctive:

    Wait for SSL certificate issuance (automatic via Let's Encrypt).

    line 171

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

CodFlow Storefront — Vercel Deployment Runbook

cod-astro/theme01 is the customer-facing storefront theme for CodFlow (Astro 7). While the CodFlow backend (cod-server) and merchant dashboard (cod-client-astro) run on Cloudflare Workers (using D1, R2, and KV), the storefront supports dynamic deployment targets (DEPLOY_TARGET=vercel or DEPLOY_TARGET=cloudflare).

Deploying the storefront to Vercel is often preferred because:

  1. Solves Cloudflare Error 1042 (Worker-to-Worker block): When cod-server is deployed on a free *.workers.dev subdomain without a custom domain, Cloudflare blocks another Cloudflare Worker on *.workers.dev from fetching it. Vercel runs outside Cloudflare's internal network, allowing the storefront to fetch cod-server on *.workers.dev without needing a custom domain.
  2. Generous Global Edge Bandwidth: Vercel includes generous bandwidth and Edge CDN caching for storefront traffic.
  3. Automatic Preview Deployments: Every Git branch/PR can have its own preview URL for testing theme changes.

Required Environment Variables

Before deploying, collect these values:

VariableDescriptionExample
DEPLOY_TARGETMandatory. Tells astro.config.mjs to use @astrojs/vercelvercel
COD_SERVER_URLMandatory. Base URL of deployed cod-server APIhttps://api.yourdomain.com or https://codflow-server.<account>.workers.dev
STORE_API_KEYMandatory. Raw store API key matching the seeded key in D1Generated in codflow-setup Step 4
MEDIA_DOMAINOptional. Custom domain for R2 image CDNmedia.yourdomain.com

[!IMPORTANT] STORE_API_KEY is secret. It is used on the server side in SSR routes and API proxies. Never expose it in client-side bundles.


Deployment Methods

Choose Method 1 (Vercel CLI) for automated/terminal deployments, or Method 2 (Vercel Dashboard / Git) for continuous deployment from GitHub.


Method 1: Deploy via Vercel CLI (Recommended for AI Agents)

1. Prerequisites

  • Ensure Vercel CLI is accessible via npx vercel (or installed globally).
  • Check authentication:
    npx vercel whoami
    If not logged in:
    • If a browser is available: npx vercel login
    • If headless/CI: Set VERCEL_TOKEN in the environment (export VERCEL_TOKEN="<token>").

2. Configure and Link Project

Navigate to the storefront directory:

cd cod-astro/theme01

Run initial setup:

npx vercel link

Follow the interactive prompts (or provide flags in non-interactive sessions):

  • Link to existing project? No (or Yes if linking existing)
  • Project name: <project>-storefront (e.g. mystore-storefront)
  • In which directory is your code located? ./

3. Set Environment Variables

Add the required production environment variables using the CLI:

# 1. Deployment Target
printf "vercel" | npx vercel env add DEPLOY_TARGET production

# 2. Backend API URL (must start with https://)
printf "https://<your-cod-server-domain>" | npx vercel env add COD_SERVER_URL production

# 3. Store API Key
printf "<your-raw-store-api-key>" | npx vercel env add STORE_API_KEY production

# 4. Optional: Media Domain (if R2 custom domain is configured)
printf "<media.yourdomain.com>" | npx vercel env add MEDIA_DOMAIN production

(Optional: also add them to preview and development environments if you plan to use preview branches).

4. Build and Deploy to Production

Execute production deployment with the Vercel adapter:

cd cod-astro/theme01
npx vercel --prod

Vercel will upload the project, execute npm run build:vercel (or astro build with DEPLOY_TARGET=vercel), compile the SSR serverless/edge functions, and provide the live production URL (e.g. https://<project>-storefront.vercel.app).


Method 2: Deploy via Vercel Dashboard (Git Integration)

Use this method when connecting a GitHub / GitLab / Bitbucket repository:

  1. Import Repository in Vercel:
    • In the Vercel Dashboard, click Add New... → Project.
    • Select the codflow-os repository.
  2. Configure Project Settings:
    • Project Name: e.g. codflow-storefront
    • Framework Preset: Astro
    • Root Directory: Click Edit and choose cod-astro/theme01. Check the option "Include source files outside of the Root Directory in the Build Step" (needed because workspace dependencies resolve to root node_modules).
    • Build Command: Toggle Override and set:
      npm run build:vercel
      (Or leave default astro build if DEPLOY_TARGET=vercel is set in Environment Variables).
    • Output Directory: Leave default (.vercel/output).
    • Install Command: Leave default (npm install / root workspace install).
  3. Configure Environment Variables: Under Environment Variables, add:
    • DEPLOY_TARGET = vercel
    • COD_SERVER_URL = https://<your-cod-server-domain>
    • STORE_API_KEY = <your-raw-store-api-key>
    • MEDIA_DOMAIN = <media.yourdomain.com> (optional)
  4. Deploy:
    • Click Deploy. Vercel will build the workspace, bundle the Astro site with @astrojs/vercel, and assign a production URL.

Verification & Smoke Testing

Once deployment completes, run these checks against the live Vercel URL:

TargetTest Command / ActionExpected Result
Homepagecurl -s -o /dev/null -w "%{http_code}" https://<storefront-url>200 (HTML response)
Catalog SSROpen https://<storefront-url>/ in browserProducts load with images, prices, and title
Product DetailOpen https://<storefront-url>/product/<slug>Product page renders with checkout / order form
Cart / Order FlowSubmit test order (or test modal)Order registers and thank-you page displays

Test via Terminal:

# Verify homepage returns 200 OK
curl -s -I "https://<your-storefront>.vercel.app" | head -n 5

# Verify API connectivity through storefront proxy
curl -s "https://<your-storefront>.vercel.app/api/cart/validate" \
  -H "Content-Type: application/json" \
  -d '{"items":[]}'
# Expect valid JSON response

Custom Domain Setup

To attach a custom domain to the Vercel storefront:

  1. In Vercel Dashboard: Project → Settings → Domains.
  2. Enter your domain (e.g. store.yourdomain.com or yourdomain.com).
  3. Configure DNS records:
    • For subdomains (store.yourdomain.com): Add CNAME pointing to cname.vercel-dns.com.
    • For apex domain (yourdomain.com): Add A record pointing to 76.76.21.21.
  4. Wait for SSL certificate issuance (automatic via Let's Encrypt).

Troubleshooting

ProblemCauseSolution
Build fails: Cannot find module '@astrojs/vercel'Missing dependency in cod-astro/theme01Run npm install @astrojs/vercel --workspace=cod-astro-theme01 at repository root.
Build produces Cloudflare output instead of Vercel outputDEPLOY_TARGET not set to vercelEnsure DEPLOY_TARGET=vercel is present in Vercel environment variables, or run npm run build:vercel.
Storefront loads but shows empty products / error bannerCOD_SERVER_URL incorrect or unreachableConfirm COD_SERVER_URL has https:// prefix and matches the live API worker. Verify curl https://<api-url>/api/docs returns 200.
Orders fail with 401 UnauthorizedSTORE_API_KEY mismatchThe value in Vercel STORE_API_KEY must match the key seeded into the D1 database in codflow-setup Step 5. Re-check or update the secret in Vercel.
Monorepo build fails to resolve shared packagesVercel root directory configurationIf using Git integration, ensure "Include source files outside of the Root Directory" is enabled in Vercel project settings, or deploy via npx vercel inside cod-astro/theme01.
Node.js version warning: Node.js 26 is not supportedVercel serverless functions support up to Node 24Normal warning on Node 26 development machines; Vercel automatically runs Node 24 in its cloud functions.
Images do not load from R2MEDIA_DOMAIN misconfigured or missing CORSVerify MEDIA_DOMAIN is set (hostname only, without https://). Ensure R2 bucket CORS policy allows requests from the Vercel domain.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.