setup-hosting
Skill0 starsChanged 18 days agoMITView on GitHub
Create the GitHub repo, the Vercel project, and its environment variables, then deploy to production.
- Reads credentials
- Installs packages
- Commits and pushes
In this repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- rules/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- convexSkill
- design-planSkill
- frontend-designSkill
- new-projectSkill
- prdSkill
- prSkill
- retroSkill
- standardsSkill
- unslopSkill
- writing-for-agentsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
20 rules. About 0 are common, 12 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 13
Before starting, verify all required CLI tools are authenticated:
- Distinctive: line 26
If any tool is missing or not authenticated:
- Very specific: line 27
gh not found: Ask user to install (brew install gh) and authenticate (gh auth login)
- Distinctive: line 29
git not configured: Ask user for name/email
- Distinctive: line 39
Ask the user for:
- Distinctive: line 46
Check for existing state:
- Distinctive: line 73
If there are no commits yet, create an initial commit with all files
- Distinctive: line 74
If there are existing commits, only commit uncommitted changes
- Distinctive: line 75
Use descriptive commit messages, not "initial commit" for projects with real code
- Very specific: line 79
Before any commit, verify these are in .gitignore:
- Very specific: line 88
If .env files exist but .gitignore is missing entries, stop and warn the user before committing.
- Very specific: line 150
Ask the user which env file contains production values: If .env.prod exists, confirm they want to use those values.
- Distinctive: line 177
Read the env file, extract key-value pairs, and push each one.
- Distinctive: line 214
If code instantiates clients at module level using env vars, the build will fail because env vars aren't available at build time on Vercel.
- Very specific: line 282
Always check .gitignore before the first commit — secrets pushed to Git history are very hard to remove
- Very specific: line 283
Use git add <specific-files> not git add -A to avoid committing .env, .DS_Store, etc.
- Distinctive: line 284
If the repo was created with a README via GitHub web UI, you'll need git pull --rebase origin main before pushing
- Very specific: line 289
If a NEXT_PUBLIC_ var changes, you must redeploy for the change to take effect
- Very specific: line 298
If detection fails, set the framework in Vercel dashboard or via vercel.json:
- Distinctive: line 305
Before reporting completion to the user, verify:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.
Files
Setup Hosting
Automate the full hosting pipeline: Git init, GitHub repo creation, Vercel project setup, environment variable configuration, and production deployment.
Prerequisites
Before starting, verify all required CLI tools are authenticated:
# Check GitHub CLI
gh auth status
# Check Vercel CLI
vercel whoami
# Check git config
git config user.name && git config user.emailIf any tool is missing or not authenticated:
- gh not found: Ask user to install (
brew install gh) and authenticate (gh auth login) - vercel not found: Install with
bun add -g vercel, thenvercel login - git not configured: Ask user for name/email
Workflow
Execute these steps in order. Ask the user to confirm before each major phase (Git, GitHub, Vercel, Deploy).
Phase 1: Gather Information
Ask the user for:
- Repository name — suggest based on current directory name (kebab-case)
- Visibility — public or private (default: private)
- Vercel team/scope — if they have multiple Vercel teams (check with
vercel teams ls) - Custom domain — optional, if they want to add one after deployment
Check for existing state:
# Is this already a git repo?
git rev-parse --is-inside-work-tree 2>/dev/null
# Does it already have a remote?
git remote -v
# Is it already linked to Vercel?
ls .vercel/project.json 2>/dev/nullSkip any steps that are already complete. Tell the user what you're skipping and why.
Phase 2: Git Setup
# Only if not already a git repo
git init
# Check for a .gitignore — CRITICAL: never commit node_modules, .env files, etc.
# If missing, warn the user and offer to create oneCommit strategy:
- If there are no commits yet, create an initial commit with all files
- If there are existing commits, only commit uncommitted changes
- Use descriptive commit messages, not "initial commit" for projects with real code
- Stage specific files — avoid
git add -Ato prevent accidentally committing secrets
Secret file check — CRITICAL:
Before any commit, verify these are in .gitignore:
.env
.env.local
.env.prod
.env.production
.env*.localIf .env files exist but .gitignore is missing entries, stop and warn the user before committing.
Phase 3: GitHub Repo Creation
# Create the repo (--private is default, --public if requested)
gh repo create <repo-name> --private --source=. --remote=origin --pushKey flags:
--source=.— use the current directory--remote=origin— sets the remote name--push— pushes after creating
If the repo already exists on GitHub, just add the remote and push:
git remote add origin git@github.com:<owner>/<repo>.git
git push -u origin mainIf the branch is master not main:
git branch -M mainPhase 4: Vercel Project Setup
# Link to Vercel (interactive — will ask to confirm settings)
vercel linkDuring vercel link:
- It will ask to link to an existing project or create new — choose Create New
- Project name should match the repo name
- It auto-detects the framework (Next.js, etc.)
If already linked (.vercel/project.json exists), skip this step.
Phase 5: Environment Variables
This is the most error-prone step. Follow carefully.
Discovery — find all env vars the project needs:
# Check for .env example files
ls .env.example .env.local.example .env.sample 2>/dev/null
# Check for .env.prod or .env.production (production values)
ls .env.prod .env.production 2>/dev/null
# Scan code for env var references
grep -r "process.env\." --include="*.ts" --include="*.tsx" --include="*.js" --include="*.jsx" -oh | sort -uAsk the user which env file contains production values. If .env.prod exists, confirm they want to use those values.
Pushing env vars to Vercel — correct syntax:
# IMPORTANT: vercel env add only accepts ONE environment target per call
# Valid targets: production, preview, development
# For each variable:
echo "<value>" | vercel env add <VAR_NAME> production
# Do NOT try to pass multiple environments in one call — this will error:
# WRONG: vercel env add VAR_NAME production preview development
# RIGHT: one call per environment targetCommon env var categories and handling:
| Category | Example | Notes |
| Public build vars | NEXT_PUBLIC_* | Needed at build time, safe to expose |
| Server secrets | BETTER_AUTH_SECRET, API keys | Production only, never expose |
| Service URLs | NEXT_PUBLIC_CONVEX_URL | Usually same across environments |
| Payment keys | STRIPE_* | Use test keys for preview, live for production |
Batch approach — push all vars efficiently:
Read the env file, extract key-value pairs, and push each one. Run the calls in parallel where possible (they're independent).
# Example for each var (run these in parallel):
echo "value1" | vercel env add VAR_NAME_1 production
echo "value2" | vercel env add VAR_NAME_2 production
# ... etcVerify after pushing:
vercel env lsPhase 6: Deploy
# Production deployment
vercel --prodIf the build fails:
- Check the build logs — the URL is in the output (the "Inspect" URL)
- Common failures and fixes:
| Failure | Cause | Fix |
NEXT_PUBLIC_* undefined at build | Env var missing or not NEXT_PUBLIC_ prefixed | Push the var to Vercel |
| Module-level env access crashes build | Code reads process.env.X at import time | Use lazy initialization pattern (see below) |
| TypeScript errors | Stricter config on Vercel | Fix locally with bun run build first |
| Missing dependencies | devDependencies not installed in prod | Move to dependencies or set INSTALL_DEV_DEPS=1 |
Lazy initialization pattern for server-side clients:
If code instantiates clients at module level using env vars, the build will fail because env vars aren't available at build time on Vercel. Fix with lazy initialization:
// BAD - crashes during Vercel build
const client = new SomeClient(process.env.SOME_URL!);
// GOOD - defers to runtime
let client: SomeClient | null = null;
export function getClient(): SomeClient {
if (!client) {
const url = process.env.SOME_URL;
if (!url) throw new Error("SOME_URL is not set");
client = new SomeClient(url);
}
return client;
}This applies to ConvexHttpClient, database clients, Stripe clients, etc. — anything that reads env vars at import time.
- After fixing, commit, push to GitHub, then redeploy:
git add <files> && git commit -m "fix: resolve Vercel build failure"
git push origin main
vercel --prodPhase 7: Post-Deploy Verification
After successful deployment:
- Report the URLs to the user:
- Production URL (e.g.,
https://project-name.vercel.app) - Inspect URL for build logs
- Dashboard URL:
https://vercel.com/<team>/<project>
- Production URL (e.g.,
- Custom domain setup (if requested):
Then instruct user to update DNS:vercel domains add <domain>- For apex domain: A record →
76.76.21.21 - For subdomain: CNAME →
cname.vercel-dns.com
- For apex domain: A record →
- Remind user about:
- Auth callback URLs. Google OAuth and other sign-in providers need the production URL added as an authorized redirect, such as
https://<domain>/api/auth/callback/google - Webhook URLs — Stripe, payment providers need the production URL
- CORS settings — if using external APIs that whitelist origins
- The auth base URL must be the production URL:
SITE_URLin the Convex deployment, orBETTER_AUTH_URLin an app without Convex
- Auth callback URLs. Google OAuth and other sign-in providers need the production URL added as an authorized redirect, such as
Gotchas and Lessons Learned
Vercel CLI quirks
vercel env addaccepts only ONE environment per call — passing multiple errors with "Invalid number of arguments"- Valid built-in environments:
production,preview,development - Custom environments (e.g.,
staging,QA) are supported on Pro/Enterprise plans. The CLI accepts custom environment names directly —vercel env add VAR_NAME stagingwill auto-create the custom environment if it doesn't exist - To deploy to a custom environment:
vercel deploy --target=staging - To remove a var from a custom environment:
vercel env rm VAR_NAME staging --yes vercel --proddeploys from local files, not from Git — for Git-triggered deploys, push to GitHub and let Vercel's GitHub integration handle itvercel linkmust be run from the project root directoryNEXT_PUBLIC_vars are flagged with a warning — this is expected, not an error- Do NOT use
previewas a staging environment —previewis Vercel's built-in PR preview system. Use a custom environment namedstaginginstead
Git pitfalls
- Always check
.gitignorebefore the first commit — secrets pushed to Git history are very hard to remove - Use
git add <specific-files>notgit add -Ato avoid committing.env,.DS_Store, etc. - If the repo was created with a README via GitHub web UI, you'll need
git pull --rebase origin mainbefore pushing
Build-time vs runtime env vars
NEXT_PUBLIC_*vars are inlined at build time — they must be set in Vercel before deploying- Server-only vars are available at runtime — they work even if added after the build
- If a
NEXT_PUBLIC_var changes, you must redeploy for the change to take effect
Better Auth on Vercel
- Google OAuth requires
https://<domain>/api/auth/callback/googlein the authorized redirect URIs in Google Cloud Console. - With Convex, the auth instance runs in Convex.
BETTER_AUTH_SECRET,SITE_URL(the production URL), and the OAuth credentials go in the production Convex deployment's environment, through the dashboard ornpx convex env set. Vercel holdsNEXT_PUBLIC_CONVEX_URL,NEXT_PUBLIC_CONVEX_SITE_URL, andNEXT_PUBLIC_SITE_URL. - Without Convex, the auth instance runs in Next.js, and Vercel holds
BETTER_AUTH_SECRET(Better Auth also readsAUTH_SECRET) andBETTER_AUTH_URL, set to the custom domain. An app that answers on several domains or on preview URLs setsbaseURL: { allowedHosts: [...] }in its auth config instead ofBETTER_AUTH_URL.
Framework detection
- Vercel auto-detects Next.js, Vite, Remix, etc. from
package.json - If detection fails, set the framework in Vercel dashboard or via
vercel.json:{ "framework": "nextjs" }
Checklist
Before reporting completion to the user, verify:
- Code is committed and pushed to GitHub
- GitHub repo visibility matches user preference
- Vercel project is linked and deployed
- All environment variables are pushed to Vercel production
- Build succeeded (no errors in build logs)
- Production URL is accessible
- User has been given: production URL, GitHub repo URL, Vercel dashboard URL
- User has been reminded about auth callback URLs and webhook URLs
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
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.

