Subagents ignore user CLAUDE.md rules (e.g. no composite shell commands)

Resolved 💬 4 comments Opened Mar 22, 2026 by ncaramello Closed Mar 26, 2026

Problem

When a user configures rules in ~/.claude/CLAUDE.md (e.g., "never chain commands with &&, ||, or ;"), the main Claude Code session respects them — but subagents launched via the Agent tool do not.

This is an insane annoyance because:

  1. The user sets a rule to avoid permission prompts (e.g., "no composite commands so each command matches an allowed prefix in settings.json")
  2. The main session obeys
  3. But every Agent subagent immediately starts running cd /some/path && grep ... or cd /some/path && git ..., triggering the exact permission prompts the rule was designed to prevent
  4. The user has to repeatedly reject or approve these, defeating the entire purpose of the rule
  5. There is no workaround — the user cannot control the internal behavior of spawned agents

Expected Behavior

Subagents should inherit and respect all CLAUDE.md rules from the parent session, including user-level (~/.claude/CLAUDE.md) and project-level rules.

Actual Behavior

Subagents operate as fresh sessions with no knowledge of CLAUDE.md rules. They use default patterns like cd /path && command which violate user-configured rules.

Reproduction

  1. Add to ~/.claude/CLAUDE.md:

``
No composite shell commands. Never chain commands with
&&, ||, or ;. Run each command as a separate Bash tool call.
``

  1. Add corresponding allowed prefixes in settings.json (e.g., Bash(git:*), Bash(grep:*))
  2. Ask Claude to do something that spawns agents (e.g., /code-review)
  3. Observe agents running grep -rn "pattern" — composite commands that trigger permission prompts

Impact

This makes Agent-heavy workflows (code review, deep review, multi-repo tasks) extremely painful for users who rely on CLAUDE.md rules for permission management. Every agent spawn becomes a permission prompt minefield.

Suggested Fix

Pass the full CLAUDE.md context (user-level + project-level) to subagents as part of their system context, the same way the parent session receives it.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗