Skip to content

feat(hooks): auto-allow Read for skill reference files#81

Open
amondnet wants to merge 1 commit intomainfrom
feat/allow-skill-references-hook
Open

feat(hooks): auto-allow Read for skill reference files#81
amondnet wants to merge 1 commit intomainfrom
feat/allow-skill-references-hook

Conversation

@amondnet
Copy link
Copy Markdown
Contributor

@amondnet amondnet commented Mar 6, 2026

Summary

  • Add hooks/allow-skill-references.sh: a common PreToolUse hook script that automatically grants allow permission when Claude reads skills/*/references/*.md files under a plugin root, eliminating repeated permission prompts during skill reference loading
  • Add plugins/*/hooks/hooks.json with a PreToolUse entry (matcher: Read) for 18 plugins that contain skills/*/references/ directories
  • Add plugins/*/hooks/allow-skill-references.sh symlinks pointing to the common script

Plugins updated: agent-browser, ai-sdk, antfu, claude-md-management, mastra, nuxt, nuxt-ui, pinia, pnpm, prisma, slidev, supabase, unocss, vite, vitepress, vitest, vue, vueuse

How it works

The hook script:

  1. Reads tool_name and tool_input.file_path from stdin JSON
  2. Exits silently for non-Read tools
  3. Canonicalizes the path (prevents traversal attacks)
  4. Matches against ${CLAUDE_PLUGIN_ROOT}/skills/<skill>/references/<file>.md
  5. Outputs {"hookSpecificOutput":{"permissionDecision":"allow"}} on match

Test plan

  • Matching path → outputs allow decision
  • Non-matching path → silent exit 0
  • Non-Read tool → silent exit 0
  • Path traversal attempt → silent exit 0 (canonicalization prevents bypass)
  • All 18 hooks.json files pass jq validity check
  • All symlinks resolve to the correct common script

Summary by cubic

Auto-approve Read tool calls for skill reference files under each plugin to remove repeated permission prompts when loading skills. Adds a safe, common PreToolUse hook with path canonicalization.

  • New Features

    • Added hooks/allow-skill-references.sh: a shared PreToolUse hook that canonicalizes paths and auto-allows reads of ${CLAUDE_PLUGIN_ROOT}/skills//references/*.md.
    • Added hooks.json entries (matcher: Read) for 18 plugins that have skill references.
    • Symlinked the hook into each plugin’s hooks directory.
  • Migration

    • No action needed; the hook only affects Read tool calls.
    • Ensure CLAUDE_PLUGIN_ROOT is set correctly for plugin paths.

Written for commit 14c4c1e. Summary will update on new commits.

Add PreToolUse hook that automatically grants permission for Read tool
calls targeting skills/*/references/*.md under each plugin root,
eliminating per-file permission prompts when Claude loads skill references.

- hooks/allow-skill-references.sh: common hook script with path
  canonicalization and glob matching against plugin root
- plugins/*/hooks/hooks.json: PreToolUse entry (matcher: Read) for 18
  plugins that contain skills/*/references/ directories
- plugins/*/hooks/allow-skill-references.sh: symlinks to common script

Plugins updated: agent-browser, ai-sdk, antfu, claude-md-management,
mastra, nuxt, nuxt-ui, pinia, pnpm, prisma, slidev, supabase, unocss,
vite, vitepress, vitest, vue, vueuse
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
claude-code-plugins Ready Ready Preview, Comment Mar 6, 2026 10:07am

Request Review

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 37 files

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the user experience by automating permission grants for Read operations on skill reference files. It implements a secure, centralized PreToolUse hook that intelligently approves access to specific markdown files, thereby eliminating repetitive permission prompts when loading skills and streamlining plugin interactions.

Highlights

  • New PreToolUse Hook Script: Introduced hooks/allow-skill-references.sh, a common bash script designed to automatically grant allow permission for Read tool calls targeting skills/*/references/*.md files within a plugin root. This script includes robust path canonicalization to prevent traversal attacks.
  • Plugin Integration: Configured 18 plugins (including agent-browser, ai-sdk, antfu, nuxt, and vue) by adding hooks.json entries. These entries specify a PreToolUse hook with a Read matcher, directing it to use the newly created common permission script.
  • Symlink Creation: Created symlinks in the hooks directories of each of the 18 updated plugins. These symlinks point to the central allow-skill-references.sh script, ensuring a single source of truth for the permission logic.
Changelog
  • hooks/allow-skill-references.sh
    • Added a new bash script to implement the auto-allow logic for skill reference files, including path canonicalization and matching for specific markdown paths.
  • plugins/agent-browser/hooks/allow-skill-references.sh
    • Added a symlink to the common allow-skill-references.sh script.
  • plugins/agent-browser/hooks/hooks.json
    • Configured a PreToolUse hook for Read operations to utilize the new permission script.
  • plugins/ai-sdk/hooks/allow-skill-references.sh
    • Added a symlink to the common allow-skill-references.sh script.
  • plugins/ai-sdk/hooks/hooks.json
    • Configured a PreToolUse hook for Read operations to utilize the new permission script.
  • plugins/antfu/hooks/allow-skill-references.sh
    • Added a symlink to the common allow-skill-references.sh script.
  • plugins/antfu/hooks/hooks.json
    • Configured a PreToolUse hook for Read operations to utilize the new permission script.
  • plugins/claude-md-management/hooks/allow-skill-references.sh
    • Added a symlink to the common allow-skill-references.sh script.
  • plugins/claude-md-management/hooks/hooks.json
    • Configured a PreToolUse hook for Read operations to utilize the new permission script.
  • plugins/mastra/hooks/allow-skill-references.sh
    • Added a symlink to the common allow-skill-references.sh script.
  • plugins/mastra/hooks/hooks.json
    • Configured a PreToolUse hook for Read operations to utilize the new permission script.
  • plugins/nuxt-ui/hooks/allow-skill-references.sh
    • Added a symlink to the common allow-skill-references.sh script.
  • plugins/nuxt-ui/hooks/hooks.json
    • Configured a PreToolUse hook for Read operations to utilize the new permission script.
  • plugins/nuxt/hooks/allow-skill-references.sh
    • Added a symlink to the common allow-skill-references.sh script.
  • plugins/nuxt/hooks/hooks.json
    • Configured a PreToolUse hook for Read operations to utilize the new permission script.
  • plugins/pinia/hooks/allow-skill-references.sh
    • Added a symlink to the common allow-skill-references.sh script.
  • plugins/pinia/hooks/hooks.json
    • Configured a PreToolUse hook for Read operations to utilize the new permission script.
  • plugins/pnpm/hooks/allow-skill-references.sh
    • Added a symlink to the common allow-skill-references.sh script.
  • plugins/pnpm/hooks/hooks.json
    • Configured a PreToolUse hook for Read operations to utilize the new permission script.
  • plugins/prisma/hooks/allow-skill-references.sh
    • Added a symlink to the common allow-skill-references.sh script.
  • plugins/prisma/hooks/hooks.json
    • Configured a PreToolUse hook for Read operations to utilize the new permission script.
  • plugins/slidev/hooks/allow-skill-references.sh
    • Added a symlink to the common allow-skill-references.sh script.
  • plugins/slidev/hooks/hooks.json
    • Configured a PreToolUse hook for Read operations to utilize the new permission script.
  • plugins/supabase/hooks/allow-skill-references.sh
    • Added a symlink to the common allow-skill-references.sh script.
  • plugins/supabase/hooks/hooks.json
    • Configured a PreToolUse hook for Read operations to utilize the new permission script.
  • plugins/unocss/hooks/allow-skill-references.sh
    • Added a symlink to the common allow-skill-references.sh script.
  • plugins/unocss/hooks/hooks.json
    • Configured a PreToolUse hook for Read operations to utilize the new permission script.
  • plugins/vite/hooks/allow-skill-references.sh
    • Added a symlink to the common allow-skill-references.sh script.
  • plugins/vite/hooks/hooks.json
    • Configured a PreToolUse hook for Read operations to utilize the new permission script.
  • plugins/vitepress/hooks/allow-skill-references.sh
    • Added a symlink to the common allow-skill-references.sh script.
  • plugins/vitepress/hooks/hooks.json
    • Configured a PreToolUse hook for Read operations to utilize the new permission script.
  • plugins/vitest/hooks/allow-skill-references.sh
    • Added a symlink to the common allow-skill-references.sh script.
  • plugins/vitest/hooks/hooks.json
    • Configured a PreToolUse hook for Read operations to utilize the new permission script.
  • plugins/vue/hooks/allow-skill-references.sh
    • Added a symlink to the common allow-skill-references.sh script.
  • plugins/vue/hooks/hooks.json
    • Configured a PreToolUse hook for Read operations to utilize the new permission script.
  • plugins/vueuse/hooks/allow-skill-references.sh
    • Added a symlink to the common allow-skill-references.sh script.
  • plugins/vueuse/hooks/hooks.json
    • Configured a PreToolUse hook for Read operations to utilize the new permission script.
Activity
  • No human activity (comments, reviews, etc.) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a shared hook to auto-allow reading skill reference files, which is a great improvement to reduce repetitive permission prompts. A security audit of the hooks/allow-skill-references.sh script found no security vulnerabilities, noting its robust implementation with multiple layers of defense against file-system-related attacks. However, there are a few suggestions to improve the efficiency and readability of the main hook script, and a discrepancy regarding symlink creation in the plugins' hook directories needs to be addressed.

Comment on lines +7 to +15
input=$(cat)

tool_name=$(echo "$input" | jq -r '.tool_name // empty')

if [ "$tool_name" != "Read" ]; then
exit 0
fi

file_path=$(echo "$input" | jq -r '.tool_input.file_path // empty')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The script currently reads the entire standard input into a variable and then invokes jq twice to parse it. This is inefficient due to multiple process forks. You can parse the input and assign variables in a single, more efficient step using eval with jq's @sh formatter. This is a common and safe pattern for this task.

Suggested change
input=$(cat)
tool_name=$(echo "$input" | jq -r '.tool_name // empty')
if [ "$tool_name" != "Read" ]; then
exit 0
fi
file_path=$(echo "$input" | jq -r '.tool_input.file_path // empty')
eval "$(cat | jq -r '@sh "tool_name=\(.tool_name // \"\") file_path=\(.tool_input.file_path // \"\")"')"
if [ "$tool_name" != "Read" ]; then
exit 0
fi

@@ -0,0 +1 @@
../../../hooks/allow-skill-references.sh No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The pull request description mentions creating symlinks, but this file is a regular text file containing a relative path. The hooks.json configuration points directly to the central script at ${CLAUDE_PLUGIN_ROOT}/hooks/allow-skill-references.sh, so this file appears to be unused and may cause confusion. If a symlink was intended, it should be created using ln -s. This comment applies to all 18 similar allow-skill-references.sh files added under plugins/*/hooks/.

Comment on lines +50 to +60
case "$abs_path" in
"${plugin_root}/skills/"*/references/*.md)
# Verify no extra path segments between skills/ and references/
remainder="${abs_path#${plugin_root}/skills/}"
skill_name="${remainder%%/*}"
after_skill="${remainder#${skill_name}/}"
if [[ "$after_skill" == references/*.md && "$after_skill" != *"/"*"/"* ]]; then
echo '{"hookSpecificOutput":{"permissionDecision":"allow"}}'
fi
;;
esac
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The path matching logic using a case statement and shell parameter expansion is complex and can be hard to follow. Using a single regular expression would make the intent clearer and the code more maintainable by precisely defining the expected path structure.

Suggested change
case "$abs_path" in
"${plugin_root}/skills/"*/references/*.md)
# Verify no extra path segments between skills/ and references/
remainder="${abs_path#${plugin_root}/skills/}"
skill_name="${remainder%%/*}"
after_skill="${remainder#${skill_name}/}"
if [[ "$after_skill" == references/*.md && "$after_skill" != *"/"*"/"* ]]; then
echo '{"hookSpecificOutput":{"permissionDecision":"allow"}}'
fi
;;
esac
if [[ "$abs_path" =~ ^${plugin_root}/skills/[^/]+/references/[^/]+\.md$ ]]; then
echo '{"hookSpecificOutput":{"permissionDecision":"allow"}}'
fi

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant