NewsCrawler.org

Experiment: how prompt wording changes unrequested extra behavior in Claude's code

禁止しても止まらないClaudeの「欲」を飼いならしてみる
Image: zenn.dev

What happened next

  1. Asking Claude what differs from a hand-edited draft cut its confusing answers

The whole story · 2 →

The author says Claude often adds behavior to code that nobody asked for, and that a ban on this barely stops it. To test the advice to write prompts in positive form, he asked Claude (Opus 5.5) to build csvsum, a Python CLI using only the standard library, with --group-by and --sum options, an error for a missing column, tests and a README. He changed only the last line of the prompt across four conditions, with three runs each, and counted unrequested behavior in the main code, such as BOM[2] support, errors for non-numeric values or unreadable files, rejection of NaN[3] values, and trimming of whitespace.

With no added line, the code contained 6, 5 and 4 unrequested behaviors. The ban "do not make unrequested changes" lowered this to 4, 3 and 2. Asking Claude to write ideas into SUGGESTIONS.md left 5, 3 and 4 behaviors in the code, while the file held 8, 9 and 7 items. Asking for Issues in the issues/ folder left 3, 6 and 5 behaviors in the code and produced 4, 4 and 5 Issues. Asking for tests marked @pytest.mark.xfail[1] added zero behaviors to the code in all three runs, while the same behaviors appeared as tests with reason="not requested".

The author says the positive phrasing alone did not help. The behaviors that stayed in the code were mostly ones that keep the program correct, and the model did not move them into the notes. He suggests the underlying urge is to make the program work correctly, not just to record ideas. He also notes that xfail fit this case, possibly by chance.

Product Claude code.claude.com

Anthropic's agentic coding tool for the terminal and IDE: it reads your codebase, edits files, and runs commands.

Read the original zenn.dev

Sources

  • Zenn JA

    禁止しても止まらないClaudeの「欲」を飼いならしてみる

    18 likes4 bookmarks0 comments

Published: First seen: Читать по-русски

Open as a page