Skip to content

feat(runner): commit as the session's GitHub account, not Claude - #268

Merged
rfay merged 1 commit into
mainfrom
20261124_rfay_runner_commit_identity
Nov 24, 2026
Merged

rfay merged 1 commit into
mainfrom
20261124_rfay_runner_commit_identity

Conversation

@rfay

@rfay rfay commented Nov 24, 2026

Copy link
Copy Markdown
Member

Short Summary (TL;DR)

Commits that a self-hosted runner session makes now name the GitHub account of the person who started the session. A SessionStart hook looks the account up through the session's git proxy, and Claude <noreply@anthropic.com> is only the fallback.

The Issue

The runner deletes ~/.gitconfig before every session, so the module sets the git identity in /etc/gitconfig. That identity is Claude <noreply@anthropic.com>, so every commit from a runner session names Claude, not the person who did the work. Before the runner, sessions committed with the workspace owner's own identity.

How This PR Solves The Issue

The new claude-session-identity script runs as a SessionStart hook, next to claude-checkout-check in the managed settings drop-in. The session's git proxy adds the GitHub credential of the person who started the session, so the hook asks that proxy for GitHub's /user, as the session's gh shim does. It writes GIT_AUTHOR_* and GIT_COMMITTER_* to $CLAUDE_ENV_FILE, which Claude Code applies to the session's Bash commands.

  • Name: the account's profile name, or its login.
  • Email: the account's public email, or <id>+<login>@users.noreply.github.com. GitHub credits both to the account.
  • The hook never uses the workspace's own gh login, because that login belongs to the workspace owner, whoever started the session.
  • When the lookup fails, the hook writes nothing, and commits keep the /etc/gitconfig identity.

Other identity sources lost. The claude.ai email in the session token is a login, not a git identity, and it can be a shared role account. A key or signing setup on the workspace would let every session act as one person. Commits stay unsigned. The README and docs say to re-sign a branch on your own computer when a repository requires signed commits.

Manual Testing Instructions

Use a freeform workspace with "Run a Claude Code self-hosted runner" on, from a template pushed from this branch.

  1. Restart the workspace, then start a session on claude.ai/code in its environment, with a repository attached.
  2. Ask Claude to run env | grep -E '^GIT_(AUTHOR|COMMITTER)_'. Expect your GitHub profile name and public email, or your users.noreply.github.com address.
  3. Ask Claude to commit a small change on a branch and push it. On GitHub, expect the commit to show your avatar and login, not Claude's.
  4. In the workspace, run grep claude-session-identity /etc/claude-code/managed-settings.d/coder-runner.json. Expect the hook command.
  5. Check the fallback: run CLAUDE_ENV_FILE=~/tmp/env.sh GIT_CONFIG_GLOBAL=/dev/null ~/.local/bin/claude-session-identity. Expect the "commits use the default git identity" message, and expect ~/tmp/env.sh to stay empty.

Automated Testing Overview

freeform/tests/validate.tftest.hcl now checks that the startup script installs claude-session-identity and adds it to the SessionStart hooks. Claude Code ran terraform fmt -recursive, make validate and make test-templates (all pass), markdownlint on the changed docs, and shellcheck on the script, all on Linux. In a runner session on coder.ddev.com, Claude Code ran the script against the real proxy: it found the right account, wrote the env file, and wrote nothing without an env file or a proxy. Nobody has confirmed yet that the $CLAUDE_ENV_FILE exports reach Bash commands in a new runner session, so step 2 above is that check. The strict Zensical docs build was not run.

Release/Deployment Notes

Restart runner workspaces after pushing the template, so they install the hook. The hook relies on two details of Anthropic's git proxy: the proxy-injected placeholder token and the ccr/ca-bundle.crt path. If either changes, commits fall back to the Claude identity.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UrTUMzWrupgmEe5ZjBfY2J

## Short Summary (TL;DR)

Commits that a self-hosted runner session makes now name the GitHub account of the person who started the session. A SessionStart hook looks the account up through the session's git proxy, and `Claude <noreply@anthropic.com>` is only the fallback.

## The Issue

The runner deletes `~/.gitconfig` before every session, so the module sets the git identity in `/etc/gitconfig`. That identity is `Claude <noreply@anthropic.com>`, so every commit from a runner session names Claude, not the person who did the work. Before the runner, sessions committed with the workspace owner's own identity.

## How This PR Solves The Issue

The new `claude-session-identity` script runs as a SessionStart hook, next to `claude-checkout-check` in the managed settings drop-in. The session's git proxy adds the GitHub credential of the person who started the session, so the hook asks that proxy for GitHub's `/user`, as the session's `gh` shim does. It writes `GIT_AUTHOR_*` and `GIT_COMMITTER_*` to `$CLAUDE_ENV_FILE`, which Claude Code applies to the session's Bash commands.

- Name: the account's profile name, or its login.
- Email: the account's public email, or `<id>+<login>@users.noreply.github.com`. GitHub credits both to the account.
- The hook never uses the workspace's own `gh` login, because that login belongs to the workspace owner, whoever started the session.
- When the lookup fails, the hook writes nothing, and commits keep the `/etc/gitconfig` identity.

Other identity sources lost. The claude.ai email in the session token is a login, not a git identity, and it can be a shared role account. A key or signing setup on the workspace would let every session act as one person. Commits stay unsigned. The README and docs say to re-sign a branch on your own computer when a repository requires signed commits.

## Manual Testing Instructions

Use a freeform workspace with "Run a Claude Code self-hosted runner" on, from a template pushed from this branch.

1. Restart the workspace, then start a session on claude.ai/code in its environment, with a repository attached.
2. Ask Claude to run `env | grep -E '^GIT_(AUTHOR|COMMITTER)_'`. Expect your GitHub profile name and public email, or your `users.noreply.github.com` address.
3. Ask Claude to commit a small change on a branch and push it. On GitHub, expect the commit to show your avatar and login, not Claude's.
4. In the workspace, run `grep claude-session-identity /etc/claude-code/managed-settings.d/coder-runner.json`. Expect the hook command.
5. Check the fallback: run `CLAUDE_ENV_FILE=~/tmp/env.sh GIT_CONFIG_GLOBAL=/dev/null ~/.local/bin/claude-session-identity`. Expect the "commits use the default git identity" message, and expect `~/tmp/env.sh` to stay empty.

## Automated Testing Overview

`freeform/tests/validate.tftest.hcl` now checks that the startup script installs `claude-session-identity` and adds it to the SessionStart hooks. Claude Code ran `terraform fmt -recursive`, `make validate` and `make test-templates` (all pass), markdownlint on the changed docs, and `shellcheck` on the script, all on Linux. In a runner session on coder.ddev.com, Claude Code ran the script against the real proxy: it found the right account, wrote the env file, and wrote nothing without an env file or a proxy. Nobody has confirmed yet that the `$CLAUDE_ENV_FILE` exports reach Bash commands in a new runner session, so step 2 above is that check. The strict Zensical docs build was not run.

## Release/Deployment Notes

Restart runner workspaces after pushing the template, so they install the hook. The hook relies on two details of Anthropic's git proxy: the `proxy-injected` placeholder token and the `ccr/ca-bundle.crt` path. If either changes, commits fall back to the Claude identity.

🤖 Developed with assistance from [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UrTUMzWrupgmEe5ZjBfY2J
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Previews

The start.coder.ddev.com landing-page preview has been removed. Read the Docs keeps or removes its own docs preview.

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 coder-ddev | 🛠️ Build #36137658 | 📁 Comparing cba8574 against latest (55ead6e)

  🔍 Preview build  

1 file changed
± workspaces/ai-tools/index.html

@rfay
rfay merged commit 42358bf into main Nov 24, 2026
21 checks passed
@rfay
rfay deleted the 20261124_rfay_runner_commit_identity branch November 24, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant