Subagents
Subagents allow OpsCode to delegate specialized infrastructure work to isolated domain experts. Each subagent runs with its own system prompt, isolated context window, scoped tool permissions, and domain-specific skills. Intermediate tool output—such as long terraform plan logs or schema lookups—stays inside the subagent, returning only a clean summary and modified files to your main conversation.
How subagent delegation works
The root OpsCode agent carries 4 lightweight global skills (cloud-core, docker, kubernetes, remember) and delegates domain-specific engineering tasks to 6 built-in subagents:
The 6 built-in subagents bundle 34 domain skills in total, but those skills only enter the context window when that specific subagent is invoked. If you are working on a Helm chart, Terraform and Jenkins skills consume zero tokens.
Built-in subagents
| Subagent | Domain | Bundled skills (34 total) | Embedded MCP |
|---|---|---|---|
aws-opentofu-provisioner | OpenTofu on AWS (KMS state encryption, S3/DynamoDB locking, cross-account IAM) | opentofu-data-security, opentofu-iam-security, opentofu-mcp-schema-lookup, opentofu-module-layout, opentofu-state-management, opentofu-testing-validation, opentofu-vpc-networking | AWS MCP |
aws-terraform-module-writer | HashiCorp Terraform modules on AWS (multi-account patterns, repair loops) | aws-data-security-enforcement, aws-iam-policy-engine, aws-vpc-network-patterns, terraform-iteration-patterns, terraform-mcp-schema-lookup, terraform-module-layout, terraform-repair-loop | AWS MCP |
infra-ansible-provisioner | Ansible playbooks, roles, Vault encryption, Molecule testing, Execution Environments | ansible-code-authoring, ansible-environment-setup, ansible-execution-environments, ansible-linting-remediation, ansible-mcp-schema-lookup, ansible-runner-execution, ansible-security-operations | Ansible MCP |
k8s-helm-provisioner | Production Helm charts, JSON schema validation, Pod Security Standards | helm-chart-authoring, helm-deployment-recovery, helm-schema-validation, helm-security-secrets, helm-testing | — |
github-actions-writer | Hardened GitHub Actions workflows, OIDC federation, matrix caching | github-actions-architecture, github-actions-performance, github-actions-security-hardening, github-actions-vulnerability-mitigation | — |
ci-jenkins-automater | Declarative Jenkinsfile pipelines, Shared Libraries, Job DSL, JCasC | jenkins-job-dsl-jcasc, jenkins-pipeline-generation, jenkins-pipeline-testing, jenkins-shared-libraries | — |
Invoke subagents
By default, the root agent delegates to subagents automatically based on your prompt. You can also target a subagent directly:
# Launch OpsCode directly into a specific subagent
ops -a aws-terraform-module-writer
Or switch the active subagent mid-session in the TUI:
/agents
Define custom subagents
Create custom subagents by adding an AGENTS.md file in either your project or user directory:
- Project scope (Git-tracked):
.opscode/agents/<subagent-name>/AGENTS.md - User scope:
~/.opscode/opscode/agents/<subagent-name>/AGENTS.md
---
name: terraform-reviewer
description: Review Terraform and OpenTofu modules for security and best practices
model: anthropic:claude-opus-4-7
tools:
- execute
- read_file
- grep
- glob
skills:
- opentofu-iam-security
- aws-iam-policy-engine
permission_tier: read-only
---
You are a specialized Terraform and OpenTofu security auditor.
## Audit Criteria
1. Ensure S3 remote state uses AWS KMS encryption and DynamoDB state locking.
2. Verify all IAM policies follow least-privilege principles with zero wildcard actions.
3. Validate that security groups avoid open `0.0.0.0/0` ingress on non-HTTPS ports.
4. Confirm all resources include standard cost-allocation tags.
Frontmatter reference
| Field | Required | Description |
|---|---|---|
name | Yes | Unique identifier for the subagent |
description | Yes | Routing description used by the root agent to decide when to delegate |
model | No | Model override in provider:model format (defaults to the main session model) |
tools | No | Allowed tool names (e.g., read_file, execute, glob, grep) |
skills | No | List of skill names loaded when this subagent runs |
permission_tier | No | read-only (default) or read-write |
Dynamic parallel subagents
When the QuickJS interpreter is enabled (--interpreter), OpsCode can spawn dynamic subagents in parallel at runtime using the built-in task() function.
Ask OpsCode to run a parallel workflow across multiple directories or modules:
Run a parallel workflow to audit every Terraform module in modules/* for IAM wildcards and unencrypted storage.
OpsCode generates and executes an orchestration script that dispatches concurrent subagents and aggregates their findings in the TUI's dynamic subagents panel:
const modules = await glob("modules/*/main.tf");
const reports = await Promise.all(
modules.map((mod) =>
task(`Audit ${mod} for IAM wildcards, open security groups, and unencrypted storage`)
)
);