AGENT.md rules not consistently followed in worktree sessions
Description
When Claude Code operates in a git worktree, project-level AGENT.md rules are not consistently followed despite being loaded at session start. This manifests as repeated failures to act on explicit instructions in AGENT.md, requiring the user to manually remind Claude of rules that are already in context.
Reproduction
- Create a project with an AGENT.md containing explicit workflow rules (e.g., "Commit and push to main immediately after verification")
- Start a Claude Code session in a worktree within that project
- Complete a task that triggers the AGENT.md rule
- Observe that Claude does not follow the rule until the user explicitly asks
Specific Example
Project AGENT.md (cncmill1/AGENT.md, line 10) states:
"Commit and push to main immediately after verification. If already in a worktree, merge and push to main before ending the session — do not leave doc changes on an unmerged branch."
After completing documentation edits, Claude did not commit or push until the user asked "has it been pushed? if not why". When pointed to the AGENT.md rule, Claude acknowledged the rule existed but had not acted on it.
This has occurred across multiple sessions — the user's own memory file documents: "User has had to ask 'is it pushed?' or 'push to main' multiple times. The AGENT.md rule already says to do this — the problem is not following it, not a missing rule."
Expected Behavior
AGENT.md rules should be treated as binding instructions that are actively followed, not just passively loaded. When a task triggers a rule in AGENT.md (e.g., completing a doc edit triggers the "commit and push immediately" rule), Claude should execute the rule without user prompting.
Environment
- Claude Code CLI on Windows 11
- Git worktree sessions (
.claude/worktrees/) - Model: Claude Opus 4.6 (1M context)
- The AGENT.md is confirmed to be in context (Claude can quote it when asked)
Additional Context
The issue appears to be behavioral rather than a context loading problem — Claude has the AGENT.md content available but does not proactively act on it. The system prompt's default cautious behavior ("do not push unless asked") appears to override project-level AGENT.md instructions even though AGENT.md should take precedence for project-specific workflow rules.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗