Git AI

Cursor Agent

Track Cursor Agent generated code with Git AI.

Commits from Cursor Agent are attributed to AI in git ai blame and the analytics on Git AI Team and Enterprise dashboards.

Capabilities

FeatureSupported
AI Attribution
Prompts
Token usage
Skill / MCP / Tool Use

Setup

Cursor's cloud Background Agents do not load user-level hooks, so the integration must be configured per-repository by committing the files below to your repo. Don't worry - these won't conflict with the user-level hooks that get invoked during local development.

1. Add the hook configuration

Create .cursor/hooks.json in your repository:

.cursor/hooks.json
{
  "hooks": {
    "afterFileEdit": [
      {
        "command": "git-ai checkpoint cursor-background --hook-input stdin"
      }
    ],
    "postToolUse": [
      {
        "command": "git-ai checkpoint cursor-background --hook-input stdin"
      }
    ],
    "preToolUse": [
      {
        "command": "git-ai checkpoint cursor-background --hook-input stdin"
      }
    ]
  },
  "version": 1
}

2. Add the install script

Create .cursor/install.sh to install Git AI on each Background Agent run:

.cursor/install.sh
#!/usr/bin/env bash
set -euo pipefail

curl -fsSL https://raw.githubusercontent.com/git-ai-project/git-ai/refs/heads/main/install.sh | bash

Optional: send checkpoints to Git AI Teams or Enterprise

If you're on Git AI Teams or Enterprise, set a telemetry write key so Background Agent telemetry is streamed to your dashboard in real-time. Add GIT_AI_WRITE_TELEMETRY as an environment variable in your Cursor Background Agent settings (you'll find the key in the Git AI dashboard), then append this line to .cursor/install.sh:

~/.git-ai/bin/git-ai config set api_key "$GIT_AI_WRITE_TELEMETRY"

3. Wire up the install script in environment.json

Tell Cursor to run the install script when the Background Agent environment boots:

.cursor/environment.json
{
  "name": "test-cursor",
  "install": "bash .cursor/install.sh"
}

Once these three files are committed, every Background Agent run will install Git AI, register the hooks, and stream checkpoints to your team's dashboard.