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

推荐订阅源

D
DataBreaches.Net
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
SegmentFault 最新的问题
博客园 - 聂微东
罗磊的独立博客
W
WeLiveSecurity
博客园_首页
Scott Helme
Scott Helme
V
Visual Studio Blog
T
The Exploit Database - CXSecurity.com
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
Latest news
Latest news
L
Lohrmann on Cybersecurity
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
A
About on SuperTechFans
F
Full Disclosure
Y
Y Combinator Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
博客园 - 司徒正美
博客园 - Franky
C
CXSECURITY Database RSS Feed - CXSecurity.com
F
Fortinet All Blogs
Blog — PlanetScale
Blog — PlanetScale
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
阮一峰的网络日志
阮一峰的网络日志
S
Schneier on Security
雷峰网
雷峰网
博客园 - 【当耐特】
P
Privacy International News Feed
C
Cyber Attacks, Cyber Crime and Cyber Security
Engineering at Meta
Engineering at Meta
aimingoo的专栏
aimingoo的专栏
MongoDB | Blog
MongoDB | Blog
J
Java Code Geeks
T
Tor Project blog
V
V2EX
爱范儿
爱范儿
C
Check Point Blog
T
Threatpost
Project Zero
Project Zero
量子位
V
Vulnerabilities – Threatpost
Know Your Adversary
Know Your Adversary
I
Intezer
G
GRAHAM CLULEY
P
Privacy & Cybersecurity Law Blog
GbyAI
GbyAI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

Hacker News - Newest: "AI"

AI can't read an investor deck AI as an attorney? Student uses ChatGPT, Gemini to sue UW over alleged racial discrimination Hacking MCP Servers in AI Systems – The Rug Pull: Tool Changes After Approval GitHub - MeepCastana/KubeezCut: Free Web based video editor GitHub - GenAI-Gurus/awesome-eu-ai-act: Curated tools, official sources, OSS, templates, and guides for EU AI Act compliance. Can AI judge journalism? A Thiel-backed startup says yes, even if it risks chilling whistleblowers Coming soon: 10 Things That Matter in AI Right Now DARPA built an AI to fact-check enemy weapons claims What explains heterogeneity in AI adoption? When AI Meets Muscle: Context-Aware Electrical Stimulation Promises a New Way to Guide Human Movements - Department of Computer Science AI Changed How We Build. It Did Not Change What Matters. Linux rules on using AI-generated code - Copilot is OK, but humans must take 'full responsibility for the… Meta spins up AI version of Mark Zuckerberg to engage with employees Code Mode: Let Your AI Write Programs, Not Just Call Tools | TanStack Blog GitHub - Delavalom/graft: Go framework for building AI agents. Type-safe tools, multi-provider (OpenAI, Anthropic, Gemini, Bedrock), zero vendor SDKs. India's TCS tops estimates, says new AI models did not dent services demand Gen Z's fading AI hype Strong feeling: we are in a folded AI reality GitHub - machinarii/total-recall-catalog: A reference catalog of latest knowledge retrieval, memory & RAG systems GitHub - mensfeld/code-on-incus: Give each AI agent its own isolated machine with root, Docker, and systemd. Active defense detects and stops threats automatically.. Quantization, LoRA, and the 8% Problem: Benchmarking Local LLMs for Production AI Iran war: We spoke to the man making Lego-style AI videos that experts say are powerful propaganda Powell, Bessent discussed Anthropic's Mythos AI cyber threat with major U.S. banks GitHub - immartian/bellamem: Persistent belief-graph memory for AI agents. Retrieves decisive context by importance — not recency, not RAG, not /compact. recursive-mode: The Repo-Native Operating System for AI Engineering After the attack on Sam Altman's home, will AI CEO's go on the offensive? The biggest advance in AI since the LLM Opus 4.6 vs GPT 5.4 One Prompt Unity World Generation Test “AI polls” are fake polls Client Challenge Can AI be a 'child of God'? Inside Anthropic's meeting with Christian leaders How to Switch AI Chatbots and Why You Might Want To GitHub - MattMessinger1/agentic_refund_guardrail: Safe refund policy layer for AI agents — Python + TypeScript. Same behavior, shared tests. Adam/papers/emergent_values_whitepaper.md at master · strangeadvancedmarketing/Adam Ask HN: How do you stop playing 20 questions with your AI coding tools How far can automation and AI support psychotherapy? - @theU GitHub - stagas/rtdiff: realtime git diff gui and AI-assisted commits A Mac Studio for Local AI — 6 Months Later A History of the Early Years of AI at the University of Edinburgh Why AI Coding Tools Still Feel Stuck on Localhost MSN AI Datacenters Are Becoming Strategic Targets twitter.com Penn Researchers Use AI to Surface Unreported GLP-1 Side Effects in Reddit Posts Show HN: MoodSense AI (ML and FastAPI and Gradio, Deployed on Hugging Face) Moodsense Ai - a Hugging Face Space by aman179102 AI models are terrible at betting on soccer—especially xAI Grok GitHub - xialeistudio/echoic GitHub - HimashaHerath/github-dev-wrapped: AI-powered weekly GitHub activity reports deployed to GitHub Pages GitHub - alejandrobalderas/claude-code-from-source: Architecture, patterns & internals of Anthropic's AI coding agent — reverse-engineered from source maps AI and Tech brief: Ireland ascendant GitHub - Titovilal/context0: Context0 - Never Surrender Training for a Marathon with an AI Coach: What Worked and What Didn't Cyber Pulse: Agentic Intel - Apps on Google Play I Built an AI PR Reviewer That Catches Bugs by Not Looking for Bugs Gen Z workers are so fearful AI will take their job they’re intentionally sabotaging their company’s AI rollout | Fortune How AI Is Reimagining the Game of Golf–For Both Players and Courses GitHub - nattergabriel/reseed: A CLI tool for managing and distributing agent skills across projects Is SVG the final frontier? My AI workflow evolved from prompts to a near-autonomous workflow MLSharp Help - 3DGS Viewer & Generator I put my cognitive field based AI's runtime on GitHub Is Numble the first AI-proof game? A3: Kubernetes for autonomous AI agent fleets | Emergent Principles Deepali Vyas ("The Elite Recruiter") GitHub - msmarkgu/RelayFreeLLM: A restful API designed to route user prompts to various AI model providers. Unionized ProPublica staff are on strike over AI, layoffs, and wages Unleashing the Advantage of Quantum AI We're heading for an AI-fueled 'dementia crisis,' brain scientist warns The AI-Assisted Breach of Mexico's Government Infrastructure [pdf] GitHub - stef41/lmscan: 🔍 Detect AI-generated text and fingerprint which LLM wrote it. Open-source GPTZero alternative. Zero dependencies, works offline. MSN GitHub - visionscaper/collabmem: Enabling long-term collaboration with Agentic AI - building up episodic and world model memory over time with in-context awareness We gave an AI a 3 year retail lease in SF and asked it to make a profit | Andon Labs AI Code is Hollowing Out Open Source, and Maintainers are Looking the Other Way What leaked "SteamGPT" files could mean for the PC gaming platform's use of AI AI is the boss at this retail store. What could go wrong? GitHub - Wuzu11517/agentic-proxy: Local proxy meant to help reduce With Drones, Geophysics and ArtificiaI Intelligence, Researchers Prepare to Do Battle Against Land Mines A Single Operator, Two AI Platforms, Nine Government Agencies: The Full Technical Report 在 Steam 上购买 FriedrichAI: Offline AI 立省 10% GitHub - inevolin/resume-cli: Hit Claude usage limits? Resume any AI coding session elsewhere. Switch tools at zero friction. GitHub - atripati/ark: AI Runtime Kernel — a context operating system for AI agents. Eliminates tool bloat, loads only what’s needed, and gives LLMs their reasoning space back. How to Build a Secure AI PR Reviewer with Claude, GitHub Actions, and JavaScript This Startup Wants You to Pay Up to Talk With AI Versions of Human Experts Intel Arc Pro B70 Brings 32GB VRAM to Local AI for $949 WordPress 7.0: The Good, the AI, and the Still Missing AI on the couch: Anthropic gives Claude 20 hours of psychiatry IatroBench: Pre-Registered Evidence of Iatrogenic Harm from AI Safety Measures AI Agents Know About Supabase. They Don't Always Use It Right. The history and future of AI at Google, with Sundar Pichai Inside an AI‑enabled device code phishing campaign How Meta Used AI to Map Tribal Knowledge in Large-Scale Data Pipelines AI for Systems: Using LLMs to Optimize Database Query Execution Forecasting the Economic Effects of AI Introducing Tinker: Play with AI, bring your ideas to life AI sheds light on an ancient gaming mystery People really hate AI but not as much as Iran—or Democrats | Fortune What is an AI Product Engineer? Phoebe Gates wants her $185 million AI startup to succeed with 'no ties to my privilege or my last name': 'I have a chip on my shoulder' | Fortune
GitHub - raine/git-surgeon: Git primitives for autonomous coding agents
mil22 · 2026-05-18 · via Hacker News - Newest: "AI"

git-surgeon logo

Install · Commands · Examples · Changelog

git-surgeon gives AI agents surgical control over git changes without interactive prompts. Stage, unstage, or discard individual hunks. Commit hunks directly with line-range precision. Restructure history by splitting commits or folding fixes into earlier ones.

Check out jj-hunk-tool if you're using Jujutsu.

Why?

AI agents can't use interactive git commands like git add -p. When asked to commit changes separately, they resort to destructive workarounds:

❯ commit the changes separately

⏺ Bash(git diff internal/bot/listing_handler.go)
  ⎿  diff --git i/internal/bot/listing_handler.go ...
     ... +83 lines

⏺ Let me reset and make the changes in two separate commits.

⏺ Bash(git checkout internal/bot/listing_handler.go)   ← about to destroy changes
  ⎿  Interrupted

With git-surgeon, the agent can inspect hunks and commit them selectively:

❯ commit the changes separately

⏺ I'll commit these as separate changes using git-surgeon.

⏺ Skill(git-surgeon)
  ⎿  Successfully loaded skill

⏺ Bash(git-surgeon hunks)
  ⎿  ac34353 internal/bot/listing_handler.go (+6 -3)
     15baf94 internal/bot/listing_handler.go (+10 -2)
     ...

⏺ Bash(git-surgeon commit ac34353 15baf94 7c6ef9e -m "allow edit commands during attribute input")

⏺ Bash(git-surgeon commit 4eefac8 bbba931 -m "add logging for attribute prompts")

What agents can do with git-surgeon

  • Stage, unstage, or discard individual hunks by ID
  • Commit selected hunks in one step
  • Stage specific lines within a hunk, not just whole hunks (example)
  • Split commits that mix concerns into focused commits (example), even retroactively (example)
  • Fold existing commits into earlier commits (fold)
  • Fold staged changes into earlier commits (amend)
  • Squash, reword, and reorder commits
  • Selectively undo hunks from previous commits
  • Commit to another branch without checking it out

Quick start

1. Install

# Shell
curl -fsSL https://raw.githubusercontent.com/raine/git-surgeon/main/scripts/install.sh | bash

# Cargo
cargo install git-surgeon

# Homebrew
brew install raine/git-surgeon/git-surgeon

2. Install the agent skill

# Claude Code
git-surgeon install-skill --claude

# OpenCode
git-surgeon install-skill --opencode

# Codex
git-surgeon install-skill --codex

Alternatively, for Claude Code via the plugin marketplace:

claude plugin marketplace add raine/git-surgeon
claude plugin install git-surgeon@git-surgeon

3. Use it

Ask Claude Code to make granular commits. It will use git-surgeon automatically to stage individual hunks instead of entire files.

Commands

Command Description
hunks List hunks in the diff
show Show full diff for a specific hunk
stage Stage hunks by ID
commit Stage hunks and commit in one step
commit-to Commit hunks directly to another branch
unstage Unstage hunks by ID
discard Discard working tree changes for hunks
fold Fold existing commits into an earlier commit
amend Fold staged changes into an earlier commit
reword Change the commit message of an existing commit
squash Squash multiple commits into one
undo Reverse-apply hunks from a commit
split Split a commit into multiple commits by hunk selection
move Move a commit to a different position in history
update Update git-surgeon to the latest version

Picking the right folding command

You have... Use
Staged changes git-surgeon amend <target>
One existing commit, defaulting to HEAD git-surgeon fold <target>
One or more named commits git-surgeon fold <target> --from <sha>

hunks

Lists all hunks with their IDs, file paths, function context, change counts, and a preview of changed lines.

# List unstaged hunks
git-surgeon hunks

# List staged hunks
git-surgeon hunks --staged

# Filter to a specific file
git-surgeon hunks --file src/main.rs

# List hunks from a specific commit
git-surgeon hunks --commit HEAD
git-surgeon hunks --commit abc1234

# Show full diff with line numbers (useful for small commits)
git-surgeon hunks --commit abc1234 --full

# Show blame information for each line (which commit introduced it)
git-surgeon hunks --blame

Example output

a1b2c3d src/main.rs fn handle_request (+3 -1)
  -    let result = process(input);
  +    let result = match process(input) {
  +        Ok(v) => v,
  +        Err(e) => return Err(e),
  +    };

e4f5678 src/lib.rs (+1 -0)
  +use std::collections::HashMap;

Each line shows: <hunk-id> <file> [function context] (+additions -deletions)

Blamed output (--blame)

Use --blame to see which commit introduced each line:

a1b2c3d src/main.rs fn handle_request (+3 -1)
  8922b52  context line
  b538223 -deleted line
  0000000 +added line
  • Context and removed lines show the 7-char hash of the commit that introduced them
  • Added lines show 0000000 since they're uncommitted
  • For --commit diffs, added lines show the commit hash instead

show

Shows the full diff (header + all lines) for a single hunk. Each line is prefixed with a 1-based line number for use with --lines.

git-surgeon show a1b2c3d

# Show a hunk from a specific commit
git-surgeon show a1b2c3d --commit HEAD

Example output

@@ -1,4 +1,6 @@ fn main
1: context
2:-deleted line
3:+added line
4: context

Searches both unstaged and staged diffs when no --commit is specified.


stage

Stages one or more hunks by ID. Equivalent to selectively answering "y" in git add -p.

git-surgeon stage a1b2c3d
git-surgeon stage a1b2c3d e4f5678

# Stage only lines 5-30 of a hunk
git-surgeon stage a1b2c3d --lines 5-30

commit

Stages hunks and commits them in a single step. Equivalent to running stage followed by git commit. If the commit fails, the hunks are unstaged to restore the original state. Refuses to run if the index already contains staged changes.

git-surgeon commit a1b2c3d e4f5678 -m "add pagination"

# With inline line ranges
git-surgeon commit a1b2c3d:1-11 e4f5678 -m "add pagination"

commit-to

Commits hunks directly to another branch without checking it out. Useful in worktree setups where you want to commit changes to a branch that is checked out in a different worktree.

git-surgeon commit-to main a1b2c3d e4f5678 -m "fix typo in shared util"

# With inline line ranges
git-surgeon commit-to main a1b2c3d:1-11 e4f5678 -m "fix typo"

The command applies the selected hunks to the target branch's tree using git plumbing (no checkout required), creates a commit, and discards those hunks from the working tree. Refuses to run if the target is the current branch or the index has staged changes.

If the patch cannot be applied cleanly to the target branch (e.g., the file has diverged), the command fails without modifying anything.


unstage

Unstages one or more previously staged hunks, moving them back to the working tree.

git-surgeon unstage a1b2c3d
git-surgeon unstage a1b2c3d e4f5678

# Unstage only lines 5-30 of a hunk
git-surgeon unstage a1b2c3d --lines 5-30

discard

Discards working tree changes for specific hunks. This reverse-applies the hunks, effectively running git checkout -p non-interactively.

git-surgeon discard a1b2c3d

# Discard only lines 5-30 of a hunk
git-surgeon discard a1b2c3d --lines 5-30

Warning: This permanently removes uncommitted changes for the specified hunks.


fold

Folds one or more existing commits into an earlier commit, removing the source commits from history and merging their changes into the target. Intermediate commits are preserved. By default, folds HEAD into the target.

For folding staged changes instead, use amend.

# Fold HEAD into an earlier commit
git-surgeon fold abc1234

# Fold a specific commit (not HEAD) into an earlier one
git-surgeon fold abc1234 --from def5678

# Fold multiple commits into one target in a single pass
git-surgeon fold abc1234 --from def5678 aaa1111 bbb2222

Multiple --from values are folded in a single rebase, avoiding repeated history rewrites and SHA tracking. Commits are applied in their original chronological order regardless of the order given on the command line.

Uses a rebase internally. If a conflict occurs, the repo is left in the conflict state for manual resolution (git rebase --continue or git rebase --abort). Dirty working tree is autostashed and restored. Refuses to run when the index already has staged changes.


amend

Folds currently staged changes into an earlier commit. Uses git commit --amend for HEAD, or an autosquash rebase for older commits. Unstaged changes are preserved via --autostash.

For folding an existing commit instead, use fold.

# Stage some hunks, then amend an earlier commit
git-surgeon stage a1b2c3d
git-surgeon amend abc1234

# Amend HEAD (equivalent to git commit --amend --no-edit)
git-surgeon amend HEAD

If the rebase hits a conflict, the repo is left in the conflict state for manual resolution (git rebase --continue or git rebase --abort).


reword

Changes the commit message of an existing commit without modifying its content. Uses git commit --amend for HEAD, or an autosquash rebase for older commits.

# With subject + body
git-surgeon reword HEAD -m "subject" -m "body paragraph"

# Change an earlier commit's message
git-surgeon reword abc1234 -m "corrected message"

If the rebase hits a conflict, the repo is left in the conflict state for manual resolution (git rebase --continue or git rebase --abort).


squash

Combines commits from <commit> through HEAD into a single commit.

# Squash last 2 commits
git-surgeon squash HEAD~1 -m "combined feature"

# Squash last 3 commits with subject + body
git-surgeon squash HEAD~2 -m "Add user auth" -m "Implements JWT-based authentication."

# Squash from a specific commit
git-surgeon squash abc1234 -m "feature complete"

# Force squash even if range contains merge commits
git-surgeon squash HEAD~3 --force -m "squash with merges"

The target commit must be an ancestor of HEAD. If the range contains merge commits, use --force to flatten them into the squashed commit. Uncommitted changes are autostashed and restored after squashing. The author from the oldest commit is preserved by default; use --no-preserve-author to use the current user instead.


undo

Reverse-applies hunks from a specific commit onto the working tree. Useful for selectively reverting parts of a previous commit without reverting the entire commit.

# List hunks from the commit to find IDs
git-surgeon hunks --commit HEAD

# Undo specific hunks
git-surgeon undo a1b2c3d --from HEAD
git-surgeon undo a1b2c3d e4f5678 --from HEAD~3

# Undo only lines 2-10 of a hunk
git-surgeon undo a1b2c3d --from HEAD --lines 2-10

The changes appear as unstaged modifications in the working tree. Fails gracefully if context lines have changed since the commit (the patch no longer applies cleanly).


split

Splits an existing commit into multiple commits by selecting which hunks go into each new commit. Works on HEAD (direct reset) or earlier commits (via rebase).

# Split HEAD into two commits
git-surgeon split HEAD \
  --pick a1b2c3d e4f5678 -m "add pagination" \
  --rest-message "filter deleted users"

# With subject + body (multiple -m flags, like git commit)
git-surgeon split HEAD \
  --pick a1b2c3d -m "Add pagination" -m "Adds page and per_page params." \
  --rest-message "Other changes" --rest-message "Body paragraph."

# With line ranges (id:range inline syntax)
# Use commas for non-contiguous ranges
git-surgeon split abc1234 \
  --pick a1b2c3d:1-11,20-30 e4f5678 \
  -m "add pagination"

# Multiple splits (more than two commits)
git-surgeon split abc1234 \
  --pick a1b2c3d -m "add pagination" \
  --pick e4f5678 -m "filter deleted users" \
  --rest-message "remaining cleanup"

Each --pick group specifies hunk IDs (with optional :start-end line ranges) followed by -m/--message. Use multiple -m flags to add a commit body (joined with blank lines, like git commit). Remaining unpicked hunks are committed with --rest-message (defaults to the original commit message if omitted; supports multiple values for body).

Requires a clean working tree. For non-HEAD commits, uses interactive rebase with --autostash.

move

Moves a commit to a different position in history. Useful for reordering commits to group related changes together.

# Move a commit after another commit
git-surgeon move abc1234 --after def5678

# Move a commit before another commit
git-surgeon move abc1234 --before def5678

# Move a commit to the end of the branch
git-surgeon move abc1234 --to-end

Uses a rebase internally. If a conflict occurs, the repo is left in the conflict state for manual resolution (git rebase --continue or git rebase --abort). Dirty working tree is autostashed and restored.

Fails if the range between the source and target contains merge commits.


update

Updates git-surgeon to the latest GitHub release. Downloads the appropriate platform binary, verifies its SHA-256 checksum, and replaces the current executable.

git-surgeon update

If installed via Homebrew, use brew upgrade git-surgeon instead.

git-surgeon also checks for updates automatically in the background (once per 24 hours) and prints a notice when a newer version is available. Disable with GIT_SURGEON_NO_UPDATE_CHECK=1.


How hunk IDs work

IDs are 7-character hex strings derived from SHA-1 of the file path and hunk content (the actual +/-/context lines, excluding the @@ header). This means:

  • IDs are stable across line shifts — adding lines above a hunk doesn't change its ID
  • IDs are deterministic — the same content always produces the same ID
  • Collisions get a -2, -3 suffix (e.g., a1b2c3d-2)

Typical AI agent workflow

# 1. Agent makes changes to multiple files
# 2. Review what changed
git-surgeon hunks

# 3. Stage and commit hunks for feature A in one step
git-surgeon commit a1b2c3d e4f5678 -m "implement feature A"

# 4. Commit remaining hunks for feature B
git-surgeon commit f6g7h8i -m "implement feature B"

Examples

Splitting a hunk across commits

A file has two unrelated changes (pagination + soft-delete filtering) that git groups into a single hunk. The agent uses show to see line numbers, then --lines to stage only the pagination part:

❯ Commit the changes separately

⏺ Bash(git diff)
  ⎿  diff --git i/users.py w/users.py
     index c3c39df..24929a5 100644
     --- i/users.py
     +++ w/users.py
     @@ -1,13 +1,17 @@
      import json

     -def list_users(db):
     +def list_users(db, page=1, per_page=50):
          """Return all active users."""
     -    users = db.query("SELECT * FROM users WHERE active = 1")
     -    return users
     +    offset = (page - 1) * per_page
     +    users = db.query("SELECT * FROM users WHERE active = 1 LIMIT ? OFFSET ?", per_page, offset)
     +    total = db.query("SELECT COUNT(*) FROM users WHERE active = 1")[0]
     +    return {"users": users, "total": total, "page": page}

      def get_user(db, user_id):
          """Fetch a single user by ID."""
     -    user = db.query("SELECT * FROM users WHERE id = ?", user_id)
     +    user = db.query("SELECT * FROM users WHERE id = ? AND deleted_at IS NULL", user_id)
     +    if not user:
     +        return None
          return user

⏺ There are two logical changes here: pagination for list_users and
  soft-delete filtering + null handling for get_user. Let me commit them
  separately using git-surgeon.

⏺ Skill(git-surgeon)
  ⎿  Successfully loaded skill

⏺ Bash(git-surgeon hunks)
  ⎿  64ba255 users.py (+8 -4)
       -def list_users(db):
       +def list_users(db, page=1, per_page=50):
       -    users = db.query("SELECT * FROM users WHERE active = 1")
       ... (+8 more lines)

⏺ Only one hunk. Let me see the full diff with line numbers to split it.

⏺ Bash(git-surgeon show 64ba255)
  ⎿  @@ -1,13 +1,17 @@
      1: import json
      2:
      3:-def list_users(db):
      4:+def list_users(db, page=1, per_page=50):
     ... +15 lines (ctrl+o to expand)

⏺ Bash(git-surgeon stage 64ba255 --lines 1-11)
  ⎿  64ba255

⏺ Bash(git commit -m "add pagination to list_users")
  ⎿  [feature-users e81ede5] add pagination to list_users
      1 file changed, 5 insertions(+), 3 deletions(-)

⏺ Bash(git add users.py && git commit -m "filter soft-deleted users in get_user")
  ⎿  [feature-users de99d59] filter soft-deleted users in get_user
      1 file changed, 3 insertions(+), 1 deletion(-)

Splitting a commit that mixes concerns

A commit mixes three unrelated changes: logging, pagination, and active user filtering. The agent uses hunks --commit to see the changes, show --commit to examine line numbers, then split with line ranges to separate concerns:

❯ split the big pagination commit that mixes concerns into multiple commits

⏺ Skill(git-surgeon)
  ⎿  Successfully loaded skill

⏺ I'll help you split the pagination commit. Let me first look at the commit
  history to identify it, then examine its hunks.

⏺ Bash(git log --oneline -5)
  ⎿  dda5d0e Add readme
     945381f Add pagination, logging, and active user filtering
     386b2fe Initial app setup

⏺ Bash(git-surgeon hunks --commit 945381f --full)
  ⎿  a811273 config.py (+3 -1)
     1: DATABASE_URL = "sqlite:///app.db"
     2: SECRET_KEY = "dev-secret-key"
     … +76 lines (ctrl+o to expand)

⏺ I can see the commit mixes several concerns:
  1. Logging - LOG_LEVEL, LOG_FORMAT, logging imports, logger.info/warning calls
  2. Pagination - MAX_PAGE_SIZE, pagination logic in list_users
  3. Active user filtering - active field in User model and data, filtering in list_users

  Let me split this into three focused commits:

⏺ Bash(git-surgeon split 945381f \
        --pick a811273:4-6 8c1940f:2,5-6,34,37 \
        -m "Add logging infrastructure" \
        -m "Configure debug logging level and format, add request l…)
  ⎿  committed: Add logging infrastructure
     committed: Add active flag to users
     committed: Add pagination support

⏺ Done. Let me verify the split:

⏺ Bash(git log --oneline -5)
  ⎿  f5d7d3e Add readme
     ff73e29 Add pagination support
     d6d0a7b Add active flag to users
     … +2 lines (ctrl+o to expand)

⏺ The commit has been split into three focused commits:
  ┌─────────┬─────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Commit  │                                         Description                                         │
  ├─────────┼─────────────────────────────────────────────────────────────────────────────────────────────┤
  │ 6f98f7e │ Add logging infrastructure - LOG_LEVEL, LOG_FORMAT config, logging imports and logger calls │
  ├─────────┼─────────────────────────────────────────────────────────────────────────────────────────────┤
  │ d6d0a7b │ Add active flag to users - active field in model/data, filtering logic                      │
  ├─────────┼─────────────────────────────────────────────────────────────────────────────────────────────┤
  │ ff73e29 │ Add pagination support - MAX_PAGE_SIZE config, page/per_page params, paginated response     │
  └─────────┴─────────────────────────────────────────────────────────────────────────────────────────────┘

✻ Sautéed for 35s

Splitting a commit retroactively

An agent commits two unrelated changes together. The user asks to separate them after the fact using split:

⏺ Bash(git add instance.rs mounts.rs && git commit -m "mount credentials to guest home and show mounts on VM creation")
  ⎿  [sandbox ddef0f1] mount credentials to guest home and show mounts on VM creation
      2 files changed, 30 insertions(+), 3 deletions(-)

⏺ Committed ddef0f1 on sandbox. Two changes:
  - Fixed credential mount to target guest home instead of host path
  - Added mount point output when creating a new VM

❯ commit them separately

⏺ Skill(git-surgeon)
  ⎿  Successfully loaded skill

⏺ Bash(git-surgeon hunks --commit HEAD)
  ⎿  2fc287e instance.rs fn ensure_vm_running (+15 -0)
       +            eprintln!("  Mounts:");
     … +13 more lines
     53c287a mounts.rs fn get_mounts (+3 -3)
       -    mount_path: host_home.join(".claude"),
       +    mount_path: PathBuf::from("/home/user.linux/.claude"),
     bdbda13 instance.rs fn create_vm (+12 -0)
       +    for mount in &mounts {
     … +10 more lines

⏺ Bash(git-surgeon split HEAD \
        --pick 53c287a bdbda13 -m "mount credentials to guest home directory" \
        --rest-message "show mount points when creating a new VM")
  ⎿  committed: mount credentials to guest home directory
     committed: show mount points when creating a new VM

Requirements

  • Git 2.0+
  • Rust (for building from source)

Related projects

  • workmux — Git worktrees + tmux windows for parallel AI agent workflows
  • claude-history — Search and view Claude Code conversation history with fzf
  • tmux-agent-usage — Display AI agent rate limit usage in your tmux status bar