Skip to content

Commit d9b04b5

Browse files
Merge pull request #47 from runtimeverification/add-gh-cli-devcontainer
Add GitHub CLI to devcontainer with persistent auth
2 parents 2d8726f + 0de43b8 commit d9b04b5

3 files changed

Lines changed: 65 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: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
Create a **fine-grained** personal access token at **GitHub → Settings → Developer
40+
settings → [Fine-grained personal access tokens](https://github.com/settings/personal-access-tokens/new)**
41+
with the least privilege for your work:
42+
43+
- **Repository access***Only select repositories*`runtimeverification/komet-node`
44+
- **Contents***Read and write*
45+
- **Pull requests***Read and write*
46+
- **Issues***Read and write* (only if you triage issues)
47+
48+
`Metadata → Read` is selected automatically; leave everything else at *No access*.
49+
50+
## Signing commits
51+
52+
To sign commits made with `git`, add an SSH or GPG key of type **Signing key** to
53+
your GitHub account.
54+
55+
> [!WARNING]
56+
> Never place an SSH key registered as an **Authentication key** in the container.
57+
> An authentication key grants full account-wide git access and would bypass the
58+
> minimal permissions of your fine-grained PAT. Use a **signing-only** key here.

0 commit comments

Comments
 (0)