Skip to content

feat(agents): remote agent sessions install the git hooks - #5126

Merged
dan-petty merged 2 commits into
mainfrom
feat/4773-remote-agent-sessions-install-the-git
Nov 12, 2026
Merged

dan-petty merged 2 commits into
mainfrom
feat/4773-remote-agent-sessions-install-the-git

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Claude Code cloud sessions and the Copilot cloud agent installed no git hooks, so their commits and pushes ran no hook. Only the devcontainer installs them, at each start.

  • .claude/settings.json and its template get a SessionStart hook (matcher startup|resume). When CLAUDE_CODE_REMOTE is true and uv and .pre-commit-config.yaml exist, it runs uv run pre-commit install in $CLAUDE_PROJECT_DIR, with the output on stderr. Else it exits 0. This is the pattern of the Claude Code cloud environment document, and a failed hook does not block the session.
  • copilot-setup-steps.yml runs uv run pre-commit install --install-hooks. The agent firewall does not govern a setup step, so the step also builds the hook environments.
  • CONTRIBUTING.md says how each agent host installs the hooks.

Closes #4773

Change: openspec/changes/archive/2026-11-12-4773-remote-agent-sessions-install-the-git/

A Claude Code cloud session runs a SessionStart hook that installs the hooks of .pre-commit-config.yaml when CLAUDE_CODE_REMOTE is true. The Copilot setup steps install the hooks and their environments.
@dan-petty dan-petty added type/feature Type feature: a new function scope/agents Agent instructions in AGENTS.md, skills and the agent hand-off labels Nov 12, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Checks run before the push (branch at 54d21dd, on origin/main 22176a0):

  • Test first: uv run devops ci test tests/commands/test_devcontainer.py -k claude_settings failed on the base with KeyError: 'hooks', and passes with the change.
  • uv run devops ci test tests/commands/test_devcontainer.py tests/core/test_third_party_telemetry.py tests/invariants/test_workflow_contracts.py tests/commands/test_openspec_scaffold.py tests/ai/test_pydantic_ai_profiles_and_providers.py tests/invariants/test_skills.py: 355 passed (after the contract test got the new command).
  • uv run devops ci --check --only actionlint,zizmor: pass. uv run devops ci --check --only docs,lint,format: pass. uv run devops openspec check: pass.

Manual check of the hook command (repeatable): clone the branch into a temporary directory, read the command from .claude/settings.json, and run it with CLAUDE_PROJECT_DIR set to the clone and VIRTUAL_ENV empty.

Case Shell Exit Hooks written
CLAUDE_CODE_REMOTE not set bash 0 none
CLAUDE_CODE_REMOTE=false bash 0 none
CLAUDE_CODE_REMOTE=true bash 0 pre-commit, pre-push (1.7 s, warm uv cache, 0 bytes on stdout)
CLAUDE_CODE_REMOTE=true, no uv on PATH dash 0 none
CLAUDE_CODE_REMOTE=true, no .pre-commit-config.yaml dash 0 none
CLAUDE_CODE_REMOTE=true dash 0 pre-commit, pre-push

Not verified here: a live claude.ai/code session and a live Copilot agent run. The Copilot Setup Steps job of this pull request runs the new step on a GitHub runner.

Owner steps: none. After the merge, GitHub reads copilot-setup-steps.yml from main. To confirm the effect, open one claude.ai/code session on this repository and run ls .git/hooks/pre-commit .git/hooks/pre-push. The acceptance check of the issue: in the 14 days after the merge, 0 commits on main with a Claude-Session trailer fail pre-commit run --files on their changed files.

@dan-petty
dan-petty marked this pull request as ready for review November 12, 2026 15:57
@dan-petty
dan-petty merged commit a04e7a9 into main Nov 12, 2026
25 checks passed
@dan-petty
dan-petty deleted the feat/4773-remote-agent-sessions-install-the-git branch November 12, 2026 15:57
dan-petty pushed a commit that referenced this pull request Nov 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.120.0](v0.119.0...v0.120.0)
(2026-11-12)


### Features

* **agents:** remote agent sessions install the git hooks
([#5126](#5126))
([a04e7a9](a04e7a9))


### Bug Fixes

* **k8s:** give the ollama-16gib tier a memory limit
([#5117](#5117))
([22176a0](22176a0))
* **roadmap:** the Status writer guards an equal label
([#5116](#5116))
([aaf3eaf](aaf3eaf))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
@dan-petty

Copy link
Copy Markdown
Owner Author

Review findings after the merge, and what I did:

  1. Major, .github/workflows/copilot-setup-steps.yml: the step Install the git hooks installs the branch-name hook (no-commit-to-branch, .pre-commit-config.yaml lines 14-20). That hook refuses each commit on a copilot/ branch, and the Copilot cloud agent cannot rename its branch.
    • Verified: the hook pattern refuses copilot/fix-login-bug, copilot/sub-pr-12 and copilot/fix-4773. The GitHub page "Risks and mitigations for GitHub Copilot cloud agent" says that the agent can push only to its copilot/ branch and cannot run git commands itself. GitHub community discussion 167906 shows that a hook installed by the setup steps runs on the commits of the agent, and that a failed hook stops the agent.
    • Done: this PR is merged, so I filed fix(ci): Copilot setup hooks refuse commits on copilot/ branches #5136 (sub-issue of feat(ci): track the agent hooks plan #4771) with the evidence and the two fix options. I did not change the workflow file, because other open work owns the files of .github/workflows/. The fix needs one live Copilot run on a test issue as proof.

@devops-cli-service devops-cli-service Bot mentioned this pull request Nov 15, 2026
1 of 21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/agents Agent instructions in AGENTS.md, skills and the agent hand-off type/feature Type feature: a new function

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(agents): remote agent sessions install the git hooks

1 participant