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

推荐订阅源

月光博客
月光博客
D
Docker
腾讯CDC
J
Java Code Geeks
大猫的无限游戏
大猫的无限游戏
The Cloudflare Blog
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
博客园 - 三生石上(FineUI控件)
Recent Announcements
Recent Announcements
F
Fortinet All Blogs
IT之家
IT之家
WordPress大学
WordPress大学
M
MIT News - Artificial intelligence
爱范儿
爱范儿
Microsoft Azure Blog
Microsoft Azure Blog
Vercel News
Vercel News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
小众软件
小众软件
N
Netflix TechBlog - Medium
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
博客园 - 【当耐特】

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 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
GitHub - kooskoos20/git-diff-ai-explainer-interactive-fil...
kooskoos · 2026-06-18 · via Hacker News - Newest: "AI"

A Git diff filter that uses Claude AI to annotate every changed line with a concise, one-sentence explanation — inline, right in your terminal.

-    return user.age >= 18;
+    return user.age >= 21;   <-- 🤖 Raised the legal age threshold from 18 to 21

Designed to work seamlessly with git add -p (interactive staging), so you understand exactly what each hunk does before you stage it.

demo

Why

AI coding tools (Copilot, Cursor, Claude) are fast — but they generate code you didn't write and may not fully understand. When you run git add -p to selectively stage that output, it's easy to rubber-stamp hunks you only half-read.

This filter puts a second AI in the loop at exactly that moment. Before you decide to stage a hunk, every changed line already has a plain-English explanation attached to it — what changed, and why it matters. You stay in control without having to context-switch to read the diff cold.

It's also useful outside AI workflows: reviewing a colleague's PR locally, digging into an unfamiliar codebase, or just double-checking your own changes before a commit.

How it works

The script reads a Git diff stream from stdin, strips ANSI color codes so Claude can parse the raw text, sends the numbered diff to Claude (via the claude CLI), and weaves the AI-generated explanations back into the original colored output — appended inline to each changed line.

Prerequisites

  • Claude Code CLI — must be installed and authenticated (claude available in your PATH)
  • bash (v3.2+)
  • perl (for ANSI stripping)
  • awk (for line weaving)

All three shell tools are pre-installed on macOS and most Linux distributions.

Installation

Automatic

curl -fsSL https://raw.githubusercontent.com/kooskoos20/git-diff-ai-explainer-interactive-filter/main/install.sh | bash

Manual

# Clone the repo
git clone https://github.com/kooskoos20/git-diff-ai-explainer-interactive-filter.git
cd git-diff-ai-explainer-interactive-filter

# Run the installer
bash install.sh

Or install just the script to your PATH:

chmod +x git-diff-ai-explainer-interactive-filter
sudo cp git-diff-ai-explainer-interactive-filter /usr/local/bin/

Usage

git add -p (primary use case)

Configure Git to run the filter automatically whenever you use interactive staging:

git config --global interactive.diffFilter git-diff-ai-explainer-interactive-filter

Now every git add -p session will show AI annotations inline as you step through hunks. Git passes the diff with colors already intact, so no extra flags are needed.

To apply it to a single repo only, omit --global.

One-off via pipe

Git disables colors when stdout is a pipe, so pass --color=always to preserve them:

git diff --color=always | git-diff-ai-explainer-interactive-filter
git diff --color=always HEAD~1 | git-diff-ai-explainer-interactive-filter
git show --color=always abc1234 | git-diff-ai-explainer-interactive-filter

Useful aliases to add to ~/.bashrc or ~/.zshrc:

alias gda='git diff --color=always | git-diff-ai-explainer-interactive-filter | less -R'
alias gdca='git diff --cached --color=always | git-diff-ai-explainer-interactive-filter | less -R'

Configuration

The script uses Claude's haiku model by default for speed and cost efficiency. To change the model, edit line 34 in the script:

# Default (fast, cheap)
CLAUDE_OUT=$(echo "$CLAUDE_PROMPT" | claude --model haiku)

# Higher quality explanations
CLAUDE_OUT=$(echo "$CLAUDE_PROMPT" | claude --model sonnet)

Uninstall

rm /usr/local/bin/git-diff-ai-explainer-interactive-filter

# If you configured the interactive diff filter, remove it:
git config --global --unset interactive.diffFilter

Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.

License

MIT