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

[BUG] Memory: Commit instruction not respected

Open ocontant opened this issue 7 months ago • 3 comments

Environment

  • Platform (select one):
    • [ ] Anthropic API
    • [ ] AWS Bedrock
    • [ ] Google Vertex AI
    • [ X ] Other: Claude Code MacOs Shell
  • Claude CLI version: 0.2.74 (Claude Code)
  • Operating System: MacOS 15.3.2 (24D81)
  • Terminal: iterm2

Bug Description

When reopening claude to continue work on a project, our commit instruction are not being respected by the AI agent. It ignores the commit instruction and skip steps we defined. It is like some other commit instruction oversede our instructions.

If there are competing instructions, the user instruction should supersede the AI initial instructions. The logic could be a OR logical where competing instruction are override by user instructions and the other functional instruction unaffected by User custom instruction are appended to user instruction, in order to not lose the benefits of initial AI instruction and benefit complementary instruction.

Steps to Reproduce

  1. Start an initial session, and configure CLAUDE.md and MEMORY to add new custom instruction about commit rules.
  2. Stop the session
  3. Start a new session in the same project and without any other prompts, request the AI to create a commit.

Expected Behavior

Expect the commit to respect the rules we defined.

Actual Behavior

Our steps are skipped and the AI agent revert to default behaviours.

Additional Context

The code is close, we cannot provide additional information to help pinpoint the root cause.

ocontant avatar Apr 19 '25 18:04 ocontant

Thanks for the report @ocontant ! To help debug this - when you start the new session, does claude print that the memory was loaded? When running /memory command, do the instructions show up as expected?

levpopov avatar Apr 21 '25 16:04 levpopov

It is present in the CLAUDE.md

I don't have a status if it read any files. I usually manually ask it to read CLAUDE.md, and other files with context I prepared. I also started to use a pattern where I put .llm_context in strategic location in the code base, like at the root directory of a module to provide concise context about a module such as what it exposes, so it doesn't have to saturate the windows context with the code.

I also prefer when I instruct Claude Code to create scripts to generate the documentation, rather than parsing the code and generating the documentation. This is something I added to the global Claude.md

tree-sitter and treediffer should be built-in tools as they are very useful to parse code efficiently. It should be used to create internal memory of the project in CST format. Which could save possibly windows context space, and provide context on how to integrate modules in other part of the project.

Sorry I drifted from the initial commit context, but this is all related in the end.

I wish the code was Open Source, so I could learn how to be more efficient with it, and suggest improvement.

ocontant avatar Apr 22 '25 01:04 ocontant

@levpopov is it required that the Claude Code session be restarted when editing memory? I used /memory to edit user memory and put an instruction for Claude Code to always use git switch and never git checkout in there and it wouldn't respect the instruction afterwards. I don't want to put this in CLAUDE.md because other team members may have a different preference.

TomasHubelbauer avatar Jun 26 '25 12:06 TomasHubelbauer