Skip to content

Commit 4d134b0

Browse files
Add GitHub CLI to devcontainer with persistent auth
Install gh via nix profile alongside the other bootstrap tooling, and persist its credentials across rebuilds with a named volume mounted at ~/.config/gh. Add CONTRIBUTOR.md documenting gh auth and how to create a minimal-permission fine-grained token.
1 parent 2d8726f commit 4d134b0

3 files changed

Lines changed: 71 additions & 2 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,16 @@ ENV PATH=/home/vscode/.nix-profile/bin:/home/vscode/.npm-global/bin:$PATH
5656
# so those live in flake.nix's devShell, not here.
5757
# - nodejs_22 → host for the Claude Code CLI (run as `claude` from
5858
# anywhere, so it stays globally on PATH, not in the shell)
59+
# - gh → GitHub CLI for PRs/issues/auth; global so it's usable
60+
# from anywhere. Auth is persisted across rebuilds via a
61+
# named volume on ~/.config/gh (see devcontainer.json).
5962
RUN . /home/vscode/.nix-profile/etc/profile.d/nix.sh \
6063
&& nix registry add nixpkgs github:NixOS/nixpkgs/nixos-25.05 \
6164
&& nix profile install \
6265
nixpkgs#direnv \
6366
nixpkgs#nix-direnv \
64-
nixpkgs#nodejs_22
67+
nixpkgs#nodejs_22 \
68+
nixpkgs#gh
6569

6670
# Claude Code CLI — installed to a per-user prefix so root isn't required.
6771
RUN . /home/vscode/.nix-profile/etc/profile.d/nix.sh \

.devcontainer/devcontainer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
"init": true,
1010
"mounts": [
1111
"source=claude-code-config-${devcontainerId},target=/home/vscode/.claude,type=volume",
12+
"source=gh-config-${devcontainerId},target=/home/vscode/.config/gh,type=volume",
1213
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.gitconfig,target=/home/vscode/.gitconfig,type=bind,readonly"
1314
],
1415
"containerEnv": {
1516
"CLAUDE_CONFIG_DIR": "/home/vscode/.claude",
1617
"GIT_CONFIG_GLOBAL": "/home/vscode/.gitconfig.local"
1718
},
18-
"postCreateCommand": "sudo chown -R vscode:vscode /home/vscode/.claude && bash .devcontainer/setup-git.sh && direnv allow /workspace && nix develop /workspace --command bash -c 'uv sync --frozen'",
19+
"postCreateCommand": "sudo chown -R vscode:vscode /home/vscode/.claude /home/vscode/.config/gh && bash .devcontainer/setup-git.sh && direnv allow /workspace && nix develop /workspace --command bash -c 'uv sync --frozen'",
1920
"customizations": {
2021
"vscode": {
2122
"extensions": [

CONTRIBUTOR.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Contributing to Komet Node
2+
3+
## Development environment
4+
5+
This repository ships a [devcontainer](.devcontainer/) that provisions the full
6+
toolchain (Nix, the flake's `nix develop` shell, the Claude Code CLI, and the
7+
GitHub CLI). Open the repo in a devcontainer-aware editor and everything below is
8+
available out of the box.
9+
10+
## Using the GitHub CLI (`gh`)
11+
12+
`gh` is preinstalled in the devcontainer for creating pull requests, reviewing
13+
issues, and other GitHub tasks from the terminal.
14+
15+
### Authenticating
16+
17+
Authenticate once with a personal access token:
18+
19+
```bash
20+
gh auth login
21+
```
22+
23+
Choose **GitHub.com****HTTPS****Paste an authentication token** when
24+
prompted, then paste the token you create below.
25+
26+
Your credentials are stored in `~/.config/gh` inside the container, which is
27+
backed by a named volume. This means **your token survives container rebuilds**
28+
you only need to authenticate once, not every time the container is recreated.
29+
30+
To check or reset your authentication at any time:
31+
32+
```bash
33+
gh auth status # show the current login
34+
gh auth logout # remove stored credentials
35+
```
36+
37+
### Creating a token with minimal permissions
38+
39+
Prefer **fine-grained personal access tokens** — they let you grant only the
40+
access you actually need, scoped to a single repository, with a short expiry.
41+
Please generate tokens with the **least privilege** required for your work; avoid
42+
broad "classic" tokens with the full `repo` scope unless there is no alternative.
43+
44+
1. Go to **GitHub → Settings → Developer settings →
45+
[Fine-grained personal access tokens](https://github.com/settings/personal-access-tokens/new)**.
46+
2. Give the token a descriptive name and set the **shortest expiry** that fits
47+
your workflow.
48+
3. Under **Repository access**, choose **Only select repositories** and pick just
49+
`runtimeverification/komet-node` (or your fork) — not "All repositories".
50+
4. Under **Permissions → Repository permissions**, grant only what you need. For a
51+
typical contributor workflow that is:
52+
- **Contents***Read and write* (clone, pull, push branches)
53+
- **Pull requests***Read and write* (open and update PRs)
54+
- **Issues***Read and write* (only if you triage or comment on issues)
55+
56+
`Metadata → Read` is required and is selected automatically. Leave every other
57+
permission at **No access**.
58+
5. Click **Generate token** and copy it — GitHub shows it only once. Paste it into
59+
the `gh auth login` prompt above.
60+
61+
> [!TIP]
62+
> Start with the narrowest set of permissions and add more only if a command
63+
> fails with an authorization error. A token that can do less is a smaller risk
64+
> if it ever leaks.

0 commit comments

Comments
 (0)