Production QA Validator
Run phases in order. Fix failures before moving to next.
When to Use
- Use before shipping or promoting a fullstack Next.js app to production.
- Use after large UI, SEO, auth, API, database, or dependency changes need a concrete launch-readiness pass.
- Use when you need a compact command-driven checklist for build, route, metadata, performance, security, and cleanup checks.
export PROD_URL="https://yourdomain.com"
export QA_AUTH_HEADER="" # optional: "Bearer eyJ..."
export PAGESPEED_API_KEY="" # optional: for auto PageSpeed API
Consolidated Runner
qa:all() { qa:code && qa:build && qa:routes / /about /contact /privacy /terms /faq /sitemap.xml /robots.txt /api/health && qa:seo && qa:api /api/health /api/tools && qa:git && qa:smoke; }
qa:full() { qa:all && qa:auth && qa:auth:cookies && qa:lazyload && qa:heavyload && qa:vulns && qa:cleanup && qa:ux:cards && qa:ux:boundaries && qa:ux:animation && qa:database && qa:secure; }
Phase 1: Code Integrity
qa:code() { npx tsc --noEmit && npx eslint . --ext .js,.jsx,.ts,.tsx --max-warnings 0 && npm test -- --runInBand --passWithNoTests; }
Phase 2: Build Verification
qa:build() { local log; log="$(mktemp "${TMPDIR:-/tmp}/qa-build.XXXXXX.log")" || return 1; set -o pipefail; npm run build 2>&1 | tee "$log"; local rc=$?; set +o pipefail; [ "$rc" -eq 0 ] && ! grep -qi "error\|failed" "$log"; local ok=$?; rm -f "$log"; return "$ok"; }
| Symbol |
Meaning |
○ |
Static |
● |
SSG |
λ |
Dynamic/serverless |
⊕ |
Partial prerender |
Phase 3: API Session & Authentication
qa:auth() {
local F=0
for ep in /api/auth/login /api/auth/session /api/auth/logout; do
curl -so /dev/null -w "%{http_code}" "$PROD_URL$ep" | grep -q "200\|401" || { echo " ✗ $ep unreachable"; ((F++)); }
done
curl -so /dev/null -w "%{http_code}" "$PROD_URL/api/protected" | grep -q "401\|403" || echo " ⚠ Protected route not denying unauthenticated"
return $F
}
qa:auth:cookies() {
for ep in /api/auth/session /api/auth/login; do
curl -sI "$PROD_URL$ep" | grep -i "^set-cookie:" | while IFS= read -r c; do
echo " $ep: $(echo "$c" | cut -d= -f1)"
echo "$c" | grep -qi "HttpOnly" || echo " ✗ Missing HttpOnly"
echo "$c" | grep -qi "Secure" || echo " ✗ Missing Secure"
echo "$c" | grep -qi "SameSite" || echo " ⚠ Missing SameSite"
done
done
}
Phase 4: Route Regression
qa:routes() { local F=0; for p; do local C=$(curl -so /dev/null -w "%{http_code}" "$PROD_URL$p"); echo "$C $p"; [ "$C" = "200" ] || ((F++)); done; return $F; }
qa:robots() { curl -s "$PROD_URL/robots.txt" | grep -qi "Disallow: /$" && echo " ✗ Blocks all crawlers" || echo " ✓ OK"; }
qa:sitemap() { curl -s "$PROD_URL/sitemap.xml" | python3 -c "import sys,xml.etree.ElementTree as ET; ET.parse(sys.stdin); print('✓ Valid XML')"; }
Phase 5: SEO — Tags, Images, Favicon, Slugs
qa:seo() {
local H=$(curl -s "$PROD_URL"); local F=0
for t in "og:title" "og:description" "og:image" "twitter:card" "canonical" "description"; do echo "$H" | grep -qi "$t" || { echo " ✗ $t"; ((F++)); }; done
echo "$H" | grep -qi "<title>" || { echo " ✗ <title>"; ((F++)); }
local T=$(echo "$H" | grep -oP '<title>\K[^<]+'); local L=${#T}; [ $L -ge 30 -a $L -le 60 ] || echo " ⚠ Title ${L}chars (target 30-60)"
curl -so /dev/null -w "%{http_code}" "$PROD_URL/favicon.ico" | grep -q 200 || echo " ⚠ No favicon.ico"
return $F
}
qa:seo:ogimage() {
local I=$(curl -s "$PROD_URL" | grep -oP 'og:image" content="\K[^"]+'); [[ "$I" =~ ^http ]] || I="$PROD_URL$I"
curl -so /dev/null -w "%{http_code}" "$I" | grep -q 200 || { echo " ✗ og:image returns non-200"; return 1; }
command -v identify &>/dev/null && curl -s "$I" | identify -format "%wx%h" - 2>/dev/null | grep -qP "12\d{2}x6\d{2}" && echo " ✓ ≥ 1200x630" || echo " ⚠ Install imagemagick to check dimensions"
}
Phase 6: API Route Behavior
qa:api() {
for p; do
local R=$(curl -so /dev/null -w "%{http_code} %{content_type}" "$PROD_URL$p")
echo " $p → $R"
done
local E=$(curl -s "$PROD_URL/api/nonexistent")
echo "$E" | python3 -c "import sys,json; d=json.load(sys.stdin); assert 'error' in d; print('✓ Consistent errors')" 2>/dev/null || echo " ⚠ Inconsistent error shape"
}
Phase 7: Git Hygiene
qa:git() {
local S=$(git diff HEAD 2>/dev/null | grep -i "password\|secret\|api_key\|localhost:3000" | grep "^+")
[ -n "$S" ] && { echo " ✗ Secrets in diff!"; echo "$S"; return 1; } || echo " ✓ No secrets"
local A=$(git status --short 2>/dev/null | grep -E "\.next|node_modules" | head -3)
[ -n "$A" ] && echo " ⚠ Build artifacts:" && echo "$A" || echo " ✓ No artifacts"
}
Phase 8: Post-Deployment Smoke Test
qa:smoke() {
curl -sI "$PROD_URL" | head -1 | grep -q "200" && echo " ✓ Homepage" || echo " ✗ Homepage"
curl -sI "$PROD_URL/sitemap.xml" | head -1 | grep -q "200" && echo " ✓ Sitemap" || echo " ✗ Sitemap"
}
Phase 9: Page Speed, Lazy Load & Bundles
qa:lazyload() {
local N=$(grep -r "loading=" app/ --include="*.tsx" 2>/dev/null | grep -c "lazy" || true)
echo " Lazy images: $N"
grep -rn "next/dynamic\|dynamic((" app/ --include="*.tsx" 2>/dev/null | head -5 | grep . || echo " ⚠ No dynamic imports"
}
qa:heavyload() {
ls -lhS .next/static/chunks/*.js 2>/dev/null | head -5
local W=$(curl -so /dev/null -w "%{size_download}" "$PROD_URL" 2>/dev/null || echo 0)
echo " HTML weight: ~$((W/1024))KB"
echo " ⚠ Run 'npx lighthouse $PROD_URL --view' for full weight analysis"
}
# PageSpeed: open "https://pagespeed.web.dev/?url=$PROD_URL"
Phase 10: Cleanup & Vulnerability Scan
qa:vulns() {
npm audit 2>/dev/null | grep -E "critical|high" | grep . && echo " ✗ Vulnerabilities!" || echo " ✓ No critical/high vulns"
npm outdated 2>/dev/null | head -5 | grep . || echo " ✓ All up to date"
local D=$(grep -rn "eval(\|new Function(\|document.write(" app/ src/ --include="*.ts" --include="*.tsx" 2>/dev/null | head -5) # security-allowlist: defensive source scan
[ -n "$D" ] && echo " ⚠ Dangerous patterns:" && echo "$D" || echo " ✓ No dangerous patterns"
}
qa:cleanup() {
local D=$(git diff --cached 2>/dev/null | grep "^+" | grep -i "console\.log\|debugger" | head -5)
[ -n "$D" ] && echo " ✗ Debug artifacts:" && echo "$D" || echo " ✓ No debug artifacts"
local T=$(git diff --cached 2>/dev/null | grep "^+" | grep -i "TODO\|FIXME\|HACK" | head -5)
[ -n "$T" ] && echo " ⚠ TODOs remain:" && echo "$T"
}
Phase 11: UI/UX — Cards, Animation, Error Boundaries
qa:ux:cards() {
local E=$(grep -rn "text-overflow\|line-clamp\|truncate" app/ --include="*.css" --include="*.tsx" 2>/dev/null | head -3)
[ -n "$E" ] && echo " ✓ Text overflow handling" || echo " ⚠ No text overflow handling"
local A=$(grep -rn "aspect-\|object-fit" app/ --include="*.css" --include="*.tsx" 2>/dev/null | head -3)
[ -n "$A" ] && echo " ✓ aspect-ratio/object-fit used" || echo " ⚠ No aspect-ratio set"
}
qa:ux:boundaries() {
for f in app/error.tsx app/global-error.tsx app/not-found.tsx app/loading.tsx; do
[ -f "$f" ] && echo " ✓ $f" || echo " ⚠ Missing $f"
done
}
qa:ux:animation() {
local A=$(grep -rn "animation.*width\|transition.*height\|@keyframes.*top\|@keyframes.*margin" app/ --include="*.css" --include="*.tsx" 2>/dev/null | head -5)
[ -n "$A" ] && echo " ⚠ Layout-triggering animations:" && echo "$A" || echo " ✓ No layout-triggering animations"
local P=$(grep -r "@media.*prefers-reduced-motion" app/ --include="*.css" --include="*.tsx" 2>/dev/null | head -3)
[ -n "$P" ] && echo " ✓ prefers-reduced-motion found in CSS" || echo " ⚠ No prefers-reduced-motion in CSS"
}
Phase 12: Database & Data Layer
qa:database() {
local H=$(grep -rn "postgres://\|mysql://\|mongodb://" app/ src/ --include="*.ts" --include="*.tsx" 2>/dev/null | grep -v ".env" | head -5)
[ -n "$H" ] && { echo " ✗ Hardcoded DB URL:"; echo "$H"; } || echo " ✓ No hardcoded DB URLs"
local R=$(grep -rn "\$queryRaw\|\.raw(" app/ src/ --include="*.ts" --include="*.tsx" 2>/dev/null | head -5)
[ -n "$R" ] && echo " ⚠ Raw SQL:" && echo "$R" || echo " ✓ No raw SQL"
local N=$(grep -rn "\.findMany\|\.findUnique" app/ src/ --include="*.ts" --include="*.tsx" 2>/dev/null | grep -v "include:" | head -5)
[ -n "$N" ] && echo " ⚠ Possible N+1:" && echo "$N" || echo " ✓ No N+1 patterns"
}
qa:db:migrations() {
[ -d "prisma/migrations" ] && echo " ✓ Prisma: $(ls prisma/migrations 2>/dev/null | wc -l) migrations" || echo " - No prisma migrations dir"
local M=$(ls db/migrations/*.sql 2>/dev/null | head -5); [ -n "$M" ] && echo " ✓ SQL migrations:" && echo "$M" || echo " - No SQL migration files"
}
Phase 13: Secure Data Rendering
qa:secure() {
local S=$(git grep -n "api_key\|API_KEY\|secret_key\|PRIVATE_KEY" -- ':!*.env*' ':!*test*' 2>/dev/null | head -5)
[ -n "$S" ] && echo " ✗ Secrets in source:" && echo "$S" || echo " ✓ No hardcoded secrets"
local D=$(grep -rn "dangerouslySetInnerHTML" app/ src/ --include="*.tsx" 2>/dev/null | head -5)
[ -n "$D" ] && echo " ⚠ XSS risk — use DOMPurify:" && echo "$D" || echo " ✓ No dangerouslySetInnerHTML"
local T=$(grep -rn "localStorage\|sessionStorage" app/ src/ --include="*.ts" --include="*.tsx" 2>/dev/null | grep -i "token\|jwt\|secret" | head -5)
[ -n "$T" ] && echo " ⚠ Tokens in storage — use httpOnly cookies:" && echo "$T" || echo " ✓ No tokens in storage"
curl -s "$PROD_URL/api/nonexistent" 2>/dev/null | grep -qi "stack\|Error:" && echo " ✗ Stack trace leak" || echo " ✓ No stack leak"
}
Pre-Commit Hook
cat > .git/hooks/pre-commit << 'EOF'
#!/bin/sh
npx tsc --noEmit || exit 1
npx eslint . --ext .js,.jsx,.ts,.tsx --max-warnings 0 || exit 1
EOF
chmod +x .git/hooks/pre-commit
CI/CD (GitHub Actions)
name: QA
on: [push, pull_request]
jobs:
qa:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm ci
- run: npx tsc --noEmit
- run: npx eslint . --ext .js,.jsx,.ts,.tsx --max-warnings 0
- run: npm test -- --runInBand --passWithNoTests
- run: npm run build
Best Practices
| ✅ Do |
❌ Don't |
| Run full 13-phase flow before deploy |
Skip typecheck or lint |
Set PROD_URL in profile/.envrc |
Hardcode URLs in scripts |
| OG images ≥ 1200×630 |
Use small OG images |
Animate with transform+opacity |
Animate width/height/top |
| Show loading/error/empty states |
Leave users on blank screens |
prefers-reduced-motion for animations |
Force motion on all users |
| HttpOnly + Secure cookies for tokens |
localStorage for auth tokens |
| Error boundaries at all levels |
White screen on crash |
| Database indexes + include/populate |
N+1 queries in loops |
npm audit before deploy |
Deploy with known vulns |
Common Pitfalls
| Problem |
Solution |
| OG tags missing in raw HTML |
Use export const metadata in Next.js |
Disallow: / in robots.txt |
Blocks all crawlers — use specific paths |
| Cards different heights in grid |
Use display: grid with equal-height rows, not flex |
| Text overflows card |
Add text-overflow: ellipsis + overflow: hidden |
| Animation jank |
Animate transform not width/height |
| Form submits twice |
Disable button on first click |
| Console errors in prod |
Add no-console ESLint rule |
| DB connection timeout |
Add connection pooling (PgBouncer/Prisma Accelerate) |
| Sensitive data in API |
Strip passwordHash/secret in response transformer |
| App crashes on error |
Add app/error.tsx error boundary |
| Large JS bundles |
Dynamic import heavy components, analyze with next/bundle-analyzer |
| Images load slowly |
Add loading="lazy", use WebP/AVIF, resize to display size |
Security Notes
- All
qa:* functions are read-only (tsc, lint, test, build, curl, grep)
PROD_URL and QA_AUTH_HEADER only for environments you own
- Basic secret scanning in
git diff — for prod, use trufflehog/git-secrets
- Auth tests with real credentials against prod is destructive — use staging
Limitations
- Passing all phases reduces risk but doesn't eliminate production bugs
- Some checks depend on project-specific tooling (Prisma, NextAuth, etc.)
- Manual UX testing still required for critical user journeys
- SEO checks verify raw HTML only — not social preview rendering
- Route checks verify status codes, not content correctness
Master Checklist
Phase 1: Code
Phase 2: Build
Phase 3: Auth
Phase 4: Routes
Phase 5: SEO
Phase 6: API
Phase 7: Git
Phase 8: Smoke
Phase 9: Speed
Phase 10: Clean
Phase 11: UI/UX
Phase 12: Database
Phase 13: Secure Rendering
1---2name: vibecode-production-qa-validator3description: "13-phase production QA for fullstack Next.js apps: build verification, SEO tags, OG images, favicon, route regression, API auth, page speed, lazy load, vulnerability scan, UI/UX cards, error boundaries, database, secure rendering, and cleanup."4category: devops5risk: safe6source: self7source_type: self8date_added: "2026-05-31"9author: Whoisabhishekadhikari10tags: [qa, nextjs, production, deployment, seo, authentication, api, performance, favicon, cleanup, lighthouse, database, security, ui-ux]11tools: [claude, cursor, gemini, claude-code, opencode]12version: 2.0.013metadata:14 source: https://skillmd.com/skills/mhassan0000/vibecode-production-qa-validator15---1617# Production QA Validator1819Run phases in order. Fix failures before moving to next.2021## When to Use2223- Use before shipping or promoting a fullstack Next.js app to production.24- Use after large UI, SEO, auth, API, database, or dependency changes need a concrete launch-readiness pass.25- Use when you need a compact command-driven checklist for build, route, metadata, performance, security, and cleanup checks.2627```bash28export PROD_URL="https://yourdomain.com"29export QA_AUTH_HEADER="" # optional: "Bearer eyJ..."30export PAGESPEED_API_KEY="" # optional: for auto PageSpeed API31```3233---3435## Consolidated Runner3637```bash38qa:all() { qa:code && qa:build && qa:routes / /about /contact /privacy /terms /faq /sitemap.xml /robots.txt /api/health && qa:seo && qa:api /api/health /api/tools && qa:git && qa:smoke; }39qa:full() { qa:all && qa:auth && qa:auth:cookies && qa:lazyload && qa:heavyload && qa:vulns && qa:cleanup && qa:ux:cards && qa:ux:boundaries && qa:ux:animation && qa:database && qa:secure; }40```4142---4344### Phase 1: Code Integrity4546- [ ] `npx tsc --noEmit`47- [ ] `npx eslint . --ext .js,.jsx,.ts,.tsx --max-warnings 0`48- [ ] `npm test -- --runInBand --passWithNoTests`4950```bash51qa:code() { npx tsc --noEmit && npx eslint . --ext .js,.jsx,.ts,.tsx --max-warnings 0 && npm test -- --runInBand --passWithNoTests; }52```5354---5556### Phase 2: Build Verification5758- [ ] `npm run build` succeeds59- [ ] SEO pages show `○`/`●` not `λ`60- [ ] Build log has no errors6162```bash63qa:build() { local log; log="$(mktemp "${TMPDIR:-/tmp}/qa-build.XXXXXX.log")" || return 1; set -o pipefail; npm run build 2>&1 | tee "$log"; local rc=$?; set +o pipefail; [ "$rc" -eq 0 ] && ! grep -qi "error\|failed" "$log"; local ok=$?; rm -f "$log"; return "$ok"; }64```6566| Symbol | Meaning |67|--------|---------|68| `○` | Static |69| `●` | SSG |70| `λ` | Dynamic/serverless |71| `⊕` | Partial prerender |7273---7475### Phase 3: API Session & Authentication7677- [ ] Auth endpoints respond (login, session, logout)78- [ ] Protected routes return 401/40379- [ ] Session cookie: HttpOnly + Secure + SameSite80- [ ] Cookie not expired, Path/Domain correct81- [ ] No rate limiting bypass8283```bash84qa:auth() {85 local F=086 for ep in /api/auth/login /api/auth/session /api/auth/logout; do87 curl -so /dev/null -w "%{http_code}" "$PROD_URL$ep" | grep -q "200\|401" || { echo " ✗ $ep unreachable"; ((F++)); }88 done89 curl -so /dev/null -w "%{http_code}" "$PROD_URL/api/protected" | grep -q "401\|403" || echo " ⚠ Protected route not denying unauthenticated"90 return $F91}92qa:auth:cookies() {93 for ep in /api/auth/session /api/auth/login; do94 curl -sI "$PROD_URL$ep" | grep -i "^set-cookie:" | while IFS= read -r c; do95 echo " $ep: $(echo "$c" | cut -d= -f1)"96 echo "$c" | grep -qi "HttpOnly" || echo " ✗ Missing HttpOnly"97 echo "$c" | grep -qi "Secure" || echo " ✗ Missing Secure"98 echo "$c" | grep -qi "SameSite" || echo " ⚠ Missing SameSite"99 done100 done101}102```103104---105106### Phase 4: Route Regression107108- [ ] Core pages, sitemap, robots.txt all 200109- [ ] URLs use kebab-case, no duplicate slugs110- [ ] robots.txt allows indexing111- [ ] Sitemap XML valid, all URLs resolve 200112113```bash114qa:routes() { local F=0; for p; do local C=$(curl -so /dev/null -w "%{http_code}" "$PROD_URL$p"); echo "$C $p"; [ "$C" = "200" ] || ((F++)); done; return $F; }115qa:robots() { curl -s "$PROD_URL/robots.txt" | grep -qi "Disallow: /$" && echo " ✗ Blocks all crawlers" || echo " ✓ OK"; }116qa:sitemap() { curl -s "$PROD_URL/sitemap.xml" | python3 -c "import sys,xml.etree.ElementTree as ET; ET.parse(sys.stdin); print('✓ Valid XML')"; }117```118119---120121### Phase 5: SEO — Tags, Images, Favicon, Slugs122123- [ ] `<title>` 30–60 chars, unique per page124- [ ] `<meta name="description">` in raw HTML125- [ ] og:title matches `<title>`, og:url matches canonical126- [ ] og:image ≥ 1200×630px, absolute URL, loads 200127- [ ] twitter:card = summary_large_image128- [ ] Canonical self-referencing, no duplicates129- [ ] `/favicon.ico` 200, apple-touch-icon present130- [ ] `hreflang` tags if multilingual131- [ ] JSON-LD structured data present132- [ ] Slugs: kebab-case, < 80 chars, no stop words133134```bash135qa:seo() {136 local H=$(curl -s "$PROD_URL"); local F=0137 for t in "og:title" "og:description" "og:image" "twitter:card" "canonical" "description"; do echo "$H" | grep -qi "$t" || { echo " ✗ $t"; ((F++)); }; done138 echo "$H" | grep -qi "<title>" || { echo " ✗ <title>"; ((F++)); }139 local T=$(echo "$H" | grep -oP '<title>\K[^<]+'); local L=${#T}; [ $L -ge 30 -a $L -le 60 ] || echo " ⚠ Title ${L}chars (target 30-60)"140 curl -so /dev/null -w "%{http_code}" "$PROD_URL/favicon.ico" | grep -q 200 || echo " ⚠ No favicon.ico"141 return $F142}143qa:seo:ogimage() {144 local I=$(curl -s "$PROD_URL" | grep -oP 'og:image" content="\K[^"]+'); [[ "$I" =~ ^http ]] || I="$PROD_URL$I"145 curl -so /dev/null -w "%{http_code}" "$I" | grep -q 200 || { echo " ✗ og:image returns non-200"; return 1; }146 command -v identify &>/dev/null && curl -s "$I" | identify -format "%wx%h" - 2>/dev/null | grep -qP "12\d{2}x6\d{2}" && echo " ✓ ≥ 1200x630" || echo " ⚠ Install imagemagick to check dimensions"147}148```149150---151152### Phase 6: API Route Behavior153154- [ ] Correct status codes + Content-Type155- [ ] Errors return consistent JSON `{ error, message }`156- [ ] Response times < 200ms157- [ ] CORS headers correct (if cross-origin)158159```bash160qa:api() {161 for p; do162 local R=$(curl -so /dev/null -w "%{http_code} %{content_type}" "$PROD_URL$p")163 echo " $p → $R"164 done165 local E=$(curl -s "$PROD_URL/api/nonexistent")166 echo "$E" | python3 -c "import sys,json; d=json.load(sys.stdin); assert 'error' in d; print('✓ Consistent errors')" 2>/dev/null || echo " ⚠ Inconsistent error shape"167}168```169170---171172### Phase 7: Git Hygiene173174- [ ] No secrets/credentials in diff175- [ ] No `.next`/`node_modules` staged176- [ ] Commit: `type(scope): message`177178```bash179qa:git() {180 local S=$(git diff HEAD 2>/dev/null | grep -i "password\|secret\|api_key\|localhost:3000" | grep "^+")181 [ -n "$S" ] && { echo " ✗ Secrets in diff!"; echo "$S"; return 1; } || echo " ✓ No secrets"182 local A=$(git status --short 2>/dev/null | grep -E "\.next|node_modules" | head -3)183 [ -n "$A" ] && echo " ⚠ Build artifacts:" && echo "$A" || echo " ✓ No artifacts"184}185```186187---188189### Phase 8: Post-Deployment Smoke Test190191- [ ] Homepage 200, key pages 200192- [ ] OG image loads 200193- [ ] No console errors (manual)194- [ ] Auth flow works (manual)195196```bash197qa:smoke() {198 curl -sI "$PROD_URL" | head -1 | grep -q "200" && echo " ✓ Homepage" || echo " ✗ Homepage"199 curl -sI "$PROD_URL/sitemap.xml" | head -1 | grep -q "200" && echo " ✓ Sitemap" || echo " ✗ Sitemap"200}201```202203---204205### Phase 9: Page Speed, Lazy Load & Bundles206207- [ ] Lighthouse ≥ 90 (Perf, A11y, SEO)208- [ ] FCP < 2.5s, LCP < 4.0s, CLS < 0.1209- [ ] Images lazy-loaded (`loading="lazy"`), WebP/AVIF210- [ ] Dynamic imports for heavy components211- [ ] Largest JS chunk < 200KB gzipped212- [ ] `font-display: swap`, no FOIT213- [ ] Total page weight < 1MB214215```bash216qa:lazyload() {217 local N=$(grep -r "loading=" app/ --include="*.tsx" 2>/dev/null | grep -c "lazy" || true)218 echo " Lazy images: $N"219 grep -rn "next/dynamic\|dynamic((" app/ --include="*.tsx" 2>/dev/null | head -5 | grep . || echo " ⚠ No dynamic imports"220}221qa:heavyload() {222 ls -lhS .next/static/chunks/*.js 2>/dev/null | head -5223 local W=$(curl -so /dev/null -w "%{size_download}" "$PROD_URL" 2>/dev/null || echo 0)224 echo " HTML weight: ~$((W/1024))KB"225 echo " ⚠ Run 'npx lighthouse $PROD_URL --view' for full weight analysis"226}227# PageSpeed: open "https://pagespeed.web.dev/?url=$PROD_URL"228```229230---231232### Phase 10: Cleanup & Vulnerability Scan233234- [ ] `npm prune`, `depcheck` — no unused deps235- [ ] No console.log/debugger in staged code236- [ ] `npm audit` — zero critical/high vulnerabilities237- [ ] No eval/new Function/document.write238- [ ] TODOs resolved239240```bash241qa:vulns() {242 npm audit 2>/dev/null | grep -E "critical|high" | grep . && echo " ✗ Vulnerabilities!" || echo " ✓ No critical/high vulns"243 npm outdated 2>/dev/null | head -5 | grep . || echo " ✓ All up to date"244 local D=$(grep -rn "eval(\|new Function(\|document.write(" app/ src/ --include="*.ts" --include="*.tsx" 2>/dev/null | head -5) # security-allowlist: defensive source scan245 [ -n "$D" ] && echo " ⚠ Dangerous patterns:" && echo "$D" || echo " ✓ No dangerous patterns"246}247qa:cleanup() {248 local D=$(git diff --cached 2>/dev/null | grep "^+" | grep -i "console\.log\|debugger" | head -5)249 [ -n "$D" ] && echo " ✗ Debug artifacts:" && echo "$D" || echo " ✓ No debug artifacts"250 local T=$(git diff --cached 2>/dev/null | grep "^+" | grep -i "TODO\|FIXME\|HACK" | head -5)251 [ -n "$T" ] && echo " ⚠ TODOs remain:" && echo "$T"252}253```254255---256257### Phase 11: UI/UX — Cards, Animation, Error Boundaries258259- [ ] Cards: equal height grid, no overlap, text ellipsis, responsive (1→2→3 col)260- [ ] No horizontal scroll at any viewport (320–1440px)261- [ ] Images: consistent `aspect-ratio` + `object-fit: cover`262- [ ] Touch targets ≥ 44×44px263- [ ] Animations use `transform`+`opacity` only (not layout props)264- [ ] `prefers-reduced-motion` respected265- [ ] Error boundaries at root + route level (`app/error.tsx`, `app/global-error.tsx`)266- [ ] `app/not-found.tsx` and `app/loading.tsx` exist267- [ ] All client fetches show loading + error + empty states268- [ ] Buttons: hover, focus-visible, active, disabled, loading states269- [ ] Forms disable submit on click (no double-submit)270271```bash272qa:ux:cards() {273 local E=$(grep -rn "text-overflow\|line-clamp\|truncate" app/ --include="*.css" --include="*.tsx" 2>/dev/null | head -3)274 [ -n "$E" ] && echo " ✓ Text overflow handling" || echo " ⚠ No text overflow handling"275 local A=$(grep -rn "aspect-\|object-fit" app/ --include="*.css" --include="*.tsx" 2>/dev/null | head -3)276 [ -n "$A" ] && echo " ✓ aspect-ratio/object-fit used" || echo " ⚠ No aspect-ratio set"277}278qa:ux:boundaries() {279 for f in app/error.tsx app/global-error.tsx app/not-found.tsx app/loading.tsx; do280 [ -f "$f" ] && echo " ✓ $f" || echo " ⚠ Missing $f"281 done282}283qa:ux:animation() {284 local A=$(grep -rn "animation.*width\|transition.*height\|@keyframes.*top\|@keyframes.*margin" app/ --include="*.css" --include="*.tsx" 2>/dev/null | head -5)285 [ -n "$A" ] && echo " ⚠ Layout-triggering animations:" && echo "$A" || echo " ✓ No layout-triggering animations"286 local P=$(grep -r "@media.*prefers-reduced-motion" app/ --include="*.css" --include="*.tsx" 2>/dev/null | head -3)287 [ -n "$P" ] && echo " ✓ prefers-reduced-motion found in CSS" || echo " ⚠ No prefers-reduced-motion in CSS"288}289```290291---292293### Phase 12: Database & Data Layer294295- [ ] Connection pool configured (no starvation)296- [ ] Schema in sync with migrations297- [ ] Indexes on all queried columns, no N+1298- [ ] No hardcoded DB credentials in source299- [ ] No raw SQL injection risk300- [ ] No sensitive data leaked in API responses301- [ ] Migrations are idempotent302303```bash304qa:database() {305 local H=$(grep -rn "postgres://\|mysql://\|mongodb://" app/ src/ --include="*.ts" --include="*.tsx" 2>/dev/null | grep -v ".env" | head -5)306 [ -n "$H" ] && { echo " ✗ Hardcoded DB URL:"; echo "$H"; } || echo " ✓ No hardcoded DB URLs"307 local R=$(grep -rn "\$queryRaw\|\.raw(" app/ src/ --include="*.ts" --include="*.tsx" 2>/dev/null | head -5)308 [ -n "$R" ] && echo " ⚠ Raw SQL:" && echo "$R" || echo " ✓ No raw SQL"309 local N=$(grep -rn "\.findMany\|\.findUnique" app/ src/ --include="*.ts" --include="*.tsx" 2>/dev/null | grep -v "include:" | head -5)310 [ -n "$N" ] && echo " ⚠ Possible N+1:" && echo "$N" || echo " ✓ No N+1 patterns"311}312qa:db:migrations() {313 [ -d "prisma/migrations" ] && echo " ✓ Prisma: $(ls prisma/migrations 2>/dev/null | wc -l) migrations" || echo " - No prisma migrations dir"314 local M=$(ls db/migrations/*.sql 2>/dev/null | head -5); [ -n "$M" ] && echo " ✓ SQL migrations:" && echo "$M" || echo " - No SQL migration files"315}316```317318---319320### Phase 13: Secure Data Rendering321322- [ ] No secrets/tokens in client source or localStorage323- [ ] No `dangerouslySetInnerHTML` without DOMPurify324- [ ] API errors don't leak stack traces325- [ ] Internal IDs use UUIDs not auto-increment326- [ ] User emails masked in UI327- [ ] NEXT_PUBLIC_ vars contain no secrets328329```bash330qa:secure() {331 local S=$(git grep -n "api_key\|API_KEY\|secret_key\|PRIVATE_KEY" -- ':!*.env*' ':!*test*' 2>/dev/null | head -5)332 [ -n "$S" ] && echo " ✗ Secrets in source:" && echo "$S" || echo " ✓ No hardcoded secrets"333 local D=$(grep -rn "dangerouslySetInnerHTML" app/ src/ --include="*.tsx" 2>/dev/null | head -5)334 [ -n "$D" ] && echo " ⚠ XSS risk — use DOMPurify:" && echo "$D" || echo " ✓ No dangerouslySetInnerHTML"335 local T=$(grep -rn "localStorage\|sessionStorage" app/ src/ --include="*.ts" --include="*.tsx" 2>/dev/null | grep -i "token\|jwt\|secret" | head -5)336 [ -n "$T" ] && echo " ⚠ Tokens in storage — use httpOnly cookies:" && echo "$T" || echo " ✓ No tokens in storage"337 curl -s "$PROD_URL/api/nonexistent" 2>/dev/null | grep -qi "stack\|Error:" && echo " ✗ Stack trace leak" || echo " ✓ No stack leak"338}339```340341---342343## Pre-Commit Hook344345```bash346cat > .git/hooks/pre-commit << 'EOF'347#!/bin/sh348npx tsc --noEmit || exit 1349npx eslint . --ext .js,.jsx,.ts,.tsx --max-warnings 0 || exit 1350EOF351chmod +x .git/hooks/pre-commit352```353354---355356## CI/CD (GitHub Actions)357358```yaml359name: QA360on: [push, pull_request]361jobs:362 qa:363 runs-on: ubuntu-latest364 steps:365 - uses: actions/checkout@v4366 - uses: actions/setup-node@v4367 - run: npm ci368 - run: npx tsc --noEmit369 - run: npx eslint . --ext .js,.jsx,.ts,.tsx --max-warnings 0370 - run: npm test -- --runInBand --passWithNoTests371 - run: npm run build372```373374---375376## Best Practices377378| ✅ Do | ❌ Don't |379|-------|----------|380| Run full 13-phase flow before deploy | Skip typecheck or lint |381| Set `PROD_URL` in profile/.envrc | Hardcode URLs in scripts |382| OG images ≥ 1200×630 | Use small OG images |383| Animate with `transform`+`opacity` | Animate width/height/top |384| Show loading/error/empty states | Leave users on blank screens |385| `prefers-reduced-motion` for animations | Force motion on all users |386| HttpOnly + Secure cookies for tokens | localStorage for auth tokens |387| Error boundaries at all levels | White screen on crash |388| Database indexes + include/populate | N+1 queries in loops |389| `npm audit` before deploy | Deploy with known vulns |390391---392393## Common Pitfalls394395| Problem | Solution |396|---------|----------|397| OG tags missing in raw HTML | Use `export const metadata` in Next.js |398| `Disallow: /` in robots.txt | Blocks all crawlers — use specific paths |399| Cards different heights in grid | Use `display: grid` with equal-height rows, not flex |400| Text overflows card | Add `text-overflow: ellipsis` + `overflow: hidden` |401| Animation jank | Animate `transform` not `width`/`height` |402| Form submits twice | Disable button on first click |403| Console errors in prod | Add `no-console` ESLint rule |404| DB connection timeout | Add connection pooling (PgBouncer/Prisma Accelerate) |405| Sensitive data in API | Strip `passwordHash`/`secret` in response transformer |406| App crashes on error | Add `app/error.tsx` error boundary |407| Large JS bundles | Dynamic import heavy components, analyze with `next/bundle-analyzer` |408| Images load slowly | Add `loading="lazy"`, use WebP/AVIF, resize to display size |409410---411412## Security Notes413414- All `qa:*` functions are read-only (tsc, lint, test, build, curl, grep)415- `PROD_URL` and `QA_AUTH_HEADER` only for environments you own416- Basic secret scanning in `git diff` — for prod, use `trufflehog`/`git-secrets`417- Auth tests with real credentials against prod is destructive — use staging418419---420421## Limitations422423- Passing all phases reduces risk but doesn't eliminate production bugs424- Some checks depend on project-specific tooling (Prisma, NextAuth, etc.)425- Manual UX testing still required for critical user journeys426- SEO checks verify raw HTML only — not social preview rendering427- Route checks verify status codes, not content correctness428429---430431## Master Checklist432433### Phase 1: Code434- [ ] `tsc --noEmit`, `eslint`, `npm test` pass435436### Phase 2: Build437- [ ] `npm run build` succeeds, no errors, pages static438439### Phase 3: Auth440- [ ] Endpoints respond, protected routes denied, secure cookies441442### Phase 4: Routes443- [ ] All core pages 200, sitemap valid, robots.txt correct444445### Phase 5: SEO446- [ ] title, description, og:*, twitter:card, canonical, favicon, slugs447448### Phase 6: API449- [ ] Status, Content-Type, consistent errors, timing450451### Phase 7: Git452- [ ] No secrets, no artifacts, conventional commit453454### Phase 8: Smoke455- [ ] Homepage + key pages 200, og:image loads456457### Phase 9: Speed458- [ ] Lighthouse ≥ 90, lazy images, dynamic imports, font-display: swap459460### Phase 10: Clean461- [ ] No vulns, no debug artifacts, unused deps pruned462463### Phase 11: UI/UX464- [ ] Cards responsive, error boundaries, button states, reduced-motion465466### Phase 12: Database467- [ ] Indexes, no N+1, no hardcoded URLs, no sensitive leaks468469### Phase 13: Secure Rendering470- [ ] No secrets in client, no XSS, no stack leaks, UUIDs