最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Claude Code接入Github的實現(xiàn)步驟

  發(fā)布時間:2026-05-27 10:28:17   作者:方圓AI分享   我要評論
本文主要介紹了Claude Code接入Github的實現(xiàn)步驟,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

目前AI編程工具可以分為3種類別:

  1. 1.本地IDE,代表產(chǎn)品有cursor、windsurf
  2. 2.在線網(wǎng)站,代表產(chǎn)品有l(wèi)ovable、bolt.new
  3. 3.命令行,代表產(chǎn)品有claude code、codex

claude code這種命令行工具可以很方便地集成到各種平臺中,本篇文章就是介紹如何把claude code快速接入到github中,在開發(fā)流程中嵌入AI能力。

claude code 接入github,我們不需要重復造輪子,anthropic官方提供并開源了名為claude code action(https://github.com/anthropics/claude-code-action)的工具,claude code action更新很頻繁,前段時間剛發(fā)布了正式版本v1,借助它可以快速把claude code集成到github中。

接下來按照配置api key、在github安裝claude、讓claude code參與開發(fā)3個步驟,分享一下如何把claude code集成到github。

配置api key

claude對國內(nèi)賬號封控很嚴重,我們很難用到claude官方的api,好在國產(chǎn)模型進步很快,并且都原生提供anthropic接口格式了,可以作為sonnet的平替接入claude code。我測試glm-4.6和kimi-k2都能夠驅(qū)動claude code正常運行??梢栽?https://bigmodel.cn/usercenter/proj-mgmt/apikeys 創(chuàng)建glm的api key,在 https://platform.moonshot.cn/console/api-keys 創(chuàng)建kimi的api key,然后在你期望接入claude code的github倉庫中配置api key。

進入github倉庫中,點擊settings,然后選擇secrets and variables中的actions,點擊new repository secret按鈕。

在新打開的頁面中填寫Name:ANTHROPIC_API_KEY,Secret:你剛剛創(chuàng)建的glm 或 kimi api key,最后點擊add secret配置成功。

在github安裝claude

接下來,需要在GitHub中安裝claude。在瀏覽器打開 https://github.com/apps/claude,進入claude github app頁面,點擊install按鈕安裝claude應用,如果按鈕位置顯示的不是install而是configure,表示已經(jīng)安裝過該應用。

然后在下面的安裝確認頁面中,可以配置安裝到所有倉庫或者指定倉庫中,點擊install & authorize按鈕確認安裝。

在安裝成功后,如果你的github倉庫還沒有.github/workflows目錄,你需要先創(chuàng)建該目錄,然后在該目錄中添加claude.yml和claude-review.yml文件。

claude.yml文件內(nèi)容如下

name:?Claude?Code
on:
??issue_comment:
????types:?[created]
??pull_request_review_comment:
????types:?[created]
??issues:
????types:?[opened,?assigned]
??pull_request_review:
????types:?[submitted]
jobs:
??claude:
????if:?|
??????(github.event_name?==?'issue_comment'?&&?contains(github.event.comment.body,?'@claude'))?||
??????(github.event_name?==?'pull_request_review_comment'?&&?contains(github.event.comment.body,?'@claude'))?||
??????(github.event_name?==?'pull_request_review'?&&?contains(github.event.review.body,?'@claude'))?||
??????(github.event_name?==?'issues'?&&?(contains(github.event.issue.body,?'@claude')?||?contains(github.event.issue.title,?'@claude')))
????runs-on:?ubuntu-latest
????permissions:
??????contents:?write
??????pull-requests:?write
??????issues:?write
??????id-token:?write
??????actions:?write
????steps:
??????-?name:?Checkout?repository
????????uses:?actions/checkout@v4
????????with:
??????????fetch-depth:?1
??????-?name:?Run?Claude?Code
????????id:?claude
????????uses:?anthropics/claude-code-action@v1
????????env:
??????????#?ANTHROPIC_BASE_URL:?https://api.moonshot.cn/anthropic
??????????ANTHROPIC_BASE_URL:?https://open.bigmodel.cn/api/anthropic
????????with:
??????????anthropic_api_key:?${{?secrets.ANTHROPIC_API_KEY?}}
??????????claude_args:?|
????????????--allowedTools?"mcp__github_inline_comment__create_inline_comment,Bash(gh?pr?comment:*),Bash(gh?pr?diff:*),Bash(gh?pr?view:*),Bash(gh?issue:*),Bash(gh?search:*),Bash(gh?label:*)"

claude-review.yml文件內(nèi)容如下

name:?Claude?Review
on:
??pull_request:
????types:?[opened,?synchronize]
????#?Optional:?Only?run?on?specific?file?changes
????#?paths:
????#???-?"src/**/*.ts"
????#???-?"src/**/*.tsx"
????#???-?"src/**/*.js"
????#???-?"src/**/*.jsx"
jobs:
??claude-review:
????#?Optional:?Filter?by?PR?author
????#?if:?|
????#???github.event.pull_request.user.login?==?'external-contributor'?||
????#???github.event.pull_request.user.login?==?'new-developer'?||
????#???github.event.pull_request.author_association?==?'FIRST_TIME_CONTRIBUTOR'
????runs-on:?ubuntu-latest
????permissions:
??????contents:?read
??????pull-requests:?write
??????id-token:?write
????steps:
??????-?name:?Checkout?repository
????????uses:?actions/checkout@v4
????????with:
??????????fetch-depth:?0
??????-?name:?Run?Claude?Review
????????id:?claude-review
????????uses:?anthropics/claude-code-action@v1
????????env:
??????????#?ANTHROPIC_BASE_URL:?https://api.moonshot.cn/anthropic
??????????ANTHROPIC_BASE_URL:?https://open.bigmodel.cn/api/anthropic
????????with:
??????????anthropic_api_key:?${{?secrets.ANTHROPIC_API_KEY?}}
??????????track_progress:?true
??????????prompt:?|
????????????REPO:?${{?github.repository?}}
????????????PR?NUMBER:?${{?github.event.pull_request.number?}}
????????????Please?review?this?pull?request?with?a?focus?on:
????????????-?Code?quality?and?best?practices
????????????-?Potential?bugs?or?issues
????????????-?Security?implications
????????????-?Performance?considerations
????????????Provide?detailed?feedback?using?inline?comments?for?specific?issues.
????????????Please?respond?in?Simplified?Chinese.
??????????claude_args:?|
????????????--allowedTools?"mcp__github_inline_comment__create_inline_comment,Bash(gh?pr?comment:*),Bash(gh?pr?diff:*),Bash(gh?pr?view:*)"

注意在上面兩個文件中有 ANTHROPIC_BASE_URL 配置,默認配置的是glm網(wǎng)址,如果使用的kimi模型,需要更改為 https://api.moonshot.cn/anthropic。另外在配置文件最后有--allowedTools參數(shù),claude code使用的是工具白名單,如果需要某個特定的工具,需要配置到該參數(shù)中。

可能有人不熟悉.github/workflows目錄,它是github中的保留目錄,用于保存自動化工作流程的配置文件,可以配置當觸發(fā)某些事件時執(zhí)行哪些操作。比如可以在此目錄中配置實現(xiàn)當提交新的代碼時自動運行打包鏡像、測試代碼等功能。claude code action也是通過此機制實現(xiàn)的讓claude回答用戶提問、自動審閱代碼等功能。

讓claude code參與開發(fā)

執(zhí)行完上述步驟,claude code就已經(jīng)接入到你的github倉庫中了。你可以在github中issue中評論@claude,讓ai回答你的問題甚至可以讓ai直接提交代碼完成你的需求。下面是一些例子

我創(chuàng)建了python包管理方案討論的issue,在評論中詢問claude,讓claude推薦一個方案。

在一個后端接口需求中直接讓claude實現(xiàn)該需求,claude code能夠提交代碼到某個分支,點擊Create PR鏈接可以手動創(chuàng)建代碼合并。

除了可以在issue/pr中@claude以外,claude-review.yml工作流還支持自動審閱代碼。提交pr后,claude可以自動審閱提交的代碼,查看代碼中的問題,并給出改進建議。

到此這篇關于Claude Code接入Github的實現(xiàn)步驟的文章就介紹到這了,更多相關Claude Code接入Github內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持腳本之家! 

相關文章

最新評論

鄱阳县| 读书| 吕梁市| 康定县| 顺昌县| 内黄县| 内黄县| 凤翔县| 南郑县| 广平县| 巫山县| 突泉县| 洞口县| 太保市| 新密市| 渭源县| 集安市| 三门县| 鄱阳县| 赤城县| 大石桥市| 兴山县| 金塔县| 新民市| 赞皇县| 临沂市| 桐城市| 盐山县| 广元市| 武宁县| 保山市| 鞍山市| 田阳县| 南京市| 亳州市| 深圳市| 无棣县| 凉城县| 农安县| 南丰县| 新野县|