Generate isolated dev/test/prod environments for uvicorn/FastAPI projects with frontend support (Vue/React) with one command.
This skill solves a common problem in multi-agent AI teams: developers, testers, and production users stepping on each other's toes. It generates a complete environment isolation setup so that:
Each environment gets its own config file, startup scripts (backend + frontend), database, media storage, and Playwright test configuration — completely isolated from the others.
Running the setup script creates this structure inside the target project:
text
your-project/
├── .env.dev # Dev config: DEBUG=True, hot reload, no rate limit
├── .env.test # Test config: rate limiting enabled, QA settings
├── .env.prod # Prod config: DEBUG=False, secure CORS, multi-worker
├── scripts/
│ # Backend scripts
│ ├── start-backend-dev.sh # Starts dev server on port 8000 with --reload
│ ├── start-backend-test.sh # Starts test server on port 8001
│ └── start-backend-prod.sh # Starts prod server on port 8002 with auto workers
│ # Frontend scripts (Vue/React)
│ ├── start-frontend-dev.sh # Starts dev frontend on port 3000
│ ├── start-frontend-test.sh # Starts test frontend on port 3001
│ └── start-frontend-prod.sh # Starts prod frontend on port 4173 (preview)
│ # Test scripts
│ └── run-playwright-tests.sh # Runs Playwright E2E tests on test environment
├── data/
│ ├── dev/ # Dev database + media uploads (safe to delete)
│ │ └── media/
│ ├── test/ # Test database + media uploads
│ │ └── media/
│ └── prod/ # Prod database + media uploads (back this up!)
│ └── media/
├── docs/
│ └── MULTI_ENV_SETUP.md # Auto-generated setup guide for the team
├── cloud_docs/frontend/
│ └── playwright.config.ts # Playwright test config (if frontend exists)
└── .gitignore # Updated to exclude .env.* and data/
bash
python3 scripts/setup_envs.py /path/to/your-project \
--name "Your Project Name" \
--dev-backend-port 8000 \
--dev-frontend-port 3000 \
--test-backend-port 8001 \
--test-frontend-port 3001 \
--prod-backend-port 8002 \
--prod-frontend-port 4173 \
--dev-user "Valina" \
--test-user "Choco" \
--app-module "server.main:app" \
--frontend-dir "cloud_docs/frontend"
All flags except --name are optional and have sensible defaults.
bash
# For Valina (Development)
./scripts/start-dev.sh # Starts both backend (8000) and frontend (3000)
# For Choco (Testing)
./scripts/start-test.sh # Starts both backend (8001) and frontend (3001)
./scripts/run-playwright-tests.sh # Runs E2E tests
# For Production
./scripts/start-prod.sh # Starts both backend (8002) and frontend (4173)
Edit the generated .env.dev, .env.test, .env.prod files to add project-specific settings like API keys, external service URLs, etc.
bash
# For development (hot reload enabled)
./scripts/start-dev.sh
# For testing
./scripts/start-test.sh
# For production
./scripts/start-prod.sh
Each script loads its own .env.* file, uses its own port, and writes to its own data/ subdirectory.
text
python3 scripts/setup_envs.py <project_dir> --name <name> [options]
FlagDefaultDescriptionproject_dir(required)Path to the target project--name(required)Project name, used in configs and docs--dev-port8020Development server port--test-port8010Testing server port--prod-port8000Production server port--dev-user(none)Developer name, shown in dev startup message--test-user(none)Tester name, shown in test startup message--db-typesqlitesqlite or postgres``--app-moduleserver.main:appUvicorn application module path--dev-db(auto)Override dev database URL--test-db(auto)Override test database URL--prod-db(auto)Override prod database URL
SettingDev (Valina)Test (Choco)ProdBackend Port800080018002Frontend Port300030014173DEBUGTrueTrueFalseHot ReloadYesNoNoCORSAllow AllAllow AllRestrictedRate LimitingOffOnOnWorkers1 (reload)1Auto (CPU cores)Log LevelDEBUGINFOWARNINGDatabasedata/dev/``data/test/``data/prod/Mediadata/dev/media/``data/test/media/``data/prod/media/Playwright Tests❌ Not recommended**✅ Recommended**❌ Never
For teams using this setup:
text
main ──────────── Production (start-prod.sh) - Ports 8002/4173
├── release/* ── Testing (start-test.sh + run-playwright-tests.sh) - Ports 8001/3001
└── feature/* ── Development (start-dev.sh) - Ports 8000/3000
feature/*, deploys to dev environment (8000/3000)release/*, Choco (Tester) validates on test environment (8001/3001)./scripts/run-playwright-tests.shmain, deploy to production (8002/4173)Key benefit: Valina and Choco can work simultaneously without conflicts!
text
Time | Valina (Dev) | Choco (Test)
------|---------------------------|---------------------------
14:00 | start-dev.sh (8000/3000) | -
14:05 | Continue coding... | start-test.sh (8001/3001)
14:10 | Continue coding... | run-playwright-tests.sh
14:20 | Continue coding... | Tests pass! Report results
14:25 | Continue coding... | stop-test.sh
No port conflicts! No data interference! ✅
.env.dev already exists, the script skips it and prints a warning. Safe to re-run.start-backend-*.sh scripts use uvicorn commands. For other frameworks, modify the scripts after generation.start-frontend-*.sh scripts use npm run dev and npm run preview. For Vite projects, they work out of the box..env.prod has a placeholder JWT_SECRET. Replace it with a strong random value before going live.data/prod/ directory contains the production database. Set up regular backups.npm install -D @playwright/testFor all environment variables and troubleshooting: read references/config-options.md