1
---
2
name: github-codespaces-efficiency
3
description: 'Audit and improve GitHub Codespaces efficiency. Use this skill when a user wants faster Codespaces startup, lower Codespaces spend, slim devcontainers, right-size machines, tune idle timeout, or scope prebuilds to branches with sustained usage.'
4
---
5
6
# GitHub Codespaces Efficiency
7
8
Use this skill as a lean entrypoint for GitHub Codespaces efficiency work. Inspect the repo, identify waste, and load only needed references.
9
10
If no `.devcontainer/` exists yet, load [`references/codespaces.md`](./references/codespaces.md) and define a baseline before proceeding with the steps below.
11
12
## Use This Skill When
13
14
- The user wants faster Codespaces startup or lower Codespaces spend.
15
- The repo has a `.devcontainer/` or explicit Codespaces configuration questions.
16
- The user asks for devcontainer optimization, machine sizing, prebuild strategy, or idle-timeout guidance.
17
- The user is setting up Codespaces for the first time or needs help creating a new `.devcontainer/` from scratch.
18
19
## Load Only What You Need
20
21
- [`references/codespaces.md`](./references/codespaces.md) — devcontainer, machine-sizing, prebuild, idle-timeout guidance, and reporting.
22
- [`references/review-rubric.md`](./references/review-rubric.md) — load only for review passes.
23
24
## Core Workflow
25
26
### 1. Measure first
27
28
```bash
29
find .devcontainer -maxdepth 2 -type f
30
gh codespace list
31
repo=$(gh repo view --json nameWithOwner --jq .nameWithOwner)
32
gh api "/repos/$repo/codespaces/machines"
33
```
34
35
If `gh` auth fails or the user lacks repo admin scope, proceed with static analysis of `.devcontainer/` files; mark machine-type and prebuild recommendations as unverified.
36
37
Look for: devcontainer image >2 GB or more than 10 features, machine type larger than usage data supports, missing `devcontainer-lock.json` (recommend adding — many repos predate lock-file support), prebuilds scoped too broadly, and idle timeout mismatched to usage patterns.
38
39
### 2. Apply guardrails
40
41
Check each proposed fix against these rules before recommending it:
42
43
1. Does not remove tools the team uses every day — drop any fix that strips required development tools or extensions.
44
2. Does not assume smaller is always better — balance machine cost against developer experience and throughput.
45
3. Does not turn the devcontainer into a production image — drop any fix that adds production-only dependencies unless the team explicitly requires it.
46
4. Incremental changes preferred — a greenfield baseline is appropriate only when no `.devcontainer/` exists; flag (do not drop) changes that restructure an existing config.
47
5. Repo changes stay separate from org settings — split any fix that mixes repo-editable files with org-level or user-level Codespaces settings into two distinct recommendations.
48
49
### 3. Select the top 3 fixes
50
51
From the six candidates below, keep only those supported by audit evidence from step 1 *and* passing all guardrails from step 2. Rank survivors by estimated monthly cost savings (USD). Select all candidates that meet both criteria, up to a maximum of 3.
52
53
1. Trim devcontainer — remove features, packages, or extensions not needed for everyday development work; target image <2 GB and fewer than 10 features
54
2. Right-size machine type — match to observed usage patterns; if data is unavailable, state assumptions explicitly
55
3. Scope prebuilds — enable for the default branch, `release/*` branches active in the last 14 days, and branches with more than 5 Codespaces per week; disable for all others
56
4. Tune idle timeout — 30 min default; 15 min if most sessions end before 30 min; 60 min if most sessions run longer
57
5. Remove unused extensions or port-forwarding rules
58
6. Reduce devcontainer image size and improve layer caching
59
60
### 4. Verify
61
62
- Start a test Codespace to confirm devcontainer changes build and start as expected.
63
- Validate machine sizing against observed usage when telemetry is available; otherwise mark as unverified.
64
- Treat unexpected build or startup failures as real bugs even when the configuration looks correct.
65
66
## Required Output
67
68
**Waste sources:** [top cost or startup-time drivers]
69
70
**Proposed fixes:** [top 3 changes supported by audit evidence and passing guardrails]
71
72
**Validation:** [proven live / static-only / remaining risk]
73
74
**Impact:**
75
- Startup time: [expected] / [measured if available]
76
- Monthly spend: [expected] / [measured if available]
77
- Resource utilization: [expected] / [measured if available]
78
79
## References
80
81
- [`references/codespaces.md`](./references/codespaces.md)
82
- [`references/review-rubric.md`](./references/review-rubric.md) — load when reviewing completed efficiency work
83