0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

CodeRabbitの設定ファイルが動的に変更できるようになりました

0
Last updated at Posted at 2026-09-29

CodeRabbitはAIコードレビューを軸に、Agentic Change Managementを提供します。AIコーディングエージェントが生成する大量のコードに対して、理解負債の解消、優先順位付け、そしてセキュアな状態を維持します。

CodeRabbitでは、リポジトリ単位の設定を .coderabbit.yaml というファイルで行えるのですが、新しく動的に(プログラマブルに)設定を変更できる .coderabbit.config.ts に対応しました。

基本的な使い方

以下、 .coderabbit.config.ts の記述例です。

.coderabbit.config.ts
import { defineConfig } from "@coderabbitai/config"
export default defineConfig({
  language: "ja-JP",
  reviews: {
    profile: "chill",
    poem: false,
  },
})

たとえば、PRのラベルに hotfix が入っている場合はprofileをassertiveに変更する場合は以下のようになります。

.coderabbit.config.ts
import { defineConfig, type CodeRabbitContext } from "@coderabbitai/config"

function isHotfix(ctx: CodeRabbitContext): boolean {
  const pr = ctx.pr
  if (!pr) return false
  return (
    /hotfix/i.test(pr.title) ||
    pr.headBranch.startsWith("hotfix/") ||
    pr.labels.some((label) => label.toLowerCase() === "hotfix")
  )
}

export default defineConfig((ctx) => ({
  reviews: {
    profile: isHotfix(ctx) ? "assertive" : "chill",
    poem: !isHotfix(ctx),
  },
}))

defineConfig を定義し、その1つ目の引数として ctx を受け取り、その内容を変更して設定のJSONを返却すればOKです。

書き方

ctx は CodeRabbitContext という型を持っています。型ファイルはnpmなどでインストールできます。

npm install --save-dev @coderabbitai/config@next

pnpm add --save-dev @coderabbitai/config@next

yarn add --dev @coderabbitai/config@next

bun add --dev @coderabbitai/config@next

あとは CodeRabbitContext で入力補完しながら進められます。基本としては設定のJSONスキーマにある内容がそのまま指定・上書きできます。

また、CLI経由のレビューかどうかで判定もできます。追加のコンテキストについては、こちらのドキュメントを参照してください。

.coderabbit.config.ts
import { defineConfig } from "@coderabbitai/config"

export default defineConfig((ctx) => ({
  reviews: {
    profile: ctx.invocation.source === "cli" ? "chill" : "assertive",
    poem: ctx.invocation.source === "cli",
  },
}))

まとめ

このプログラマブルな設定を使えば、担当者によってレビュー言語を変更する(日・英)など、より柔軟な運用が可能になります。ラベルなどを使うことで、レビュープロフィールを変更すれば、厳しく見て欲しい場面とそうでない時を簡単に切り替えられるでしょう。

ぜひ新しい設定ファイルフォーマットを試してください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?