Skip to content

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

Closed

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

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 11, 2026
  2. github-actions commented on Mar 11, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  3. added a commit that references this issue on Mar 16, 2026
    dd2a1cc
  4. askpatrickw commented on Mar 16, 2026

    @askpatrickw
    Author

    I coudl have sworn I saw this failing (I see it fail in Claude) and I must have confused the two. Re-tested and I can see it is working. Sorry about the PR Noise.. ;-)

  5. mikaelj commented on Mar 18, 2026

    @mikaelj

    @askpatrickw I saw it with OpenCode / GLM-5-Turbo. Still uses relative resources against CWD. Also MacOS.

  6. askpatrickw commented on Mar 20, 2026

    @askpatrickw
    Author

    Here's what I've observed and how I finally fixed it.

    This only affects skills that in subfolders. I have plan/, dev/, tools/ folders in the reop I sync with Skillshare.
    This only affects SCRIPTS, where you have node|sh|bach scipts/exmaple.

    The READ commands to get referecens, works fine.
    Running scripts evaluates from the project root and so if I update my SKILL.md or the othe .md files that mention the scripts to have the full plan/skill-name/scripts/ path, they work fine.

  7. mikaelj commented on Mar 20, 2026

    @mikaelj

    Right, so it's really not at all fixed either by what you're saying or officially, since it does a) for one case and b) for another. That's not good UX.

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

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