惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学
人人都是产品经理
人人都是产品经理
酷 壳 – CoolShell
酷 壳 – CoolShell
L
LangChain Blog
Blog — PlanetScale
Blog — PlanetScale
阮一峰的网络日志
阮一峰的网络日志
Microsoft Azure Blog
Microsoft Azure Blog
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
Hugging Face - Blog
Hugging Face - Blog
Y
Y Combinator Blog
D
DataBreaches.Net
Engineering at Meta
Engineering at Meta
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements

Butler's Log

Figma agent vs. one button: shipping design tokens to npm Local Model Performance on an M5 Max GitButler 0.22 - "Catch 22" Agentic Version Control Benchmarks Grit: rewriting Git in Rust with agents Git Merge 2026 Agent-safe Git with GitButler We’ve raised $17M to build what comes after Git Announcing the GitButler CLI for Linux The Great CSS Expansion A couple of git nits Simplifying Git by Using GitButler Introducing the GitButler CLI GitButler 0.19 - "Commander Keen" But Head: Crafting a Custom Font MCP vs RAG: Two Very Different Ways to Gain Context Getting Started With GitButler Agents Using the GitButler MCP Server to Build Better AI-Driven Git Workflows Using GitButler With Multiple GitHub Accounts Advent of Code! Upcoming GitButler Events Use GitButler for your Gerrit workflow Integrating GitButler and GitHub Enterprise Butler Flow: shipping code faster (but less like Alfred, more like CI on steroids) - Part 3 Butler Flow: shipping code faster (but less like Alfred, more like CI on steroids) - Part 2 Butler Flow: shipping code faster (but less like Alfred, more like CI on steroids) - Part 1 Grid Happens: Because Flexbox Wasn’t Enough Deep Dive into the new Cursor Hooks A Responsive Item Counter with CSS only GitButler 0.16 - "Sweet Sixteen"
Using Cursor Hooks for automatic version control
Scott Chacon · 2025-09-24 · via Butler's Log

Today's release of Cursor 1.7 introduces a new lifecycle hooks feature, which makes it easy to use GitButler to automatically write smart commits and create new branches from your Cursor chats in the background.

Introduction to using GitButler with Cursor Hooks

One of the nice things about the GitHub Mafia is that there are helpful Hubbers everywhere.

After we made the Claude Code hooks integration, I reached out to some amazing ex-Hubbers at Anysphere to see if they could help us with a way to more easily see what Cursor was doing when it worked, so we could build some tools to help automate the version control of it's work.

At the time, they were working on writing temporary Git commits into a hidden ref as the agent worked as a sort of snapshotting system and we thought we could tie into that. However, after some issues turned up, they moved on to pursuing a hooks system instead.

Happily, they invited us to try out the new system as it was being built in the nightlies, so we got to give early feedback and hopefully help improve the API and documentation. This is how we're able to provide our hooks compatibility on the first day.

There are a few challenges that I think we've all faced when using agentic coding systems, expecially around version control.

If you do setup some sort of Git subagent, MCP server or ruleset, you have to wait for it to run every time and you simply end up with one big stack of commits. So most developers just wait and do the committing by hand, which means you probably mix up work or lose context. Or best case, have to switch context when the agentic task is done.

It's much nicer (and much, much faster) to have this done automatically and have the commits aware of the agentic context prompt when crafting the commit message.

Cursor hooks are read from a hooks.json file, either in your project's .cursor directory, or your user's global ~/.cursor directory if you want the hooks to run for all your projects. (There is also an enterprise directory at /etc/cursor/hooks.json but I assume that's rarely used?)

You need to install the GitButler CLI from either brew install gitbutler or through your GitButler settings.

That gives you the but command line tool, which is what you need to setup as your hooks. Your hooks file would then look like this:

JSON

{
  "version": 1,
  "hooks": {
    "afterFileEdit": [
      {
        "command": "but cursor after-edit"
      }
    ],
    "stop": [
      {
        "command": "but cursor stop"
      }
    ]
  }
}

We make use of the afterFileEdit hook to mark files that Cursor has modified and assign them to a branch, then commit and write a message on the stop hook.

Now every new chat you do will automatically be put in a new branch and every time the task is completed, a new commit will be made based off your prompt. You can always easily squash down commits later, but now you have a nice starting point and a reminder of what your prompt history was.

The other nice thing is that creating a new chat automatically makes a new branch in parallel, meaning it's easier to have it start work on a new thing and easily split that out into an independent PR.

Check out our video intro or docs to learn more about how cool it is to use Cursor with GitButler in the background automatically handling everything.

I'm glad you asked!

We learned a lot about hooks while reviewing the functionality and developing the integration, so we wrote up a deep dive article if you're interested in how hooks work and what else you can currently do with them.

The Cursor hooks integration is available in the latest GitButler release's CLI. If you have questions or feedback, join us in our Discord community - we'd love to hear about your experience!

Scott Chacon

Written by Scott Chacon

Scott Chacon is a co-founder of GitHub and GitButler, where he builds innovative tools for modern version control. He has authored Pro Git and spoken globally on Git and software collaboration.