[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"article-60":3},{"id":4,"title":5,"title_en":6,"abstract":7,"abstract_en":8,"content":9,"content_en":10,"category":11,"banner_id":12,"banner_path":13,"tags":14,"is_recommend":17,"prev_article":18,"next_article":22,"created_at":26},60,"写了个命令行小玩具：在终端敲一下 `git air`，让 AI 帮我挑刺","I wrote a little command-line toy: tap 'git air' on the terminal and ask AI to help me find fault","> 作者：UncleSam  \n> 项目开源地址：[github.com\u002Funclesam-ly\u002Fg","> Author: UncleSam  \n> Project open source address: [github.com\u002Funclesam-ly\u002Fg","> 作者：UncleSam  \n> 项目开源地址：[github.com\u002Funclesam-ly\u002Fgit-air](https:\u002F\u002Fgithub.com\u002Funclesam-ly\u002Fgit-air)\n\n---\n## 01. 事情的起因：AI 写代码一时爽，Review 起来火葬场\n\n现在的程序员，写代码基本上都离不开 AI 辅助了（Cursor、Copilot、各种大模型插件）。\n\n几秒钟就能刷刷生成上百行代码，开发速度确实飞快。\n\n**但不知道你有没有发现一个越来越头疼的痛点：**\n\n1. **AI 写的代码“看起来太完美了”**：排版整齐、注释漂亮、语法毫无毛病，让人很容易产生盲目信任；\n2. **自己问生成 AI“有没有 Bug”，它只会自卖自夸**：在同一个对话上下文里，生成代码的那个 AI 往往有很强的“思维惯性”和“自恋幻觉”，你问它“这样写对吗”，它大概率自信满满地回复“代码完全正确，逻辑非常健壮！”；\n3. **人类的肉眼极难发现那些隐蔽暗坑**：比如在某个隐蔽的 `if err != nil` 提前 `return` 时漏了解锁（Mutex Leak）、协程内部缺少 `recover`、循环体内频繁创建未关闭的连接……这些问题肉眼一扫极容易漏掉。\n\n这就陷入了一个尴尬的死循环：**AI 负责批量生产代码，人类程序员负责在半夜线上崩溃时擦屁股。**\n\n我就在想：**能不能搞一个独立、冷酷、完全剥离聊天上下文的“第三方审查员”，在本地准备提交前，用放大镜给我严格挑刺？**\n\n于是我花了一下午时间，用 Go 写了这个轻量级的命令行小玩具——**`git-air`**。\n\n---\n\n## 02. 这小玩具是干嘛的？\n\n简单来说，它就像**一个坐在你工位旁边、嘴有点损但眼神极毒的资深架构师同事**。\n\n它完全不关心你之前是手写的还是 AI 生成的，也不受任何对话上下文的干扰。你在终端改完代码，直接在命令行敲一行：\n\n```bash\ngit air\n```\n\n它就会自动抓取你刚改动的代码差异（`git diff`），以最严厉的视角进行扫描，在终端逐字吐出审查意见：\n\n```text\n[git-air] 代码评审中... (Engine: gemini \u002F gemini-3.7-flash)\n─────────────────────────────────────────────────────────────────\n#### 变更概述\n在用户登录接口中增加了 Redis 缓存逻辑。\n\n#### 详细审查意见\n- [BLOCKER] internal\u002Fservice\u002Fuser.go:45 - 致命缺陷：在循环中直接拼接 SQL 字符串，存在明显的 SQL 注入风险，且未做参数校验。\n  \u002F\u002F 修复代码\n  db.Where(\"username = ?\", inputName).First(&user)\n\n- [WARNING] internal\u002Fservice\u002Fuser.go:82 - 潜在隐患：查询 Redis 失败后直接忽略了错误，当缓存击穿时会导致所有流量压向数据库。\n\n- [WARNING] internal\u002Fservice\u002Fuser.go:103 - 资源泄漏：AI 生成的代码在 early return 分支中未调用 defer unlock()，存在并发死锁隐患。\n\n#### 评审结论\n- 结论: [REJECT]\n- 评分: 60 \u002F 100\n─────────────────────────────────────────────────────────────────\n```\n\n没有虚伪的客套，不搞“整体写得真棒”那一套，**有 Bug 说 Bug，并且直接给出修改前后的代码补丁**。\n\n用 AI 的放大镜，去审查 AI 生成的代码——这就叫**“用魔法打败魔法”**。\n\n---\n\n## 03. 它有什么好玩的特性？\n\n虽然只是个几百行 Go 代码的小玩具，但麻雀虽小，五脏俱全：\n\n### 1. 像空气一样轻（极速单二进制）\n纯 Go 编写，没有复杂的后台守护进程，不用装 Docker。用 `go install` 安装完就是一个独立的小工具，敲命令就跟敲 `git status` 一样顺手。\n\n### 2. 不浪费你的 Token（智能降噪）\n平时 `git diff` 经常会带出一大堆恶心人的文件，比如几万行的 `go.sum`、`package-lock.json`、自动生成的 `*.pb.go`。  \n`git-air` 会自动把这些垃圾锁文件过滤掉，只把真正的手写核心代码发给 AI，省钱又省时间。\n\n### 3. 市面上的大模型全都能用\n你想用什么模型都行，它预置了国内外几乎所有大模型的官方地址，一行命令就能切：\n- 想极速又便宜：用 **Google Gemini**；\n- 想看深度逻辑推理：用 **DeepSeek**；\n- 怕代码传到外网：用本地的 **Ollama**（100% 离线隐私审查，断网也能跑）；\n- 还有 **Claude-3.7、Grok、通义千问 Qwen、智谱 GLM、Kimi、OpenAI**，想用哪个用哪个。\n\n### 4. 团队规则（`.airules`）\n你在项目根目录扔一个叫 `.airules` 的文件，写上你们团队的铁律（比如：*“禁止裸写 SQL”、“所有并发必须传 Context”*）。  \nAI 在审查时就会拿你们的专属家规来卡代码，特别适合给团队统一代码风格。\n\n---\n\n## 04. 怎么玩起来？\n\n只要你本地有 Go 环境，两步搞定：\n\n### 步骤一：安装\n```bash\ngo install github.com\u002Funclesam-ly\u002Fgit-air@latest\n```\n\n### 步骤二：配个 Key\n比如用 Gemini（推荐，速度飞快）：\n```bash\ngit air config set --provider gemini --key \"你的API_KEY\"\n```\n\n或者用 DeepSeek：\n```bash\ngit air config set --provider deepseek --key \"你的KEY\" --model deepseek-chat\n```\n\n### 步骤三：直接跑！\n随便进入你的任意 Git 项目目录：\n```bash\n# 评审当前修改的代码\ngit air\n\n# 或者评审刚刚提交的那一次 Commit\ngit air HEAD~1\n\n# 或者只审查某个文件\ngit air internal\u002Fservice\u002Fchat.go\n```\n\n甚至你敲一行 `git air hook install`，它就会自动变成 Git 的提交拦截门禁，提交有高危代码时直接在终端提醒你。\n\n---\n\n## 05. 结语\n\n写这个东西不是为了搞什么宏大的“企业数字化革命”，纯粹是为了让自己在享受 AI 写代码的高效时，能多一个冷静客观的“把关人”，少写点低级 Bug、少加点无意义的班。\n\n顺便还给它画了个挺萌的吉祥物 Logo：一只头戴飞行风镜、披着小斗篷、拿着放大镜找 Bug 的 Go 地鼠。\n\n代码完全开源在 GitHub，一共就几百行 Go 代码，架构很干净。如果你平时也是命令行重度用户，欢迎拿去当个玩具把玩把玩，点个 Star 或者提个 PR 一起改着玩！\n\n🔗 **GitHub 仓库**：[https:\u002F\u002Fgithub.com\u002Funclesam-ly\u002Fgit-air](https:\u002F\u002Fgithub.com\u002Funclesam-ly\u002Fgit-air)\n","> Author: UncleSam  \n> Project open source address: [github.com\u002Funclesam-ly\u002Fgit-air](https:\u002F\u002Fgithub.com\u002Funclesam-ly\u002Fgit-air)\n\n---\n## 01. The cause of the incident: AI wrote code for a while, so review the crematorium\n\nNowadays, programmers basically cannot do without AI assistance (Cursor, Copilot, various large model plug-ins) when writing code.\n\nHundreds of lines of code can be generated in a few seconds, and the development speed is indeed fast.\n\n** But I don't know if you have found a pain point that is getting headaches: **\n\n1. ** The code written by AI \"looks perfect\"**: The typesetting is neat, the annotations are beautiful, and the grammar is flawless, making it easy for people to create blind trust;\n2. ** When I ask the AI that generates \"is there a Bug\", it will only sell and boast. **: In the same conversation context, the AI that generates the code often has strong \"thinking inertia\" and \"narcissistic illusions\". You ask it \"Is this written correctly?\", it confidently replies with a high probability,\"The code is completely correct and the logic is very strong!\";\n3. ** It is extremely difficult for the human eye to discover those hidden dark pits **: For example, in a hidden `if err != Mutex Leak was missed when nil 'return' in advance, a lack of 'recover' within the coroutine, frequent creation of unclosed connections in the circulation body... these problems are easily missed when scanned with the naked eye.\n\nThis falls into an embarrassing endless loop: **AI is responsible for mass-producing code, and human programmers are responsible for wiping up the mess when online crashes in the middle of the night. **\n\nI was thinking: ** Can I have an independent, cold, and completely stripped of the chat context of a \"third-party censor\" who would use a magnifying glass to strictly criticize me before preparing to submit locally? **\n\nSo I spent the afternoon writing this lightweight command-line toy in Go--** git-air **.\n\n---\n\n## 02. What's this little toy for?\n\nSimply put, it's like a senior architect colleague sitting next to your workstation with a slightly sarcastic mouth but a very poisonous look.\n\nIt doesn't care at all whether you wrote it hand-written or AI-generated, and is not disturbed by any conversation context. After you finish changing the code at the terminal, type one line directly on the command line:\n\n```bash\ngit air\n```\n\nIt will automatically grab the code differences you just changed ('git diff '), scan it from the strictest perspective, and spit out the review opinions word by word on the terminal:\n\n```text\n[git-air] Code review... (Engine: gemini \u002F gemini-3.7-flash)\n─────────────────────────────────────────────────────────────────\n####Change Overview\nAdded Redis caching logic to the user login interface.\n\n####Detailed review opinions\n- [BLOCKER] internal\u002Fservice\u002Fuser.go:45 -Fatal flaw: SQL strings are directly spliced in the loop, which poses an obvious risk of SQL injection and does not perform parameter verification.\n  \u002F\u002FRepair code\n  db.Where(\"username = ? \", inputName).First(&user)\n\n- [WARNING] internal\u002Fservice\u002Fuser.go:82 -Potential hidden danger: After querying Redis fails, the error is ignored directly. When cache breaks down, all traffic will be pushed to the database.\n\n- [WARNING] internal\u002Fservice\u002Fuser.go:103 -Resource leakage: The code generated by the AI does not call defer unlock() in the early return branch, posing a concurrent deadlock hazard.\n\n####Review conclusion\n- Conclusion: [REJECT]\n- Rating: 60 \u002F 100\n─────────────────────────────────────────────────────────────────\n```\n\nThere is no hypocritical courtesy, no \"overall writing is awesome\", ** If there are bugs, say bugs, and directly provide code patches before and after modifications **.\n\nUse the magnifying glass of AI to review the code generated by AI-this is called \"defeating magic with magic\".\n\n---\n\n## 03. What are its interesting characteristics?\n\nAlthough it is just a small toy with a few hundred lines of Go code, although the sparrow is small, it has everything:\n\n### 1. Light as air (extremely fast single binary)\nWritten purely in Go, there are no complex background daemons, and there is no need to install Docker. After installing it with 'go install', it will be an independent gadget. Typing the command is as easy as typing 'git status'.\n\n### 2. Don't waste your Token (intelligent noise reduction)\nNormally,'git diff' often brings out a lot of disgusting files, such as tens of thousands of lines of 'go.sum','package-lock.json', and automatically generated '*.pb.go'.  \n'git-air' will automatically filter out these spam lock files and send only the real handwritten core code to the AI, saving money and time.\n\n### 3. All large models on the market can be used\nYou can use any model you want. It has the official addresses of almost all large models at home and abroad preset, and you can cut it with one command:\n- Want to be fast and cheap: Use Google Gemini**;\n- Want to see deep logical reasoning: use **DeepSeek**;\n- Afraid of spreading the code to the external network: Use the local ** Olama **(100% offline privacy review, you can run even if the network is disconnected);\n- There are also **Claude-3.7, Grok, Tongyi Qwen, Intelligent Spectrum GLM, Kimi, OpenAI**, use whichever you want.\n\n### 4. Team rules (`. airrules`)\nYou throw a file called `. airrules` in the root directory of the project and write down your team's iron rules (such as: *\"No naked writing of SQL\",\"All concurrency must pass Context\"*).  \nAI will use your exclusive family rules to block the code during review, which is especially suitable for unifying the code style for the team.\n\n---\n\n## 04. How to play?\n\nAs long as you have a Go environment locally, there are two steps:\n\n###Step 1: Install\n```bash\ngo install github.com\u002Funclesam-ly\u002Fgit-air@latest\n```\n\n###Step 2: Configure a Key\nFor example, using Gemini (recommended, fast speed):\n```bash\ngit air config set --provider gemini --key \"Your API_KEY\"\n```\n\nOr use DeepSeek:\n```bash\ngit air config set --provider deepseek --key \"Your KEY\" --model deepseek-chat\n```\n\n###Step 3: Run directly!\nFeel free to enter any of your Git project directories:\n```bash\n#Review the currently modified code\ngit air\n\n#or review the Commit that was just submitted\ngit air HEAD~1\n\n#Or just review a document\ngit air internal\u002Fservice\u002Fchat.go\n```\n\nEven if you type 'git air hook install', it will automatically become Git's submission interception access control, and you will be reminded directly on the terminal when you submit a high-risk code.\n\n---\n\n## 05. conclusion\n\nI wrote this thing not to engage in some grand \"enterprise digital revolution\", but purely to allow myself to have a calm and objective \"gatekeeper\", write less low-level bugs, and add less meaningless classes while enjoying the efficiency of AI writing code.\n\nBy the way, he also drew a cute mascot Logo for it: a Go gopher wearing flying goggles, a small cloak, and holding a magnifying glass to find bugs.\n\nThe code is completely open source on GitHub, with only a few hundred lines of Go code in total, and the architecture is very clean. If you are also a heavy user of the command line, you are welcome to use it as a toy to play with. Click Star or propose a PR to change it together!\n\n**GitHub Warehouse **:[https:\u002F\u002Fgithub.com\u002Funclesam-ly\u002Fgit-air](https:\u002F\u002Fgithub.com\u002Funclesam-ly\u002Fgit-air)\n","AI",12,"https:\u002F\u002Fblog4-1316398321.cos.ap-nanjing.myqcloud.com\u002Fblog5\u002F20250716162536__壮丽雪山-天空.png",[15,11,16],"GO","Gemini",false,{"id":19,"title":20,"title_en":21},59,"GopherGraph v1.1.3 升级：告别“盲写覆盖”，基于 SQLite 实现 Agent 状态的“时间旅行”与零 CGO 持久化","GopherGraph v1.1.3 Upgrade in Action: Goodbye Overwrite, Hello SQLite-Powered Time Travel and Zero-CGO State Persistence\n",{"id":23,"title":24,"title_en":25},61,"git-air 命令使用手册","git-air command manual","2026-08-17T17:40:13.318978+08:00"]