Custom agents via --agent flag silently ignored on Windows (2.1.87)
Bug Description
claude --agent <custom-agent-name> opens a regular Claude Code session on Windows. The custom agent identity is silently ignored — no error, no warning.
Additionally, --system-prompt-file and --append-system-prompt-file work in non-interactive mode (-p) but are silently dropped in interactive mode.
Environment
- Claude Code version: 2.1.87
- Platform: Windows 11 Home 10.0.26200 (AMD)
- Shell: Git Bash / cmd.exe
- Agent file location:
.claude/agents/triathlon-coach.md(also tested in~/.claude/agents/)
Agent File
Valid YAML frontmatter:
---
name: triathlon-coach
description: |
AI triathlon coach calibrated to athlete...
model: opus
maxTurns: 30
---
Reproduction
claude agents only lists built-in agents (general-purpose, Explore, Plan, statusline-setup, claude-code-guide). Custom agents in .claude/agents/ never appear.
What Was Tested
| Flag | Non-interactive (-p) | Piped input | Interactive |
|------|----------------------|-------------|-------------|
| --agent | FAIL | Not tested | FAIL |
| --system-prompt-file | SUCCESS | Not tested | FAIL |
| --append-system-prompt-file | SUCCESS | SUCCESS | FAIL |
| --append-system-prompt (inline) | SUCCESS | Not tested | Not tested |
Pattern: All custom prompt flags work in non-interactive mode but are silently ignored in interactive mode. The --agent flag doesn't work at all for custom project agents.
Expected Behavior
claude --agent triathlon-coachshould load the custom agent from.claude/agents/triathlon-coach.mdin interactive modeclaude agentsshould list custom project agents alongside built-in agents--system-prompt-fileand--append-system-prompt-fileshould work in interactive mode (not just-pmode)
Workaround
Piping an initialization message works:
echo "Load agent identity" | claude --append-system-prompt-file .claude/agents/triathlon-coach.md
This loads the agent identity and continues in interactive mode.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗