5.4. GitHub Codespaces and Dev Containers
Setting up a working local development environment can eat a whole morning — Codespaces exists to make that setup someone else's problem, reproducibly.
💡 First Principle: A Codespace is a complete, cloud-hosted development environment — compute, a terminal, and your editor of choice — provisioned from a dev container definition stored in the repository. Because the environment's configuration (devcontainer.json) lives in the repo alongside the code, every contributor who opens a Codespace for that project gets an identical, ready-to-code setup, with no "works on my machine" setup drift.
The devcontainer.json file specifies the base image, extensions, and setup commands a Codespace should have — customizing it once means every future Codespace for that repository inherits the same configuration. Teams that open Codespaces frequently can also configure prebuilds, which pre-run the setup steps ahead of time so a new Codespace starts faster.
⚠️ Exam Trap: A dev container's configuration lives in the repository (devcontainer.json), not in personal account settings — that's what makes every contributor's Codespace for a given project consistent, regardless of who opens it.
Reflection Question: A new team member joins and opens a Codespace for the team's repository for the first time. Why would their environment already match everyone else's, without them installing anything manually?