Skip to content

fix(opencode): preserve user request for skill slash commands - #40472

Closed
BrickerP wants to merge 1 commit into
anomalyco:devfrom
BrickerP:fix/skill-slash-preserve-user-request
Closed

fix(opencode): preserve user request for skill slash commands#40472
BrickerP wants to merge 1 commit into
anomalyco:devfrom
BrickerP:fix/skill-slash-preserve-user-request

Conversation

@BrickerP

@BrickerP BrickerP commented Aug 4, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #40463

Related / previously reported: #26185, #27686, #28241 (closed as dupes / stale)

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Skill slash commands (/skill-name user request here) were registered as normal commands whose template is the raw SKILL.md body. SessionPrompt.command then ran $ARGUMENTS / $N substitution against that body.

That caused two failure modes:

  1. Skill docs that mention $ARGUMENTS or $1 (common in examples) swallowed the real user args into those example spots.
  2. Skills without placeholders only appended the user text after a long skill body, so models often ignored the request and asked "what do you mean?".

Fix: when cmd.source === "skill", do not substitute placeholders inside the skill body. Wrap it as:

Follow the skill instructions below for skill "<name>".

<skill_content name="<name>">
...raw skill body, placeholders left literal...
</skill_content>

## User request
<user arguments or a clear empty-request note>

Regular commands and MCP prompts keep the existing $ARGUMENTS / $N / append behavior.

Also set skill command hints to ["$ARGUMENTS"] so the slash UI can show that trailing input is supported.

How did you verify your code works?

cd packages/opencode
bun test test/session/prompt.test.ts -t "skill slash command preserves|unknown command|command ! expansion"

Result: 3 pass, 0 fail (includes new regression test that asserts $ARGUMENTS/$1 in skill docs stay literal and the user request appears under ## User request).

Screenshots / recordings

N/A — server-side prompt construction only.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Skill slash commands were treated as command templates, so $ARGUMENTS/$N
inside SKILL.md docs swallowed user args, or long skill bodies buried the
request at the end. Wrap skill bodies without placeholder substitution and
append a dedicated User request section.

Closes anomalyco#40463
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found some related PRs but no duplicates of PR #40472:

Related PRs (not duplicates):

  1. fix(opencode): include skill files when invoking via slash command #35522 - fix(opencode): include skill files when invoking via slash command - Related to skill slash command handling
  2. fix(session): hide skill template text from chat and terminal UIs #28239 - fix(session): hide skill template text from chat and terminal UIs - Related to skill template display/processing
  3. fix(tui): insert skill name without wiping existing prompt text #27632 - fix(tui): insert skill name without wiping existing prompt text - Related to skill command interaction in TUI

These are addressing related issues around skill commands but are distinct from PR #40472's specific fix about preserving user requests and preventing placeholder substitution within skill bodies.

No duplicate PRs found.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: slash-invoked skills replace user prompt with full SKILL.md (arguments swallowed / lost at end)

1 participant