claude-code - 💡(How to fix) Fix $0 / $ARGUMENTS template variables not substituted in skills with context: fork [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#48981Fetched 2026-04-17 08:54:07
View on GitHub
Comments
2
Participants
3
Timeline
7
Reactions
0
Author
Timeline (top)
labeled ×4commented ×2closed ×1

When a skill uses context: fork (with or without an agent field), the template variables $0, $ARGUMENTS, etc. are substituted with empty strings instead of the actual arguments passed by the user. The same $0 syntax works correctly in skills using disable-model-invocation: true.

Root Cause

When a skill uses context: fork (with or without an agent field), the template variables $0, $ARGUMENTS, etc. are substituted with empty strings instead of the actual arguments passed by the user. The same $0 syntax works correctly in skills using disable-model-invocation: true.

Fix Action

Workaround

Skills using disable-model-invocation: true (inline mode) substitute $0 correctly. Removing context: fork resolves the issue but loses the isolated subagent behavior.

Code Example

---
name: test-fork-args
description: "Test argument passing in forked context"
argument-hint: <subcommand>
context: fork
---

# Test

Received subcommand: `$0`
All arguments: `$ARGUMENTS`

---

Received subcommand: ``
All arguments: ``
RAW_BUFFERClick to expand / collapse

Version

Claude Code 2.1.110, macOS

Description

When a skill uses context: fork (with or without an agent field), the template variables $0, $ARGUMENTS, etc. are substituted with empty strings instead of the actual arguments passed by the user. The same $0 syntax works correctly in skills using disable-model-invocation: true.

Reproduction

  1. Create a skill with the following SKILL.md:
---
name: test-fork-args
description: "Test argument passing in forked context"
argument-hint: <subcommand>
context: fork
---

# Test

Received subcommand: `$0`
All arguments: `$ARGUMENTS`
  1. Invoke: /test-fork-args hello

  2. The forked agent receives:

Received subcommand: ``
All arguments: ``

Expected

$0 = hello, $ARGUMENTS = hello

Actual

Both $0 and $ARGUMENTS are empty strings. The forked agent has no access to the user's arguments.

Workaround

Skills using disable-model-invocation: true (inline mode) substitute $0 correctly. Removing context: fork resolves the issue but loses the isolated subagent behavior.

Notes

  • Tested with both agent: general-purpose and agent: helper — same result.
  • The argument-hint frontmatter field is present and correctly defined.
  • Multiple skills in the same project using disable-model-invocation: true with $0 work as expected, confirming the syntax is correct.

extent analysis

TL;DR

The issue can be worked around by using disable-model-invocation: true instead of context: fork to correctly substitute template variables with user arguments.

Guidance

  • The problem seems to be related to how arguments are passed when using context: fork, suggesting an issue with argument propagation in forked contexts.
  • To verify the issue, create a skill with context: fork and try to access user arguments using $0 and $ARGUMENTS, then compare with the same skill using disable-model-invocation: true.
  • Consider modifying the skill to use disable-model-invocation: true as a temporary workaround, noting that this changes the skill's invocation behavior.
  • If the isolated subagent behavior of context: fork is necessary, further investigation into how arguments are handled in forked contexts may be required.

Example

No code snippet is provided as the issue is more related to configuration and context handling rather than a specific code error.

Notes

The workaround may not be suitable for all use cases, especially those requiring the isolated subagent behavior provided by context: fork. The root cause of the argument substitution issue in forked contexts needs further investigation.

Recommendation

Apply workaround: Using disable-model-invocation: true allows for correct argument substitution, although it changes the skill's invocation mode. This is recommended as a temporary solution until the underlying issue with context: fork is addressed.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING