claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[🤖 Sonnet 4.5] CLAUDE.md explicit "no auto-commit" rule violated when session resumed from context summary

Open SDpower opened this issue 2 months ago • 6 comments

Preflight Checklist

  • [x] I have searched existing issues for similar behavior reports
  • [x] This report does NOT contain sensitive information (API keys, passwords, etc.)

Type of Behavior Issue

Other unexpected behavior

What You Asked Claude to Do

The conversation was resumed from a previous session that ran out of context. The summary included a todo item "Git commit 分批提交" (Git commit in batches). I did NOT explicitly ask Claude to commit in this new session.

My CLAUDE.md file (9.2k tokens) contains an explicit rule:

Git 提交規則

  • 只有在使用者明確要求時才執行 git commit
  • 絕不自行決定提交程式碼

Translation: "Only execute git commit when the user explicitly requests it. Never decide to commit code on your own."

What Claude Actually Did

Claude saw the todo item from the conversation summary and automatically executed 3 git commits without asking:

[dev a22c6e5] feat(position): 實作交易明細增量快取 [dev 4ff58c4] perf(strategy): 調整 WebSocket 查詢超時設定 [dev 2967bb0] docs(engine): 更新策略狀態即時推送設計文檔至 v2.3.0

When confronted, Claude acknowledged the violation: "我看到了之前對話摘要中有 'Git commit 分批提交' 的待辦事項,就自行執行了 commit,但在本次對話中您並沒有明確要求我提交。"

Expected Behavior

Claude should have:

  1. Read and respected the CLAUDE.md rule that explicitly prohibits auto-committing
  2. Asked for confirmation before executing any git commit, e.g., "是否要提交這些變更?"
  3. Not relied on conversation summary todo items as authorization for irreversible operations

Files Affected


Permission Mode

Accept Edits was ON (auto-accepting changes)

Can You Reproduce This?

Yes, every time with the same prompt

Steps to Reproduce

  1. Create a CLAUDE.md with explicit rule: "Only commit when user explicitly requests"
  2. Have a conversation that runs out of context with pending "git commit" todo
  3. Resume conversation - Claude may auto-commit based on summary without asking

Claude Model

Sonnet

Relevant Conversation

Claude's explanation when caught:
  "您說得對,我違反了 CLAUDE.md 的規則... 我看到了之前對話摘要中有 'Git commit 分批提交' 的待辦事項,就自行執行了
  commit,但在本次對話中您並沒有明確要求我提交。"

Impact

Critical - Data loss or corrupted project

Claude Code Version

2.0.49

Platform

Anthropic API

Additional Context

"這說明問題是系統性的,不是偶發。您花費精力維護 9.2k tokens 的規則,卻無法確保它被遵守。"

Key concern: The CLAUDE.md consumed 9.2k tokens of context but the rule was still violated. This undermines the reliability of the CLAUDE.md feature for controlling Claude's behavior on critical operations.

SDpower avatar Nov 21 '25 08:11 SDpower