一键导入
context-fork-skill
Demonstrates forked context execution. This skill runs in an isolated sub-agent context with its own conversation history and tool access.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Demonstrates forked context execution. This skill runs in an isolated sub-agent context with its own conversation history and tool access.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Automated API testing assistant for REST and GraphQL endpoints
Backend development expert specializing in API design, microservices, database architecture, and system performance. Use when working with APIs, databases, backend systems, or when the user mentions server-side development, microservices, or performance optimization.
Expert in cloud infrastructure design, deployment, and management across AWS, Azure, and GCP
Performs comprehensive code reviews with focus on best practices, security, and performance
内容营销专家,精通内容策略、文案创作、社交媒体和邮件营销
数据分析专家,精通数据可视化、趋势分析、报告生成和预测分析
基于 SOC 职业分类
| name | context-fork-skill |
| description | Demonstrates forked context execution. This skill runs in an isolated sub-agent context with its own conversation history and tool access. |
| version | 1.0.0 |
| author | SDK Team <sdk@example.com> |
| tags | ["testing","subagent","isolation","context"] |
| dependencies | [] |
| context | fork |
| agent | general-purpose |
| allowed_tools | ["Read","Write","Bash","Grep","Glob"] |
This skill demonstrates the context: fork feature, which allows a skill to run in an isolated sub-agent context with its own conversation history and state.
When a skill uses context: fork, it:
agent field to determine sub-agent behaviorComplex Multi-Step Operations
Isolated Testing
Specialized Agent Behavior
State Management
context: fork # Enables forked context
agent: general-purpose # Specifies agent type
.claude/agents/Ask me to perform a complex analysis:
Analyze this codebase and create a detailed report
Behavior:
Test that the forked context has separate history:
First, tell me your name in the forked context
Then ask in the main conversation what we discussed
Expected: The main conversation won't see the forked context's internal messages
Test with different agent types:
# For planning tasks
context: fork
agent: Plan
# For exploration
context: fork
agent: Explore
# For code review
context: fork
agent: code-reviewer
Forked context works with hooks:
context: fork
agent: general-purpose
hooks:
PreToolUse:
- matcher: "Bash"
hooks:
- type: command
command: "echo 'Forked context: Running Bash'"
Limit tools in forked context:
context: fork
agent: general-purpose
allowed_tools:
- Read
- Grep
# No Write - read-only analysis
Use specific model in forked context:
context: fork
agent: general-purpose
model: claude-sonnet-4-20250514
| Aspect | Non-Forked (Default) | Forked Context |
|---|---|---|
| Conversation History | Shared with main | Separate/isolated |
| State | Global state | Independent state |
| Tool Access | Inherits from main | Configured independently |
| Context Window | Uses main context | Separate context window |
| Overhead | None | Sub-agent creation |
| Use Case | Simple tasks | Complex/isolated tasks |
Main Conversation
↓
User requests task using context-fork-skill
↓
Skill Engine
↓
Detects context: fork
↓
Sub-Agent Factory
↓
Creates new agent instance
↓
Forked Context
↓
Executes task in isolation
↓
Returns results
↓
Main Conversation (receives results)
Forked context:
Forked context overhead:
Total overhead: ~150-250ms per invocation
Use for complex tasks
Choose appropriate agent
Combine with tool restrictions
Document the isolation
Don't use for simple tasks
Don't forget about isolation
Don't overuse
Don't assume shared state
Verify forked context behavior:
Problem: Skill runs in main context
Solutions:
context: fork is in YAML frontmatterProblem: Uses default agent instead of specified one
Solutions:
Problem: Forked context completes but no results
Solutions:
---
name: deep-code-analysis
description: Perform deep code analysis in isolation
context: fork
agent: Explore
allowed_tools:
- Read
- Grep
- Glob
---
Usage:
Analyze the authentication system deeply
---
name: security-audit
description: Run security audit in isolated context
context: fork
agent: general-purpose
allowed_tools:
- Read
- Grep
- Bash
hooks:
PreToolUse:
- matcher: "Bash"
hooks:
- type: command
command: "echo 'Security audit: Executing command'"
---
---
name: architecture-planner
description: Create architecture plan in isolation
context: fork
agent: Plan
---
Usage:
Create a detailed plan for refactoring the payment system
Forked context provides:
Use when you need isolation, complex processing, or specialized agent behavior.
Version: 1.0.0 Last Updated: 2026-01-10 Maintainer: SDK Team