Reference

carrick.json

Per-repo config that tells the scanner which services a repo contains and which env vars and domains name internal services versus third-party APIs.

Carrick writes the configuration for your repositories itself, so you do not need a carrick.json to get an index. Add or edit one when Carrick gets a boundary wrong, to:

  • name a service or split a monorepo
  • classify an outbound call as internal or external
  • leave files out
  • declare a routeless operation
  • name a GraphQL schema

A carrick.json you commit takes precedence over what Carrick derives. It tells Carrick how to read your code. AGENTS.md and CLAUDE.md tell your agent how to work in it.

Single-service configuration

The simplest file names one service. Put the name and any classification lists at the root:

{
  "serviceName": "order-service",
  "externalEnvVars": ["STRIPE_API"]
}

A fuller one, with every classification list:

{
  "serviceName": "order-service",
  "internalEnvVars": ["USER_SERVICE_URL", "INVENTORY_API"],
  "externalEnvVars": ["STRIPE_API", "GITHUB_API"],
  "internalDomains": ["https://api.yourcompany.com"],
  "externalDomains": ["https://api.stripe.com", "https://api.github.com"]
}

Field reference

Field Type Description
serviceName string Identifier for this service displayed in MCP responses and the dashboard.
internalEnvVars string array Environment variables whose values resolve to internal services in your organisation. Calls constructed using these variables are validated against the index.
externalEnvVars string array Environment variables whose values resolve to third-party APIs. Calls constructed using these variables are ignored during contract verification.
internalDomains string array URL prefixes for internal services. Outbound calls starting with these prefixes are matched against the index.
externalDomains string array URL prefixes for external APIs. Outbound calls starting with these prefixes are ignored.
exclude string array Paths the scan leaves out, in gitignore syntax, relative to the service directory. A matching file is not read or indexed. The scan prints how many files the patterns left out.
graphqlSchemas string array Printed GraphQL SDL files that define the operations this service serves, relative to carrick.json. Globs are allowed. See Code-first GraphQL schemas.

Outbound call classification

When code builds a request URL dynamically (such as fetch(${process.env.ORDER_SERVICE_URL}/orders)), Carrick cannot tell whether the destination is an internal service or an external vendor. Classify the variable or domain so contracts are validated correctly.

  • Environment variables match URLs built with template literals or string concatenation.
  • Domains match explicit URL literals and prefixes.

Pull request comments do not report calls built from unclassified environment variables. Add the variables to internalEnvVars or externalEnvVars to classify them.

Monorepo service configuration

When a repository contains several services, declare them in the top-level services array. Carrick scans, type-checks and indexes each entry as an independent service, and checks contracts between them:

{
  "services": [
    {
      "serviceName": "api",
      "directory": "services/api",
      "include": ["packages/shared"],
      "tsconfig": "tsconfig.json",
      "internalEnvVars": ["WORKER_URL"]
    },
    {
      "serviceName": "worker",
      "directory": "services/worker",
      "include": ["packages/shared"]
    },
    {
      "serviceName": "web",
      "directory": "apps/web",
      "tsconfig": "tsconfig.json",
      "externalDomains": ["https://api.stripe.com"]
    }
  ]
}

Service entry fields

Field Type Description
serviceName string Unique service identifier. Always provide an explicit name for each service in a monorepo to avoid index collisions. name is accepted as an alias.
directory string Path to the service root directory, relative to carrick.json.
include string array Additional directories of shared source code to include during type resolution, relative to carrick.json.
tsconfig string Path to the service’s tsconfig.json, relative to directory. For Deno services, omit this to use the nearest deno.json or deno.jsonc.
exclude string array Paths this service leaves out, in gitignore syntax, relative to directory.
graphqlSchemas string array Printed GraphQL SDL files that define the operations this service serves, relative to carrick.json. Globs are allowed. See Code-first GraphQL schemas.
  • Each entry also takes the classification fields (internalEnvVars, externalEnvVars, internalDomains, externalDomains).
  • Files outside declared service directories, node_modules, build output directories and test files are not indexed.
  • When services has at least one entry, sibling top-level fields are ignored. An empty services array falls back to them.
  • An explicit carrick.json takes precedence over the services Carrick derives from workspace manifests.

For a Deno service:

  • An ordinary TypeScript config in tsconfig selects the TypeScript path.
  • A Deno config must name the nearest Deno manifest. deno.json takes precedence over deno.jsonc when both exist.
  • Import maps must be local files.

The optional top-level includes map declares classification for a shared source root once. See Declaring a shared root once.

Declared and routeless operations

Serverless functions (such as AWS Lambdas or Cloudflare Workers) often route on an event payload field or HTTP header rather than a path. To index these handlers as operations, declare an operations block:

{
  "operations": [
    {
      "service": "orders",
      "route": "POST /v1/orders",
      "dispatch": { "location": "body", "field": "action" },
      "operations": [
        { "value": "create", "handler": "src/create.ts:handleCreate" },
        { "value": "refund" }
      ]
    }
  ],
  "services": [
    { "serviceName": "orders", "directory": "functions/orders" }
  ]
}

Operations block fields

Field Type Description
service string Target service matching a declared serviceName.
route string The route served by the handler ("POST /path"). Required when nothing in the source states the route. Omit it when the route is in the source: the block then applies to the service’s dispatching operations that read the same field.
dispatch.location string Dispatch field source: "body" or "header".
dispatch.field string The property or header name that determines dispatch.
operations[].value string An accepted dispatch value representing a distinct operation.
operations[].handler string Optional "file:symbol" mapping to navigate directly to the specific handler function.
source string "generated" on a block Carrick Cloud wrote. Its rows are candidates, not facts you declared. Leave it as written.

Declaring a shared root once

When several services reach a third-party API through the same shared directory, the calls belong to that directory. The top-level includes map declares classification per shared source root:

{
  "includes": {
    "packages/shared": {
      "externalEnvVars": ["STRIPE_API"],
      "externalDomains": ["https://api.stripe.com"]
    }
  },
  "services": [
    {
      "serviceName": "api",
      "directory": "apps/api",
      "include": ["packages/shared"]
    }
  ]
}
  • Each key is a source root spelled as a service names it in its include. A leading ./ and a trailing / are ignored when matching.
  • Each value takes the same four classification fields as a service.
  • Every service whose include lists that root inherits those declarations, unioned with its own. A name declared in both places appears once.
  • A service that does not include the root inherits nothing.
  • A key that no service lists in its include fails the scan, so a mistyped root is reported instead of leaving calls unclassified.

Code-first GraphQL schemas

Carrick reads a GraphQL server’s operations from SDL, meaning .graphql and .gql files under the service’s own directory and gql template literals. A schema built in code (Pothos, TypeGraphQL, Nexus) has no SDL in source, so its queries and mutations are not indexed until the service names the printed schema.

{
  "services": [
    {
      "serviceName": "api",
      "directory": "apps/api",
      "graphqlSchemas": ["apps/api/dist/schema.graphql"]
    }
  ]
}
  • Each entry is a path relative to carrick.json, or a glob such as packages/schema/generated/*.graphql.
  • The file can sit anywhere in the repository, including a build folder like dist/ or another app’s directory, if it is committed.
  • Every Query, Mutation and Subscription field it defines is indexed as an operation this service serves.
  • A single-service carrick.json accepts the field at the top level.

The scan output warns about an entry that matches no file, or a file that defines no root field. It also suggests this setting when a service depends on a GraphQL library and serves HTTP routes but indexes no GraphQL fields. A field is indexed at its resolver’s line where Carrick finds the resolver, and at its schema line where it does not.

GraphQL documents for another team’s API

A client’s GraphQL documents (.graphql and .gql files, and gql template literals) are indexed as calls only when they are written against a schema this repository serves. A committed schema file counts as served when a service names it in graphqlSchemas, or when it sits under a service’s directory and that service serves HTTP routes or has a resolver for one of its fields.

Documents written against any other committed schema, such as a vendor schema downloaded into dist/ or a copy inside a client app, are treated as calls to an external API and are not indexed as calls. The scan output names the schema file and counts its operations. If a schema is served here but not detected, add it to graphqlSchemas.

Two kinds of document are also left out:

  • A document whose fields no single schema holds.
  • A document whose fields sit in both a served and an external schema, unless the file’s environment reads settle it: a file that reads only internalEnvVars counts as internal, and one that reads only externalEnvVars as external.

A document whose fields appear in no schema the repository holds stays a call, because its server may be another repository in the project.

carrick-workspace.json

A folder that holds several repositories can carry a carrick-workspace.json that adjusts which repositories Carrick covers. Carrick finds the repositories in the folder itself, and the file adds or removes some:

{
  "repos": ["../shared-client"],
  "exclude": ["scratch", "old-api"]
}
Field Type Description
repos string array Extra repository paths to cover, relative to the file or absolute.
exclude string array Repositories to leave out, by directory name or path.

carrick init writes the names you leave out of the selection into exclude. It records them under a carrick key so that carrick remove takes back only what init added. Do not edit that key.

  • A listed path that is not a directory on this machine is skipped, and init names it in a warning.
  • Two repositories with the same directory name stop the run. Rename one or list only one.
  • Quickstart covers setup, which writes no configuration files you need to edit.
  • PR comments describes the contract checks posted on pull requests.
  • What Carrick covers details framework extraction and routing support.