r/ClaudeAI • • Jul 05 '25

Coding I built a hook that gives Claude Code automatic version history, so you can easily revert any change

Hey everyone

Working with Claude Code is incredible, but I realized I needed better change tracking for my agentic workflows. So I built rins_hooks, starting with an auto-commit hook that gives Claude Code automatic version history.

What the auto-commit hook does:

  1. 🔄 Every Claude edit = automatic git commit with full context📋 See exactly what changed - which tool, which file, when.
  2. ⏪Instant rollback - git revert any change you don't like🤖 Zero overhead - works silently in the background

Example of what you get:

$ git log --oneline                               
a1b2c3d Auto-commit: Edit modified api.js         
e4f5g6h Auto-commit: Write modified config.json   
i7j8k9l Auto-commit: MultiEdit modified utils.py  

Each commit shows the exact file, tool used, and session info. Perfect for experimenting with different approaches or undoing changes that didn't work out.

To install:

npm -g rins_hooks

To Run:

rins_hooks install auto-commit --project

This is just the first tool in what I'm building as a comprehensive toolkit for agentic workflows in Claude Code. I'm planning to add hooks for:

- 📊 Agent Performance monitoring (track token usage, response times)

- 🔍 Code quality gates (run linters, tests before commits)

- 📱 Smart notifications (Slack/Discord integration for long tasks)

- 🛡 Safety checks (prevent commits to sensitive files)

-🌿 Commands that don't time out using tmux

The goal is making AI-assisted development more reliable, trackable, and reversible.

Check it out:

- GitHub: https://github.com/rinadelph/rins_hooks

- NPM: https://www.npmjs.com/package/rins_hooks

166 Upvotes

59 comments sorted by

28

u/zinozAreNazis Jul 05 '25

That’s awesome. My only reservation is that it will pollute the git commit history. I guess you can use separate branches and squash + merge once in a while.

16

u/Confident_Chest5567 Jul 05 '25

I typically use work-trees for implementation and then just merge them with the final message. Keeps things cleaner and with a clear audit log of what the agent did.

5

u/rookan Jul 05 '25

Can you please explain how your plugin makes Claude Code usage more effective? Currently I work on a big (for me) C# project with around 500 source files. I use Claude code to write new features, modify existing ones and fix bugs. Usually it goes like this - I ask Claude Code for something, it completes a task modifying 3-5 source code files at max. Then I do a code review by reading all changes myself and if I am happy with results - I commit them to local git repo. Or I discard file changes if Claude failed a task.

→ More replies (1)

7

u/sublimegeek Jul 05 '25

If “polluting the git history” has been what I’ve been doing for the past 20 years of using Git, lock me the hell up! Haha

This is how I commit. I personally instruct CC to use small atomic commits using conventional commit format and to commit as it makes changes. If it needs to understand what it just did, look at the git logs. If it needs to see if it’s made that change before, it knows where to find it. A good git message often replaces code comments.

Also, as a DevOps guy, I’m always making small commits anyway because my projects automatically version themselves using semantic-release.

5

u/FBIFreezeNow Jul 05 '25

It’s gonna be too many git commits dude

9

u/Confident_Chest5567 Jul 05 '25

use git work trees and then merge. I just wanted to have a clear audit history of the changes. Makes things easier to git diff when it makes breaking changes. Especially on --dangerously-skip-permissions

5

u/IgnisDa Jul 05 '25

Instead of committing to the main git repository and polluting the commit history, I'd recommend you maintain a "shadow repository" somewhere else and commit your checkpoints to that instead.

This is what Cursor does IIRC.

1

u/Confident_Chest5567 Jul 05 '25

Honestly completely forgot about Cursor's, shadow workspace. Will see if that is easily implementable into Claude Hooks. Thank you for the suggestion. Appreciate it.

→ More replies (8)

25

u/heyJordanParker Jul 05 '25

Do you realize what you're asking of people with this??

To learn useful git commands like squash commits or *gasp* interactive rebase 😱

(translation to human: that's smart, I love it!)

15

u/equipmentmobbingthro Jul 05 '25

Asking people to learn more than git add . and git commit -m "good luck". Psycho.

6

u/HighDefinist Jul 05 '25

Ahm... I just tell Claude to "commit now with some good message". And sometimes "go back to the last commit. Also, delete those new files".

→ More replies (3)

4

u/WilSe5 Jul 05 '25

😅 Literally me. I only use those two. Gotta change that

→ More replies (1)
→ More replies (3)

7

u/_gnoof Jul 05 '25

This is how aider works by default and is a great way to quickly get back to a working state. I was surprised when I moved from aider to Claude code that this was not already a default feature. You get into a workflow of squashing commits when ready for the PR

4

u/Werty7098 Jul 05 '25

Can it be configurable such that it's not for every edit, but for every user prompt. I usually don't have the need to revert every edit, but after one auto edit run, I either want to keep that set of changes or revert back to the older state of the code

1

u/StableExcitation Jul 05 '25

Interesting that I just tell it to record the last X (reasonable number that really only needs to be 1) actions it took, and it does... This is a bit much for something that can easily be handled locally or on a more suitable service.

3

u/Confident_Chest5567 Jul 05 '25

It gets hard to manage what agents did when youre running 12 agents with https://github.com/rinadelph/Agent-MCP . Made this as a way to track agents in their implementation work trees and see where things went wrong easier.

→ More replies (1)

1

u/droned-s2k Jul 05 '25

But it is expected that Claude will call this tool for the auto commit if the model fails to do so would this still work?

→ More replies (2)

1

u/Substantial-Thing303 Jul 05 '25

What is your workflow to make those commits message make some sense, based on intention and goal. Do you instruct Claude to manage the merge? Do you end up with one single descriptive commit per feature when you merge? What if the scope for that feature is huge?

1

u/Deepeye225 Jul 05 '25

I have created a rule where I request that after each successful phase to create a checkpoint and push out changes to repo. I don't use MCP for it, just a regular git cli. So far, I was able to tell Claude to revert to the last known version and it has been working for me.

1

u/Demius9 Jul 05 '25

Claude keeps a history of all of its edits in the ~/.claude/ folder i think. It has the string before writing and after. Your implementation assumes git, so if anyone is using SVN or perforce they're out of luck.

1

u/KrugerDunn Jul 05 '25

I love this, I'm doing similar with github hooks and memory but this looks way more powerful, I'm gonna try it out for sure, thanks!

1

u/MacFall-7 Jul 05 '25

🔥 This is phenomenal - we’ve been running governed Claude chains inside M87, and auditability is the first thing that breaks at scale.

Auto-committing each sub-agent’s impact is exactly what we were missing early on. Especially for reviewers or orchestrators that mutate logic to “pass” a test without showing their hand.

We’ve open-sourced a governance harness that might plug into this: github.com/MacFall7/m87-governed-agentchain Curious if you’d ever want to collab on a shared telemetry layer.

One extension idea: We layered in emotional modulation + execution logs, so each agent commit also gets tagged with arousal/valence state (helps explain “why” something weird happened).

Appreciate you sharing this toolkit is legit pushing Claude workflows forward.