主题
Claude Code 与 GitHub Enterprise Server
把 Claude Code 接入自托管的 GitHub Enterprise Server 实例。
是什么
GitHub Enterprise Server (GHES) 支持让组织能在自管理的 GitHub 实例(而非 github.com)托管的仓库上使用 Claude Code。该能力面向 Team 和 Enterprise 套餐。
管理员只需把 GHES 实例连接一次,开发者即可运行 web sessions、获得自动化 code review、并从内部 marketplace 安装插件,无需任何按仓库的额外配置。
怎么工作
- 管理员一次性连接:在 claude.ai/admin-settings/claude-code 找到 GitHub Enterprise Server 区域并点击 Connect,输入显示名与 GHES hostname(如 github.example.com);自签名/私有 CA 可粘贴 CA 证书。
- 引导式流程生成 GitHub App manifest 并跳转到 GHES,点击 Create GitHub App 一键创建,凭据自动回传 Claude;若网络阻断跳转,可改用 Add manually 手动设置。
- 在 GHES 的 GitHub App 页面把 app 安装到目标仓库或组织(可先装一部分,之后再加)。
- 回到 admin-settings 启用 Code Review、Claude Security、contribution metrics,配置方式与 github.com 相同。
- 开发者侧无需配置:Claude Code 从工作目录的 git remote 自动检测 GHES hostname。
- 正常 clone GHES 仓库后,用 claude --remote "<任务>" 启动 web session;会话在 Anthropic 基础设施上运行、从 GHES clone 并把改动 push 回分支。
- 用 claude --teleport 把 web session 拉到本地终端;teleport 会先校验你处于同一 GHES 仓库的 checkout。
- 插件 marketplace 结构与 github.com 相同,仅引用方式不同:必须用完整 git URL 而非 owner/repo 简写。
怎么配置 / 用法
开发者启动会话:
bash
git clone git@github.example.com:platform/api-service.git
cd api-service
claude --remote "Add retry logic to the payment webhook handler"添加 GHES marketplace(用完整 URL,owner/repo 简写只解析到 github.com):
bash
/plugin marketplace add git@github.example.com:platform/claude-plugins.git
/plugin marketplace add https://github.example.com/platform/claude-plugins.gitmanaged settings 中用 hostPattern 放行整个 GHES 实例:
json
{
"strictKnownMarketplaces": [
{ "source": "hostPattern", "hostPattern": "^github\\.example\\.com$" }
]
}为开发者预注册内部 marketplace:
json
{
"extraKnownMarketplaces": {
"internal-tools": {
"source": { "source": "git", "url": "git@github.example.com:platform/claude-plugins.git" }
}
}
}替代 GitHub MCP server:gh auth login --hostname github.example.com 后由 Claude 在会话中调用 gh 命令。
什么时候用
- 组织在自托管 GHES 实例(而非 github.com)上托管仓库,且使用 Team 或 Enterprise 套餐
- 需要在 GHES 仓库上运行 web sessions、自动化 code review 或 Claude Security
- 要从内部 GHES 托管的 marketplace 分发内部插件工具
- 希望开发者无需按仓库配置即可使用 Claude Code
限制 / 坑
- GitHub MCP server 不支持 GHES,需改用为 GHES host 配置的 gh CLI
- /install-github-app 仅适用于 github.com;GHES 须走 claude.ai 的 admin setup 流程
- GitHub Actions 需手动配置 workflow(参考官方 claude.yml 示例手动适配)
- marketplace 的 owner/repo 简写始终解析到 github.com,GHES 必须用完整 git URL
- GHES 实例须能从 Anthropic 基础设施访问;若在防火墙后,需放行 Anthropic API IP 地址
硬事实速查(12 条)
- GHES 支持面向 Team 和 Enterprise 套餐
- Claude Code on the web、Code Review、Claude Security、Teleport sessions、Plugin marketplaces、Contribution metrics、GitHub Actions 均支持 GHES
- GitHub MCP server 不支持 GHES
- Claude Security 处于 public beta,面向 Enterprise 套餐,地址 claude.ai/security
- admin 设置入口为 claude.ai/admin-settings/claude-code,需要 Claude 组织 admin 权限及在 GHES 创建 GitHub App 的权限
- GitHub App 权限:Contents 读写、Pull requests 读写、Issues 读写、Checks 读写、Actions 只读、Repository hooks 读写、Metadata 只读
- App 订阅事件:pull_request、issue_comment、pull_request_review_comment、pull_request_review、check_run
- 开发者侧无需配置,Claude Code 从 git remote 自动检测 GHES hostname
- 用 claude --remote 启动 web session,会话运行在 Anthropic 基础设施上
- managed settings 用 hostPattern source 类型可放行整个 GHES 实例的 marketplace
- contribution metrics 通过 webhooks 投递到 analytics dashboard
- 若 GHES 在防火墙后,需 allowlist Anthropic API IP 地址才能 clone 与发布 review 评论
官方出处:https://code.claude.com/docs/en/github-enterprise-server