Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AI Builder Club Skills setup sh

From Leeroopedia
Knowledge Sources
Domains Dev_Environments, Cloud_Infrastructure
Last Updated 2026-10-24 00:00 GMT

Overview

Concrete tool for bringing a full dev stack up idempotently (docker → services → env → deps → migrate → dev server), designed for both cloud box and local use, provided by the crabbox-setup skill.

Description

The setup.sh script is an idempotent full-stack boot script that runs inside a crabbox cloud box (backgrounded by cbx_sh) or locally. Every step is check-before-act: if Docker is already running, skip; if the dev server is already serving, skip; if .env.local exists, don't overwrite. It emits a STACK READY marker when complete, which cbx.sh polls for. Includes timing phases for diagnostics and supports optional pre-baked Docker image loading.

Usage

Run on a crabbox cloud box via cbx.sh up (which backgrounds this script and polls for STACK READY), or run locally with bash setup.sh. Edit the INSTALL_CMD, DEV_CMD, MIGRATE_CMD, and NEEDS_DOCKER config variables for the target project.

Code Reference

Source Location

Signature

# Config section (EDIT for target project):
APP_PORT=3000
INSTALL_CMD="pnpm install"
DEV_CMD="pnpm dev"
MIGRATE_CMD="pnpm run db:migrate"  # must be non-destructive & idempotent
NEEDS_DOCKER=1                     # 1 if containers needed, else 0

# Key internal function:
phase()  # prints elapsed time per phase for diagnostics

# Execution phases (idempotent at each step):
# 1. Docker: start dockerd if not running, wait for readiness
# 2. Env: ensure .env.local exists, inject forwarded secrets
# 3. Services: start DB/infra idempotently (e.g. supabase)
# 4. Install: run INSTALL_CMD
# 5. Migrate: run MIGRATE_CMD (if set)
# 6. Dev server: start if not already serving, wait for health check
# 7. Emit: "STACK READY"

Import

# Run on a cloud box (via cbx.sh which backgrounds it):
# cbx.sh up agent1  # internally runs: setsid bash setup.sh >/tmp/setup.log 2>&1

# Or run locally:
bash setup.sh

I/O Contract

Inputs

Name Type Required Description
APP_PORT int Config Dev server port (default: 3000)
INSTALL_CMD str Config Package install command (e.g. pnpm install)
DEV_CMD str Config Dev server start command (e.g. pnpm dev)
MIGRATE_CMD str Config DB migration command (must be non-destructive)
NEEDS_DOCKER int Config 1 if containers needed, else 0

Outputs

Name Type Description
STACK READY stdout Marker emitted when all phases complete successfully
/tmp/setup.log file Full setup log (read by cbx.sh logs)
/tmp/dev.log file Dev server log (read on failure)

Usage Examples

Cloud Box Boot

# cbx.sh runs this backgrounded on the box:
unset NODE_OPTIONS
setsid bash setup.sh >/tmp/setup.log 2>&1 </dev/null &

# Polling for readiness (cbx.sh does this):
for _ in $(seq 1 60); do
  grep -q 'STACK READY' /tmp/setup.log && echo "✓ STACK READY"
  sleep 10
done

Local Boot

# Run the same stack locally (idempotent — safe to re-run):
bash setup.sh

# Output:
# [setup] docker already up
# [t] +0s (total 0s) — docker up
# [setup] install…
# [t] +12s (total 12s) — install
# [setup] migrate…
# [t] +3s (total 15s) — migrate
# [setup] dev server already up
# [t] +0s (total 15s) — dev server up
# STACK READY

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment