You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Persist gh cli authentication across container rebuilds (#67)
* Persist gh cli authentication across container rebuilds
* Use GH CLI auth for GitHub MCP
- Fixes error where the GitHub MCP fails to authenticate
* Adds deny permissions to prevent destructive actions by claude
* Update readme with gh permissions
-[UI Development vs Production Mode](#ui-development-vs-production-mode)
@@ -143,6 +144,87 @@ The config file is mounted to `/home/vscode/.aws/config` inside the container an
143
144
144
145
Once the container is running with valid credentials, run `claude` in the terminal to start Claude Code.
145
146
147
+
## GitHub CLI
148
+
149
+
The dev container includes the [GitHub CLI](https://cli.github.com/) (`gh`). The GitHub CLI's authentication is reused by the GitHub MCP server for agentic development.
150
+
151
+
### Authentication
152
+
153
+
GitHub CLI authentication is **persisted across container rebuilds** using a bind mount. Credentials stored via `gh auth login` are saved and automatically available inside the container after a rebuild.
154
+
155
+
To authenticate for the first time:
156
+
157
+
```bash
158
+
gh auth login
159
+
```
160
+
161
+
Follow the prompts to authenticate via browser or token.
162
+
163
+
### Recommended: Use a Fine-Grained Personal Access Token
164
+
165
+
We strongly recommend authenticating with a **fine-grained personal access token (PAT)** rather than a full OAuth login. Fine-grained PATs let you limit exactly what `gh` can do on your behalf.
166
+
167
+
**To create a fine-grained PAT:**
168
+
169
+
1. Go to **GitHub → Settings → Developer settings → Personal access tokens → Fine-grained tokens**
170
+
2. Click **Generate new token**
171
+
3. Set an expiration date
172
+
4. Under **Repository access**, select only the repositories relevant to your work
173
+
5. Under **Permissions**, grant only what you need — a reasonable read-heavy baseline:
174
+
175
+
| Permission | Access |
176
+
|---|---|
177
+
| Contents | Read-only |
178
+
| Issues | Read and write |
179
+
| Pull requests | Read and write |
180
+
| Metadata | Read-only (required) |
181
+
| Actions | Read-only |
182
+
| Secrets | None |
183
+
| Administration | None |
184
+
185
+
6. Click **Generate token**, copy it, then run:
186
+
187
+
```bash
188
+
gh auth login --with-token <<<"your_token_here"
189
+
```
190
+
191
+
> Avoid granting `Administration`, `Secrets`, or `Members` permissions — these allow destructive or sensitive operations that are unlikely to be needed during normal development.
192
+
193
+
### Claude Code Restrictions
194
+
195
+
To prevent accidental or unintended destructive actions, Claude Code has been configured to **deny** the following `gh` commands in `.claude/settings.json`:
196
+
197
+
**Raw API access**
198
+
-`gh api` — bypasses all CLI safeguards; denied entirely
199
+
200
+
**Delete operations**
201
+
-`gh alias delete`, `gh cache delete`, `gh codespace delete`
-`gh repo visibility` — prevents accidentally making a private repo public
213
+
214
+
**Operational disruption**
215
+
-`gh run cancel` — halts CI runs
216
+
-`gh workflow disable` — disables automation
217
+
-`gh issue transfer` — moves issues to other repos
218
+
-`gh codespace rebuild` — destroys current codespace state
219
+
220
+
**Credential operations**
221
+
-`gh auth logout` — removes stored credentials
222
+
-`gh config clear-cache` — wipes cached auth data
223
+
224
+
Claude will be blocked from running any of the above and will need to ask you to run them manually if they are genuinely required.
225
+
226
+
227
+
146
228
## Memory Optimization
147
229
148
230
The Crucible development environment includes 30+ microservices and can be memory-intensive. Several optimizations are configured to reduce memory usage:
0 commit comments