vercel-deployments – skill DevOps & Hạ tầng cho agent AI
Triển khai ứng dụng frontend và full-stack trên Vercel với preview, edge function, thăng hạng môi trường và các rào chắn cho production.
Cài skill vercel-deployments bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/vercel-deployments-15ee0.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /vercel-deployments – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/vercel-deployments-15ee0.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $vercel-deployments – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/vercel-deployments-15ee0.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /vercel-deployments – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/vercel-deployments-15ee0.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /vercel-deployments – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
Vercel Deployments
Ship web apps quickly with preview environments and managed edge infrastructure.
When to Use This Skill
Use this skill when:
- Deploying Next.js, SvelteKit, Nuxt, or static sites
- Setting up preview environments for every PR
- Configuring edge functions and serverless APIs
- Managing environment variables across preview/production
- Setting up custom domains and redirects
Prerequisites
- Node.js 18+
- Vercel account (free tier works for personal projects)
- Git repository (GitHub, GitLab, or Bitbucket)
Quick Start
# Install CLI
npm i -g vercel
# Login and link project
vercel login
vercel link
# Deploy to preview
vercel
# Deploy to production
vercel --prod
# Pull environment variables locally
vercel env pull .env.localProject Configuration
// vercel.json
{
"framework": "nextjs",
"buildCommand": "npm run build",
"outputDirectory": ".next",
"installCommand": "npm ci",
"regions": ["iad1", "sfo1", "cdg1"],
"headers": [
{
"source": "/api/(.*)",
"headers": [
{ "key": "Cache-Control", "value": "no-store" },
{ "key": "X-Content-Type-Options", "value": "nosniff" }
]
},
{
"source": "/(.*)",
"headers": [
{ "key": "X-Frame-Options", "value": "DENY" },
{ "key": "Strict-Transport-Security", "value": "max-age=63072000; includeSubDomains" }
]
}
],
"redirects": [
{ "source": "/blog/:slug", "destination": "/posts/:slug", "permanent": true }
],
"rewrites": [
{ "source": "/api/v1/:path*", "destination": "https://api.example.com/:path*" }
]
}Environment Variables
# Add environment variables
vercel env add DATABASE_URL production
vercel env add DATABASE_URL preview
vercel env add NEXT_PUBLIC_API_URL production
# List all env vars
vercel env ls
# Pull to local .env.local
vercel env pull .env.local
# Remove an env var
vercel env rm SECRET_KEY productionEnvironment Separation Pattern
# Production — real credentials
vercel env add DATABASE_URL production <<< "postgresql://prod-host:5432/app"
vercel env add STRIPE_SECRET_KEY production
# Preview — staging/test credentials
vercel env add DATABASE_URL preview <<< "postgresql://staging-host:5432/app"
vercel env add STRIPE_SECRET_KEY preview # Use test mode key
# Development — local values
vercel env add DATABASE_URL development <<< "postgresql://localhost:5432/app"Edge Functions
// app/api/geo/route.ts — Edge API route (Next.js App Router)
import { NextRequest } from 'next/server';
export const runtime = 'edge';
export function GET(request: NextRequest) {
const country = request.headers.get('x-vercel-ip-country') || 'US';
const city = request.headers.get('x-vercel-ip-city') || 'Unknown';
return Response.json({
country,
city,
region: request.headers.get('x-vercel-ip-country-region'),
timestamp: new Date().toISOString(),
});
}// middleware.ts — Deployment geolocation routing example (not authentication)
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
export function middleware(request: NextRequest) {
// Block non-US traffic from admin
if (request.nextUrl.pathname.startsWith('/admin')) {
if (request.headers.get('x-vercel-ip-country') !== 'US') {
return NextResponse.redirect(new URL('/blocked', request.url));
}
}
// Add security headers
const response = NextResponse.next();
response.headers.set('X-Request-Id', crypto.randomUUID());
return response;
}
export const config = {
matcher: ['/admin/:path*', '/api/:path*'],
};GitHub Actions Integration
# .github/workflows/preview.yml
name: Vercel Preview
on: pull_request
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- run: npm ci
- run: npm run lint
- run: npm run test
- name: Deploy to Vercel Preview
id: deploy
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
run: |
# Prerequisite: reviewed pinned Vercel CLI installed by the job.
URL=$(vercel --token "$VERCEL_TOKEN" --yes)
echo "url=$URL" >> "$GITHUB_OUTPUT"
- name: Comment PR with preview URL
uses: actions/github-script@v7
env:
PREVIEW_URL: ${{ steps.deploy.outputs.url }}
with:
script: |
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Preview deployed: ${process.env.PREVIEW_URL}`
});CLI Commands Reference
# Deployments
vercel # Deploy to preview
vercel --prod # Deploy to production
vercel rollback # Rollback last production deploy
vercel promote <url> # Promote preview to production
# Domains
vercel domains add example.com
vercel domains ls
vercel certs ls
# Logs
vercel logs <deployment-url>
vercel logs <deployment-url> --follow
# Project management
vercel project ls
vercel project rm <name>
# Inspect deployment
vercel inspect <deployment-url>Production Guardrails
- Require preview checks before merge (GitHub branch protection)
- Separate preview and production environment variables — never share API keys
- Use branch protection with required deployment status checks
- Monitor function duration and cold start behavior in Vercel Analytics
- Set spend limits in Vercel dashboard to prevent cost surprises
- Enable Vercel Firewall for DDoS and bot protection
- Use
vercel.jsonheaders for security (CSP, HSTS, X-Frame-Options)
Monitoring & Analytics
# Enable Speed Insights in Next.js
npm install @vercel/speed-insights
# Enable Web Analytics
npm install @vercel/analytics// app/layout.tsx
import { Analytics } from '@vercel/analytics/react';
import { SpeedInsights } from '@vercel/speed-insights/next';
export default function RootLayout({ children }) {
return (
<html>
<body>
{children}
<Analytics />
<SpeedInsights />
</body>
</html>
);
}Troubleshooting
| Issue | Solution |
|-------|---------|
| Build fails | Check vercel logs, verify Node.js version in engines field |
| Env vars missing | Run vercel env pull, check variable scope (preview vs production) |
| Edge function timeout | Edge has 30s limit; move heavy work to serverless (no runtime = 'edge') |
| Cold starts slow | Use edge runtime where possible, reduce bundle size |
| Domain not working | Check DNS propagation, verify vercel domains configuration |
Related Skills
- github-actions (
github-actions) — Automated deployment gates - cloudflare-pages (
cloudflare-pages) — Alternative edge hosting - ssl-tls-management (
ssl-tls-management) — Custom certificate setup
Limitations
- Infrastructure commands can disrupt services: confirm target host/scope and have backups/snapshots before mutating state.
- Docs-only import: upstream scripts and templates not bundled.
NextRequest.geo was removed in Next.js 15; the sample uses Vercel deployment headers and must run behind the trusted platform ingress. Geolocation is approximate and is not user authentication or authorization. Validate preview URLs and use a trusted-branch job with least-privilege credentials; do not expose deployment secrets to untrusted fork code. Production deploy, promote, rollback and domain commands require the exact authorized project/target.
Skill liên quan
- vllm-server – Triển khai và quản lý vLLM để suy luận LLM thông lượng cao. Cấu hình continuous…
- vpn-setup – Cấu hình WireGuard, OpenVPN và VPN đám mây. Triển khai truy cập từ xa an toàn và kết nối…
- windows-server – Quản trị hệ thống Windows Server. Quản lý IIS, Active Directory và tự động hóa bằng…
- actual-setup – Thiết lập suy luận Actual Computer (actual.inc) trong Hermes.
- asn-infrastructure-mapping – Lập bản đồ hạ tầng IP của tổ chức qua ASN, CIDR, mở rộng TLD và reverse DNS.
- cloudflare-deploy – Triển khai ứng dụng và hạ tầng lên Cloudflare bằng Workers, Pages và các dịch vụ nền…
- aegisops-ai – Rào chắn tự động cho DevSecOps & FinOps. Hướng dẫn rà soát bản vá kernel Linux, thay đổi…
- cloud-iam-deep – Khai thác lỗ hổng trên cloud GCP/AWS/Azure -- Cloud Functions, Firestore, Cloud Run, S3…