Skip to content

Commit c651ade

Browse files
sjnimsclaude
andcommitted
docs: minor script and documentation improvements from security review
Address four low-priority improvements identified during security review: 1. Add chmod reminder to hook-development SKILL.md - users copying example scripts encounter permission errors; added note to make scripts executable 2. Parameterize plugin name in read-settings-hook.sh - replaced hardcoded "my-plugin" with ${PLUGIN_NAME:-my-plugin} pattern to teach portable hooks 3. Add timeout to jq validation in test-hook.sh - maintains defensive consistency with other timeout patterns in the script 4. Document race condition behavior in parse-frontmatter.sh - clarifies that settings files are assumed stable (changes require Claude Code restart) Fixes #163 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent ecfecb6 commit c651ade

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

plugins/plugin-dev/skills/hook-development/SKILL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,8 @@ For detailed patterns and advanced techniques, consult:
689689

690690
Working examples in `examples/`:
691691

692+
> **Note:** After copying example scripts, make them executable: `chmod +x script.sh`
693+
692694
- **`validate-write.sh`** - File write validation example
693695
- **`validate-bash.sh`** - Bash command validation example
694696
- **`load-context.sh`** - SessionStart context loading example

plugins/plugin-dev/skills/hook-development/scripts/test-hook.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ if [[ "$TEST_INPUT" =~ [\;\|\&\`\$\(\)\{\}\<\>] ]]; then
169169
exit 1
170170
fi
171171

172-
# Validate test input JSON
173-
if ! jq empty "$TEST_INPUT" 2>/dev/null; then
172+
# Validate test input JSON (with timeout for defensive consistency)
173+
if ! timeout 5 jq empty "$TEST_INPUT" 2>/dev/null; then
174174
echo "❌ Error: Test input is not valid JSON"
175175
exit 1
176176
fi

plugins/plugin-dev/skills/plugin-settings/examples/read-settings-hook.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/bin/bash
2-
# Example hook that reads plugin settings from .claude/my-plugin.local.md
2+
# Example hook that reads plugin settings from .claude/<plugin>.local.md
33
# Demonstrates the complete pattern for settings-driven hook behavior
44

55
set -euo pipefail
66

7-
# Define settings file path
8-
SETTINGS_FILE=".claude/my-plugin.local.md"
7+
# Define settings file path using environment variable with default
8+
# This allows the plugin name to be configured externally if needed
9+
PLUGIN_NAME="${PLUGIN_NAME:-my-plugin}"
10+
SETTINGS_FILE=".claude/${PLUGIN_NAME}.local.md"
911

1012
# Quick exit if settings file doesn't exist
1113
if [[ ! -f "$SETTINGS_FILE" ]]; then

plugins/plugin-dev/skills/plugin-settings/scripts/parse-frontmatter.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/bin/bash
22
# Frontmatter Parser Utility
33
# Extracts YAML frontmatter from .local.md files
4+
#
5+
# Note: This script assumes the settings file is stable (not being written to).
6+
# Settings changes require a Claude Code restart to take effect, so there's no
7+
# need for file locking in normal usage.
48

59
set -euo pipefail
610

0 commit comments

Comments
 (0)