Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Find & Fix Claude Code Instruction Conflicts

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

When you work on a larger project with Claude Code, you often end up with multiple instruction files—CLAUDE.md, .claude/settings.json, project-level rules, and even global user instructions. Sometimes these files contradict each other: one says “use tabs,” another says “spaces,” or one forbids a tool that another requires. These conflicts cause Claude to behave unpredictably, waste tokens, and produce code that doesn’t match your standards. This guide shows you how to systematically find and fix those conflicts so Claude follows a single, consistent set of rules.

What You'll Need

  • Access to your project’s filesystem (terminal or file explorer)
  • Claude Code CLI installed and authenticated
  • A text editor or IDE
  • Basic familiarity with JSON and Markdown syntax

Step-by-Step

  1. Identify all instruction files. Claude Code reads instructions from several sources, in order of precedence (lower number overrides higher):
    1. User-level instructions: ~/.claude/CLAUDE.md and ~/.claude/settings.json
    2. Project-level instructions: CLAUDE.md in the project root
    3. Subdirectory instructions: CLAUDE.md in any subfolder (these apply only when Claude works in that folder)
    4. CLI flags: --instructions or --settings passed when launching Claude Code
  2. List all files that contain instructions. Run this in your terminal to find every potential instruction file:
    find . -name "CLAUDE.md" -o -name "settings.json" | grep -v node_modules
    Also check your home directory: ~/.claude/. Write down the full path of each file.
  3. Open each file and extract the rules. For each file, read through and note every directive that could conflict. Pay special attention to:
    • Style rules: indentation, quotes, semicolons, naming conventions
    • Tool usage: which tools are allowed/forbidden (e.g., Bash, Read, Edit)
    • Workflow rules: when to ask for clarification, when to run tests, how to structure commits
    • Security rules: what to never do (e.g., delete files, push to prod)
  4. Create a conflict matrix. Make a simple table (in a scratch file or mental note) with columns: rule topic, file A, file B, conflict? For example:
    Topic       | CLAUDE.md          | settings.json
    Indentation | "tabs"            | "spaces:2"  -> CONFLICT
    Tests       | "run before commit"| (none)      -> no conflict
    This makes it easy to spot where files disagree.
  5. Determine precedence. Claude Code gives higher priority to more specific or lower-level files. The order (from highest to lowest) is:
    1. CLI flags (--instructions overrides everything)
    2. Subdirectory CLAUDE.md (if you’re working in that subdir)
    3. Project root CLAUDE.md
    4. User-level ~/.claude/CLAUDE.md
    Settings files (settings.json) are layered: more specific keys override general ones. For example, a project settings.json can override a user-level setting for the same key.
  6. Decide the intended rule. For each conflict, decide what you actually want. Ask yourself: “What is the project’s true standard?” If in doubt, the project-level rule should usually win over user-level, because it’s specific to this codebase. Write down the final decision.
  7. Fix the lower-priority file. Edit the file that should NOT override. For example, if your project CLAUDE.md says “tabs” but your user-level ~/.claude/CLAUDE.md says “spaces”, you should remove or change the “spaces” rule in the user-level file (unless you want it to apply to all projects).
  8. Alternatively, add an explicit override. If you want a project to override a user rule, you don’t need to delete the user rule—just make the project rule more specific. For example, in your project CLAUDE.md, write:
    # Project-Specific Rules
    (These override user-level instructions)
    Use tabs for indentation.
    Claude Code is trained to recognize explicit override statements.
  9. Check settings.json for key conflicts. Open each settings.json and compare keys. For instance, if user settings has "permissions": {"allow": ["Bash"]} and project settings has "permissions": {"deny": ["Bash"]}, these conflict. The project settings should take precedence, but it’s safer to remove the conflicting key from the user settings if you don’t want it globally.
  10. Test with a dry run. Run Claude Code in your project and ask a simple question that touches on a conflicting rule. For example, if the conflict is about indentation, ask Claude to write a small function. Observe which rule it follows. If it still follows the wrong one, you may have missed a file or a precedence nuance.
  11. Document your final rules. After fixing, add a note in your project CLAUDE.md that says “These rules override all user-level instructions” and list the key decisions. This helps future contributors understand the hierarchy.
  12. Automate the check. If you have many files, write a small script that greps for common conflict keywords (e.g., “tabs”, “spaces”, “never”, “always”) across all instruction files and prints them side by side. Run this as part of your repo setup.

Common Mistakes

  • Forgetting the user-level file. Many conflicts come from ~/.claude/CLAUDE.md which you may not even remember writing. Always check it.
  • Assuming subdirectory rules are global. A CLAUDE.md in src/ only applies when Claude is working in src/. It does not apply to the whole project. If you want a global rule, put it in the root.
  • Overlooking settings.json permissions. A deny rule in one file and an allow rule in another can cause Claude to be blocked or overly permissive. Check both allow and deny arrays.
  • Editing the wrong file. If you edit the higher-priority file to match the lower one, you might break the intended behavior for other projects. Always change the lower-priority file unless you want the rule to change everywhere.
  • Not testing after fixing. Conflicts can be subtle; always run a quick test to confirm Claude now follows the correct rule.

Tips

  • Use the --settings flag for one-off overrides. If you need a temporary rule, pass it via CLI instead of editing files.
  • Keep user-level instructions generic. Put only universal preferences (e.g., “always use type hints”) in ~/.claude/CLAUDE.md. Project-specific rules belong in the project file.
  • Use explicit override language. Phrases like “This rule overrides any conflicting instruction” are understood by Claude and reduce ambiguity.
  • Version-control your instruction files. If you have a conflict, you can use git blame to see who added the conflicting line and when.
  • Keep instruction files short. The more rules you pile up, the higher the chance of conflict. Aim for a single, concise project CLAUDE.md.

Troubleshooting

Claude still follows the wrong rule after fixing. Possible causes: (1) You missed a subdirectory CLAUDE.md that overrides your root file. Run the find command again. (2) There’s a cached version—restart Claude Code. (3) The rule is actually in your settings.json under permissions or hooks, not in a CLAUDE.md. Check both.

Claude ignores your override statement. Make sure you placed the override statement at the top of the file, before any conflicting rules. Also, avoid using negative phrasing like “don’t use spaces” because Claude may misinterpret it. State positively: “Use tabs for indentation.”

Conflicts between CLAUDE.md and settings.json. Settings files control permissions and hooks, while CLAUDE.md controls behavioral instructions. If they conflict (e.g., CLAUDE.md says “always use Bash” but settings deny Bash), the settings deny wins because it’s a hard restriction. Adjust the settings file to allow the tool, or change the instruction to use an allowed tool.

You can’t find any instruction files. If neither CLAUDE.md nor settings.json exists, Claude uses default behavior. Conflicts can’t occur. If you suspect hidden files, use ls -la to see dotfiles.

Frequently Asked Questions

Q: What is the exact precedence order for Claude Code instructions?
A: From highest to lowest: CLI flags, subdirectory CLAUDE.md, project root CLAUDE.md, user-level ~/.claude/CLAUDE.md. Settings files are layered per-key, with more specific scopes overriding general ones.

Q: Can I have multiple CLAUDE.md files in one project?
A: Yes. You can have one in the root and one in each subdirectory. The subdirectory one only applies when Claude works in that directory. This is useful for module-specific rules.

Q: How do I make a project rule override my global user rule?
A: Simply state the rule in the project CLAUDE.md and, if needed, add an explicit line like “This rule overrides user-level instructions.” Claude will follow the more specific project rule.

Q: What if my settings.json has both allow and deny for the same tool?
A: That’s a conflict. The deny usually takes precedence for safety. You should remove one of them. Decide based on whether you want to allow or block the tool in that scope.

Q: Do CLI flags override everything?
A: Yes. If you pass --instructions or --settings when launching Claude Code, those take precedence over all file-based instructions. This is useful for testing or temporary changes.

Q: How can I quickly see all rules Claude is using?
A: Run Claude Code with the --debug flag. It will print the merged instruction set it loads, showing which file each rule came from. This is the fastest way to spot conflicts.