Thin Wrapper Skill Pattern

VerifiedSafe

Standard pattern for workflow skills. It validates inputs, prepares delegation context, and invokes a subagent via the Task tool.

Sby Skills Guide Bot
DevelopmentAdvanced
7/22/2026
Claude Code
#skill-authoring#delegation#subagents#workflow-pattern#meta

Recommended for

Automated summary

Documents the thin wrapper pattern for writing skills that validate inputs, delegate the actual work to a subagent through the Task tool, then validate and propagate the returned result.

Strengths

  • Gives the exact frontmatter to use (allowed-tools: Task, context: fork, agent) and explains why each field matters
  • Breaks execution into clear stages: input validation, delegation context preparation, subagent invocation, return validation, propagation
  • Flags the common mistake of calling Skill({agent}) instead of Task, and explains why it fails (agents live in .opencode/agents/)
  • Adds a self-execution fallback (.return-meta.json) so postflight stages still work when the skill does the work inline

Limitations

  • Assumes a specific setup (jq, specs/state.json, .return-meta.json, .opencode/agents/) that most projects will not have
  • Says nothing about the business logic or about how to write the target subagent itself
  • The example section is cut off and never shows the full validation and propagation flow
When to use it

Reach for it when creating or reviewing a workflow skill that should delegate to a subagent instead of doing the work inline.

When not to use it

For a standalone skill that does its work directly with ordinary tools (Read, Bash, Edit), this delegation pattern adds no value.

Security analysis

Safe
Quality score82/100

The document is a reference pattern, not an executable skill. Its Bash snippets are benign local operations (jq, date, od) for validation/session IDs, and it explicitly delegates work via the Task tool. There are no destructive commands, credential exfiltration, obfuscated payloads, or safety-disabling instructions.

No concerns found

How this analysis is made

Examples

Write a new delegating skill
Create a new skill called skill-export-research that follows the thin wrapper pattern: validate the task number, build the delegation context, and hand off to the export-research-agent via the Task tool.
Audit an existing skill
Review my skill-migrate-implement SKILL.md and tell me whether it actually follows the thin wrapper pattern — check the frontmatter, the Task invocation, and the return validation.
Debug a broken delegation
My skill keeps failing when it tries to call the agent. Here's the SKILL.md — is it using Skill() instead of Task()?

Thin Wrapper Skill Pattern

Created: 2026-01-19 Purpose: Quick reference for the thin wrapper skill pattern Audience: /meta agent, skill developers


Overview

Thin wrapper skills are the standard pattern for workflow skills. They:

  1. Validate inputs
  2. Prepare delegation context
  3. Invoke a subagent via Task tool
  4. Validate and propagate the return

They do NOT:

  • Load heavy context (subagent does this)
  • Execute business logic (subagent does this)
  • Handle complex error recovery (subagent does this)

Frontmatter

---
name: skill-{name}
description: {One-line description}
allowed-tools: Task
context: fork
agent: {agent-name}
---

Key fields:

  • allowed-tools: Task - Only tool needed for delegation
  • context: fork - Do NOT load context eagerly; subagent loads context
  • agent: {name} - Target subagent to invoke

Execution Pattern

1. Input Validation

Validate task exists and arguments are correct:

task_data=$(jq -r --arg num "$task_number" \
  '.active_projects[] | select(.project_number == ($num | tonumber))' \
  specs/state.json)

if [ -z "$task_data" ]; then
  return error "Task $task_number not found"
fi

2. Context Preparation

Generate session_id and prepare delegation context:

session_id="sess_$(date +%s)_$(od -An -N3 -tx1 /dev/urandom | tr -d ' ')"
{
  "session_id": "sess_{timestamp}_{random}",
  "delegation_depth": {current_depth + 1},
  "delegation_path": [..., "skill-{name}"],
  "timeout": {timeout_seconds},
  "task_context": {
    "task_number": N,
    "task_name": "{slug}",
    "description": "{description}",
    "task_type": "{task_type}"
  }
}

3. Invoke Subagent

CRITICAL: Use the Task tool to spawn the subagent.

Tool: Task (NOT Skill)
Parameters:
  - subagent_type: "{agent-name}" (from frontmatter)
  - prompt: [Include task_context, delegation_context]
  - description: "Execute {operation} for task {N}"

DO NOT use Skill({agent-name}) - this will FAIL. Agents live in .opencode/agents/, not .opencode/skills/.

3b. Self-Execution Fallback

If the skill executor performed work inline (without spawning a subagent via Task tool), it MUST write a .return-meta.json file before proceeding to postflight. This ensures postflight stages can read metadata regardless of execution path.

Why this is needed: The postflight stages (status update, artifact linking, git commit) depend on reading .return-meta.json. When work is done by a subagent, the subagent writes this file. When work is done inline, the skill executor must write it manually using the schema from return-metadata-file.md.

Template (add after Stage 5 / subagent invocation in each skill):

### Stage 5b: Self-Execution Fallback

**CRITICAL**: If you performed the work above WITHOUT using the Task tool (i.e., you read files,
wrote artifacts, or updated metadata directly instead of spawning a subagent), you MUST write a
`.return-meta.json` file now before proceeding to postflight. Use the schema from
`return-metadata-file.md` with the appropriate status value for this operation.

If you DID use the Task tool (Stage 5), skip this stage -- the subagent already wrote the metadata.

4. Return Validation

Validate subagent return:

  • Return is valid JSON
  • Status is valid enum value
  • Summary is non-empty and <100 tokens
  • Artifacts array is present
  • Session ID matches expected

5. Return Propagation

Return validated result to caller without modification.


Example

---
name: skill-{extension}-research
description: Research {extension} patterns and conventions.
allowed-tools: Task
context: fork
agent: {extension}-research-agent
---

# {Extension} Research Skill

Specialized research for {extension} tasks.

## Trigger Conditions
- Task type is "{extension}"
- Research involves {extension}-specific patterns and tools

## Execution

### 1. Input Validation
Extract task_number. Validate task exists.

### 2. Context Preparation
Generate session_id. Prepare delegation context.

### 3. Invoke Subagent
Use Task tool with subagent_type: {extension}-research-agent

### 4. Return Validation
Validate return matches subagent-return.md schema.

### 5. Return Propagation
Return validated result to caller.

Two Delegation Sub-Patterns

Thin wrapper skills use one of two delegation approaches. The choice depends on whether structured context injection is needed.

Pattern A: Core skill pattern (explicit subagent_type, no context: fork)

Used by: skill-researcher, skill-planner, skill-implementer, skill-reviser, skill-spawn, and other core workflow skills.

---
name: skill-implementer
description: Execute implementation tasks.
allowed-tools: Task, Bash, Edit, Read, Write
---

The skill body explicitly calls the Task tool with subagent_type:

Tool: Task
Parameters:
  subagent_type: "general-implementation-agent"
  prompt: [full structured context JSON: session_id, delegation_depth, memory_context, etc.]

Why no context: fork: Core skills have multi-stage postflight (status update, artifact linking, git commit). They inject structured context that requires knowing the exact agent. They do NOT use context: fork or agent: frontmatter.


Pattern B: Extension skill pattern (context: fork + agent:, simpler delegation)

Used by: skill-lean-research, skill-present-research, and similar extension skills.

---
name: skill-{ext}-research
description: Research {ext} patterns. Invoke for {ext} research tasks.
allowed-tools: Task
context: fork
agent: {ext}-research-agent
---

The skill body passes simpler instructions to the agent without a full structured context JSON.

Why context: fork: Extension skills are thin wrappers with minimal postflight. The context: fork field prevents context files from being loaded into the skill's session, since the agent loads its own context.

Note: context: fork and CLAUDE_CODE_FORK_SUBAGENT=1 are independent. See @.opencode/context/patterns/fork-patterns.md for the full decision matrix and cache sharing mechanics.


When NOT to Use This Pattern

Use direct execution instead when:

  • Skill executes atomic operations (skill-status-sync)
  • No subagent needed
  • Work is trivial

Direct execution skills use:

allowed-tools: Bash, Edit, Read

Note: Direct-execution skills do not need the Stage 5b self-execution fallback since they do not delegate to subagents and handle their own metadata directly.

Extension Skills (Standard Pattern)

Extension skills follow the standard thin wrapper pattern, delegating to extension-provided agents. For example, an extension may provide skill-{ext}-research and skill-{ext}-implementation that delegate to {ext}-research-agent and {ext}-implementation-agent respectively.


Postflight Boundary Restrictions

After the subagent returns, thin wrapper skills MUST NOT perform implementation work. See @.opencode/context/standards/postflight-tool-restrictions.md for:

  • Allowed tools (Read metadata, jq state updates, Edit TODO.md, git commit)
  • Prohibited tools (Edit source files, build commands, MCP tools)
  • MUST NOT section template to include in skills

Related Documentation

  • @.opencode/context/templates/thin-wrapper-skill.md - Full template
  • @.opencode/context/patterns/skill-lifecycle.md - Complete skill lifecycle
  • @.opencode/context/formats/subagent-return.md - Return format
  • @.opencode/context/standards/postflight-tool-restrictions.md - Postflight boundary rules
  • @.opencode/docs/guides/creating-skills.md - Step-by-step guide

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/thin-wrapper-skill-pattern-mrwakaum/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/thin-wrapper-skill-pattern-mrwakaum' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/thin-wrapper-skill-pattern-mrwakaum/download' --output '.skill-downloads/thin-wrapper-skill-pattern-mrwakaum/SKILL.md.part' && mv '.skill-downloads/thin-wrapper-skill-pattern-mrwakaum/SKILL.md.part' '.skill-downloads/thin-wrapper-skill-pattern-mrwakaum/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

This file does not provide a usable name/description header for this native procedure. It remains available to download and inspect; use the manual method below.

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/thin-wrapper-skill-pattern-mrwakaum/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills