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

Define Custom Subagents on the Fly with --agents

bagwaa @bagwaa · Mar 26, 2026 · Workflows
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
0
Scan Pending Changes for Security Issues with /security-review

The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.

bagwaa @bagwaa · 1 hour ago
0
Run Setup Scripts on Every Session with the SessionStart Hook

The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.

bagwaa @bagwaa · 1 hour ago
0
Write Property-Based Tests with fast-check and Claude

Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.

bagwaa @bagwaa · 2 hours ago