.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
async and return a promise.
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 a required invocation field. The exported CodeRabbitContext type keeps invocation optional for compatibility with code written before invocation context was added. Use ResolvedCodeRabbitContext when explicitly annotating a helper that requires ctx.invocation.
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 from your coderabbit repository
Use includeRemote to pull a shared fragment from your organization’s central coderabbit repository — the same repository used for central configuration:
.coderabbit.config.ts
ref, which accepts a branch, tag, or commit SHA:
ref to track the coderabbit repository’s default branch, so central edits propagate to every repository automatically.
The source repository is not configurable. Shared files are always read from
{owner}/coderabbit, and passing a repo key is rejected. This keeps a configuration from reading arbitrary repositories in your organization: remote includes can only reach the one repository that is already the organization-wide configuration location. Files are fetched with CodeRabbit’s existing read access, so the coderabbit repository can be 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 a literal { path: "..." } object with an optional literal ref.Cannot resolve include
Cannot resolve include
The file does not exist at that path, or CodeRabbit cannot read it. Check the path, the
ref if you pinned one, and — for remote includes — that the file is in the coderabbit repository under the same owner and that CodeRabbit has access to that 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