Define Custom Subagents on the Fly with --agents
Instead of creating agent definition files, the --agents flag lets you define subagents inline as JSON when launching Claude Code. This is great for quick experiments or CI pipelines where you need specialised agents without committing files to the repo.
claude --agents '{
"reviewer": {
"description": "Reviews code for security issues",
"prompt": "You are a security-focused code reviewer. Flag any potential vulnerabilities, injection risks, or unsafe patterns."
}
}'
Claude can then spawn the "reviewer" subagent during the session to delegate security review tasks. The JSON structure uses the same fields as subagent frontmatter, so anything you can define in a .md agent file works here too.
You can define multiple agents at once:
claude --agents '{
"tester": {
"description": "Writes unit tests",
"prompt": "Write thorough unit tests with edge cases."
},
"documenter": {
"description": "Writes documentation",
"prompt": "Write clear, concise documentation for the given code."
}
}'
This pairs well with --print mode for scripted workflows where you want Claude to orchestrate specialised agents without any interactive setup:
claude -p --agents '{"linter":{"description":"Checks style","prompt":"Check code style"}}' \
"Review the src/ directory using the linter agent"
Spin up purpose-built agents from the command line, no config files required.
Log in to leave a comment.
Turn your most common prompts into reusable slash commands — drop a markdown file into .claude/commands/ and it becomes a /command you and your team can invoke anytime, with consistent instructions every time.
Create reusable slash commands in your project so common prompts like "run tests and fix failures" or "review this file for security issues" become a single /command instead of typing the same instructions every time.
The $ARGUMENTS placeholder in custom slash command files turns a static prompt into a reusable tool — pass different values each time you invoke it, just like a function that takes arguments.