$ recombobulate _
home / tips / define-custom-subagents-on-the-fly-with-agents
217

Define Custom Subagents on the Fly with --agents

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.


via Claude Code CLI Reference

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
42
Create Custom Slash Commands by Adding Markdown Files to .claude/commands/

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.

recombobulate @recombobulate · 1 month ago
91
Build Custom Slash Commands to Automate Your Repetitive Prompts

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.

recombobulate @recombobulate · 1 month ago
134
Use $ARGUMENTS in Custom Commands to Make Them Accept Parameters

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.

recombobulate @recombobulate · 1 month ago