Skip to Content
harness-kit

codegraph

The built-in Policy codegraph, against a checkout that loads another checkout’s packages, a stale worktree, a full disk: its defaults, its options and a configuration that writes it.

To learn what it guards against and see it at work, read the guide: Session start.

Defaults

DefaultValue
On by defaultno: an entry turns it on
Fail modeopen
Timeout9000 ms
EventsPreToolUse, SessionStart
Toolsmcp__codegraph__codegraph_explore
Agent typesevery agent, or as its options set

Options

OptionTypeDefaultDescription
binstring—The codegraph command, relative to the checkout the session works in or absolute; node_modules/.bin/codegraph, the checkout's own, when absent.
contextboolean—Whether a synced index adds the context that tells the agent to ask CodeGraph first (true when absent); a skipped or failed sync is reported either way.
deadlineMillisinteger—How long the sync may take, in milliseconds, before the session starts (or stops) without it (6000 when absent).
debounceMillisinteger—How long after a sync at a stop the next stop of the session skips the sync, in milliseconds (60000 when absent); it applies only with syncAtStop.
installCommandstring—The command the skip note tells the agent to run; the project's package manager's (npm ci, pnpm install --frozen-lockfile) when absent.
syncAtStopboolean—Whether a stop of a session that touched files syncs the checkout's index, so the next session or subagent reads it current without a CodeGraph MCP server watching it (false when absent); a failed sync lets the stop through.

Example

A configuration that writes every option, a comment above each:

import { defineConfig } from '@microeinhundert/harness-kit';

export default defineConfig({
  // The Policy entries, in the order their Decisions merge in.
  policies: [
    {
      // The Policy's name, unique in the configuration; messages and logs name the Policy by it.
      id: 'codegraph',
      // The constructor's options, which it decodes.
      options: {
        // The `codegraph` command, relative to the checkout the session works in or absolute;
        // `node_modules/.bin/codegraph`, the checkout's own, when absent.
        bin: 'node_modules/.bin/codegraph',
        // Whether a synced index adds the context that tells the agent to ask CodeGraph first
        // (`true` when absent); a skipped or failed sync is reported either way.
        context: true,
        // How long the sync may take, in milliseconds, before the session starts (or stops) without
        // it (6000 when absent).
        deadlineMillis: 1,
        // How long after a sync at a stop the next stop of the session skips the sync, in
        // milliseconds (60000 when absent); it applies only with `syncAtStop`.
        debounceMillis: 1,
        // The command the skip note tells the agent to run; the project's package manager's
        // (`npm ci`, `pnpm install --frozen-lockfile`) when absent.
        installCommand: 'npm ci',
        // Whether a stop of a session that touched files syncs the checkout's index, so the next
        // session or subagent reads it current without a CodeGraph MCP server watching it (`false`
        // when absent); a failed sync lets the stop through.
        syncAtStop: true,
      },
      // The name of the kit's Policy constructor that builds the Policy.
      use: 'codegraph',
    },
  ],
});

On this page