← Back to Skills Marketplace
126
Downloads
1
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install safe-subagent-spawn
Description
Safely create and manage subagents through a strict wrapper instead of calling sessions_spawn directly. Use whenever a task needs a subagent, detached helper...
Usage Guidance
This skill appears to do what it says, but review a few things before installing or using it: 1) Confirm where context files are written: inspect CONTEXT_DIR (create_context.py) to ensure files go to a safe location and won't expose or overwrite sensitive directories. 2) Treat context files and preserved sessions as persistent storage: they may contain user data and are kept indefinitely by the skill's rules—decide on retention and access control policies. 3) Be careful with append_to_context.py --content-file: callers can read and append arbitrary local files into a context (make sure you don't accidentally inject secrets). 4) Understand the execution environment for subagents: safe_subagent_spawn embeds the absolute path into the child prompt and assumes the child can read that file; if the child runs remotely or in a different sandbox, this may fail or leak path information. 5) If you need stricter privacy, consider modifying the workflow to redact secrets before appending, store context files in a controlled location, or change the cleanup policy. If you want, provide the full installation path where this skill will live and the runtime environment for spawned subagents and I can point out the exact CONTEXT_DIR and any path-leakage risks.
Capability Analysis
Type: OpenClaw Skill
Name: safe-subagent-spawn
Version: 1.0.0
The skill bundle provides a structured and audited framework for managing subagents via persistent Markdown context files. It uses helper scripts (create_context.py, append_to_context.py, and safe_subagent_spawn.py) to enforce sequential task execution, verbatim history logging, and strict prompt construction. The instructions in SKILL.md act as a defensive wrapper by forbidding direct calls to the underlying session spawning mechanism, ensuring all subagent activity is recorded in a permanent audit trail within the workspace.
Capability Assessment
Purpose & Capability
The name/description match the provided scripts: create_context.py, safe_subagent_spawn.py, and append_to_context.py implement the declared workflow. No unrelated credentials, binaries, or install steps are requested. One implementation detail to note: create_context writes files under a computed CONTEXT_DIR (four parents up + 'sub-agents') which may place files in the workspace root; this is plausible for the purpose but worth verifying in your environment.
Instruction Scope
SKILL.md enforces strict rules about sequencing and that the parent should not read context files; the scripts implement and validate those rules. Two practical caveats: (1) append_to_context.py accepts --content-file and will read any file path you provide — so a caller can accidentally (or intentionally) inject arbitrary local file contents into a context file; (2) safe_subagent_spawn includes the absolute context file path in the generated 'task' text it sends to the child, which can reveal local paths in logs or payloads and assumes the child execution environment can access that path. These behaviors are coherent with the skill's purpose but have privacy/operational implications.
Install Mechanism
This is an instruction-only skill (no install spec). The package ships Python scripts but does not download or execute remote code during install. No extract/download URLs or external package installs are present.
Credentials
The skill requests no environment variables or credentials. It operates on files passed as arguments and on context files it creates; those file I/O operations are expected for the task. There is no unexplained credential access.
Persistence & Privilege
The skill explicitly requires context files to be permanent and configures spawned sessions with 'cleanup': 'keep', preserving child sessions and outputs. This creates persistent artifacts (context files and kept sessions) that may accumulate user data or sensitive content. Additionally, the default CONTEXT_DIR path construction could place these files outside the skill directory (e.g., workspace root). These are operational/privacy concerns rather than indicators of maliciousness, but you should account for retention, access controls, and potential leakage.
How to Use
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install safe-subagent-spawn - After installation, invoke the skill by name or use
/safe-subagent-spawn - Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
**Initial release of safe-subagent-spawn — a reliability-focused skill for safe, standardized subagent creation and multi-round lifecycle management.**
### Why this skill exists
OpenClaw's `sessions_spawn` tool accepts many parameters and supports multiple spawn modes (run, ACP, Discord session, etc.), but:
1. **Models frequently get the parameters wrong.** GPT-5.4 and other models commonly confuse `agentId` (a real agent id from `agents.list`) with model strings like `"google/gemini-2.5-pro"`, include unsupported fields, or pick incorrect default values — causing repeated trial-and-error failures that waste tokens and time.
2. **Non-run modes are fragile for most users.** ACP mode and Discord session mode depend on locally installed packages and additional infrastructure that most non-developer users don't have. These modes are a frequent source of hard-to-diagnose failures. This skill exclusively uses **run mode** — the most stable and universally available spawn mode — eliminating an entire category of setup-related errors.
### What's included
- **safe_subagent_spawn.py** — Validated wrapper that generates a ready-to-use `sessions_spawn` JSON payload. Enforces correct invariants (`runtime: subagent`, `mode: run`, `thread: false`, `cleanup: keep`, no `streamTo`), validates that `agentId` and `model` are not confused, and ensures the context file contains at least one directive before allowing a spawn. The output is passed directly to `sessions_spawn` with no manual assembly required.
- **create_context.py** — Creates a structured Markdown context file with metadata (timestamp, task slug, file path), standing instructions for the child, background information, and an optional first directive. Task slugs are validated (lowercase alphanumeric + hyphens, 1–48 chars). Supports deferred directives — create context with background only, then collect external information before formulating the first task.
- **append_to_context.py** — Appends directives, child outputs, or external messages to an existing context file. Features include:
- **Automatic round numbering** — tracks round numbers across directive/child-output pairs, keeping them in sync.
- **Strict sequential ordering** — enforces that Directive Round N exists before Child Output Round N can be appended, and Child Output Round N-1 exists before Directive Round N+1. Prevents out-of-order spawns.
- **External message merging** — consecutive external messages are merged into a single section without redundant headers, keeping context files clean.
- **Content deduplication** — silently discards duplicate appends (identical content to the latest entry of the same role), preventing accidental double-writes.
- **Flexible input** — accepts content via `--content` (inline), `--content-file` (from file), or stdin (pipe/heredoc), accommodating both short directives and large child outputs.
### Key design decisions
- **Full verbatim history** — every child output is preserved in full; no summarization, no truncation. The next child in a multi-round workflow reads the entire context file and acts on the latest directive.
- **Context files are permanent** — never deleted, providing a complete audit trail of all subagent interactions.
- **Parent never reads back** — the parent agent tracks context files by path and task slug but never re-reads them after creation, avoiding context window pollution.
- **No automatic retry** — if a subagent times out, the parent reports the failure to the user instead of silently retrying, ensuring transparency.
- **No nested subagents** — standing instructions in every context file prohibit the child from spawning its own subagents, keeping the delegation tree flat and predictable.
Metadata
Frequently Asked Questions
What is safe-subagent-spawn?
Safely create and manage subagents through a strict wrapper instead of calling sessions_spawn directly. Use whenever a task needs a subagent, detached helper... It is an AI Agent Skill for Claude Code / OpenClaw, with 126 downloads so far.
How do I install safe-subagent-spawn?
Run "/install safe-subagent-spawn" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is safe-subagent-spawn free?
Yes, safe-subagent-spawn is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does safe-subagent-spawn support?
safe-subagent-spawn is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created safe-subagent-spawn?
It is built and maintained by Devymex (@devymex); the current version is v1.0.0.
More Skills