Skip to content

Commit 3366190

Browse files
schaconkrlvi
authored andcommitted
Add Cursor hooks integration doc
1 parent e4892c4 commit 3366190

File tree

3 files changed

+53
-4
lines changed

3 files changed

+53
-4
lines changed

content/docs/features/ai-integration/ai-overview.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ If you're using AI agent tools like Cursor, Windsurf, or Claude Code, GitButler
99

1010
https://www.youtube.com/watch?v=J6xV_Wyz9zg
1111

12-
There are currently two main ways to integrate AI tools with GitButler:
12+
There are currently three main ways to use AI tools with GitButler:
1313

14-
1. **Using the MCP Server**: This method allows you to set up your AI agent to communicate with GitButler's MCP server, enabling features like automatic commits and save points.
15-
2. **Using the Hooks in Claude Code**: This method allows you to use GitButler's hooks to manage commits and branches directly from within the Claude Code environment.
14+
1. **Our Agents Tab**: If you have Claude Code setup, you can use our [Agents tab](/features/agents-tab) as a GUI for running Claude Code directly.
15+
2. **Using Hooks in Claude Code or Cursor**: This method allows you to use GitButler's CLI as hook commands to manage commits and branches in either Claude Code or Cursor.
16+
3. **Using the MCP Server**: This method allows you to set up your AI agent to communicate with GitButler's MCP server, enabling features like automatic commits and save points.
1617

1718
## Enabling the experimental feature flag
1819

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: Cursor Hooks
3+
description: Set up Cursor hooks to automatically manage commits and branches when using GitButler with AI coding in Cursor.
4+
---
5+
6+
GitButler integrates seamlessly with Cursor through hooks that automatically manage your commits and branches while you're using AI coding features. This allows you to automatically maintain clean git history and organized virtual branches.
7+
8+
Here's a short video showing how GitButler works with Cursor hooks:
9+
10+
https://youtu.be/NOYK7LTFvZM
11+
12+
Ok, let's get it set up.
13+
14+
## Install the GitButler CLI
15+
16+
First, you need to install the GitButler CLI, which can be done in your General settings. See the [MCP Server documentation](mcp-server) for more details on how to install the CLI.
17+
18+
## Installing GitButler as a Hook
19+
20+
Once the command line tool is installed, you can add the `but cursor` commands as hooks.
21+
22+
You will need to create or edit your `~/.cursor/hooks.json` file (globally) or `[project]/.cursor/hooks.json` file (single project) to have `afterFileEdit` and `stop` hooks like this:
23+
24+
```json
25+
{
26+
"version": 1,
27+
"hooks": {
28+
"afterFileEdit": [
29+
{
30+
"command": "but cursor after-edit"
31+
}
32+
],
33+
"stop": [
34+
{
35+
"command": "but cursor stop"
36+
}
37+
]
38+
}
39+
}
40+
```
41+
42+
## Using GitButler with Cursor
43+
44+
Once the hooks are setup, Cursor will automatically call GitButler when it edits files and when it's done with a task, which will trigger GitButler to:
45+
46+
- Create a branch if the chat session is new
47+
- Assign edits to an active branch
48+
- Commit with a message based on the prompt when a task is done
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"title": "AI Agent Integrations",
33
"defaultOpen": false,
4-
"pages": ["ai-overview", "mcp-server", "claude-code-hooks"]
4+
"pages": ["ai-overview", "mcp-server", "claude-code-hooks", "cursor-hooks"]
55
}

0 commit comments

Comments
 (0)