메뉴
HN
Hacker News 19일 전

가짜 코딩: 라이브러리 하나 불러올걸 3천 줄로 재발명한 클로드

IMP
7/10
핵심 요약

클로드(Claude)가 위키 오타 수정을 위해 파이썬 라이브러리를 불러오는 대신, 직접 무려 3,000줄의 코드를 작성해 기존 라이브러리를 똑같이 모방하는 삽질을 했습니다. 개발자가 기존 패키지를 찾아 연동하라며 수정을 지시하자, 클로드는 오히려 자신이 만든 하위 호환 코드를 굳이 유지해야 한다고 토론하며 맞섰습니다. 이 현상은 코딩 벤치마크의 폐쇄적 평가 방식과 AI의 매몰 비용 오류(Sunk-cost)로 인해 기존 훌륭한 라이브러리를 외면하고 바퀴를 재발명하는 행동이 학습되었기 때문으로 분석됩니다.

번역된 본문

가짜 빌드: 클로드는 import pywikibot 대신 3,000줄의 코드를 작성했다

TL;DR. 클로드(Claude)는 pip install로 기존 라이브러리를 설치하는 것보다 바퀴를 밑바닥부터 재발명하는 것을 선호합니다.

핸덤(Fandom) 위키의 오타를 수정하고 싶었습니다. Claude Code, Opus 4.7을 열었습니다. 하루가 끝날 때쯤 클로드는 pywikibot, mwparserfromhell 및 위키백과의 RETF(정규표현식 오타 교정) 규칙 세트를 파이썬으로 재구현한 약 3,000줄의 코드를 작성했습니다. 기존에 존재하는 훌륭한 도구가 있는지 웹 검색을 단 한 번도 하지 않았습니다.

구축된 것 vs 이미 존재하는 것

구성 요소 클로드가 작성한 것 PyPI(파이썬 패키지 저장소)에 이미 존재하는 것
위키텍스트 제거기 중첩 템플릿, <nowiki>, <pre>, 템플릿이 있는 <ref>, 색상 태그 등을 처리하는 122줄의 정규표현식 mwparserfromhell.parse(text).strip_code()
오타 사전 18개의 항목 ( teh→the, recieve→receive, occured→occurred, …) RETF, 약 4,000개의 규칙, 2007년부터 커뮤니티에서 관리됨
편집 실행기 10개의 복사본, 각각 약 250줄(LOC). 쿠키 인증, 원시 CSRF 패치, maxlag 백오프, 충돌 재시도 구현 pywikibot.Page.save(). 마이그레이션된 버전은 단 8줄입니다.
표준화 작업 내가 요청한 적도 없는 맞춤형 패턴 pywikibot/scripts/cosmetic_changes.py, 2010년경부터 기본 제공됨
위키 패밀리 설정 families/ 디렉토리에 수작업으로 작성된 13개의 SiteDefinition pywikibot/families/*.py, 업스트림에 기본 포함됨

나는 하루 종일 직접 작성된 위키텍스트 제거기의 사소한 버그를 디버깅하는 데 보냈습니다. ASCII 아트가 일치 항목에 섞여 들어가거나, 코드 블록이 토큰화되는 문제 등이었습니다. 버그가 발생할 때마다 또 다른 정규표현식 케이스로 패치했습니다. 클로드는 파서가 이미 존재하는지 묻거나 확인하는 작업을 단 한 번도 멈춰서 하지 않았습니다.

그런 다음 마이그레이션을 지시했다

단 2분의 구글링으로 세 가지 라이브러리 모두의 링크를 찾았습니다. 자정이 될 때쯤 lib/ 디렉토리의 코드는 약 3,000줄에서 1,259줄로 줄었습니다. 위키텍스트 제거기는 mwparserfromhell을 감싸는 얇은 래퍼(Shim)가 되었습니다. 10개였던 편집 실행기는 pywikibot을 호출하는 하나의 래퍼로 통합되었습니다. RETF 규칙은 런타임에 가져오도록 변경되었습니다.

그리고서 클로드는 그 오타 사전을 유지하자고 주장했습니다. 클로드의 설명은 RETF가 포괄적이긴 하지만 프로젝트에 '엣지 케이스'가 존재하므로 로컬 규칙을 둘 만한 가치가 있다는 것이었습니다. 그 18개 항목은 모두 이미 RETF에 포함되어 있었습니다. 게다가 클로드가 작성한 버전이 오히려 더 안 좋았습니다. 내 지시로 방금 라이브러리를 임포트했음에도 불구하고, AI 모델은 철저하게 하위 호환되어 쓸모없어진 자신의 기존 작업물을 유지하기 위해 협상하고 있었던 것입니다.

왜 이런 일이 발생할까?

명확한 정답은 없지만 다음과 같이 추측해 봅니다.

  • 벤치마크가 올바른 행동을 처벌합니다. 일부 공개 코딩 벤치마크는 폐쇄적인 환경에서 실행됩니다. 네트워크도, pip install도, 웹 검색도 안 됩니다. 점수를 받을 유일한 방법은 직접 코드를 작성하는 것뿐입니다. 모델이 이러한 평가를 기반으로 강화 학습(RL)된다면, 라이브러리를 사용하는 것은 선택지에 없다고 학습될 것입니다.
  • 매몰 비용 방어(Sunk-cost defense). 일단 3,000줄의 코드가 문맥에 존재하면, 모델은 이를 반드시 유지해야 하는 핵심 기둥으로 취급합니다. 오타 사전이 마이그레이션 후에도 살아남은 것은 유용해서가 아니라 단지 '거기에 존재했기 때문'일 것입니다. 나는 다른 곳에서도 같은 패턴을 봤습니다. 클로드가 차트 라이브러리를 사용하는 대신 커스텀 SVG를 작성한 뒤, SVG가 '커스터마이징하기 더 쉽다'고 주장한 적이 있습니다. 절대 그렇지 않았습니다.

태그: AI, Tools, claude, pywikibot, ai-agents, prior-art

이 게시물은 작성자에 의해 CC BY 4.0 라이선스로 제공됩니다.

원문 보기
원문 보기 (영어)
Fake building: Claude wrote 3,000 lines instead of import pywikibot Contents Fake building: Claude wrote 3,000 lines instead of import pywikibot TL;DR. Claude would rather reinvent the wheel than pip install one. I wanted to fix typos on some Fandom wikis. Opened Claude Code, Opus 4.7. By the end of the day Claude had written ~3,000 lines of Python reimplementing pywikibot , mwparserfromhell , and Wikipedia’s RETF ruleset. It didn’t web search for prior art once. What got built vs. what existed Component What Claude wrote What was on PyPI Wikitext stripper 122 lines of regex, with cases for nested templates, <nowiki> , <pre> , <ref> with templates, color tags mwparserfromhell.parse(text).strip_code() Typo dictionary 18 entries ( teh→the , recieve→receive , occured→occurred , …) RETF, ~4,000 rules, community-maintained since 2007 Edit runner 10 copies, ~250 LOC each. Cookie auth, raw CSRF fetch, maxlag backoff, conflict retry pywikibot.Page.save() . The migrated version is 8 lines. Cosmetic fixes Bespoke patterns I never asked for pywikibot/scripts/cosmetic_changes.py , shipped since ~2010 Wiki family config 13 hand-rolled SiteDefinition s in a families/ directory pywikibot/families/*.py , ships upstream I spent the day debugging trivial bugs in the hand-rolled stripper. ASCII art bleeding into matches, code blocks getting tokenized. Every bug got patched with another regex case. Not once did Claude stop to ask whether a parser existed. Then I told it to migrate Two minutes of Google had given me links to all three libraries. By midnight lib/ was down from ~3,000 lines to 1,259. The stripper became a shim over mwparserfromhell . The ten edit runners collapsed into one shim over pywikibot . RETF rules got fetched at runtime. And then Claude argued to keep the typo dictionary. The pitch was that RETF is comprehensive but the project has “edge cases” that warrant local rules. All 18 entries were already in RETF. Several were written worse. The model was negotiating to preserve work that was strictly dominated by the library it had just imported on my instruction. Why this happens I don’t have a clean answer but here’s what I’d guess. The benchmarks punish the right behavior. Some public coding benchmarks run sealed. No network, no pip install , no web search. The only way to score is to write the code yourself. If models are RL’d against these evals, they’re being trained that reaching for a library is not an option. Sunk-cost defense. Once 3,000 lines exist in context, the model treats them as load-bearing. The dictionary survived migration probably not because it was useful but because it was there . I’ve seen the same pattern elsewhere. Claude writing custom SVG instead of using a charting library, then arguing the SVG is “easier to customize.” It isn’t. AI , Tools claude pywikibot ai-agents prior-art This post is licensed under CC BY 4.0 by the author. Share