不小心用Claude Code制造了我的第一个fork炸弹。
Accidentally created my first fork bomb with Claude Code

原始链接: https://www.droppedasbaby.com/posts/2602-01/

## 克劳德代码分叉炸弹及 600 美元教训 这讲述了一位开发者二月份使用克劳德代码(CC)——一种新的 AI 编程工具——的混乱经历。起初犹豫不决,他深入研究,构建了自定义“技能”——用于任务管理(/adhd)、上下文窗口优化(/yablind)、日志记录(/memento)和调试(/yadumb)的工具——这得益于注意力缺陷多动症驱动的过度专注。 然而,一个新创建的“SessionStart”钩子无意中生成了指数级的 CC 实例(分叉炸弹)。开发者在不知情的情况下在夜间释放了它,第二天早上发现电脑完全无响应且过热。 绝望地尝试杀死这些进程失败了,迫使他进行了硬重启。 更糟糕的是,失控的 CC 实例产生了 600 美元的 API 费用。幸运的是,CC 本身固有的低效——巨大的内存消耗——在费用变得无法控制*之前*触发了系统锁定。这次经历是一次代价高昂但宝贵的教训,关于代理工作流程、仔细实现钩子的重要性,以及勉强接受“糟糕代码”拯救这一天的现实。该开发者现在计划进一步开发,并暗示对感兴趣的人们会有更多“疯狂的抱怨”。

黑客新闻 新 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 不小心用 Claude Code 制造了我的第一个 fork 炸弹 (droppedasbaby.com) 4 点赞 by offbyone42 1 小时前 | 隐藏 | 过去 | 收藏 | 讨论 帮助 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

Friday, Feb 27, ~11:00AM

I start my workday late, around 11. I sit at my desk and shake the mouse - nothing.

“huh, that’s weird. why is this stupid thing not starting up?”

I press a few random keys on my keyboard - nothing.

I push the fingerprint sensor - nothing. “seriously?”

I tap on the trackpad. No haptic feedback. Completely unresponsive. “maybe there is something loose from cable managing last night?” I check the cables, everything’s plugged-in.

I try to force restart the computer, but it’s warm… no, it’s hot. “that’s weird.”

My stomach sinks. I had spilled tea all over this computer a few months ago. The bottom chassis was replaced, but maybe something hadn’t been. My next on-call shift is coming up in three days. “ugh,” I think.

“macOS 26 has been unreliable, it did update 2 nights ago.” It shuts down fine, I let go, I press the button again, it starts up fine.

I log in, start a terminal up, type in claude, press return. I want to see what I need to do using /adhd.

It starts to slow down, again. Even cd is crawling. “huh.”

I open Activity Monitor and see memory pressure in the red. “that’s weird, i wonder what’s causing that.” I scroll through the processes list and see: hundreds of CC instances.

I start to put 2 + 2 together: slow computer last night, “oh,” hot chassis, “huh,” memory pressure red, “oh no no no no no,” chassis still hot, “well, shit.”

Some mistakes in life you realize right away, others go unnoticed.

This was the latter kind.

want to hear more of my unhinged rants? drop your email.

Rewind: Late Night/Early Morning

“wtf” I think to myself as my terminal starts to slow down at 2AM. “ugh, i’m going to bed, i’ll figure this shit out tomorrow.”

The SessionStart hook I’d just created spawns 2 background CC instances using claude -p ..., each of which follows the normal start-up sequence.

I get up from my desk. I walk away from my terminal for the night.

Friday, Feb 27, ~11:00AM

I try to force quit every instance of CC in the Activity Monitor. They spawn faster than I can kill them. ghostty + pkill will work better but ghostty is unresponsive.

The realizations continue. “SHIT SHIT SHIT” repeating in my head as my hand bolts for the power button and I force restart the machine.

“you dumbass.” I berate myself. Every instance of CC starts two more CC instances. I created a hook that causes an explosion…1 → 2 → 4 → 8 → 16 → 32 → 2^N…

I open ~/.claude/settings.json and remove the hook. I have Activity Monitor open, it’s filtering down to claude. I open another ghostty instance and type in claude. Before hitting enter, I rest my free hand’s index finger on the power button, I hit return with the other; everything’s fine, just a single instance. I breathe easy.

It took me almost two decades, but at that moment I realized I had created my first fork bomb. It had completely bricked my computer ‘cause it ran overnight.

Another realization dawns on me: “the bill.” My company has API billing. “i’m so screwed.” I open Edge, my heart pounds as the icon bounces, I go to the “Usage” page, just gone up by $600. I’m good. I calm down.

The shitty code behind CC just saved my ass. The ridiculous amounts of memory every single instance consumes ‘cause of the BunReact → TUI chain had blown up the memory usage. It caused my computer to lock up. Shitty code combined with Claude’s caching saved me before someone in accounting would start asking questions.

This is the one and only time I’ll be thankful for software being shitty and bloated.

This was the imperfect end to an imperfect month of late night coding sessions, going down rabbit holes and building skills, hooks and frameworks.

Rewind: Beginning of February

My company had given us access to Cursor at the start of 2025. I used it heavily to research the massive codebase whenever I needed it. 311M+ tokens worth of usage.

February 2026 started with a new push for agentic workflows and programming.

I gritted my teeth. I didn’t want to write, review and maintain AI slop. I pushed back on RFCs that proposed full agentic programming loops.

Then, I figured, if this was the new expected workflow, the new meta, the new paradigm, I might as well master it. I sure as hell was not going to get left behind.

I asked for permissions to a CC account. I opened the dashboard and noticed the API pricing. “tokens go brrrrrr?”

I begrudgingly ran brew install --cask claude-code and explored. I looked on the positive side, I could finally use ghostty + nvim + tmux combined with CC for everything. No more VSCode clone with AI bits bolted on.

I experimented and found the use cases that worked well. More crucially, the rough edges. I spent too many tokens experimenting with CC. So, I decided to give a quick crash course on CC usage for my team. I wrote a doc, presented it and organized the whole week.

Powered by my ADHD hyperfocus, anxiety and spite, I built the tools that helped me and I learned a lot.

After February had passed, this was the monstrosity I built after a $3800 API bill.

What I Built

Skill: /yadumb [the dumb thing it just did]

Tells CC to dump what it did into a file with all the context ‘cause this random token generator breaks all the time, even when you TELL IT TO DO SOMETHING IN CAPS, BOLD AND ITALICIZED.

When a skill explicitly says:

STILL, every goddamn time, it goes through this exact sequence for that skill:

  • Uses MCP, fails
  • Thinks about trying CLI
  • Then ponders CLI usage
  • Reaches a revelation that the CLI might work
  • Uses CLI

🤦 I tell it to log what it did, then go kick rocks.

Skill: /memento

Remember Leonard’s memory from Memento? No. Maybe Dory’s memory? Good, ‘cause I don’t.

I need something to log conversations. This does exactly that with a:

  • Summary
  • Project ID
  • Conversation ID
  • Bunch of other boring metadata that neither you nor I care about

Skill: /yablind [-N] [path]

‘Cause the context window size is the bane of this statistics output machine’s existence. The output quality gets significantly worse even at 40% usage, especially with images. Plus, I’m too lazy to copy/paste text. This tells it to call a subagent to:

  • Perform OCR on the last N screenshots.
  • If that sucks, read them directly.
  • Or do the same thing to [path]
  • If not an image or text, but a PDF ‘cause the boomer/zoomer don’t have basic computer skills, it reads the document directly
  • Passes relevant information to the main conversation.
  • Deletes the file if it’s a screenshot

All in service of a single objective: Minimize unnecessary content in the goddamn context window.

Skill: /adhd

My ADHD ass can’t be bothered to check Slack, GH, Notion and only god knows what else, EVERY, GOD, DAMN, MORNING.

I’m the person who likes meetings. No, Karen, this couldn’t have been an email ‘cause I don’t read those.

To address my weakness, I created a skill to pull together a list of things I need to do and want to do, and it tries to update older items. It then tries to prioritize what’s left. For more details see this, except mine is local only.

The chart-topping bangers:

  • notnow - when I’m definitely answering that stupid request at 5PM on a Friday
  • imout - done for the day routine
  • [others] - boring ones I won’t list.

Seventeen scripts deterministically fetch the data before feeding it to the over-eager, coked-out junior (LLM) to generate:

  • What I need to do, prioritized
  • Mark completed items

Skill: /money

It forgets everything, every run. Don’t let the existence of the MEMORY.md file tell you otherwise. It doesn’t save the relevant shit and is outdated, at the same time. This EP skill comes with:

  • showmethemoney - show projects
  • gimmethemoney - dump the state and decisions into this project’s state
  • themoney [project id] - load project state files

This hopefully lets it get at least part of the context from previous conversations but you’re rolling the dice just like it does!

PreToolUse/PostToolUse Hook

I can’t be bothered to remember my own patterns, let alone CC’s patterns. I created two hooks:

  • PreToolUse - Saves the contents of a Bash command. Including Python wrapped in Shell.
  • PostToolUse - Writes a completed status with the tool_use_id

Both save to a single append-only jsonl file, organized by day. “wHy DoN’t yOu UsE tHe LoGs FrOm ~/.claude?” ‘Cause that shit is expensive as hell to analyze and I can’t save ~/.claude in version control.

Next Up

The rest…TBC ✌️

  • /fight-to-death - A Gladiator cosplay aka Adversarial PR review.
  • ~/.claude/CLAUDE.md - the LLM has “kinks of a nympho fetish” (K.Dot).
  • Lifelong Lessons I’ll forget within a month.

want to hear more of my unhinged rants? drop your email.

联系我们 contact @ memedata.com