Docs
Refer a friend. Get a weekly-quota reset.Friend signs up and uses it → +1 reset (valid 30 days) · up to 10% cash back on their spend.
+1 resetGenerate link

Agents (Subagents)

wrok Code automatically spawns subagents to parallelize complex tasks. /agents manages configs, /tasks shows background tasks, and CRABCODE_MAX_CONCURRENT_AGENTS caps concurrency.

What it is

When wrok Code's main loop hits a task that needs a wide investigation before any edits—"survey the codebase first"—it spawns a subagent: an isolated agent with its own context and tool set that runs in parallel, then reports a brief back. Big tasks may fan out several subagents at once (search code, run tests, check docs).

Subagents are core to how wrok Code handles large work. You don't dispatch them by hand—the main model decides. But you do control: which subagent type to use (specialty), how to author your own (project / user), and the concurrency cap.

When you'll see them

  • Main loop prints "Spawning subagent: …" or similar
  • Multiple Agent tool blocks appear concurrently
  • /agents lists available types
  • /tasks lists running background tasks

Built-in subagent types

wrok Code ships 6 built-in types (src/tools/AgentTool/built-in/):

subagent_typeBest for
general-purposeCatch-all: open-ended code search, multi-step tasks, fallback when you're unsure
ExploreWide-net read-ups — slurps many files and returns a summary
PlanRead-only planning — explicitly forbidden from editing, designs implementation
verificationEnd-of-task verification (tests truly passed? change matches intent?)
statusline-setupHelps the user configure the statusline
crabcode-guidewrok Code usage guide assistant

The main model picks based on each type's whenToUse description; omitting subagent_type defaults to general-purpose.

Custom subagents

You can author your own subagent types. Files live in two places:

LocationScope
~/.crabcode/agents/<name>.mdUser-level (visible in every project)
<repo>/.crabcode/agents/<name>.mdProject-level (commit to git)

Format (markdown with frontmatter):

markdown
---
name: db-migration-reviewer
description: Reviews DB migration scripts for safety issues
tools: [Read, Grep, Bash]
model: deepseek-flash
---

You are a database migration safety reviewer.

When invoked, read the migration files passed in, check for:
- Missing rollback statements
- Locking risks on large tables
- Foreign-key constraint violations

Report findings concisely.
---
name: db-migration-reviewer
description: Reviews DB migration scripts for safety issues
tools: [Read, Grep, Bash]
model: deepseek-flash
---

You are a database migration safety reviewer.

When invoked, read the migration files passed in, check for:
- Missing rollback statements
- Locking risks on large tables
- Foreign-key constraint violations

Report findings concisely.

Fields:

  • name — subagent type identifier (required)
  • description — when this subagent should be chosen (required, used by the main model to pick)
  • tools — allowed tool list; omit or use ["*"] for full access
  • model — pin a specific model; omit to inherit the default subagent model
  • color — color tag in the TUI
  • The body is the subagent's system prompt

Save the file and it's picked up on next wrok Code start. /agents will list it.

/agents command

/agents opens the subagent management menu:

  • View all available subagents (built-in + user + project)
  • See each subagent's description, tools, and source file
  • Jump to edit

It does not dispatch a subagent — dispatch is the main model's job. The command is a config panel.

/tasks and the task panel

Use /tasks for background work. The desktop task panel also shows main tasks, subagents, background commands and MCP progress, including usage, model, output and stop state. See tasks.

Concurrency cap

To prevent the main model from dispatching dozens of subagents at once and saturating the gateway, wrok Code applies a client-side concurrency budget to subagent dispatch (src/services/tools/StreamingToolExecutor.ts:24-34):

  • Default cap: 3 in-flight at a time
  • Over-budget dispatches queue, they don't fail
  • Override via env: CRABCODE_MAX_CONCURRENT_AGENTS=5 raises the cap to 5

The cap only affects the Agent tool — other tools (Read / Bash / Grep) are not throttled. Raising it can speed up large tasks but risks hitting gateway rate limits; lowering it serializes work and produces cleaner error traces.

Hooks

Subagent lifecycle exposes 4 hook events (see hooks):

EventWhen it fires
SubagentStartJust before a subagent is dispatched
SubagentStopWhen the subagent returns its report
TaskCreatedNew task created (multi-agent collaboration)
TaskCompletedTask finished

Use these for logging, audit, or injecting extra context before a subagent starts.

Troubleshooting

SymptomCheck
Custom subagent doesn't show upname / description present + file ends .md + located in .crabcode/agents/
Subagent hangs/tasks for background processes; Esc to interrupt the main loop
Subagents repeatedly hit 429Lower CRABCODE_MAX_CONCURRENT_AGENTS or split the task
Subagent lacks toolstools in frontmatter missed entries; use ["*"] to open everything