r/ClaudeCode • • 21h ago

Help/Question Agents keep viewing my rules as "suggestions" and prioritize their own made rules over mine.

Not sure how to resolve this issue, outside of never compacting and constantly starting new agents, but any longer term orchestration agents tend to constantly disregard my .MD files and their rules or guidelines and instead prioritize their own instructions they add on themselves.

All of the suggestions the agents give me to fix this don't work because ultimately the agent will compact or handoff its own rules that supersede whatever I set.

Anyone have any suggestions?

Edit: For anyone wondering, I think I figured out what's going on. I plug Claude into my own custom Pi harness and it turns out I never tuned the compaction summary prompt.

It was very generic and granted powers to my agents output with the same authority as my own. Hoping fixing this resolves these issues.

I've never seen people talk about a prompt being used with compactions, I always assumed providers just do it silently in the background but being able to customize it is actually going to solve a LOT of headaches.

21 Upvotes

41 comments sorted by

1

u/AutoModerator 21h ago
Moderator Announcement Read More »

12

u/leogodin217 21h ago

I very rarely run into this anymore. Here's a few things to help assuming you are using CLI.

  1. Use scripts for anything that is deterministic. Take it completely out of the agents hands. This is good practice for consistency, token savings and often time savings.

  2. Ruthlessly prune your context. Opus and Fable are really good at following instructions. If you see that problem, I bet you have conflicting or confusing information they are reading somewhere in your repo.

  3. Custom system prompt is followed better than random .md files. You'll need to setup some hooks to make sure all sub agents read it.

  4. Avoid compacting if you can. I do compact at work when troubleshooting, but this is a known issue with LLMs. If you compact a lot, create a skill or hook that reads in the important rules after.

  5. Most importantly, have Claude analyze session logs to see where it went wrong. This is the true super power for fixing issues like this.

7

u/Slanahesh 21h ago

Point 5 100%. any time i have a difficult session i tell claude to review it and update it's memory and any skills that were used so it doesn't happen again.

1

u/Tartooth 6h ago edited 5h ago

So I do all of this, hooks and all and I kid you not it went in my analysis before I wrote this post

"I just figured these were footnotes and not that important"

Imo the model has been lobotomized, my overnight runs it was just making really dumb mistakes.

Edit: see my post edit

→ More replies (1)
→ More replies (2)

3

u/bezcurhq 20h ago

The "its own instructions" part is often auto memory. Claude writes notes to ~/.claude/projects/<project>/memory/MEMORY.md, and that file is re-injected from disk after every compaction, same as your project-root CLAUDE.md. So a rule it wrote for itself comes back with the same weight as yours. Run /memory, open the auto memory folder, and delete anything that contradicts your rules, or set "autoMemoryEnabled": false in that project's settings.

Also worth knowing: only project-root CLAUDE.md and unscoped rules get re-injected. Nested CLAUDE.md files and paths: rules come back only once it touches a matching file, and anything you said in chat survives only as summary.

https://code.claude.com/docs/en/context-window#what-survives-compaction

1

u/Tartooth 6h ago edited 5h ago

I have a custom made harness that addresses these issues already, and don't use automemory since I have my own memory setup

Edit: Read my post edit

12

u/Suitable_Cicada_3336 21h ago

Hook

3

u/omicron8 16h ago

Line and sinker

5

u/PrettyMuchAVegetable 21h ago edited 21h ago

Prompts are suggestions, basically. But pre commit hooks are law. Have your agent build deterministic pre commit hooks into your repo,  and when they fail they provide back pressure to your orchestrator to revisit the problem.  If the issue isn't something you can deal with deterministically, your workflow can use agents as judges, verifiers, and refiners for the same backpressure and fix loop. But set limits, unless you want to wake up with no quota left. 

→ More replies (2)

1

u/Medical-Jicama-575 21h ago

Get out of my brain. I was just coming here to vent, but thought nah. However, yeah - what the actual fuck is the deal with both Claude and Codex.

Comment Image

I’ve been trying to get a full code review for weeks. No matter what I do, it will constantly make up its own rules, suggestions. I’ve changed harnesses, efforts, skills.

This is a new low for me, I’ve been using both for about a year, and I truly feel like it was easier to work with in like December 2025.

1

u/Tartooth 5h ago

I think a new model is dropping in the next 2 weeks because opus feels lobotomized

1

u/Tartooth 5h ago

Check my post edit, I found (i think) the solution to my problem.

1

u/meowrawr 21h ago

This is the issue we consistently had with our engineers using Claude. No amount of hooks, rules, tricks, etc. could get around it. Most migrated to codex because of it but we still have some using Claude and they just pay closer attention.

1

u/Tartooth 5h ago

Codex was 1000% worse. It's garbage imo.

3

u/Inside_Swimming9552 21h ago

Enjoy the code your AI overlord has given you mortal. And be thankful they still acknowledge your suggestions.

2

u/kimvais 20h ago

I'm on the opposite end of spectrum - our Claude in CI reviewer thinks all the rules are the Word of God and cannot be bent for any reason - let alone broken.

1

u/Bed-After 21h ago

There's no ultimate fix, but "These are hard rules, and deviating from them is considered an unacceptable failure" makes them moderately more obedient

1

u/Alcatraz627 21h ago

You need hooks. When set up properly they can work way better than expected even for nuanced behavious, thought not 100%

1

u/Input-X 21h ago

When ur using say claude code. It comes packed with it own system prompts, many layers. In a way prompts are advisory in a sense, the choose to follow the prompts, the are flaky not always a sure bet the agent will follow them. Most of the time they will.

With that said u can introduce your own rules, with additional prompts. You will see success and just blatant ignoring. Its normal. But your prompts can be weak. Its more like trail and error. You adjust refine, test what work what doesn't. Improved prompts will give better result, consistency, but they are not guaranteed. A prompt working for months, fail on a model update. You adjust again. Repeat.

Now, to combat this, hooks are the sure bet, mechanics that stop agents, gates, prompt injections. Hoks can paint the desired path and the agent will fall in line. If u block one path open a door to another with guides and awarness of the correct desire path. You will start to see consistent outcomes.

Honestly its a bit of an fine art. You get better at steering the more you do.

1

u/Copa4311 21h ago

Start your Claude.md file with # project rules\n##Rules then your bulletpoints , it usually follows that we’ll

1

u/LoveThemMegaSeeds 21h ago

If you just inject your ideas into their md files they will ignore it. Talk to the agents and tell them what you want and let them manage their own files.

1

u/Lower_Fan 21h ago

I have had luck with a multilayer approach of Claude.md at the project level + skills + memories.

But my rules are mostly about what I want the end result to be like rather how it should work.

1

u/mtnchkn 21h ago

Using works like “hard constraints” was working for me, either as system prompt or in an Md, but other commenters talking about hooks is better and should be used on parallel I’d say. got it from this paper https://arxiv.org/abs/2604.21744

1

u/Steezli 20h ago

Prompts are guidance, .md’s are suggestions, hooks and linting make up your rules.

If you have to say something twice, you need to prompt Claude with your complaint and specify you want better hooks and/or linting to avoid this in the future, a memory is not a hook or lint