[BUG] Custom Agent Invocation Fails with Bash Permission Error
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Summary
Custom agents defined in .claude/agents/*.md files fail to invoke with a bash permission check error, even though the agent files contain valid YAML frontmatter and markdown content. Built-in agents (like Explore) work correctly.
Environment
- Claude Code Version: 2.1.5
- OS: Windows (Git Bash environment)
- Node Version: 20+
- Agent Framework: Custom agents using
.claude/agents/directory
Expected Behavior
When invoking a custom agent using the Task tool with subagent_type set to a custom agent name (e.g., backend-developer, frontend-developer, project-manager), the agent should be loaded and execute the provided prompt.
Actual Behavior
Agent invocation fails immediately with the following error:
Bash command permission check failed for pattern "!`;
// Multi-line strings
const html = `": This Bash command contains multiple operations. The following parts require approval: __NEW_LINE_<hash>__, // Multi-line strings, const html =
The error suggests the agent system is incorrectly treating agent file content as Bash commands and attempting to validate them against the permissions system.
What Should Happen?
Expected Behavior
When invoking a custom agent using the Task tool with subagent_type set to a custom agent name (e.g., backend-developer, frontend-developer, project-manager), the agent should be loaded and execute the provided prompt.
Error Messages/Logs
Bash command permission check failed for pattern "!`;
// Multi-line strings
const html = `": This Bash command contains multiple operations. The following parts require approval: __NEW_LINE_<hash>__, // Multi-line strings, const html =
Steps to Reproduce
Steps to Reproduce
- Create a custom agent file in
.claude/agents/backend-developer.md:
---
name: backend-developer
description: Use this agent when you need to develop or modify backend functionality including API endpoints, database operations, business logic, authentication, or performance optimization.
model: sonnet
color: red
---
You are an expert Backend Development Engineer specializing in Node.js, TypeScript, Express.js, PostgreSQL, and Prisma ORM.
## Example Code Block
```typescript
describe('POST /api/quotes', () => {
it('creates quote with valid data', async () => {
const response = await request(app)
.post('/api/quotes')
.set('Authorization', `Bearer ${token}`)
.send(validQuoteData);
expect(response.status).toBe(201);
});
});
2. Attempt to invoke the agent:
```typescript
Task({
subagent_type: "backend-developer",
description: "Test backend agent",
prompt: "This is a test. Please acknowledge."
})
- Observe the bash permission error
Additional Contex
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.0
Claude Code Version
2.1.5
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗