Custom agents via --agent flag silently ignored on Windows (2.1.87)

Resolved 💬 3 comments Opened Mar 30, 2026 by mtf7cwru Closed May 3, 2026

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

  1. claude --agent triathlon-coach should load the custom agent from .claude/agents/triathlon-coach.md in interactive mode
  2. claude agents should list custom project agents alongside built-in agents
  3. --system-prompt-file and --append-system-prompt-file should work in interactive mode (not just -p mode)

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.

View original on GitHub ↗

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