Mount a Skill for an Agent in a Sandbox
Use an SDK to write a Skill directory to the path that an Agent expects, which mounts the Skill for the Agent in FC Agent Sandbox.
Overview
A Skill is the unit that extends the capabilities of an Agent: one directory plus one SKILL.md. In FC Agent Sandbox, the method for mounting a Skill is unified across Agents. Write the Skill directory to the path that the Agent expects inside the sandbox, and the Agent automatically scans that path at the start of a session. Agents differ only in the path and the invocation syntax. The write method is exactly the same.
This topic describes the general integration procedure, the path mapping across Agents, and when an overwritten Skill takes effect. For complete scenario tutorials on individual Agents, see Use Claude Code Sandbox and OpenClaw Template.
For first-time use, complete the preparations, API Key creation, and SDK configuration described in Use FC Agent Sandbox with the SDK.
Prerequisites
-
SDK integration is complete. SDK integration covers the E2B API Key,
api_url, anddomain. -
An Agent template in the
readystate is built, asandboxis created from it, and the Agent responds as expected.-
For Claude Code, see Claude Code Template.
-
For OpenClaw, see OpenClaw Template. After the sandbox is created, also run
onboardand configure the default model. For more information, see OpenClaw Template. -
For other Agents, see Build and manage templates by using OpenAPI.
-
-
A Skill source directory is prepared on the local machine. Example:
./my-skills/summarize-changes/SKILL.md ./my-skills/summarize-changes/scripts/collect.sh
Step 1: Identify the Skill path of the target Agent
The following table lists the Skill root directory, explicit invocation syntax, and loading verification method for common Agents:
|
Agent |
Global scope |
Project or workspace scope |
Explicit invocation |
Verify loading |
|
Claude Code |
|
|
|
No built-in command. Use |
|
OpenClaw |
|
|
|
|
The integration is exactly the same for other Agents, such as Codex CLI, Cursor CLI, or the AGENTS.md ecosystem with its neutral .agents/skills/ convention. Skill discovery and loading are handled by the Agent itself—the Agent scans the directory that it expects at the start of a session. FC Agent Sandbox only places files in that directory and does not parse them. Therefore, integrating any Agent requires no change to the write logic. Confirm only the following two items:
-
The Skill root directory of the Agent: Check the Skills chapter in the official documentation of the Agent, or run the skills-related subcommand of its command-line interface (CLI) in the sandbox. Note that the default user in the sandbox is
userand the home directory is/home/user. Replace~/in the official documentation with/home/user/. -
SKILL.mdfrontmatter requirements: Required fields vary across Agents. For more information, see Step 2: Write the Skill.
Once both items are confirmed, replace the destination path in the examples of the next step with the Skill root directory of the Agent. The write logic stays unchanged.
Step 2: Write the Skill
Images do not include custom Skills. The SDK writes Skills at runtime. The write must happen after the sandbox is created and before the target session starts—the Agent snapshots the Skill list at the start of a session. A session that has already started may not recognize Skills written afterwards. For more information, see When an overwritten Skill takes effect.
About Template.copy: Presetting files duringTemplate.buildwith.copy("local-dir", "/home/user/.claude/skills/...")is not supported. Use the runtime write methods below for custom Skills.
Use the union of frontmatter fields
Agents have different frontmatter requirements for SKILL.md: Claude Code requires only description, while OpenClaw requires both name and description. user-invocable is an optional OpenClaw field that defaults to true. To use one Skill with multiple Agents, include the union of these fields to satisfy all requirements at the same time:
---
name: summarize-changes
description: Summarizes uncommitted changes and flags risks. Use when reviewing diffs or writing commit messages.
user-invocable: true
---
## Instructions
1. Run `git diff HEAD` and summarize changes in 2–3 bullets.
2. List risks such as missing error handling or hardcoded values.
3. If the diff is empty, say there are no uncommitted changes.
The description field determines whether the model can automatically select the Skill without an explicit invocation. State clearly what it does and when to use it, as in Use when reviewing diffs or writing commit messages. in the preceding example.
Single-file Skill
If the Skill consists only of SKILL.md, write it directly:
sandbox.files.write(
"/home/user/.claude/skills/summarize-changes/SKILL.md",
"""---
name: summarize-changes
description: Summarizes uncommitted changes and flags risks. Use when reviewing diffs or writing commit messages.
user-invocable: true
---
## Instructions
1. Run `git diff HEAD` and summarize changes in 2–3 bullets.
2. List risks such as missing error handling or hardcoded values.
3. If the diff is empty, say there are no uncommitted changes.
""",
)
Multi-file Skill directory
If the Skill contains supporting files such as scripts/ and references/, write them all in one batch with files.write_files instead of calling files.write file by file:
from pathlib import Path
def upload_skill_dir(sandbox, local_dir: str, remote_root: str) -> None:
local = Path(local_dir).resolve()
entries = []
for path in local.rglob("*"):
if path.is_file():
rel = path.relative_to(local).as_posix()
entries.append({
"path": f"{remote_root.rstrip('/')}/{rel}",
"data": path.read_bytes(),
})
sandbox.files.write_files(entries)
upload_skill_dir(
sandbox,
"./my-skills/summarize-changes",
"/home/user/.claude/skills/summarize-changes",
)
To switch Agents, replace only remote_root. For example, use /home/user/.openclaw/skills/summarize-changes for the OpenClaw Managed scope.
One source directory, multiple mount points
To use one Skill with multiple Agents in the sandbox, list the mount points in an array and still call write_files only once:
from pathlib import Path
# The Skill root directory of each Agent. Add or remove entries as needed.
MOUNTS = [
"/home/user/.claude/skills", # Claude Code
"/home/user/.openclaw/skills", # OpenClaw Managed
]
def upload_skill(sandbox, local_dir: str, mounts: list[str]) -> None:
local = Path(local_dir).resolve()
name = local.name
entries = []
for path in local.rglob("*"):
if not path.is_file():
continue
rel = path.relative_to(local).as_posix()
data = path.read_bytes()
for mount in mounts:
entries.append({
"path": f"{mount.rstrip('/')}/{name}/{rel}",
"data": data,
})
sandbox.files.write_files(entries)
upload_skill(sandbox, "./my-skills/summarize-changes", MOUNTS)
Maintain one Skill source directory locally, and each Agent in the sandbox gets a copy. To add an Agent, append its root directory to MOUNTS.
Step 3: Invoke the Skill and verify loading
After writing the Skill, confirm that the Agent has recognized it before running tasks.
OpenClaw
OpenClaw can list the loaded Skills directly, and an explicit invocation verifies the result:
print(sandbox.commands.run("openclaw skills list").stdout)
result = sandbox.commands.run(
'openclaw agent --local --agent main --message "/skill summarize-changes"',
timeout=0,
)
print(result.stdout)
Claude Code
Claude Code has no equivalent list command. Use an explicit invocation as a probe:
result = sandbox.commands.run(
'claude --dangerously-skip-permissions < /dev/null -p "/summarize-changes"',
timeout=0,
)
print(result.stdout)
Claude Code invokes a Skill explicitly with /<name> in the prompt. OpenClaw uses /skill <name>, which is always available. Alternatively, describe the task only, and the model loads the Skill automatically based on its description.
Complete example
Skills are not persisted with the image. A sandbox is created and destroyed with each task, so the write-and-invoke flow must be repeated for every new sandbox. Inject the model API Key through envs when creating the sandbox. The following example uses Alibaba Cloud Model Studio. For the template name and the value of OPTS, see Claude Code Template.
Obtain an API Key (starting with sk-) from the Model Studio console.
[workspace-id] is the ID of the Model Studio workspace, and [region] is the region where the API Key resides, such as cn-beijing and ap-southeast-1. The API Key and the base URL must be in the same region.
from e2b_code_interpreter import Sandbox
BAILIAN_API_KEY = "<YOUR-BAILIAN-API-KEY>"
BAILIAN_BASE_URL = "https://[workspace-id].[region].maas.aliyuncs.com/apps/anthropic"
BAILIAN_MODEL = "qwen3.8-max"
sandbox = Sandbox.create(
template=TEMPLATE_NAME,
envs={
"ANTHROPIC_AUTH_TOKEN": BAILIAN_API_KEY,
"ANTHROPIC_BASE_URL": BAILIAN_BASE_URL,
"ANTHROPIC_MODEL": BAILIAN_MODEL,
"ANTHROPIC_DEFAULT_HAIKU_MODEL": BAILIAN_MODEL,
"ANTHROPIC_DEFAULT_SONNET_MODEL": BAILIAN_MODEL,
"ANTHROPIC_DEFAULT_OPUS_MODEL": BAILIAN_MODEL,
},
timeout=3600,
**OPTS,
)
# Initialize `~/.claude.json` before the first run. Otherwise, the configuration may be reported as corrupted.
sandbox.commands.run("echo '{}' > /home/user/.claude.json")
upload_skill(sandbox, "./my-skills/summarize-changes", MOUNTS)
result = sandbox.commands.run(
'claude --dangerously-skip-permissions < /dev/null -p "/summarize-changes"',
timeout=0,
)
print(result.stdout)
sandbox.kill()
When an overwritten Skill takes effect
The Skill list is snapshotted at the start of a session. Subsequent turns in the same session usually reuse that snapshot.
OpenClaw: The Skill watcher is enabled by default. After a SKILL.md is added, overwritten, or updated, the current session usually refreshes the snapshot on the next turn. To make sure that the change takes effect immediately, start a new session or reset the current one:
-
CLI: Specify a new
--session-id. -
Gateway or chat UI: Send
/newor/resetas a standalone message. Do not include it in the same message as the task./newcreates a new session and switches to it./resetkeeps the current session key, but generates a new sessionId and context.
If the watcher is disabled, if a change is not detected, or if a deterministic refresh is required, use /new or /reset. Session data is stored in an SQLite database in the sandbox file system, so after a process restart the default session and its old snapshot are still reused. In addition, openclaw skills list scans the Skill directory in the sandbox, whereas the current session reads its own snapshot. The presence of a Skill in the list does not mean that the current session is using it.
Claude Code: Each claude -p call runs in a new process and a new session, so an overwrite takes effect from the next call.
FAQ
|
Symptom |
Resolution |
|
The Skill does not take effect |
Make sure the write path matches the path that the Agent expects. The home directory in the sandbox is |
|
No response to an explicit invocation |
Make sure that Claude Code uses |
|
The model does not invoke the Skill automatically |
The |
|
The old Skill content still runs after an overwrite |
The current session still uses the snapshot taken at its start. Start a new session: specify a new |
|
The Skill is listed by |
As in the previous row, the Skill takes effect after a new session starts. |
|
|
Presetting at build time is not supported. Use the runtime |
|
Other SDK or build issues |
For more information, see Template management. |
Related documentation
-
Use Claude Code Sandbox: Scenario tutorials such as cloning a repository, Model Context Protocol (MCP), Skills, and structured output.
-
OpenClaw Template: Gateway deployment, Agent CLI, safety mode, and Skill extensions.
-
Claude Code Template: Image addresses, template building, and the MCP and Skill capability conventions.
-
OpenClaw Template: Image addresses, template building, Gateway parameters, and Skill capability conventions.