--- name: setup-browser-app description: Prepare a student's local browser-app project, Git history, and browser preview with agent-operated tools. Use for Web Application Builder setup or missing local prerequisites. --- # Set up a browser app Read the [shared workflow](../../references/workflow.md). Help the student reach a working preview and local revision history without typing commands themselves. 1. **Inspect first.** Confirm the selected folder, operating system, file/shell access, Git, and browser/preview tools. Check host-provided tool paths as well as PATH before deciding software is missing. Inspect existing files and `git rev-parse --show-toplevel` if inside a repository. Do not accidentally operate on an enclosing repository. If this is not the intended project root, resolve the destination before initialization or staging. 2. **Check Git separately.** Reuse host-provided Git or a working installation. Do not silently install Xcode tools, Git, a package manager or another system prerequisite. If local Git is unavailable, record the gap and continue planning/build preparation; history and publication remain incomplete until an authorized Git capability is available. Never bypass managed-device restrictions. 3. **Distinguish new from existing.** Read the plan and actual files. Every new app uses the [uniform managed starter and local setup](../../references/managed-build.md), even a simple form with no optional libraries. Copy the starter into the intended empty app directory, preserving plans/host files and merging ignore rules. Resolve collisions before writing; do not use a bulk copy over existing source. Do not copy the Pages workflow yet. Existing plain or managed apps retain their source, package/lockfile, runtime and recorded commands. Do not add the new launcher or migrate an existing app unless explicitly requested. 4. **Prepare the new project's private runtime.** On macOS run `bash app.sh setup`; on Windows run `powershell.exe -NoProfile -File .\app.ps1 setup`. The checked-in platform launcher downloads and verifies portable Node, then installs locked dependencies with a project-local cache. Use the launcher for subsequent local commands. Do not install Node globally, modify PATH permanently or change PowerShell execution policy. An OS restriction stops that operation with a concrete explanation. No Python, Homebrew, WSL, Docker or separate PowerShell 7 prerequisite. 5. **Establish preview.** For a new project run the launcher's `build`, then `dev` in an agent-owned foreground terminal session. Record the URL and terminal session; stop that session before cleanup. If the port is occupied, choose another through `dev --port PORT`; never kill an unrelated server. Existing apps use their verified setup. For an existing plain app prefer the host preview or an already-installed loopback server; do not install a runtime merely for its preview. Missing browser tools remain an explicit gap, not permission to claim interaction checks. 6. **Start history.** Initialize the intended new project with `git init -b main`; preserve an existing repository's branch and settings. Follow the shared attribution rule and set any identity using `git config --local`. If attribution is deferred, do not commit. Inspect files, stage only intended public/synthetic content, inspect `git diff --cached`, and make the initial commit. Avoid global Git changes and unrelated remotes. 7. **Prove readiness.** Open the starter through the preview, confirm its React module displays readiness, and activate its button. On an existing app, verify its actual module loading and a representative interaction instead; do not require starter controls. Verify the project root and initial commit. Save `SETUP.md` with actual Git invocation/version, project-local Node/npm versions, launcher or existing-runtime invocation, app URL, test-page location, restart procedure, completed steps, and gaps. Record host-local paths only where needed for resuming; exclude private account details. On rerun, recheck current state and finish missing work. Do not reinstall working tools, create duplicate history, overwrite files, or claim setup complete while preview or history is missing. Hand off to [Plan](../plan-browser-app/SKILL.md), or resume the stage that requested setup.