Claude ignores agent frontmatter constraints when selecting subagents

Resolved 💬 4 comments Opened Jan 17, 2026 by SalesforceRocks Closed Mar 1, 2026

Problem

When using the Task tool to delegate work to subagents, Claude ignores the agent's frontmatter metadata (description, allowedProjectGlobs, disallowedProjectGlobs) and selects inappropriate agents.

Example

User was working in project SBWZ_Docs (a documentation repository). Claude needed to write a simple markdown file (an ADR - Architecture Decision Record).

Claude selected terraform-developer agent, which has this frontmatter:

name: terraform-developer
description: Expert Terraform developer - implements production-grade GCP infrastructure from approved designs with security, validation, and operational excellence
allowedProjectGlobs:
  - "**/docsense/**"
  - "**/infrastructure/**"
disallowedProjectGlobs:
  - "**/SBWZ_Docs*/**"
  - "**/sabewa*/**"

Problems:

  1. The description clearly says "Terraform developer" and "GCP infrastructure" - completely irrelevant to writing a markdown file
  2. The disallowedProjectGlobs explicitly excludes **/SBWZ_Docs*/** - the exact project being worked on
  3. Claude should have used general-purpose agent or written the file directly

Expected Behavior

Claude should:

  1. Read and respect disallowedProjectGlobs - never select an agent for a disallowed project
  2. Match the task to the agent's description - don't use a Terraform agent for markdown files
  3. Prefer simpler solutions (direct tool use or general-purpose agent) for trivial tasks

Environment

  • Claude Code CLI
  • Model: claude-opus-4-5-20251101
  • Custom agents defined in ~/.claude/agents/

View original on GitHub ↗

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