GitHub Codespaces Setup Cheat Sheet

Configure reproducible dev environments in the cloud

Last Updated: November 21, 2025

Configuration Focus

Area Action
.devcontainer/devcontainer.json Declare features, extensions, and forwarded ports for every workspace.
Dotfiles Install your shell, git, and editor preferences automatically.
postCreateCommand Bootstrap tools, linters, and cache directories after creation.
Custom Dockerfile Base your Codespace on a consistent image instead of the stock container.

Commands & Options

gh codespace create --repo owner/app --branch main
Launch a Codespace from a specific branch.
gh codespace ports --codespace myenv
View forwarded ports and access URLs.
devcontainer features install golang
Add features during container creation.
codespaces.portVisibility = 'public'
Expose previews securely to teammates.

Summary

Define devcontainer configs, dotfiles, and post-creation scripts so every Codespace boots with the same tools.

💡 Pro Tip: Pin Codespace images by referencing a custom Dockerfile to avoid surprise dependency updates.
← Back to Developer Tools | Browse all categories | View all cheat sheets