MANDATORY - You MUST follow the Workflow steps below in order. Do not skip steps.
Agent Selection
Explicit request: If user specifies an agent (e.g., "use gemini", "spawn codex"), use that agent
No agent specified: Use DEFAULT_AGENT (claude-code)
Check enabled: Verify the ENABLED_*_CLI flag is true before proceeding
Reading Cookbooks
Based on the selected agent, follow the 'Cookbook' section to read the appropriate .md file
You MUST read and execute the appropriate cookbook file before spawning the agent
Red Flags - STOP and follow Cookbook
If you're about to:
Spawn an agent without reading the cookbook first
Execute a CLI command without running --help
Skip steps because "this is simple"
Run a CLI agent with a prompt but without checking INTERACTIVE_MODE requirements
STOP -> Read the appropriate cookbook file -> Follow its instructions -> Then proceed
Common Mistake: When spawning agentic CLIs (Claude, Codex, Gemini) with a prompt,
most require command chaining (e.g., && claude --continue) to stay in interactive
mode after the prompt completes. Always check the cookbook for the correct pattern.
Spawn Summary User Prompt
IF: The user requests spawning an agent with a summary of the conversation
THEN:
Read and REPLACE the and fields in './prompts/fork-summary-user-prompt.md' with the history of the conversation between you and the user.
Include the next users request in the Next User Request field.
This will be what you pass into the PROMPT field of the agentic coding tool.
Spawn the agent with: fork_terminal(command: str, capture=False, log_to_file=False, log_agent_output=True)
Examples:
"Spawn agent use claude code to with a summary"
"spin up a new terminal with with claude code. Include a summary of the conversation."
"create a new agent with claude code to . Summarize work so far."
"spawn agent use gemini to with a summary"
Workflow
MANDATORY CHECKPOINTS - Verify each before proceeding:
Understand the user's request
SELECT AGENT: Determine which agent (explicit or DEFAULT_AGENT)
READ: './fork_terminal.py' to understand the tooling
Follow the Cookbook (read the appropriate .md file for selected agent)
CHECKPOINT: Confirm cookbook instructions were followed (e.g., ran --help)
IF 'READ_CAPTURED_OUTPUT' is true: Read and display the agent output using read_fork_output()
Cookbook
Claude Code (Default)
IF: User requests Claude Code OR no agent explicitly specified
THEN: Read and execute './cookbook/claude-code.md'
Examples:
"Spawn an agent to "
"Fork terminal to " (no agent specified = claude-code)
"Spawn agent use claude code to "
"spin up a new terminal with claude code"
Codex CLI
IF: User requests Codex/OpenAI agent and 'ENABLED_CODEX_CLI' is true
THEN: Read and execute './cookbook/codex-cli.md'
Examples:
"Spawn agent use codex to "
"create a new terminal with codex cli to "
"spawn openai agent to "
Gemini CLI
IF: User requests Gemini/Google agent and 'ENABLED_GEMINI_CLI' is true
THEN: Read and execute './cookbook/gemini-cli.md'
Examples:
"Spawn agent use gemini to "
"create a new terminal with gemini cli to "
"spawn google agent to "
Cursor CLI
IF: User requests Cursor agent and 'ENABLED_CURSOR_CLI' is true
THEN: Read and execute './cookbook/cursor-cli.md'
Examples:
"Spawn agent use cursor cli to "
"create a new terminal with cursor to "
"spawn cursor agent to "
OpenCode CLI
IF: User requests OpenCode agent and 'ENABLED_OPEN_CODE_CLI' is true
THEN: Read and execute './cookbook/opencode-cli.md'
Examples:
"Spawn agent use opencode cli to "
"create a new terminal with opencode to "
"spawn opencode agent to "
Copilot CLI
IF: User requests Copilot/GitHub agent and 'ENABLED_COPILOT_CLI' is true
THEN: Read and execute './cookbook/copilot-cli.md'
Examples:
"Spawn agent use copilot cli to "
"create a new terminal with copilot to "
"spawn github copilot agent to "
Output Retrieval
The fork_terminal() function supports three output controls:
Parameter
Default
Output File
Description
log_agent_output
True
/tmp/fork-agent-*.json
Clean agent JSON response
log_to_file
False
/tmp/fork-debug-*.txt
Full terminal output (debug)
capture
False
N/A
Block and return content directly
Parameter Combinations
capture
log_agent_output
log_to_file
Behavior
False
True (default)
False
Returns agent JSON file path
False
False
True
Returns debug file path
False
False
False
Returns empty string
True
True
*
Blocks, returns agent JSON content
True
False
True
Blocks, returns debug content
Retrieving Output Later
When log_agent_output=True (default), clean agent output is logged. Use read_fork_output(file_path) to retrieve it:
# Spawn without blocking (returns path to JSON output)
file_path = fork_terminal(cmd, log_agent_output=True)
print(f"Agent output will be at: {file_path}")
# Later, read the output when needed
output = read_fork_output(file_path, timeout=60)
Debug Mode
For debugging, enable log_to_file=True to capture full terminal output (including stderr):
1---2name: spawn-agent-23description: Spawn an AI coding agent in a new terminal (Claude, Codex, Gemini, Cursor, OpenCode, Copilot). Defaults to Claude Code if unspecified.4---56# Purpose
78Spawn an AI coding agent in a new terminal window. Follow the 'Instructions', execute the 'Workflow', based on the 'Cookbook'.
910## Variables
1112| Variable | Default | Description |
13|----------|---------|-------------|
14| DEFAULT_AGENT | claude-code | Agent to use when not explicitly specified |
15| ENABLED_CLAUDE_CLI | true | Enable Claude Code agent |
16| ENABLED_CODEX_CLI | true | Enable OpenAI Codex agent |
17| ENABLED_GEMINI_CLI | true | Enable Google Gemini agent |
18| ENABLED_CURSOR_CLI | true | Enable Cursor agent |
19| ENABLED_OPEN_CODE_CLI | true | Enable OpenCode agent |
20| ENABLED_COPILOT_CLI | true | Enable GitHub Copilot agent |
21| LOG_TO_FILE | false | Write full terminal output to debug file |
22| LOG_AGENT_OUTPUT | true | Write clean agent JSON response to file |
23| READ_CAPTURED_OUTPUT | false | Read and display agent output after spawn |
24| AGENTIC_CODING_TOOLS | claude-code, codex-cli, gemini-cli, cursor-cli, opencode-cli, copilot-cli | Available agentic tools |
2526## Instructions
2728**MANDATORY** - You MUST follow the Workflow steps below in order. Do not skip steps.
2930### Agent Selection
31321. **Explicit request**: If user specifies an agent (e.g., "use gemini", "spawn codex"), use that agent
332. **No agent specified**: Use DEFAULT_AGENT (claude-code)
343. **Check enabled**: Verify the ENABLED_*_CLI flag is true before proceeding
3536### Reading Cookbooks
3738- Based on the selected agent, follow the 'Cookbook' section to read the appropriate .md file
39- You MUST read and execute the appropriate cookbook file before spawning the agent
4041## Red Flags - STOP and follow Cookbook
4243If you're about to:
44- Spawn an agent without reading the cookbook first
45- Execute a CLI command without running --help
46- Skip steps because "this is simple"
47- Run a CLI agent with a prompt but without checking INTERACTIVE_MODE requirements
4849**STOP** -> Read the appropriate cookbook file -> Follow its instructions -> Then proceed
5051> **Common Mistake**: When spawning agentic CLIs (Claude, Codex, Gemini) with a prompt,
52> most require command chaining (e.g., `&& claude --continue`) to stay in interactive
53> mode after the prompt completes. Always check the cookbook for the correct pattern.
5455### Spawn Summary User Prompt
5657- IF: The user requests spawning an agent with a summary of the conversation
58- THEN:
59 - Read and REPLACE the <user_prompt_summary> and <agent_response_summary> fields in './prompts/fork-summary-user-prompt.md' with the history of the conversation between you and the user.
60 - Include the next users request in the `Next User Request` field.
61 - This will be what you pass into the PROMPT field of the agentic coding tool.
62 - Spawn the agent with: fork_terminal(command: str, capture=False, log_to_file=False, log_agent_output=True)
63- Examples:
64 - "Spawn agent use claude code to <xyz> with a summary"
65 - "spin up a new terminal with <xyz> with claude code. Include a summary of the conversation."
66 - "create a new agent with claude code to <xyz>. Summarize work so far."
67 - "spawn agent use gemini to <xyz> with a summary"
6869## Workflow
7071**MANDATORY CHECKPOINTS** - Verify each before proceeding:
72731. [ ] Understand the user's request
742. [ ] **SELECT AGENT**: Determine which agent (explicit or DEFAULT_AGENT)
753. [ ] READ: './fork_terminal.py' to understand the tooling
764. [ ] Follow the Cookbook (read the appropriate .md file for selected agent)
775. [ ] **CHECKPOINT**: Confirm cookbook instructions were followed (e.g., ran --help)
786. [ ] Execute fork_terminal(command: str, capture=False, log_to_file=False, log_agent_output=True)
797. [ ] IF 'READ_CAPTURED_OUTPUT' is true: Read and display the agent output using read_fork_output()
8081## Cookbook
8283### Claude Code (Default)
84- IF: User requests Claude Code OR no agent explicitly specified
85- THEN: Read and execute './cookbook/claude-code.md'
86- Examples:
87 - "Spawn an agent to <xyz>"
88 - "Fork terminal to <xyz>" (no agent specified = claude-code)
89 - "Spawn agent use claude code to <xyz>"
90 - "spin up a new terminal with claude code"
9192### Codex CLI
93- IF: User requests Codex/OpenAI agent and 'ENABLED_CODEX_CLI' is true
94- THEN: Read and execute './cookbook/codex-cli.md'
95- Examples:
96 - "Spawn agent use codex to <xyz>"
97 - "create a new terminal with codex cli to <xyz>"
98 - "spawn openai agent to <xyz>"
99100### Gemini CLI
101- IF: User requests Gemini/Google agent and 'ENABLED_GEMINI_CLI' is true
102- THEN: Read and execute './cookbook/gemini-cli.md'
103- Examples:
104 - "Spawn agent use gemini to <xyz>"
105 - "create a new terminal with gemini cli to <xyz>"
106 - "spawn google agent to <xyz>"
107108### Cursor CLI
109- IF: User requests Cursor agent and 'ENABLED_CURSOR_CLI' is true
110- THEN: Read and execute './cookbook/cursor-cli.md'
111- Examples:
112 - "Spawn agent use cursor cli to <xyz>"
113 - "create a new terminal with cursor to <xyz>"
114 - "spawn cursor agent to <xyz>"
115116### OpenCode CLI
117- IF: User requests OpenCode agent and 'ENABLED_OPEN_CODE_CLI' is true
118- THEN: Read and execute './cookbook/opencode-cli.md'
119- Examples:
120 - "Spawn agent use opencode cli to <xyz>"
121 - "create a new terminal with opencode to <xyz>"
122 - "spawn opencode agent to <xyz>"
123124### Copilot CLI
125- IF: User requests Copilot/GitHub agent and 'ENABLED_COPILOT_CLI' is true
126- THEN: Read and execute './cookbook/copilot-cli.md'
127- Examples:
128 - "Spawn agent use copilot cli to <xyz>"
129 - "create a new terminal with copilot to <xyz>"
130 - "spawn github copilot agent to <xyz>"
131132## Output Retrieval
133134The `fork_terminal()` function supports three output controls:
135136| Parameter | Default | Output File | Description |
137|-----------|---------|-------------|-------------|
138| `log_agent_output` | `True` | `/tmp/fork-agent-*.json` | Clean agent JSON response |
139| `log_to_file` | `False` | `/tmp/fork-debug-*.txt` | Full terminal output (debug) |
140| `capture` | `False` | N/A | Block and return content directly |
141142### Parameter Combinations
143144| `capture` | `log_agent_output` | `log_to_file` | Behavior |
145|-----------|-------------------|---------------|----------|
146| `False` | `True` (default) | `False` | Returns agent JSON file path |
147| `False` | `False` | `True` | Returns debug file path |
148| `False` | `False` | `False` | Returns empty string |
149| `True` | `True` | * | Blocks, returns agent JSON content |
150| `True` | `False` | `True` | Blocks, returns debug content |
151152### Retrieving Output Later
153154When `log_agent_output=True` (default), clean agent output is logged. Use `read_fork_output(file_path)` to retrieve it:
155156```python
157# Spawn without blocking (returns path to JSON output)
158file_path = fork_terminal(cmd, log_agent_output=True)
159print(f"Agent output will be at: {file_path}")
160161# Later, read the output when needed
162output = read_fork_output(file_path, timeout=60)
163```
164165### Debug Mode
166167For debugging, enable `log_to_file=True` to capture full terminal output (including stderr):
168169```python
170# Debug mode: capture everything
171file_path = fork_terminal(cmd, log_to_file=True, log_agent_output=False)
172```
Run npx skillmds add majiayu000/spawn-agent-2 in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Spawn an AI coding agent in a new terminal (Claude, Codex, Gemini, Cursor, OpenCode, Copilot). Defaults to Claude Code if unspecified. It is listed under AI & ML on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Capability flags: docs only. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
majiayu000 (@majiayu000) published this skill. Their other Agent Skills are listed on their SkillMD profile.