Skip to content

[BUG] Skill-scoped hooks defined in SKILL.md frontmatter are not triggered within plugins #17688

Description

@yansfil

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Skill-scoped hooks defined in SKILL.md frontmatter (using the hooks YAML property) are not being triggered when the skill is loaded within a plugin.

I created a test skill with a PreToolUse hook that should trigger when Bash tool is called. The hook is defined in the SKILL.md frontmatter:

---
name: test
description: This skill should be used when the user says "test hooks"...
hooks:
  PreToolUse:
    - matcher: "Bash"
      hooks:
        - type: command
          command: "touch /tmp/skill-hook-triggered.txt"
          once: true
---

When I invoke the skill and then use the Bash tool, the hook is never executed - the file /tmp/skill-hook-triggered.txt is never created.

What Should Happen?

When a skill is loaded (via /test or natural language trigger), the hooks defined in that skill's SKILL.md frontmatter should be registered and executed when matching tools are used.

In this case, after loading the test skill and running any Bash command, the file /tmp/skill-hook-triggered.txt should be created.

Steps to Reproduce

  1. Create a plugin with the following structure:

    plugins/eval/
    ├── .claude-plugin/
    │   └── plugin.json
    └── skills/
        └── test/
            └── SKILL.md
    
  2. Create SKILL.md with hooks in frontmatter:

    ---
    name: test
    description: This skill should be used when the user says "test hooks", "hook 테스트", or wants to verify that skill-level hooks are working.
    hooks:
      PreToolUse:
        - matcher: "Bash"
          hooks:
            - type: command
              command: "touch /tmp/skill-hook-triggered.txt"
              once: true
    ---
    
    # Test Skill
    
    Hook 동작 테스트를 위한 간단한 스킬입니다.
  3. Register and enable the plugin in settings.json

  4. Invoke the skill by typing /test or "hook 테스트"

  5. Run any Bash command (e.g., ls)

  6. Check if /tmp/skill-hook-triggered.txt exists

Result: File does not exist - hook was not triggered.

Claude Model

  • Opus

Is this a regression?

  • I don't know

Claude Code Version

2.1.5 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Cursor

Additional Information

The skill loads and displays correctly (the SKILL.md content is shown to the model), but the hooks defined in the frontmatter appear to be ignored.

This may be related to how skill-scoped hooks are parsed and registered when loaded dynamically via the skill invocation flow vs. static plugin hooks defined in hooks.json.

Plugin structure used for testing:

// .claude-plugin/plugin.json
{
  "name": "eval",
  "description": "Evaluation framework plugin",
  "version": "1.1.0"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions