.coderabbit.config.ts file lets you author your CodeRabbit configuration as TypeScript code instead of static YAML. You get editor autocomplete and author-time type checking, you can build configuration with ordinary JavaScript (loops, conditionals, functions), you can share fragments across repositories, and you can adapt settings to the pull request and invocation that triggered the review.
The @coderabbitai/config SDK used in the examples below is optional. CodeRabbit evaluates your configuration file server-side either way; installing the package only adds types and autocomplete while you write it. See Install the SDK.
When to use TypeScript configuration
TypeScript configuration adds capabilities a static YAML file does not have:Catch mistakes before review
With the optional SDK, misspelled keys and invalid enum values are flagged in your editor and in CI, not silently at review time
Adapt to the review context
Change the review profile based on labels, target branch, author association, or whether the review runs in the CLI
Generate repetitive settings
Build
path_instructions for a dozen packages from an array instead of hand-writing each entryShare configuration fragments
Compose organization-wide defaults with repository-specific overrides
Install the SDK (optional)
The@coderabbitai/config package is entirely optional. CodeRabbit evaluates your configuration server-side with its own implementation of defineConfig, mergeConfig, and includeRemote, so a .coderabbit.config.ts works exactly the same whether or not the package is installed. Nothing in this guide requires it.
What the package adds is author-time tooling: types, editor autocomplete, and the ability to type-check your configuration in CI. If you would rather not add a dependency, write the same file without it and CodeRabbit will still evaluate it — you just lose autocomplete and local type errors.
The SDK is currently published under the next tag. To install it as a development dependency:
Your first configuration
Create a.coderabbit.config.ts file in the root of your repository, with a defineConfig call as its default export:
.coderabbit.config.ts
.coderabbit.yaml
Adapt configuration to the review context
defineConfig also accepts a factory function that receives a context object describing the platform, repository, organization, and pull request. This is the capability a static YAML file cannot provide.
Pull request context
Review outside contributions more strictly than internal ones:.coderabbit.config.ts
.coderabbit.config.ts
.coderabbit.config.ts
async and return a promise.
Author teams and groups
On GitHub and GitLab, configuration can use the pull request author’s team or group memberships. This example selects a review profile for authors in regional platform teams:.coderabbit.config.ts
groups contains the author’s visible teams in the repository organization. On GitLab, it contains direct group memberships under the repository’s top-level namespace; inherited and shared memberships are not included. The field is unsupported on other providers and in local CLI reviews.
Check status === "resolved" before using groups for a policy decision. A status of unavailable means the membership lookup failed or timed out, while stale is reserved for cached membership data that may be out of date. groups is empty for unavailable and unsupported results.
Repository topics and custom properties
Use repository topics and GitHub custom properties to select configuration for a repository without duplicating configuration files:.coderabbit.config.ts
ctx.repo.topics.names is a sorted string array. ctx.repo.customProperties.values is keyed by property name; each value is a string, a string array, or null.
Both metadata objects include a status with the following values:
"resolved": CodeRabbit received an authoritative result. The names or values collection may be empty."unavailable": A timeout, permission issue, provider failure, or unsupported GitHub Enterprise Server version prevented resolution. The empty collection represents an unknown result and does not prove that the repository has no topics or properties."unsupported": The current provider or invocation does not support the lookup. Providers other than GitHub and local CLI reviews currently use this status."stale": Reserved for a future cached result.
Invocation context for CLI reviews
The invocation context distinguishes local CodeRabbit CLI reviews from reviews started through a source control provider. For example, use thechill profile when running coderabbit review locally and the assertive profile for hosted pull request reviews:
.coderabbit.config.ts
ctx.invocation.source is "cli" for a local coderabbit review invocation and "review" for reviews initiated through a source control provider or another review client. Use this field instead of ctx.platform when configuration depends on whether the CLI started the review.
The CLI automatically discovers configuration in the repository root. It checks .coderabbit.yaml, .coderabbit.yml, coderabbit.yaml, and coderabbit.yml before .coderabbit.config.ts; the first YAML file found takes precedence.
Context reference
CodeRabbit computes the context and injects it at evaluation time. It contains only non-sensitive metadata — there are no tokens or secrets in it.ctx.pr is resolved for every event that triggers a review, not only the pull request webhook — comment commands such as @coderabbitai review, label events, and manual re-reviews included. Still guard with ctx.pr?. because it is null for events with no pull request. Any field that cannot be resolved degrades gracefully instead of failing configuration resolution.defineConfig factory has required invocation and ctx.pr.authorGroups fields. The exported CodeRabbitContext type keeps both additions optional for compatibility with code written before they were added. ResolvedCodeRabbitContext requires invocation but keeps authorGroups optional for the same compatibility reason.
Compose configuration with mergeConfig
mergeConfig deep-merges configuration fragments left to right, so you can layer overrides onto a base:
.coderabbit.config.ts
Merge rules
Generate configuration programmatically
Because the file is code, repetitive configuration can be derived instead of hand-written:.coderabbit.config.ts
Share configuration across files and repositories
Local includes
Split a large configuration into multiple files in the same repository and pull them in with ordinary relative imports:.coderabbit.config.ts
- YAML files can be imported. A
.yamlor.ymlimport becomes a module whose default export is the parsed object, so existing YAML fragments can be reused as-is. - Extensionless imports work. CodeRabbit tries
.ts,.mts,.cts,.js,.mjs,.cjs,.yaml, and.yml, then the same extensions under<path>/index, matching how your editor resolves the import. - Imports cannot escape the repository root. A relative path that resolves outside the repository tree is rejected rather than silently clamped.
Remote includes
UseincludeRemote to pull a shared fragment from another repository. When repo is omitted, CodeRabbit reads from your organization’s central coderabbit repository — the same repository used for central configuration:
.coderabbit.config.ts
repo uses the provider’s native fully qualified repository format, such as owner/repository on GitHub or group/subgroup/repository on GitLab. GitHub targets must have the same owner as the reviewed repository. GitLab targets may use another namespace when the configured CodeRabbit connection can read it.
Pin a specific version with the optional ref, which accepts a branch, tag, or commit SHA:
ref to track the selected repository’s default branch, so shared edits propagate automatically.
CodeRabbit verifies access before reading a selected repository. Its configured provider connection must be able to read the repository. When the .coderabbit.config.ts comes from the pull or merge request’s head branch, both the request author and the distinct human actor who started the review must also be able to read it. If CodeRabbit cannot verify either user’s access, configuration resolution fails closed. Trusted target-branch configuration relies on the configured provider connection without this additional user check. The reviewed repository and the central coderabbit repository retain their existing trusted behavior.
Omit
repo for the established central-configuration flow. For example, includeRemote({ path: "base.ts" }) still reads {owner}/coderabbit, including when that repository is private.How evaluation works
Understanding the pipeline explains most of the constraints below:1
Discovery
CodeRabbit looks for configuration files in the repository under review.
.coderabbit.config.ts is checked last, so any YAML configuration wins.2
Bundling
Your entry file, every file it includes (local and remote), and an implementation of
@coderabbitai/config are bundled server-side into a single self-contained program. All file fetching happens here, outside the sandbox. Includes are modeled as imports, so recursion, deduplication, and cycles are handled by the module graph.3
Sandboxed evaluation
The bundle runs in an isolated sandbox with all outbound networking denied, an empty environment, no secrets, and a hard timeout. Configuration evaluation legitimately needs none of those, so they are removed rather than restricted.
4
Validation
The resulting object is validated against the same schema a
.coderabbit.yaml uses, and then flows through the same pipeline — including configuration inheritance, UI settings priority, and global overrides..coderabbit.config.ts in your central coderabbit repository works as a central configuration too.
Constraints and limits
The
remote_config YAML redirect described in shared configuration applies to YAML files only. In a TypeScript configuration, use relative imports and includeRemote for the same purpose.Verify the resolved configuration
Run@coderabbitai configuration on any pull request to see the fully resolved configuration as YAML, annotated with the source that supplied each value. For TypeScript configurations, the annotations identify the specific file each value came from, so you can tell an organization default apart from a repository override in a composed configuration.
Type-check your configuration in CI
With the SDK installed and.coderabbit.config.ts included in your TypeScript project, your project’s TypeScript compiler validates the configuration file like any other TypeScript source. For example:
profile: "aggressive") are reported as type errors. Adding this to CI catches configuration mistakes before they reach a review.
Troubleshooting
My TypeScript configuration is being ignored
My TypeScript configuration is being ignored
A committed
.coderabbit.yaml or .coderabbit.yml takes precedence over .coderabbit.config.ts. Delete the YAML file. Confirm with @coderabbitai configuration on a pull request, which reports the source of every resolved value.Unsupported import
Unsupported import
Only
@coderabbitai/config, relative includes, and includeRemote are permitted. Configuration files cannot import npm packages or Node.js built-ins — the bundle has no access to your node_modules. Move any logic that requires a dependency out of your configuration.includeRemote(...) requires an inline object literal
includeRemote(...) requires an inline object literal
includeRemote is resolved before your configuration runs, so its argument cannot be computed. Conditionals can select between separate includeRemote calls with literal arguments, including inside mergeConfig. Each includeRemote argument must remain an inline object with a literal path and optional literal repo and ref values.Cannot resolve include
Cannot resolve include
The file does not exist at that path, or CodeRabbit cannot read it. Check the path, repository name, and
ref if you pinned one. For head-branch configuration, also confirm that the pull or merge request author and the human actor who started the review can read the selected repository.Evaluation timed out
Evaluation timed out
Configuration evaluation is capped at 10 seconds. Configuration files are meant to compute a configuration object, not to do heavy work. Remove long loops and expensive computation.
Configuration file must resolve to an object
Configuration file must resolve to an object
The default export must resolve to a configuration object, or be a factory that returns one.
defineConfig is recommended for type checking but is not required at evaluation time. Make sure the configuration is the default export.API reference
What’s next
Configuration reference
Every available option, with defaults and descriptions
Central configuration
Set up the
coderabbit repository that includeRemote reads fromConfiguration priority
How CodeRabbit resolves conflicting configuration sources