Skip to content
codespaces logo

GitHub Codespaces

codespaces

Create, manage, and optimize GitHub Codespaces cloud development environments. Configure devcontainers, manage resources, and streamline cloud-based development. Use when setting up cloud development environments, configuring devcontainers, or managing Codespaces. Triggers on codespace, devcontai...

SKILL.md

Full skill instructions

GitHub Codespaces

Cloud development environments that work anywhere.

Prerequisites

  • GitHub Account: With Codespaces access
  • gh CLI: Install from https://cli.github.com/
  • Authentication: Run gh auth login

Quick Reference

Core Commands

ActionCommand
Create codespacegh codespace create -r owner/​repo
List codespacesgh codespace list
Open in VS Codegh codespace code -c <name>
Open in browsergh codespace view -c <name> -w
SSH into codespacegh codespace ssh -c <name>
Stop codespacegh codespace stop -c <name>
Delete codespacegh codespace delete -c <name>

Machine Types

TypevCPUsRAMStorageBest For
Basic28GB32GBSimple projects, docs
Standard416GB32GBMost development
Large832GB64GBFull-stack, multiple services
XL1664GB128GBData science, ML
GPU4+16GB+64GB+ML training, CUDA

DevContainer Configuration

Directory Structure

.devcontainer/
+-- devcontainer.json           # Default configuration
+-- web-frontend/
|   +-- devcontainer.json       # Frontend-specific
+-- backend-api/
|   +-- devcontainer.json       # Backend-specific
+-- data-science/
    +-- devcontainer.json       # Data science config

Basic devcontainer.json

{
  "name": "Project Dev Environment",
  "image": "mcr.microsoft.com/​devcontainers/​universal:2",
  "features": {
    "ghcr.io/​devcontainers/​features/​node:1": {},
    "ghcr.io/​devcontainers/​features/​python:1": {}
  },
  "customizations": {
    "vscode": {
      "extensions": [
        "GitHub.copilot",
        "ms-python.python"
      ]
    }
  },
  "postCreateCommand": "npm install",
  "forwardPorts": [3000, 5000]
}

Lifecycle Scripts

postCreateCommand

Runs once when container is created:

"postCreateCommand": "npm install && npm run setup"

postStartCommand

Runs every time codespace starts:

"postStartCommand": "npm run dev:services"

postAttachCommand

Runs when VS Code attaches:

"postAttachCommand": "echo 'Welcome! Run npm start to begin.'"

Secrets Management

Setting Secrets

# For a specific repo
gh secret set API_KEY --repo owner/​repo

# For Codespaces specifically
gh secret set DB_PASSWORD --app codespaces

# For user (all Codespaces)
gh secret set NPM_TOKEN --user

Using Secrets in devcontainer.json

{
  "containerEnv": {
    "DATABASE_URL": "${localEnv:DATABASE_URL}"
  },
  "secrets": {
    "API_KEY": {
      "description": "API key for external service"
    }
  }
}

Port Forwarding

Automatic Forwarding

{
  "forwardPorts": [3000, 5000, 8080],
  "portsAttributes": {
    "3000": {
      "label": "Frontend",
      "onAutoForward": "openBrowser"
    },
    "5000": {
      "label": "API",
      "onAutoForward": "notify"
    }
  }
}

Manual Forwarding

gh codespace ports forward 3000:3000 -c <codespace-name>

Common Workflows

Quick Start New Feature

# Create codespace for feature branch
gh codespace create -r owner/​repo -b feature-branch -m standardLinux

# Open in VS Code
gh codespace code

PR Review in Codespace

# Create codespace from PR
gh codespace create -r owner/​repo --branch pr-branch

# Or use the PR directly
gh pr checkout 123
gh codespace create

Share Environment

# Export port with visibility
gh codespace ports visibility 3000:public -c <name>

# Get shareable URL
gh codespace ports -c <name>

Performance Optimization

Prebuilds

Enable prebuilds for faster startup:

// .github/​codespaces/​prebuild.json
{
  "triggers": {
    "branches": ["main", "develop"],
    "paths": ["package.json", ".devcontainer/​**"]
  }
}

Dotfiles Repository

Configure personal dotfiles in GitHub Settings > Codespaces.

Cost Management

Auto-stop Settings

Configure in GitHub Settings > Codespaces:

  • Default idle timeout: 30 minutes
  • Retention period: 7 days

Best Practices

  1. Stop when not in use: gh codespace stop
  2. Delete completed work: gh codespace delete
  3. Use appropriate machine size: Don't over-provision
  4. Enable prebuilds: Faster startup, less billing

Troubleshooting

IssueSolution
Slow startupEnable prebuilds
Out of storageDelete unused files, increase disk
Extension not workingCheck devcontainer extensions config
Port not accessibleCheck forwardPorts configuration
Environment variables missingVerify secrets are set

When to Use This Skill

  • Setting up cloud development environments
  • Configuring devcontainers for team consistency
  • Managing Codespaces via CLI
  • Optimizing development environment performance
  • Sharing development environments
  • PR reviews in isolated environments

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View