Skip to content
Page 3 of 7

Going Parallel

Background Execution

Until now, you've been working synchronously: you give AI a task, watch it work, and review the output before moving on. But once you trust the pattern (story → tests → implementation → verification), you can let AI work in the background while you focus on something else.

Background execution means sending a task to AI and continuing your own work while AI builds. When it finishes, you review the output, just like checking on a colleague who's had time to complete an assignment.

In Your AI Assistant

Open Code does not yet have a single-key shortcut for background execution. The stable approach for parallel work is to run tasks in separate terminals:

  • Open a second terminal in your workspace and launch opencode there. Each terminal gets its own conversation and context window.
  • Use opencode run "prompt" to execute a task non-interactively, which is useful for batch operations or scripting.

Each separate session can work on a different task independently.

Two ways to send work to the background:

  • Ask in your prompt. Include "in the background" in your message, e.g., "Run the tests in the background" or "Build this feature in the background while I work on something else." Claude Code will run it as a background process automatically.
  • Press Ctrl+B while a task is already running to push it to the background on the fly.

Either way, Claude Code keeps working in a separate process. You can check on background tasks anytime with /tasks.

Antigravity CLI uses dynamic subagents for parallel work. The main agent can delegate tasks to subagents that run independently, each with its own auto-provisioned Git worktree for isolation. Use /tasks to monitor running subagents and check on their progress.

Two ways to run work without the interactive TUI:

  • Use codex exec "task description" to run a task non-interactively, streaming progress to stderr. This is useful for batch operations or scripting.
  • Delegate to subagents. Ask Codex to delegate work to subagents that run independently, each in its own git worktree for isolation.

Monitor running threads with /agent or /subagents to inspect and switch between them.

Sub-Agents

When AI encounters a complex task, it can recruit sub-agents, focused AI instances that handle specific parts of the work. Think of it like a team lead who brings in specialists: one handles research, another writes tests, another focuses on implementation.

You don't need to manage sub-agents directly. When you give your AI coding assistant a complex task, it may spin up sub-agents behind the scenes, each one getting a focused slice of context rather than the entire conversation. This often produces better results because each sub-agent gets a full oxygen tank (from Lesson 1) dedicated to its specific task, rather than sharing one tank across everything.

In Your AI Assistant

Open Code uses sub-agents automatically for complex tasks: built-in types include Explore (read-only search), Scout (external docs and dependency research), and General (full tool access). Plan is a primary mode you can switch to with the Tab key. You can also create custom agents by adding markdown files to .opencode/agents/.

Claude Code uses sub-agents automatically for complex tasks: built-in types include Explore (read-only search), Plan (codebase research), and general-purpose (full tool access). You can also create custom agents by adding markdown files to .claude/agents/, or ask Claude to create one for you.

Antigravity CLI uses dynamic subagents for complex tasks, spawning specialized agents on the fly with auto-provisioned Git worktrees for isolation. The main agent delegates tasks to subagents that run independently. You can also define custom agents through the plugin system, which bundles agents with skills, rules, and MCP servers.

Codex CLI uses sub-agents for complex tasks: built-in types include default (general-purpose), worker (execution-focused), and explorer (read-heavy analysis). Each sub-agent runs in its own git worktree for isolation. You can also define custom agents in .codex/agents/*.toml files.

Keeping Parallel Work Focused

When you're running more than one task at a time, context management matters more. The oxygen tank metaphor from Lesson 1 still applies, but now you're managing more than one tank.

The pattern:

  • One conversation per task. Don't build three features in one conversation. Each feature gets its own fresh context.
  • Start fresh for each new workstream. Your project context file (from Lesson 1) means every new conversation starts with the right baseline. AI already knows your project. You don't re-explain anything; you just hand over the next story.
  • Reset when context gets stale. If AI starts repeating itself or missing earlier instructions, the tank is running low. Start a new conversation rather than fighting through it.
  • Keep workstreams independent. If Feature A depends on Feature B's output, don't run them in parallel. Sequence them. Parallel workstreams must be independently buildable (the same "independently shippable" test from Lesson 2's decomposition).

In Your AI Assistant

Which command when:

Command When to Use
/new Switching to a different task entirely. Your project context file reloads automatically.
/compact Still on the same task but context is getting large. Keeps the thread alive while freeing space. E.g., /compact keep the API decisions.
/sessions Returning to a workstream you set aside earlier. Opens a session picker to restore a previous conversation.

Which command when:

Command When to Use
/clear Switching to a different task entirely. Your project context file reloads automatically.
/compact Still on the same task but context is getting large. Keeps the thread alive while freeing space. E.g., /compact keep the API decisions.
/resume Returning to a workstream you set aside earlier. Restores the full conversation history.

Which command when:

Command When to Use
/clear (or Ctrl+L) Switching to a different task entirely. Starts a fresh conversation. Your project context file reloads automatically.
/compress Still on the same task but context is getting large. Condenses the conversation to free space while keeping the thread alive.
/resume Returning to a workstream you set aside earlier. Opens an interactive session browser to browse and resume previous sessions.

Which command when:

Command When to Use
/clear Switching to a different task entirely. Starts a new conversation. Your project context file reloads automatically.
/compact Still on the same task but context is getting large. Summarizes the conversation to free space while keeping the thread alive. E.g., /compact keep the API decisions.
/resume Returning to a workstream you set aside earlier. Opens a session picker to resume a previous conversation.

Your project context file and skills from earlier lessons pay off here. Every new conversation starts with AI knowing your project, your conventions, and your processes, including the TDD workflow from Lesson 3.

Launch a Background Task

Mob Session | ~5 minutes total | One person drives, everyone else navigates.

Rotate the driver. Pick someone who hasn't been at the keyboard recently.

Pick one feature from your Final Sprint backlog that passed the delegation-ready test. Write a quick user story with 2-3 acceptance criteria.

Ask your AI coding assistant:

Here's a user story. Build it following TDD. Write failing tests
from the acceptance criteria first, then implement until they pass.

[Paste your story and AC here]

After sending the prompt, move the task to the background so you can start something else.

In Your AI Assistant

Open the task in a second terminal: launch opencode in a new terminal window and paste your prompt there. Then switch back to your first terminal and type /new to start a fresh conversation for your next task. When you're ready to return to a previous workstream, use /sessions.

Press Ctrl+B to push the running task to the background. Then type /clear to start a fresh conversation for your next task. Alternatively, include "in the background" right in your prompt: "Build this in the background following TDD..." When you're ready to come back to a previous workstream, use /resume.

Delegate the task to a subagent: describe the work and Antigravity will spawn a subagent with its own isolated Git worktree. Use /tasks to monitor running subagents. Then type /clear to start a fresh conversation for your next task. When you're ready to come back to a previous workstream, use /resume.

Use codex exec "Build this following TDD..." to run the task non-interactively, or ask Codex to delegate it to a subagent. Each subagent gets its own git worktree for isolation. Use /agent or /subagents to monitor running threads. Then type /clear to start a fresh conversation for your next task. When you're ready to come back to a previous workstream, use /resume.

While that runs, start your next task in a fresh conversation. Your project context file means you don't need to re-explain anything. AI already knows your project, your conventions, and your TDD workflow.

Trust and Oversight

Team Discussion | ~3 minutes total

Discuss: What's different about working this way compared to watching AI build step by step? What do you trust at this point, and what would you still want to check when the background task finishes? How do your automated tests (Lesson 3) change your comfort level with letting AI work unsupervised?

Key Insight

Going parallel means shifting from watching AI work to reviewing AI's output. Background execution lets AI build while you move on. Sub-agents let AI recruit specialists behind the scenes. Context management (one conversation per task, fresh starts, independent workstreams) keeps each parallel effort focused. Your project context file and skills make every new conversation productive from the first prompt.