Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Start all local services (backend, frontend, docs) with dependency checking, error diagnosis, and automatic recovery. Handles missing npm/python packages, port conflicts, and stale processes.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-08 | ✗→✓ | ▲ Improved | 79% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 37% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 35% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 124% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 45% | 0% |
Start all local development services with pre-flight dependency checks and automatic error recovery.
This command automates the full startup workflow:
run_services.shPorts are allocated in groups of 3 with a +10 offset between groups:
| Group | Frontend | Backend | Docs | |-------|----------|---------|------| | Default | 8080 | 8081 | 8082 | | +10 | 8090 | 8091 | 8092 | | +20 | 8100 | 8101 | 8102 | | +30 | 8110 | 8111 | 8112 | | +40 | 8120 | 8121 | 8122 |
| Service | Env Var | Base Port | |---------|---------|-----------| | Frontend (Next.js) | FRONTEND_PORT | 8080 | | Backend (FastAPI) | BACKEND_PORT | 8081 | | Docs (Fumadocs) | DOCS_PORT | 8082 | Step 0 (Smart Port Selection) determines which group to use automatically, unless ports are already set via environment variables.
Pre-check: If BACKEND_PORT, FRONTEND_PORT, or DOCS_PORT are already set in the environment, skip auto-detection entirely and use those values directly. Report "Using pre-configured ports" and proceed to Step 1.
0.1 Get current worktree root:
bashWORKTREE_ROOT=$(git rev-parse --show-toplevel)
0.2 For each port group (offset 0, 10, 20, 30, 40 — max 5 attempts), check all 3 ports in the group. For each port, determine its status:
bashPID=$(lsof -t -i:$PORT 2>/dev/null | head -1)
If no PID → port is free.
If PID exists, get the process's working directory:
bashPROC_CWD=$(lsof -a -p $PID -d cwd -Fn 2>/dev/null | tail -1 | sed 's/^n//')
Then classify:
$PROC_CWD starts with $WORKTREE_ROOT (use prefix match, since child processes like Next.js run from subdirectories like $WORKTREE_ROOT/reflexio/website)$PROC_CWD does NOT start with $WORKTREE_ROOT0.3 Decision per group:
0.4 Export the chosen ports:
bashexport FRONTEND_PORT=<8080+N> export BACKEND_PORT=<8081+N> export DOCS_PORT=<8082+N> export API_BACKEND_URL="http://localhost:${BACKEND_PORT}"
Report which group was selected and why, e.g.:
Also record whether any ports in the chosen group were "own" (needs stop) or all "free" (skip stop).
Run these checks before starting anything. They are idempotent and fast when deps are already installed.
Python dependencies (run first — creates .venv if missing):
bashuv sync
Activate virtual environment (after uv sync so .venv exists):
bashsource .venv/bin/activate
Worktree editable packages: In a git worktree, uv sync may resolve reflexio_commons and reflexio_client to a different worktree's path. Check and fix:
bashpython -c "import reflexio_commons; import os; assert os.path.abspath(reflexio_commons.__file__).startswith(os.path.abspath('.'))" 2>/dev/null || uv pip install -e reflexio/reflexio_commons -e reflexio/reflexio_client
Frontend dependencies (reflexio/website): Check if node_modules exists and has content. If missing or empty, install:
bashls reflexio/website/node_modules/.package-lock.json 2>/dev/null || (cd reflexio/website && npm install)
Docs dependencies (reflexio/public_docs): Check if node_modules exists and has content. If missing or empty, install:
bashls reflexio/public_docs/node_modules/.package-lock.json 2>/dev/null || (cd reflexio/public_docs && npm install)
If any ports in the chosen group were classified as "own" in Step 0: stop existing services first:
bash./stop_services.sh
Wait 2 seconds for ports to fully release.
If all ports were "free": skip this step entirely — nothing to stop.
Run run_services.sh in the background with the exported port variables:
bashFRONTEND_PORT=$FRONTEND_PORT BACKEND_PORT=$BACKEND_PORT DOCS_PORT=$DOCS_PORT ./run_services.sh > /tmp/reflexio-services.log 2>&1 &
Wait ~15 seconds for services to boot. Next.js compilation takes time on first request.
Check each service individually. Use curl --max-time 10 -s -o /dev/null -w "%{http_code}" to get HTTP status codes.
Backend:
bashcurl --max-time 10 -s -o /dev/null -w "%{http_code}" http://localhost:${BACKEND_PORT}/health
Expected: 200
Frontend:
bashcurl --max-time 10 -s -o /dev/null -w "%{http_code}" http://localhost:${FRONTEND_PORT}
Expected: 200 or 3xx (redirect is OK)
Docs:
bashcurl --max-time 10 -s -o /dev/null -w "%{http_code}" http://localhost:${DOCS_PORT}
Expected: 200 or 3xx (redirect is OK)
A status of 000 means the service is not responding at all.
If any health check fails, read the log for error details:
bashcat /tmp/reflexio-services.log
Also check if processes are even running:
bashlsof -i:${BACKEND_PORT} -i:${FRONTEND_PORT} -i:${DOCS_PORT}
a. "Cannot find package" / "Cannot find module" (npm) An npm dependency is missing. Fix:
bash# Identify which service (website or public_docs) from the error path cd reflexio/website && npm install # or reflexio/public_docs
Then retry from Step 3.
b. "ModuleNotFoundError" / "ImportError" (Python — general) A Python dependency is missing. Fix:
bashuv sync
Then retry from Step 3.
b2. "ModuleNotFoundError" for reflexio_commons or reflexio_client (worktree path mismatch) In a worktree, editable packages may resolve to a different worktree's path. Fix:
bashuv pip install -e reflexio/reflexio_commons -e reflexio/reflexio_client
Then retry from Step 3.
c. "Address already in use" / "EADDRINUSE" A port is still occupied. Fix:
bash# Kill whatever is on the port lsof -t -i:PORT | xargs kill -9 2>/dev/null
Wait 2 seconds, then retry from Step 3.
d. ".next build cache errors" / "ENOENT .next" Stale Next.js build artifacts. Fix:
bashrm -rf reflexio/website/.next reflexio/public_docs/.next
Then retry from Step 3.
e. Script syntax errors or unknown errors Report the error output to the user and suggest manual steps. Do not retry.
Report a summary table:
Service | Port | Status
-----------|-------|-------
Backend | 8091 | Running
Frontend | 8090 | Running
Docs | 8092 | Running
Port group: offset +10 (8090/8091/8092) — default ports occupied by another worktreeInclude the port group selection reason in the summary (e.g., "all free", "restarting own services", "default ports occupied by another worktree").
If all services are running, confirm success. If any failed after retries, show:
.env files — port overrides come from shell environment variables only/tmp/reflexio-services.log contains combined service outputBACKEND_PORT, FRONTEND_PORT, or DOCS_PORT env vars are already setOther measured skills in the registry, with their headline benchmark lift.