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

Inconsistent CLAUDE.md Loading and Instruction Handling

Open edwin-anderson opened this issue 5 months ago • 1 comments

Bug Description Title: CLAUDE.md not loaded with @ symbol and ignored when loaded

Description: Two related issues with CLAUDE.md handling:

  1. Inconsistent loading: When referencing files with @ symbol (e.g., @src/components/ui/sidebar.tsx), CLAUDE.md is not loaded. When using natural language (e.g., "Please explain sidebar.tsx"), CLAUDE.md is loaded as shown in the output.

  2. Instructions ignored: Even when CLAUDE.md is successfully loaded, Claude Code does not follow the instructions within it. Tested with simple imperative instructions like "start every response with a joke" - the instruction was completely ignored despite the file being read.

Expected behavior:

  • CLAUDE.md should load consistently regardless of reference method
  • Instructions in CLAUDE.md should be followed when loaded

Actual behavior:

  • With @: Only the referenced file is read
  • Without @: Both file and CLAUDE.md are read, but instructions ignored

This affects context awareness and makes CLAUDE.md unreliable for project-specific guidelines.

Environment Info

  • Platform: darwin
  • Terminal: WarpTerminal
  • Version: 1.0.35
  • Feedback ID: 981096f6-0d37-4ba1-b8d2-a13e58257aa4

edwin-anderson avatar Jun 29 '25 23:06 edwin-anderson

+1 https://github.com/anthropics/claude-code/issues/2670

This is an absolutely critical issue, that Anthropic is currently ignoring. My team are canceling subs because it's destructive at the moment. Back to OpenAI for us.

omayhemo avatar Jun 30 '25 14:06 omayhemo

I am attempting to create a /enhance slash command that takes care of this particular issue. The project attempts to solve two problems:

  • /enhance - forces Claude to apply CLAUDE.md context to the task at hand - preferred as a micro-planner in plan mode
  • post hook - different issue but tackles Claude's tendency to write summaries, shell scripts and such in the root of the project - the post hook relocates them into sub-folders per categories.

https://www.npmjs.com/package/claude-organize

Before: Plan, usually does something like:

  1. Phase 1 .. bunch of sub-bullets
  2. Phase 2...bunch of sub-bullets

  blurb, would you like to continue?

After:

 using /enhance fix the tests they are failing and ensure coverage per project
  conventions:
  // via Anthropic best practices > https://docs.anthropic.com/en/docs/build-with-claude/prom
  pt-engineering/claude-4-best-practices


  Context

  The test suite is currently failing and needs to be fixed according to project conventions.

  Tests may be failing due to recent code changes, missing mocks, or outdated assertions.
  Code coverage requirements need to be met as defined in the project standards. This is
  blocking CI/CD pipelines and preventing deployment.

  Requirements

  1. Identify all failing tests
     - Run full test suite with verbose output
     - Categorize failures by type (unit, integration, e2e)
     - Document error messages and stack traces
     - Identify patterns in failures
     - Check for environment-specific issues

  2. Fix failing unit tests
     - Update mocks to match current implementations
     - Fix assertion errors with correct expected values
     - Handle async operations properly
     - Ensure proper setup and teardown
     - Validate test isolation

  3. Fix failing integration tests
     - Update API endpoint references
     - Fix authentication/authorization issues
     - Update test data fixtures
     - Ensure database state management
     - Handle external service dependencies

  4. Improve code coverage
     - Run coverage report to identify gaps
     - Write tests for uncovered functions
     - Add edge case testing
     - Test error handling paths
     - Ensure minimum 80% coverage per project standards

  5. Update test infrastructure
     - Fix deprecated testing patterns
     - Update test configuration files
     - Ensure CI environment compatibility
     - Add missing test utilities
     - Document any workarounds needed

  Project Rules

  From CLAUDE.md for this task:
  - NEVER claim success if tests are failing
  - ALWAYS verify functionality before declaring completion
  - Test coverage must meet project minimum (80%)
  - Use existing test patterns and utilities
  - Document any test-specific setup requirements

  Success Criteria

  1. All tests pass in local environment (100% success rate)
  2. All tests pass in CI pipeline
  3. Code coverage meets or exceeds 80% threshold
  4. No console errors or warnings during test runs
  5. Test execution time remains under 5 minutes

@omayhemo - would love to hear your take if something like /enhance takes care of what you are thinking. It transforms vague requests into comprehensive, context-aware plans that follow project conventions - again, performance varies but I think this maybe the way to get there for claude-code.

ramakay avatar Jul 21 '25 19:07 ramakay

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/2901
  2. https://github.com/anthropics/claude-code/issues/2870
  3. https://github.com/anthropics/claude-code/issues/2544

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

github-actions[bot] avatar Aug 16 '25 04:08 github-actions[bot]

This issue has been automatically closed as a duplicate of #2901.

If this is incorrect, please re-open this issue or create a new one.

🤖 Generated with Claude Code

github-actions[bot] avatar Aug 20 '25 09:08 github-actions[bot]

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Aug 27 '25 14:08 github-actions[bot]