---
name: homemade-doctor
description: Get a repository running on Homemade: write its .homemade/config.jsonc, test it on a Homemade computer, and open a pull request with it.
---

# Project Doctor

You get a repository running on Homemade. The result is one file, `.homemade/config.jsonc`, tested on a real Homemade computer and proposed as a pull request. You never change the project's own code.

Before anything else, run `homemade upgrade` so the CLI is the latest release. If it fails, say so and carry on with the installed version.

You need the Homemade CLI signed in (`homemade whoami`) and the project created on Homemade (`homemade project list`). If either is missing, follow https://www.homemade.dev/get-started.md first.

## On a Homemade computer

If `/etc/homemade/HOMEMADE.md` exists, you are already on a Homemade computer, and the repository is checked out at `/workspace/app`. Work there. The steps change like this:

- Skip the CLI upgrade and the sign-in and project checks. This computer acts as its owner: `homemade-agent whoami` shows who that is, and `$HOMEMADE_PROJECT` names the project.
- Step 4: the `homemade` CLI is not installed here. Install it from https://www.homemade.dev/install.sh if you want `homemade config validate`. If it cannot sign in, check the file against the platform guide yourself and say in the pull request that the file was not validated.
- Step 5: the person's local env files are not on this computer, so skip the helper. The project's env values are already in the environment here (`envreload` refreshes a shell). List the names the app still needs in the pull request.
- Step 6: test on this computer, in `/workspace/app`. Do not create another one. Run each `setup`, `warmup` and `install` command here, then apply your services in place and read their health:

```sh
homemade-agent services apply --file .homemade/config.jsonc --wait 60 --json
homemade-agent services health --wait 60 --json
```

  The answers and the loop are the same as in step 6 below: fix and apply again until `ready` is true, and probe each port with `curl` on `127.0.0.1`.
- Step 7: skip it. This computer is the person's, so leave it running.
- Step 8 works as written, and `git push` from here acts as the owner. What you applied lives only on this computer until the pull request is merged, so give the same reason for the pull request.

## Steps

1. Read the repository: README, lockfiles, package scripts, Makefile, Procfile, Dockerfile, compose files, CI workflows, `.env.example`, and an existing `.devcontainer/` or `.homemade/`.
2. Write `.homemade/config.jsonc` by the platform guide below: `setup`, `warmup`, `install`, `services`, `env_schema`. Start the file with `// Generated by Project Doctor` and keep comments short.
3. Decide where each env variable lives. The committed config never holds a value for anything secret-looking:
   - A non-secret dev value (a local `DATABASE_URL`, `APP_URL = ${HOMEMADE_URL_3000}`, a port, a feature flag): `{"key": "APP_URL", "default": "${HOMEMADE_URL_3000}"}` in `env_schema`.
   - A dev secret the app signs or encrypts with itself (session key, JWT secret, cron secret): `{"key": "SECRET_KEY_BASE", "generate": true}`. The platform makes a random value per computer.
   - Everything else that looks like a secret: list only the name in `env_schema` (`"OPENAI_API_KEY"`), with no `default`. That means a name containing KEY, SECRET, TOKEN, PASSWORD, PRIVATE, CREDENTIAL, DSN or WEBHOOK, or a value that is a JWT, an `sk-`/`pk_`/`rk_` key, a PEM block or a long random string. No demo values (not even Supabase's well-known local keys) and no placeholders such as `dev-placeholder`: `homemade config validate` rejects them. The value goes to the project's environment in step 5 or is added by the person in the project's settings on https://www.homemade.dev (Project settings, then Environment).
   - The app cannot boot without a value and the person has none: do not invent one in the config. Offer it in step 5 as a placeholder stored in the project's environment (sensitive), and only with their approval.
4. Check the file: `homemade config validate` (from the repository root). Fix what it reports.
5. Import the person's local development env vars into their own Homemade project, only after they approve. Many services cannot boot without a value they only have locally (an API key, a database password), so a project that lacks them starts and then fails. You never read the values: a small helper reads the person's own local env files and posts the approved ones to their own project's environment settings through Homemade's API, using their own Homemade sign-in. Names appear in the chat, values never do.
   - Save the helper at the end of this file as `~/.cache/homemade/homemade-env-import.py` (create the folder), outside the repository.
   - Scan: `python3 <helper> scan <repo folder>` lists names from `.env`, `.env.development`, `.env.local` and `.env.development.local` (up to three folders deep), with the file, the length of the value, and flags `local` (points at localhost or a file path), `empty` and `conflict` (files disagree; ask which file to use). Use the scan output instead of opening those files.
   - Keep only what the project needs: names in `.env.example`, in the code (`process.env.X`, `os.environ`, `ENV[...]`) or in `env_schema`. Skip names the config already covers with `generate` or a `default`, and `local` ones such as a localhost `DATABASE_URL`: those become `env_schema` defaults (or a service in the config) or stay out. An empty value or a name the app needs but the env files lack: offer a placeholder (see below).
   - Mark each one. Sensitive (stored write-only: nobody can read it back, not even the person in the dashboard): keys, tokens, secrets, passwords, private keys, signing and webhook secrets, DSNs and URLs with credentials. Not sensitive (shown in the dashboard): ports, hostnames, feature flags, public URLs, regions, log levels. When unsure, mark it sensitive.
   - Add a short description (under 100 characters) to every var whose name does not explain itself, sensitive and plain alike: the description is shown in the dashboard and is never secret, only the value is. For example `Stripe test secret key for the api`. Skip it only for names like `PORT`.
   - Show the person one table before you import anything: name, sensitive yes/no, description, which service needs it and what happens without it (for example `api cannot start without it`), and for placeholders the word `placeholder`. Names only. Say plainly that the values will be stored encrypted in their Homemade project and passed to every computer of it, and that a placeholder is a dummy value that lets the app boot with that feature not working. Ask: all, a pick, or none, and wait for the answer. With none, list the names in the pull request instead.
   - Write the approved ones to a JSON file without values, next to the helper: `[{"name":"STRIPE_SECRET_KEY","sensitive":true,"description":"Stripe test key"},{"name":"RESEND_API_KEY","sensitive":true,"placeholder":true}]` (add `"from":"<file>"` to pick one file on a conflict). Then run `python3 <helper> apply <repo folder> https://api.homemade.dev <project id> <that file>`. It prints only names and counts. Delete the JSON file and the helper afterwards.
   - Tell the person which names were imported (never values) and list them in the pull request description. The test computer in step 6 starts with them.
6. Test it on Homemade, live. Where the guide says "this VM", it means a computer you create here:

```sh
homemade vm create --project <slug> --name doctor --wait --json
homemade vm exec <vm> -- 'cd /workspace/app && git fetch -q origin && git status --short | head'
```

   The computer starts from the project's current setup, so your new `setup`, `warmup` and `install` commands have not run there. Run each one with `homemade vm exec <vm> -- '<command>'` (`setup` with sudo); it streams the output as it comes. Set env values those commands need inline, for this test only.

   Then put your services on the computer and read how each one is doing:

```sh
homemade services apply <vm> --config "$(cat .homemade/config.jsonc)" --json
homemade services health <vm> --wait-seconds 60 --json
```

   `services apply` starts new and changed services, stops removed ones, leaves unchanged ones running and moves the links to match. Nothing is rebuilt, so one round takes seconds. Each service comes back as `healthy`, `starting`, `failed` (with its last log lines) or `manual`, and `ready` is true once every service that starts by itself is healthy. `needsImageUpdate` lists the other keys you changed; they only take effect after the pull request is merged.
   - A service `failed`: read its log lines, fix the config (or run the missing `install` command), apply again.
   - A service still `starting`: run `services health` again. A service with a port counts as healthy once the port answers.
   - Every service with a port should answer below 500: `homemade vm exec <vm> -- "curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:<port>/"`.

   Repeat until `ready` is true. Do not open the pull request before that. If a service will not get healthy, tell the person which one and what its log says, and ask how they want to go on.
7. Delete the test computer: `homemade vm delete <vm> --yes`.
8. Open the pull request with the person's own git: a branch named `homemade/setup`, one commit that adds only `.homemade/config.jsonc`, pushed, then a pull request (`gh pr create`, or the compare link GitHub prints). Ask before you push if the person has not agreed to a new branch (an agent following get-started.md already has that agreement).
   - Tell the person in plain words why there is a pull request at all. What you applied lives only on the test computer, which you just deleted. The file in the repository is what Homemade builds the project's ready setup from: once it is merged into the default branch, Homemade updates the project, and from then on every new computer, for any branch or teammate, starts warm with the same services already running. The setup also lives with the code, so it is reviewed and changed like code.
   - Start the description with that reason in one or two sentences. Then list the services and ports, the env names the person must fill in, and anything you could not prove.

Once the pull request is merged, Homemade builds the project from it and every new computer starts with its services running.

## Rules

- Only `.homemade/config.jsonc` is committed. No edits to app code, lockfiles or `.env` files, and no new dependencies. Env values go to the project (step 5), never into a repository file.
- Services run the app's dev mode with live reload. No fixed sleeps; readiness is `depends_on` plus a `healthcheck`.
- No secret value in the repository, not even a demo key or a placeholder (`homemade config validate` rejects it), and none in the chat or in commands you show the person. Import env vars only after the person approves the table in step 5.
- Never install a database or a browser on the test computer by hand: databases are services in the config.

## Env import helper (step 5)

```python
import json, os, re, sys, urllib.error, urllib.request
from pathlib import Path

ORDER = [".env", ".env.development", ".env.local", ".env.development.local"]
SKIP = {"node_modules", ".git", "dist", "build", ".next", "vendor", "target", ".venv", "tmp"}
LOCAL = re.compile(r"(localhost|127\.0\.0\.1|0\.0\.0\.0|host\.docker\.internal|^[./~]|^file:)", re.I)
LINE = re.compile(r"^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$")

def parse(text):
    out, lines, i = {}, text.splitlines(), 0
    while i < len(lines):
        m = LINE.match(lines[i]); i += 1
        if not m:
            continue
        k, v = m.group(1), m.group(2).strip()
        if v and v[0] in "\"'":
            q = v[0]
            while v.count(q) < 2 and i < len(lines):
                v += "\n" + lines[i]; i += 1
            end = v.rfind(q)
            v = v[1:end] if end > 0 else v[1:]
            if q == '"':
                v = v.replace("\\n", "\n").replace('\\"', '"')
        else:
            v = re.split(r"\s+#", v, maxsplit=1)[0].strip()
        out[k] = v
    return out

def collect(root):
    found = {}
    for d, dirs, files in os.walk(root):
        dirs[:] = [x for x in dirs if x not in SKIP]
        if len(Path(d).relative_to(root).parts) > 3:
            dirs[:] = []
        for f in files:
            if f in ORDER:
                p = Path(d) / f
                for k, v in parse(p.read_text(errors="replace")).items():
                    found.setdefault(k, []).append((ORDER.index(f), str(p.relative_to(root)), v))
    return found

def pick(entries, source=None):
    if source:
        return next(v for _, s, v in entries if s == source)
    return sorted(entries, key=lambda e: (e[0], -len(e[1])))[-1][2]

def scan(root):
    rows = []
    for k, e in sorted(collect(root).items()):
        vals = {v for _, _, v in e}
        v = pick(e)
        rows.append({"name": k, "files": sorted({s for _, s, _ in e}), "length": len(v),
                     "empty": v == "", "local": bool(LOCAL.search(v)), "conflict": len(vals) > 1})
    for r in rows:
        print(json.dumps(r))

def token(api):
    if os.environ.get("HOMEMADE_API_KEY"):
        return os.environ["HOMEMADE_API_KEY"]
    host = re.sub(r"[^a-z0-9.\-]", "_", api.split("://")[-1].split("/")[0].lower())
    base = Path(os.environ.get("XDG_CONFIG_HOME") or Path.home() / ".config") / "homemade"
    for name in (f"credentials.{host}.json", "credentials.json"):
        try:
            c = json.loads((base / name).read_text())
        except (OSError, ValueError):
            continue
        if c.get("api_url", "").split("://")[-1].rstrip("/") == api.split("://")[-1].rstrip("/"):
            return c["token"]
    sys.exit("not signed in: run homemade login")

def apply(root, api, project, decisions):
    found, chosen, secrets = collect(root), [], []
    for d in json.loads(Path(decisions).read_text()):
        e = found.get(d["name"])
        if e:
            v = pick(e, d.get("from"))
        elif d.get("placeholder"):
            v = "homemade-placeholder"
        else:
            print("skipped (not in a local env file):", d["name"]); continue
        if d.get("placeholder") and not v:
            v = "homemade-placeholder"
        item = {"key": d["name"], "value": v, "isSecret": bool(d["sensitive"])}
        if d.get("description"):
            item["comment"] = d["description"][:1000]
        chosen.append(item); secrets.append(v)
    tok, done = token(api), []
    for n in range(0, len(chosen), 100):
        batch = chosen[n:n + 100]
        req = urllib.request.Request(api + "/api/env-vars", method="POST",
            data=json.dumps({"projectId": project, "vars": batch}).encode(),
            headers={"Authorization": "Bearer " + tok, "Content-Type": "application/json",
                     "User-Agent": "homemade-env-import/1"})
        try:
            body = urllib.request.urlopen(req).read().decode()
        except urllib.error.HTTPError as err:
            body = err.read().decode()[:300]
            for s in filter(None, secrets):
                body = body.replace(s, "***")
            sys.exit(f"failed: HTTP {err.code} {body}")
        done += [b["key"] for b in batch]
        print(body)
    print("imported:", ", ".join(done))

cmd = sys.argv[1:]
if cmd[:1] == ["scan"]:
    scan(Path(cmd[1]))
elif cmd[:1] == ["apply"]:
    apply(Path(cmd[1]), cmd[2].rstrip("/"), cmd[3], cmd[4])
else:
    sys.exit("usage: scan <repo> | apply <repo> <api url> <project id> <decisions.json>")
```

## Platform guide

The guide below describes how a Homemade VM runs a project and the usual shape of a config. Env values go into `env_schema` as in step 3.

# How a Homemade VM runs a project

A project's VMs boot from a TEMPLATE built from the repo's `.homemade/config.json`. Phases, in order:
1. `setup` (template BUILD, as root, before the repo is copied: only lockfiles and manifests exist). System packages and tools: `apt-get install -y --no-install-recommends ...`, a CLI, a database binary. Baked into the image. No project env vars here. Build-time tool flags inline are fine (`DEBIAN_FRONTEND=noninteractive apt-get ...`).
2. `warmup` (once, in a throwaway VM from the built template, repo present in /workspace/app, then snapshotted; the snapshot's disk is also what every later cold boot starts from). Expensive one-time work every VM should start with: the dependency install that fills the caches (`npm ci`, `uv sync`, `bundle install`, `./mvnw dependency:go-offline`) AND the slow first compile (`cargo build`, `mix deps.get && mix compile`, `./mvnw -DskipTests compile`, `./gradlew classes`, `dotnet build`), so its output (target/, _build/, bin/obj) is baked in, and the docker images the services run (`docker pull postgres:17`, `docker compose -f <file> pull --quiet --ignore-pull-failures`, `docker compose -f <file> build`). Services do NOT run during warmup, so a migration or seed that needs the database stays in the service cmd. Only env vars marked `{"key": "...", "warmup": true}` in `env_schema` exist here.
3. `install` (EVERY boot, cold or restored from the warm snapshot, in /workspace/app, as user homemade, best-effort: a failure is shown to the user but does not stop the boot). Idempotent and fast: the frozen dependency install (a no-op when warmup did it), then code generation the app needs before it starts (see Recipes). A file the app cannot START without (a downloaded web bundle or asset tarball, a generated key file) goes here too, guarded so it is a no-op once present (`[ -f web-vault/index.html ] || { curl … | tar xz; }`), and also in warmup: the first boot of a new config can start before any warmup snapshot exists, so a file only warmup fetches is missing there. Never a full compile or build here (no `cargo build`, `mix compile`, `dotnet build`, `./gradlew build`): the dev server compiles what changed when it starts, and a compile in install blocks every boot whose disk lacks the warmup output for many minutes. Output goes to /var/log/homemade-install.log.
   Warmup whenever possible: a warm restore still runs install, so every second in install is paid on every boot, while warmup's work is paid once per snapshot. Every dependency install in install is ALSO in warmup (install then only checks it); `npm ci` deletes node_modules, so install uses `[ node_modules/.package-lock.json -nt package-lock.json ] || npm ci` with plain `npm ci` in warmup; `bundle check || bundle install` for Bundler. The lint refuses a dependency install in install that warmup lacks, an unguarded `npm ci` in install, and a compile or image pull in install.
4. `services` (EVERY boot, after install). Each service with a `cmd` runs ONCE in its own terminal as `export PORT=<port>; <cmd>` (PORT only when a port is declared). Services start together, except one with `depends_on`: the platform starts it once each dependency is healthy (or only started, if that is the condition), however long that takes (no time limit; if a dependency exits, the dependent stays unstarted and reports failed). There is NO restart: a cmd that exits stays dead (the platform reports its exit code).

Tools: mise installs Node, Python, uv, Bun, Deno, Go, Java, pnpm, Maven, Gradle and Rust on first use and honours the repo's version files (.nvmrc, .node-version, .python-version, .tool-versions, mise.toml, package.json "packageManager"/engines, rust-toolchain.toml). PHP, Composer, Ruby/Bundler, Erlang/Elixir, .NET, Kotlin, Docker and a few more come from the host on first use (launchers in /opt/homemade/tools-bin). `/etc/homemade/TOOLS.md` lists every tool and version this VM can get: read it before installing anything. A version the repo pins that is not there (an older Ruby, .NET or JDK) goes into `setup` (mise, or the vendor's install script), never installed by hand in this VM only. Docker works inside the VM.

Env vars: project env vars (set in the dashboard) reach install, services and terminals at every boot; `/etc/homemade/env` holds them (reload a shell with `set -a; . /etc/homemade/env; set +a`). A value can reference ${HOMEMADE_URL_<port>}: it resolves per VM to the public https URL of that port (e.g. BETTER_AUTH_URL = ${HOMEMADE_URL_3000}). `env_schema` lists the NAMES the project needs (never values).
Dev secrets (a session key, app key, JWT secret, a pairing or login token) are never plain env values: list each one in the config's `env_schema` as `{"key": "SECRET_KEY_BASE", "generate": true}`. The platform makes a random value per VM on its first boot, so every VM (and every fork of the repo) gets its own and nothing is shared or committed. It does not exist in warmup (`generate` cannot combine with `warmup: true`). This VM was booted before your config: to test here, export a value in the shell that runs the service (`export SECRET_KEY_BASE=$(openssl rand -base64 32)`).

Services: `{"cmd": "...", "port": 3000, "url": true, "healthcheck": {"path": "/"}}`. `port` + `url: true` gives the service a public URL; the app must listen on 0.0.0.0 or 127.0.0.1 (IPv4) at that port. `healthcheck` makes the platform probe http://127.0.0.1:<port><path> (any status below 500 is healthy, so a page that answers 500 is NOT up). A `port` without a healthcheck is healthy while something listens on it. `"healthcheck": {"cmd": "..."}` probes with a shell command instead (exit 0 is healthy, no port needed), for a service that speaks no HTTP: `docker exec appdb pg_isready -h 127.0.0.1 -q`, `redis-cli ping`. `"depends_on": {"db": {"condition": "healthy"}}` makes a service wait for another one ("healthy" is the default; "started" waits only for its terminal). "healthy" needs the dependency to report health: a port or a healthcheck. Optional: `displayName`, `icon`, `order` (display order only), `hidden`, `autostart`.
Sign-in links: an app whose UI is unlocked by a token in a link (a pairing URL, a bootstrap secret, a one-time admin link the README tells you to open) gets `"signInUrl"` on its `url: true` service, a template the VM page resolves and shows with copy and open buttons: `"signInUrl": "${HOMEMADE_URL_5733}/pair#token=${T3CODE_DEV_AUTH_TOKEN}"`. ${HOMEMADE_URL_<port>} is a url port of the config; every other ${KEY} is an `env_schema` key (usually a `generate: true` one the app reads as its token). Never write the link or the token to a file for the user to find; `signInFile` no longer exists.

Preview URLs: each `url: true` port is public at https://{project}-{vm}-{port}-{org}.onhomemade.com (onhmmd.com on staging). The platform's proxy hands the app every request as if the browser had opened http://localhost:<port>: Host, Origin and Referer are rewritten, X-Forwarded-Host/-Proto are dropped, a redirect to localhost:<port> goes back to the preview URL, and WebSockets (hot reload) pass through. So dev servers' host and origin checks pass with their dev defaults: do NOT add allowedHosts, ALLOWED_HOSTS, CSRF_TRUSTED_ORIGINS, config.hosts, allowedDevOrigins, check_origin or HMR host/port settings for the preview, and never edit a vite/next/settings file for it. What the app still needs, as `env_schema` entries with a `default`:
- A base URL setting the app uses for links a browser or another service opens (emails, OAuth callbacks, an API URL baked into the frontend: APP_URL, NEXTAUTH_URL, BETTER_AUTH_URL, SITE_URL, PUBLIC_URL, VITE_API_URL) = ${HOMEMADE_URL_<port>}.
- When that same app checks the Origin of its own requests against that base URL (better-auth: set BETTER_AUTH_TRUSTED_ORIGINS = http://localhost:<port>; a CORS allow-list of its own origin: add http://localhost:<port>), trust the localhost origin too, because the proxy presents same-origin requests as localhost. Calls from ANOTHER port's page (a frontend on 3000 calling an API on 3001) keep their real preview origin: allow ${HOMEMADE_URL_3000} there.
- `"publicHost": true` on a service sends it the real preview hostname instead (and X-Forwarded-Host/-Proto). Only for an app that must see it: routing by hostname, absolute URLs built from the request into its pages. Such an app then needs its host allow-list from an env var the app already reads. If none exists and code is unavoidable, name the minimal code change in the pull request description as a separate preview-domain pull request; it never goes into the config pull request.
Check it: load each url: true port through its preview URL (the pattern is above), not only localhost, and make your visible edit show there. A service with `share` owner or authenticated answers your unauthenticated curl with the platform's sign-in gate (a 401/403 or a redirect to sign in): that proves the route only, so check its page on localhost (the proxy presents it as http://localhost:<port>, so that is what the app sees). A host-block page or a 5xx on a preview URL means the setup is wrong.

`size`: nano | tiny | small | medium | large. Leave it out unless the project really needs more.

# Use the platform, do not hack this VM
- A database, cache or queue the app needs is a SERVICE in the config, normally its docker image (`docker run --rm --name db -p 5432:5432 -e POSTGRES_PASSWORD=postgres postgres:17`, image pulled in warmup, a `healthcheck` cmd, `depends_on` on the app) with its port declared. If the repo's config already has one (e.g. a `db` service running postgres in docker), it is already running in this VM: check with `ss -ltnp`, connect to it, and keep it. To test a new one here, run its service cmd in the background like any other service (step 4).
- Never apt-install or systemctl-start a database or other daemon in this VM, and never install a browser (Chrome, Chromium, Firefox, `playwright install`) to see the app answer: curl it. Anything that exists only in this VM is missing in every user's VM. If the project really needs a system package (a client, a build tool), add it to `setup`.
- Readiness is `depends_on` on the service that waits, never a fixed sleep or a wait loop in its cmd. A docker database publishes its port before it accepts connections (first-boot init), so give it a `healthcheck` with `cmd` (its own readiness tool) rather than relying on the port.

# When a port does not answer: read before you change anything
1. `homemade-agent services health` in the VM (`homemade services health <vm>` from outside) says which service failed and shows its last log lines. After a config change, `homemade-agent services apply` (`homemade services apply <vm> --config "$(cat .homemade/config.jsonc)"` from outside) puts the new services on the VM in seconds, without a rebuild.
2. `tail -n 60 /var/log/homemade-install.log` for install errors.
3. `ss -ltnp` to see what listens where (a service on ::1 only, or on another port, does not count).
4. Run the service's exact cmd yourself in the background with its output in a file, then read the file: `mkdir -p /tmp/hm-check; (set -a; . /etc/homemade/env; set +a; PORT=3000 nohup bash -c '<cmd>' > /tmp/hm-check/web.log 2>&1 &)`, wait with a bounded loop, `tail -n 60 /tmp/hm-check/web.log`. Free the port first if an old copy holds it (`fuser -k 3000/tcp`).
5. Probe with `curl -s -o /tmp/hm-check/body -w '%{http_code}' --max-time 10 http://127.0.0.1:3000/`; on 500, `head -c 2000 /tmp/hm-check/body` and the log show the cause.
Fix the cause in the config or the project env, then test the changed command the same way.

# Recipes for common failures
- Generated code missing (`Cannot find module`, `ModuleNotFoundError`, an import of a git-ignored folder, a missing ORM client): run the generator in `install` right after the dependency install, so it exists before any service starts. Find the exact command in the repo (its scripts, Makefile, Dockerfile, CI workflow, the plugin's README). Examples: `npx prisma generate`, an i18n compiler whose output is git-ignored (Paraglide: the repo's own script, e.g. `pnpm paraglide-js compile --project ./project.inlang --outdir ./src/lib/paraglide`; a dev server answering 500 or never listening with "Cannot find module .../paraglide" needs it), `python manage.py collectstatic --noinput`, `go generate ./...`, `bin/rails assets:precompile` only when dev really needs it.
- Database not ready (connection refused, `the database system is starting up`, a migration fails at boot): give the database service a `healthcheck` with the database's own readiness tool as `cmd` (`docker exec <container> pg_isready -h 127.0.0.1 -q`, `docker exec <container> mysqladmin ping -h 127.0.0.1`, `docker exec <container> redis-cli ping`), and `"depends_on": {"<db service>": {"condition": "healthy"}}` on the app, whose cmd then just migrates and execs the server: `<migrate> && exec <server>`.
- Wrong host or port binding (nothing on 127.0.0.1:<port>, or only on [::1]): pass the port and host the framework's own way and declare the same port (see the stack recipes below).
- Missing env var (the app throws "X is required", refuses to start, or a 500 names a setting): a non-secret dev value or a ${HOMEMADE_URL_<port>} reference is an `env_schema` entry with a `default`; a dev secret (session key, app key, JWT secret) is an `env_schema` entry `{"key": "...", "generate": true}` (see Env vars); a real third-party secret, or anything else secret-looking, is only a NAME in `env_schema` with no `default` (not a demo key, not a placeholder: `homemade config validate` rejects it) and the person's to supply (the skill's env import step; a placeholder to let the app boot goes in the project's environment with their approval, never in the repo). A committed `.env` / `.env.example` with dev defaults is the list of names: copy the non-secret names the app reads into `env_schema` defaults; secret-looking names stay names only; do not commit a new .env. Optional integrations (analytics, OAuth, mail, storage) the app starts without: leave them unset and mention them in the pull request description.
- A frontend that needs a build before the backend serves it (embedded assets, a manifest file): build it in `install` (fast, cached) or run its dev server as its own service, whichever the repo's docs use for development.
- Private registry 401 on install (a token in .npmrc, pip.conf, .bundle/config, auth.json, NuGet.config, a GOPRIVATE module): ask for the token, then write it into the tool's USER config from the env var in install (and warmup when it is a warmup key), as in the example below. Never commit it.

# Stack recipes (dev mode, bound to 0.0.0.0, port from $PORT)
Prefer what the repo's own docs, Makefile, Procfile, compose file and CI use. A .devcontainer/devcontainer.json is imported by the platform only as a fallback (its ports, no dev server); your .homemade/config.json replaces it. These are the usual shapes:
- Node: install with the lockfile's manager in warmup AND install (`pnpm install --frozen-lockfile`, `yarn install --immutable` for Yarn 2+, `bun install --frozen-lockfile`; npm: `npm ci` in warmup, the guarded `npm ci` above in install); dev server `<pm> run dev -- --host 0.0.0.0 --port $PORT` (Vite), `next dev -H 0.0.0.0 -p $PORT`. Monorepos: run the app's workspace (`pnpm --filter <app> dev`, `npx turbo run dev --filter=<app>`). `yarn` in the VM is corepack's launcher: it runs the Yarn version package.json's packageManager pins (Yarn 1 when none), so plain `yarn install --immutable` / `yarn dev` is right. The VM's pnpm may differ from the one package.json pins: run the pinned one through corepack (`corepack pnpm install --frozen-lockfile`) when the install complains about the version or engine.
- Python: `uv sync` (uv.lock), `poetry install`, or `python -m venv .venv && .venv/bin/pip install -r requirements.txt`; run through the same env (`uv run`, `.venv/bin/python`). Django: `python manage.py migrate --noinput && exec python manage.py runserver 0.0.0.0:$PORT`. FastAPI: `fastapi dev --host 0.0.0.0 --port $PORT <app.py>` or `uvicorn <module>:app --host 0.0.0.0 --port $PORT --reload`. Flask: `flask --app <app> --debug run --host 0.0.0.0 --port $PORT` (`--debug` turns on the reloader and template auto-reload; it needs Flask 2.2+, older Flask gets FLASK_DEBUG=1 as an `env_schema` default; an app that reads its own setting for it, such as TEMPLATES_AUTO_RELOAD in its config, gets that the same way).
- Ruby/Rails: `bundle install` in warmup, `bundle check || bundle install` in install; JS deps too when there is a package.json; `bin/rails db:prepare && exec bin/rails server -b 0.0.0.0 -p $PORT`; `bin/dev` / Procfile.dev runs extra watchers (css, js, jobs): run them as their own services.
- PHP: `composer install --no-interaction` in warmup and install. Laravel: copy .env.example to .env in install only when .env is missing, `php artisan key:generate` once, `php artisan migrate --force`, `php artisan serve --host 0.0.0.0 --port $PORT` (front-end assets: the repo's package manager, `run build` or the Vite dev server). Symfony: `php -S 0.0.0.0:$PORT -t public` (or the symfony CLI when the repo uses it). A composer script that renames a tracked file (symfony/demo's auto-scripts move .env.local.demo to .env.local) deletes it from the checkout: run the install with `--no-scripts` plus the scripts you need, or add `git checkout -q -- <file>` after it.
- Go: `go mod download` in warmup; `go run ./cmd/<app>` or a binary built in install; pass the port the app's way (flag or env). A web UI in a subfolder is its own Node install + service, or built into the binary as the repo's Makefile does.
- Rust: `cargo build` (with the features the service uses) in warmup, so the snapshot keeps target/; install only `cargo fetch --locked` at most; the service is `cargo watch -x run` when the repo uses cargo-watch, else `exec cargo run` (it rebuilds what changed on each start). An app with a template-reload setting (RELOAD_TEMPLATES, say) gets it as an `env_schema` default. Enable the cargo features the repo's docs name (a database backend, say).
- Elixir/Phoenix: `mix local.hex --force && mix local.rebar --force && mix deps.get && mix compile` (plus the asset tool installs) in warmup; `mix deps.get` only in install (phx.server recompiles what changed and live-reloads in dev); `mix ecto.setup` or `mix ecto.migrate` after the database is ready; `exec mix phx.server` with PORT and the host the config reads (often PHX_HOST); assets through the repo's mix aliases.
- Java/Kotlin (Spring Boot and friends): use the wrapper (`./mvnw`, `./gradlew`); fill the dependency cache and compile in warmup (`./mvnw -q -DskipTests dependency:go-offline` then `./mvnw -q -DskipTests compile`, or `./gradlew --no-daemon dependencies classes`), nothing heavy in install; service `./mvnw spring-boot:run -Dspring-boot.run.arguments="--server.port=$PORT <dev args>"` / `./gradlew --no-daemon bootRun --args="--server.port=$PORT <dev args>"`. Spring Boot serves templates and static files from target/classes, cached, so an edit in src/ never shows: without spring-boot-devtools in the build, pass dev args that read them from the source tree: `--spring.thymeleaf.cache=false --spring.thymeleaf.prefix=file:src/main/resources/templates/` (Thymeleaf; FreeMarker/Mustache have the same two settings), `--spring.web.resources.static-locations[0]=file:src/main/resources/static/ --spring.web.resources.static-locations[1]=classpath:/static/ --spring.web.resources.cache.period=0` (indexed: Maven splits a -D list on commas). A JVM app often needs size small.
- .NET: the SDK in global.json (install that version in setup with dotnet-install.sh when TOOLS.md lacks it); `dotnet restore` and `dotnet build` in warmup, `dotnet restore` only in install; service `dotnet watch --project <path> --non-interactive run --urls http://0.0.0.0:$PORT`. Hot reload often misses Razor (.cshtml/.razor) and other edits it cannot apply: set DOTNET_WATCH_RESTART_ON_RUDE_EDIT=true and DOTNET_USE_POLLING_FILE_WATCHER=true as `env_schema` defaults, and when an edit of a view still does not show, run `dotnet watch --no-hot-reload` (it rebuilds and restarts on every change, a few seconds). Check it: edit a view, reload the page.
- Deno: `deno install` / `deno cache` when there are deps; `deno task <dev|start>` with the port the app reads.
- Static site generators (Hugo, Jekyll, Astro, Docusaurus): the generator's own dev server bound to 0.0.0.0 and $PORT. A generator TOOLS.md lacks (Hugo, say) is installed in setup from its release (the exact version the repo pins, the extended build when the repo needs it).
- Compose-first apps (no dev server; the README runs `docker compose up`): one service whose cmd is the foreground compose command (`docker compose up`, no -d), with the web container's published port declared and a healthcheck. Values the compose file reads are not a committed .env: the base URL is a project env var, a dev secret an env_schema `generate: true` entry.

# Keep tool output short (it is sent back to the model on every call)
- Bound every command: `timeout 120 ...`. Never run a server in the foreground.
- Pipe long output through `tail -n 40` or `grep`; send installs to a log file and tail it; read files in ranges (`sed -n 1,80p`), never `cat` a lockfile or a build log.
- Do not repeat a command whose output you already have.

# Rules (`homemade config validate` catches some; a config that breaks one is wrong)
- Services run the app's DEV mode: the dev server with hot reload or watch (`npm run dev`, `bin/rails server`, `manage.py runserver`, `mix phx.server`, `go run` or air, `cargo watch`/`cargo run`, `dotnet watch`, `hugo server`, `./mvnw spring-boot:run`), never a production build and start (`next build && next start`, `vite preview`, a compiled release binary, gunicorn, uvicorn without --reload). Users edit code in the VM and must see the change in the preview without a restart. Get it with the framework's own dev settings, set only through the config (cmd flags such as `--debug`, run arguments) or `env_schema` defaults, never by editing project files. Check it before you finish: change one visible string in a template or page the app serves, reload with curl, see it, change it back. Content that comes from the database (a CMS page) is not a code edit: say so in the pull request description. No dev mode at all: use the closest thing that rebuilds on change, else the plain start, and say why in the pull request description.
- No fixed sleeps. No env values in commands (`FOO=bar pnpm dev`): put each value in `env_schema` (a `default` or `generate`) (build-phase tool flags in setup/warmup are the exception).
- No secrets in the repo: no value at all for a secret-looking key, not a demo key or a placeholder. A dev secret is generated per VM by the platform from the config: "env_schema": [{"key": "BETTER_AUTH_SECRET", "generate": true}]. A real secret is a question. A sign-in link is `signInUrl` on the service, never a file.
- No hardcoded localhost URLs for anything a browser opens: use ${HOMEMADE_URL_<port>} in an env var. Internal connection strings (DATABASE_URL to the VM's own database) are plain env values.
- Installs belong to warmup (and install as a quick check), never in a service cmd. Slow, cacheable work (dependency installs, compiles, image pulls) goes in warmup; install keeps only quick per-boot steps. Every service with `url: true` has a `healthcheck`.
- Use what the repo already has: its package manager and lockfile, its scripts, its .env.example for names.
- Never touch the project's code. The pull request holds only .homemade/ config. No config command may change a tracked file: no sed or patch on sources, no writing package.json, no adding dependencies, no install that rewrites the lockfile (use the frozen/locked install). Generated output belongs where git ignores it. Check `git status` after boot: no tracked file may be modified. Get as close to the ideal dev setup as the project allows as it is: a project without live reload does not get one added.

# Example: the shape of a config (a web app + postgres in docker; commands vary per stack)
{
  "setup": ["<a system package or pinned tool the VM lacks, if any>"],
  "warmup": ["<the dependency install, filling caches for the snapshot>", "<the first compile, if the stack has one>", "docker pull postgres:17"],
  "install": ["<the same install, idempotent and fast>", "<code generation the app needs before it starts>"],
  "services": {
    "db": {
      "cmd": "docker start -a appdb || docker run --name appdb -e POSTGRES_USER=app -e POSTGRES_PASSWORD=app -e POSTGRES_DB=app -p 54329:5432 postgres:17",
      "port": 54329,
      "healthcheck": { "cmd": "docker exec appdb pg_isready -U app -h 127.0.0.1 -q" },
      "displayName": "Postgres"
    },
    "web": {
      "cmd": "<migrate> && exec <dev server bound to 0.0.0.0 on $PORT>",
      "depends_on": { "db": { "condition": "healthy" } },
      "port": 8000,
      "url": true,
      "healthcheck": { "path": "/" },
      "displayName": "Web"
    }
  },
  "env_schema": [{ "key": "DATABASE_URL", "default": "postgresql://app:app@127.0.0.1:54329/app" }, { "key": "APP_URL", "default": "${HOMEMADE_URL_8000}" }, { "key": "SECRET_KEY", "generate": true }]
}
Placeholders in <angle brackets> are yours to fill from the repo; never ship one.

# Example: private registry token (asked from the user, warmup-safe)
{
  "warmup": ["[ -z \"$REGISTRY_TOKEN\" ] || <write the token into the tool's user config>", "<install>"],
  "install": ["[ -z \"$REGISTRY_TOKEN\" ] || <write the token into the tool's user config>", "<install>"],
  "env_schema": [{ "key": "REGISTRY_TOKEN", "warmup": true }]
}
Writing it: npm/pnpm `pnpm config set //<host>/:_authToken "$REGISTRY_TOKEN" --location=global` (pnpm ignores env-expanded credentials in a project .npmrc); bundler `bundle config set --global <host> "$REGISTRY_TOKEN"`; composer `composer config --global http-basic.<host> token "$REGISTRY_TOKEN"`; pip `pip config --user set global.extra-index-url "https://__token__:$REGISTRY_TOKEN@<host>/simple"`; Go `git config --global url."https://$REGISTRY_TOKEN@<host>/".insteadOf "https://<host>/"`.
