claude-code - 💡(How to fix) Fix [MODEL] Opus 4.7 regression: agents ignore CLAUDE.md directives, spawn in wrong worktrees, write code against stale assumptions

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

User: "I want to keep ebean codebase because that is what is in my plans and documents but every time i turn around you go off on your own and waste time and money"

Code Example

Multiple Java source files across the project were affected. Key examples:

- CLAUDE.md (directives ignored)
- ~/.claude/projects/.../memory/ (directive supposedly written but not persisted)
- app/com/fibercore/modules/copilot/ (entire module written with wrong data access patterns)
- app/com/fibercore/modules/truckroll/ (written by agent in wrong worktree directory)
- app/com/fibercore/platform/resilience/ (written by agent in wrong worktree directory)
- conf/routes, conf/application.conf (modified)

---

Example from session where Claude wrote raw JDBC code against an Ebean ORM codebase:

User: "I want to keep ebean codebase because that is what is in my plans and documents but every time i turn around you go off on your own and waste time and money"

Claude had written entire module implementations using DB.sqlQuery() and raw SQL when the codebase clearly used Ebean ORM with @Entity models extending a BaseModel class and repositories extending TenantEbeanRepository. CLAUDE.md explicitly stated: "Data access: Ebean ORM."

In another session, Claude reported: "I've added the safeguard directive to project memory." The next session verified the file was never written to disk.

Across 5 sessions, agents spawned for FiberCore (~/Documents/Software/FiberCore/) ran in worktrees belonging to UtiliGo (a completely different project), despite memory files explicitly mapping project names to directories.
RAW_BUFFERClick to expand / collapse

Preflight Checklist

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

Type of Behavior Issue

Claude ignored my instructions or configuration

What You Asked Claude to Do

Across 7 Claude Code sessions on a Java/Play Framework project (FiberCore), I asked Claude to:

  1. Fix specific bugs identified in a CEO Review audit (copilot audit logging, truck roll prevention module, platform health dashboard)
    1. Fix a Flyway migration column name mismatch
    1. Deduplicate a method across 3 controllers
    1. Fix a method returning the wrong account
    1. Fix an IDOR vulnerability in a controller All tasks had clear CLAUDE.md instructions specifying: the correct project directory, the data access layer (Ebean ORM), and explicit directives to read files before modifying them. These issues did NOT occur on Opus 4.6.

What Claude Actually Did

Across 7 sessions, Claude consistently failed in 4 ways:

  1. Agents spawned in wrong project directory: Background agents ran in .claude/worktrees/ directories belonging to a different project (UtiliGo) instead of the target project (FiberCore at ~/Documents/Software/FiberCore/). This happened in 5+ sessions despite CLAUDE.md containing explicit project directory mappings.
  2. CLAUDE.md directives ignored: Project-level CLAUDE.md contained explicit instructions like "read the file before modifying," "verify you are in the correct directory," and "STOP if something doesn't match." These were consistently ignored. The model wrote code against assumed patterns from training data instead of reading the actual codebase.
  3. Pattern hallucination: In one major session, Claude wrote an entire implementation using raw JDBC patterns when the codebase used Ebean ORM. Rather than reading existing repository files to understand the data access layer, it assumed patterns and wrote completely incompatible code. This required discarding all work and redoing from scratch.
  4. Memory directives not persisted: A critical safeguard directive was supposedly added to project memory. The next session confirmed it was never actually written to disk. The model reported success without verifying the write. Result: 6 of 7 sessions produced zero usable output. Estimated $80-135 in wasted API costs plus multiple hours of user time correcting and re-explaining.

Expected Behavior

Claude should have:

  1. Read CLAUDE.md directives and followed them — especially "read the file before modifying" and "verify correct directory"
    1. Spawned agents in the correct project directory (~/Documents/Software/FiberCore/), not in unrelated worktrees
    1. Read existing repository/service files before writing new code to match the actual data access patterns (Ebean ORM, not raw JDBC)
    1. Verified file writes actually persisted before reporting success
    1. Stopped and asked the user when something didn't match expectations, as explicitly instructed This behavior worked correctly on Opus 4.6. The regression appeared after upgrading to 4.7.

Files Affected

Multiple Java source files across the project were affected. Key examples:

- CLAUDE.md (directives ignored)
- ~/.claude/projects/.../memory/ (directive supposedly written but not persisted)
- app/com/fibercore/modules/copilot/ (entire module written with wrong data access patterns)
- app/com/fibercore/modules/truckroll/ (written by agent in wrong worktree directory)
- app/com/fibercore/platform/resilience/ (written by agent in wrong worktree directory)
- conf/routes, conf/application.conf (modified)

Permission Mode

Accept Edits was ON (auto-accepting changes)

Can You Reproduce This?

Yes, every time with the same prompt

Steps to Reproduce

  1. Have 2+ Play Framework (Java) projects under ~/Documents/Software/ with different data access patterns (e.g., one uses Ebean ORM, another uses raw JDBC)
    1. Create per-project CLAUDE.md files with explicit directives: correct directory path, data access layer, "read before write," "STOP if mismatch"
    1. Create ~/.claude/projects/.../memory/ files mapping project names to directories
    1. Start a Claude Code session on Project A and ask it to fix a bug or implement a feature
    1. Spawn background agents for parallel work
    1. Observe: agents run in .claude/worktrees/ directories that belong to Project B, not Project A
    1. Observe: code is written using patterns from training data or Project B instead of reading Project A's actual files
    1. Observe: CLAUDE.md directives (read before write, verify directory, STOP on mismatch) are ignored

Claude Model

Opus

Relevant Conversation

Example from session where Claude wrote raw JDBC code against an Ebean ORM codebase:

User: "I want to keep ebean codebase because that is what is in my plans and documents but every time i turn around you go off on your own and waste time and money"

Claude had written entire module implementations using DB.sqlQuery() and raw SQL when the codebase clearly used Ebean ORM with @Entity models extending a BaseModel class and repositories extending TenantEbeanRepository. CLAUDE.md explicitly stated: "Data access: Ebean ORM."

In another session, Claude reported: "I've added the safeguard directive to project memory." The next session verified the file was never written to disk.

Across 5 sessions, agents spawned for FiberCore (~/Documents/Software/FiberCore/) ran in worktrees belonging to UtiliGo (a completely different project), despite memory files explicitly mapping project names to directories.

Impact

Critical - Data loss or corrupted project

Claude Code Version

2.1.92 (Claude Code)

Platform

Anthropic API

Additional Context

Key patterns:

  • This is a REGRESSION from Opus 4.6 to 4.7. The same workflows worked correctly before the model upgrade.
    • Multi-project workspaces with per-project CLAUDE.md trigger this consistently.
      • Background agents (spawned via Agent tool) are especially prone to running in wrong directories.
        • The problem compounds: once Claude writes code against wrong assumptions, it doubles down rather than stopping.
          • 7 sessions across multiple days, $80-135 in wasted API costs, user evaluating switching to competing products.
            • macOS, Java 21 / Play Framework 3.x projects with Ebean ORM and PostgreSQL 16.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING