Claude-skill-registry dev-environment-manager
Manage local development environment, database resets, health checks, deployment validation, production data sync, and Vercel environment variables; use when setting up dev environment, resetting databases, running pre-deployment checks, syncing production data to staging/local, or fixing Vercel env vars with trailing newlines
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/dev-environment-manager" ~/.claude/skills/majiayu000-claude-skill-registry-dev-environment-manager && rm -rf "$T"
skills/data/dev-environment-manager/SKILL.mdDev Environment Manager
When to Use This Skill
Use this skill when:
- Setting up or resetting local development environment
- Running health checks on databases
- Validating environment before deployment
- Syncing production data to local or staging
Quick Commands (Recommended)
The easiest way to reset and sync your local database:
# Reset local DB + sync from STAGING (default) pnpm supabase:web:reset # Reset local DB + sync from PRODUCTION pnpm supabase:web:reset --prod # Reset local DB only (no data sync) pnpm supabase:reset:no-sync
These commands:
- Apply all migrations (reset schema)
- Sync data from staging/production
- Include auth.users for login testing
Login locally with any synced user email + password password
Full Sync Workflow: Production → Staging → Local
For a complete refresh of all environments:
# Step 1: Sync production data to staging ./.claude/skills/dev-environment-manager/scripts/sync-prod-to-staging.sh --confirm --yes # Step 2: Reset local and sync from staging pnpm supabase:web:reset
This ensures staging mirrors production, then local mirrors staging.
Scripts
Location:
.claude/skills/dev-environment-manager/scripts/
| Script | Description |
|---|---|
| Copy production data to staging (READ-only from prod) |
| Copy production data to local (READ-only from prod) |
| Unified sync script (staging or prod to local) |
| Complete local database reset with optional production sync |
| Database health verification |
| Pre-deployment validation |
| Fix production environment variables |
| Verify production env vars are set |
Data Sync Details
Safety Guarantees
All sync scripts have multiple safety layers to prevent accidental production writes:
- Read-only production connection - Scripts only construct READ connections to production
- Explicit confirmation required - Must pass
flag AND type confirmation text--confirm - Target verification - Scripts verify the target database before writing
- Clear visual warnings - Red warning banners before any destructive operation
Sync Production → Staging
# Preview what will happen (safe, no changes) ./.claude/skills/dev-environment-manager/scripts/sync-prod-to-staging.sh # Execute the sync (requires confirmation) ./.claude/skills/dev-environment-manager/scripts/sync-prod-to-staging.sh --confirm # Skip interactive prompt ./.claude/skills/dev-environment-manager/scripts/sync-prod-to-staging.sh --confirm --yes
What it does:
- READ all public + auth schema data from production
- ERASE all data in staging
- COPY production data to staging
- Verify row counts match
Production is NEVER modified.
Sync to Local (Staging or Production)
# Sync from STAGING (default) pnpm supabase:web:reset # Sync from PRODUCTION pnpm supabase:web:reset --prod # Or use scripts directly: ./.claude/skills/dev-environment-manager/scripts/sync-prod-to-local.sh --confirm --yes
What it does:
- Reset local database (apply all migrations)
- READ all data from staging/production
- COPY data to local (includes auth.users)
- Verify row counts match
Credentials
Scripts automatically load credentials from:
(preferred).env.local- 1Password (fallback, then cached to .env.local)
Required environment variables:
- Production database passwordSUPABASE_DB_PASSWORD_PROD
- Staging database passwordSUPABASE_DB_PASSWORD_STAGING
Quick Start Examples
Fresh Local Setup (Most Common)
# Start local Supabase + reset with staging data pnpm supabase:web:start pnpm supabase:web:reset
Refresh All Environments
# Full sync: prod → staging → local ./.claude/skills/dev-environment-manager/scripts/sync-prod-to-staging.sh --confirm --yes pnpm supabase:web:reset
Reset Without Sync
# Fresh migrations, no external data pnpm supabase:reset:no-sync
Pre-Deployment
# Run all checks before deploying ./.claude/skills/dev-environment-manager/scripts/pre-deployment-checks.sh
Database References
| Environment | Project Ref | Host | Port |
|---|---|---|---|
| Production | | | 5432 |
| Staging | | | 5432 |
| Local | N/A | | 54322 |
Troubleshooting
"Local Supabase is not running"
cd apps/web && pnpm supabase start
"Failed to get password from 1Password"
# Authenticate with 1Password op signin # Or set credentials manually in apps/web/.env.local: SUPABASE_DB_PASSWORD_PROD="your-password" SUPABASE_DB_PASSWORD_STAGING="your-password"
"Connection timeout"
- Ensure you're using
(not aws-0)aws-1-eu-central-1.pooler.supabase.com - Check network/VPN connection
- Verify credentials are correct
Resetting Remote Database (Staging)
WARNING:
supabase db reset has --local=true by default!
# WRONG - This resets BOTH local AND staging! supabase db reset --db-url "postgresql://staging..." # CORRECT - Only reset staging supabase db reset --db-url "postgresql://staging..." --local=false
For staging schema reset, prefer using the sync script which handles this correctly:
./.claude/skills/dev-environment-manager/scripts/sync-prod-to-staging.sh --confirm --yes
Vercel Environment Variables
Fix Trailing Newlines
Vercel env vars sometimes get trailing
\n characters that break API connections.
# Fix production only (interactive) ./.claude/skills/dev-environment-manager/scripts/fix-production-env-vars.sh # Fix production only (non-interactive) ./.claude/skills/dev-environment-manager/scripts/fix-production-env-vars.sh --yes # Fix preview/staging only ./.claude/skills/dev-environment-manager/scripts/fix-production-env-vars.sh --env preview --yes # Fix ALL environments (preview + production) ./.claude/skills/dev-environment-manager/scripts/fix-production-env-vars.sh --env all --yes
What it does:
- Pulls current env vars from Vercel
- Finds vars with trailing
characters\n - Removes and re-adds them using
(no trailing newline)echo -n - Verifies the fix worked
Verify Environment Variables
./.claude/skills/dev-environment-manager/scripts/verify-production-env-vars.sh
Related Skills
- Query production/staging databasesproduction-database-query
- Create and apply migrationsdatabase-migration-manager