Skip to content

Bug: Agent resolves skill resource relative paths against CWD instead of skill's install directory #17101

@askpatrickw

Description

@askpatrickw

Description

When running a skill that includes bundled resources (like a references/ or scripts/ folder) placed alongside its SKILL.md, the AI agent fails to read those resources.

If the SKILL.md contains an instruction like:
Read references/investigation-tools.md

The agent attempts to resolve this path against the user's current working directory (CWD), rather than the directory where the skill is installed (e.g., ~/.config/opencode/skills/<skill-name>/).

This results in an error like: Error: File not found: /Users/.../current-project/references/investigation-tools.md

Root cause: The agent resolves relative paths against the project root rather than the directory of the loaded skill. The agent's system prompt instructs resolution against project root, not skill location. It doesn't know relative paths may be intended to be relative to the skill definition itself.

Suggested Solutions:

  • Add a prompt instruction: "When reading files requested by a loaded skill's instructions, resolve relative paths against the skill's absolute location (from available skills), not the project root."
  • Provide a built-in context variable ({{SKILL_DIR}} or $__dirname) for skill authors to reliably reference bundled files.

Plugins

N/A

OpenCode version

1.2.24

Steps to reproduce

  1. Install a skill (via Skillshare or manually) with SKILL.md and a subfolder like references/.
  2. Invoke the skill in OpenCode from any project directory.
  3. Agent tries to read a reference file based on skill instructions, fails (looks in CWD).
  4. Error: File not found: /Users/.../current-project/references/investigation-tools.md

Expected: relative paths in skill instructions are resolved against skill's install directory.

Screenshot and/or share link

No response

Operating System

macos 26

Terminal

Kitty + TMUX

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions