Universal devstart Command on Windows

This guide shows how to build a reusable devstart CLI command for local development.

Why this is useful in real projects

In day-to-day development, a lot of time is lost on repetitive startup tasks:

  • opening the same folders in multiple terminals
  • starting Docker manually
  • waiting for the daemon to be ready
  • launching backend and frontend in the right order

A small command layer (devstart <project>) removes this friction and gives you:

  • faster context switches between projects
  • a consistent startup flow for the whole team
  • less onboarding pain for new developers
  • one place to evolve your local setup over time

What you are building

You will create a modular setup:

  • one global dispatcher script: devstart.bat
  • one script per project in projects\
  • optional Docker startup with a readiness wait loop
  • automatic terminal windows for services (API, web app, workers, etc.)

After setup, you can run:

devstart demo

from any directory.

Prerequisites

  • Windows 10/11
  • Docker Desktop (if your project needs containers)
  • Command line tools your project needs (git, node, python, etc.)

Step 1: Create folder structure

Create a central script directory in your user profile:

  1. Open File Explorer.
  2. Go to C:\Users\<YourUserName>.
  3. Create folder devscripts.
  4. Inside it, create folder projects.

Final structure:

C:\Users\<YourUserName>\devscripts\projects

Step 2: Create the dispatcher script (devstart.bat)

Create C:\Users\<YourUserName>\devscripts\devstart.bat with:

@echo off
setlocal
set "PROJECTS_DIR=%~dp0projects"

:: 1) Validate input
if "%~1"=="" goto SHOW_HELP

:: 2) Resolve target script
set "PROJECT_NAME=%~1"
set "PROJECT_SCRIPT=%PROJECTS_DIR%\%PROJECT_NAME%.bat"

:: 3) Ensure script exists
if not exist "%PROJECT_SCRIPT%" (
    echo [ERROR] Project "%PROJECT_NAME%" not found.
    echo.
    goto SHOW_HELP
)

:: 4) Run project script
echo ============================================
echo [devstart] Launching project: %PROJECT_NAME%
echo ============================================
call "%PROJECT_SCRIPT%"
exit /b %ERRORLEVEL%

:SHOW_HELP
echo Usage: devstart ^<project-name^>
echo Available projects:
for %%f in ("%PROJECTS_DIR%\*.bat") do echo   - %%~nf
echo.
exit /b 1

Why this design:

  • keeps one stable entry point (devstart)
  • avoids hardcoding project logic in one huge file
  • scales well as you add more repositories

Step 3: Create one project script (template)

For each project, create one .bat file in:

C:\Users\<YourUserName>\devscripts\projects

Example: demo.bat

@echo off
title Devstart - Demo Project
setlocal

:: Adjust this to your local repository path
set "BASE_DIR=C:\Path\To\Your\Project"
set "DOCKER_EXE=C:\Program Files\Docker\Docker\Docker Desktop.exe"

echo ----------------------------------------
echo [1/3] Ensuring Docker is ready...
echo ----------------------------------------

:: If Docker daemon is not ready, try to start Docker Desktop
docker info >nul 2>&1
if errorlevel 1 (
    if exist "%DOCKER_EXE%" (
        echo Starting Docker Desktop...
        start "" "%DOCKER_EXE%"
    ) else (
        echo [WARN] Docker Desktop executable not found:
        echo        %DOCKER_EXE%
    )
)

:: Wait loop (max ~120s) until Docker responds
set /a RETRIES=0
:WAIT_DOCKER
docker info >nul 2>&1
if not errorlevel 1 goto DOCKER_READY
set /a RETRIES+=1
if %RETRIES% geq 40 (
    echo [WARN] Docker not ready after 120 seconds. Continuing anyway...
    goto START_TERMINALS
)
timeout /t 3 /nobreak >nul
goto WAIT_DOCKER

:DOCKER_READY
echo Docker daemon is ready.

:START_TERMINALS
echo ----------------------------------------
echo [2/3] Starting development terminals...
echo ----------------------------------------

:: Backend example (Python/FastAPI)
start "Demo Backend" cmd /k "cd /d ""%BASE_DIR%\backend"" && call .\venv\Scripts\activate.bat && uvicorn main:app --reload"

:: Frontend example (Node/Vite/Next)
start "Demo Frontend" cmd /k "cd /d ""%BASE_DIR%\frontend"" && npm run dev"

echo ----------------------------------------
echo [3/3] Startup finished.
echo ----------------------------------------

Practical notes:

  • The Docker wait loop prevents race conditions where containers fail because Docker was not ready yet.
  • Keep each project script focused on startup only. Heavy setup steps (npm install, migrations) should usually stay explicit.
  • If you need more services, add more start "Name" cmd /k "..." lines.

Step 4: Add devscripts to your PATH

To run devstart from anywhere:

  1. Press the Windows key and search for Environment Variables.
  2. Open Edit environment variables for your account.
  3. Click Environment Variables....
  4. In User variables, select Path and click Edit....
  5. Click New.
  6. Add C:\Users\<YourUserName>\devscripts.
  7. Confirm all dialogs with OK.

Step 5: Test the setup

  1. Close all currently open terminals (to reload PATH).
  2. Open a new terminal (PowerShell, cmd, or integrated terminal in your IDE).
  3. Run:
devstart demo

If you run devstart without arguments, it shows all available project scripts from projects\.

Step 6: Team usage recommendation

If multiple developers work on the same stack:

  • share a base template for project scripts
  • agree on terminal names and startup order
  • document project-specific prerequisites at the top of each .bat file

This keeps local development predictable and reduces "works on my machine" startup differences.