Claude Code Error: Invalid --agents configuration:
Read the second line of an invalid --agents error to locate broken JSON, a missing prompt field, or a leading hyphen in the agent name.
Error: Invalid --agents configuration:invalid JSON: JSON Parse error: Expected '}'Read the second line when --agents stops a fresh session from opening. The same heading covers three failures, and the detail tells you which part of the argument to edit.
[1] Check the string passed by the shell if the detail starts with invalid JSON.
$ timeout 20 claude --agents '{broken'The opening brace starts an object that the parser cannot finish. Adding a closing brace alone would leave {broken}, which still does not describe a JSON object. In Bash, wrap the whole argument in single quotes and use double quotes around keys and string values inside it.
[2] Follow the field path when the second line names one.
$ timeout 20 claude --agents '{"review":{"description":"Review text"}}'Error: Invalid --agents configuration:review.prompt: Invalid input: expected string, received undefinedParsing succeeded this time. The outer key names the agent, review. Inside it, description tells Claude when to use the agent. The missing prompt must be a string containing its instructions.
[3] Check the first character of the name after filling in both fields.
$ timeout 20 claude --agents '{"-review":{"description":"Review text","prompt":"Review the text."}}'Error: Invalid --agents configuration:-review: agent names must not start with '-'Remove the leading hyphen. The following is the complete Bash argument for --agents after that edit. A CLI definition belongs to the current session. To keep an agent for later sessions, see creating a subagent file and checking the list.
'{"review":{"description":"Review text","prompt":"Review the text."}}'[4] Check the launch options if the same input produces no error.
Before v2.1.242, an invalid definition still allowed the session to start. On versions with validation, safe mode enabled through --safe-mode or CLAUDE_CODE_SAFE_MODE ignores the flag entirely. Resuming with --resume or --continue skips the inline JSON check, so a successful resume cannot confirm your edit. Definitions read from a file are checked on resume. Official error reference
File paths are accepted with --print (-p) starting in v2.1.281. Use an inline object for an interactive session. If a path error appears when you intended to pass JSON, check the shell quoting and whether the argument still starts with {.