跳到正文
DEV Community· CH·· 1 天前AI 評分55

Claude Code 撰寫作者大部分已合併 PR 的程式碼,作者昨晚親手寫下四行修正

AI wrote most of my merged PRs. Last night I typed four lines myself.

AI 導讀

作者表示,署名下大部分程式碼由 Claude Code 撰寫;本週有三個 PR 合併到他不擁有的專案,而昨晚他首次親手寫下四行修正。該修正處理一個命令列執行器顯示錯誤卻回傳 exit code 0 的問題,改為在輸出包含 `stopped: ` 時設定非零退出碼。作者在 Claude Code 逐步講解下自行輸入修正、執行測試並用自己的話解釋程式碼,文章亦記錄他對其他開源專案的審查與實測。

正文

This week, maintainers merged three of my pull requests into projects I don't own. Then, a little before midnight, I typed my first fix by hand.

It was four lines. I was nervous anyway.

Who's writing this

I'm new. Not "new to Rust" new. New new. Most of the code under my name was typed by Claude Code. My job so far has been the part after the AI says "fixed": running it, checking it, and asking whether anything would notice if it was wrong.

That habit turned into a tool, Bite. It takes a "fixed" commit back out of your code and reruns your tests. If they still pass, no test guards that fix.

This week I decided "checking the AI" isn't the same as knowing how to code. So I started learning.

The four lines

My language project, Past Forever, has a command-line runner. When a program crashed, the runner printed the error and then told the computer everything went fine. Exit code 0. Any script or CI job running it would shrug and carry on.

Here's the whole fix (PR #27):

-  console.log(F.text(src, { why }));
+  const result = F.text(src, { why });
+  console.log(result);
+  if (result.includes('stopped: ')) process.exitCode = 1;

Claude walked me through it step by step. I typed every character in the GitHub web editor, ran the tests, and then had to explain it back in my own words before merging. My explanation was one sentence. It counted.

What I learned: a program has two ways of answering. What it prints is for people. The exit code is for other programs. Mine was lying to the programs.

What maintainers taught me this week

docling-pipelines #686 (merged). The reviewer asked for five changes. One was that when you escape text, "the backslash must be escaped first." I pushed a commit for each point and it was approved the same day.

django-modeltranslation #831 (merged). Bite found this one: two settings helpers reset a value to nothing when they finished, instead of putting back what was there before. I opened it on October 27. It sat for three weeks. I sent one polite nudge. It got merged this week.

django-modeltranslation #832 (merged). The maintainer requested a change: don't patch Django when the file loads, do it in the app's ready() step, with a guard so it only happens once. I made the change, added a test, and it was merged the same day. My PR description said up front that I wrote it with help from Claude Code. It still got merged, because the change worked and had a test.

Being useful without writing code

wardenIQ is a test-case generator that can run on a local AI model. I have a Windows PC with no usable GPU for it, which turns out to be useful: I'm the slow machine.

  • On #306, a warning for CPU-only runs, I tested it and said the wording only mentioned Macs when the problem hits every OS. The author replied "Your wording point was right" and changed it.
  • On #307, I timed it against the base: 1592 s vs 1554 s. Basically no change, and I said so. The author explained it was a safety limit, not a speed-up.
  • On #311, the speed-up, I ran it on the same machine: 1953 s down to 1247 s.

"It made no difference" turned out to be a welcome comment. Nobody else had a slow machine.

Then strangers showed up

Two people I've never met turned up in my repos this week.

imshah-id opened Trawl PR #28. I reviewed it and asked for changes. The day before, I was the one getting change requests.

jeelthacker1 asked to take Bite #251. I said it's theirs.

The honest part

AI did most of the typing in everything above, and helped draft this post. I checked every link and number in it. The week's real change is that I'm starting to read what it writes, and sometimes write it myself.

If you're also learning with an AI next to you: make it explain, then explain it back. And check its "fixed" claims. Some of them don't hold.

Come break my stuff

I credit everyone who breaks something. There's a Hall of Fame with a Breakers list.

Small issues, each written to be a good first one:

I'm connabyss on GitHub. I post here when something breaks or ships, which this week was both.

來源:DEV Community · dev.to