wordpress-hook-integration
Skill19 starsChanged 5 months agoMITView on GitHub
Use when creating Claude Code agent hooks, implementing PreToolUse or PostToolUse patterns, or integrating WordPress workflows with custom agents in this template. Keywords: agent hooks, PreToolUse, PostToolUse, Claude Code hooks, custom agents, workflow automation, WordPress automation
In this repository12 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- block-pattern-creationSkill
- canva-to-fse-autonomous-workflowSkill
- figma-to-fse-autonomous-workflowSkill
- fse-block-theme-developmentSkill
- fse-pattern-first-architectureSkill
- indesign-conversionSkill
- visual-qa-verificationSkill
- wordpress-internationalizationSkill
- wordpress-security-hardeningSkill
- wordpress-testing-workflowsSkill
- wp-cli-workflowsSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 5 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
Use this skill when:
- Very specific: line 49
If path contains wp-content/(themes|plugins|mu-plugins)/, exits with code 2 (blocks operation)
- Very specific: line 62
Only triggers for HTML files matching themes/*/templates/*.html
- Distinctive: line 64
Always exits 0 (warns, never blocks) to avoid interrupting conversion flow
- Distinctive: line 166
All hooks run for every agent.
- Distinctive: line 198
Run for extended periods (> 10 seconds) without user notification
- Distinctive: line 203
Run destructive operations (delete, reset) without confirmation
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
WordPress Hook Integration for Claude Code Agents
Overview
Claude Code agent hooks execute shell scripts before/after tool use. This template uses hooks to enforce project conventions, validate generated themes, and run quality checks during the Figma-to-FSE pipeline.
Core Principle: Hooks automate quality enforcement and project rules without manual intervention. They warn or block based on severity.
When to Use
Use this skill when:
- Creating hooks for custom agents in this template
- Adding validation to the Figma-to-FSE conversion pipeline
- Enforcing project conventions (e.g., root-level file locations)
- Running quality checks after template generation
- Understanding or modifying existing hook behavior
Symptoms that trigger this skill:
- "create hook"
- "agent hook"
- "PreToolUse"
- "PostToolUse"
- "validate template"
- "block markup"
Current Hook Architecture
This template has 3 active hooks in .claude/hooks/:
.claude/hooks/
├── validate-theme-location.sh # PreToolUse: Blocks writes to wp-content/
├── figma-fse-post-template.sh # PostToolUse: Validates each generated template
└── figma-fse-completion.sh # PostToolUse: Final conversion report and validationHook 1: validate-theme-location.sh (PreToolUse)
Purpose: Enforces root-level file structure. Blocks any Write/Edit targeting wp-content/themes/, wp-content/plugins/, or wp-content/mu-plugins/.
Behavior:
- Reads JSON input from stdin (Claude Code tool input format)
- Extracts
file_pathfrom tool input - If path contains
wp-content/(themes|plugins|mu-plugins)/, exits with code 2 (blocks operation) - Suggests the corrected root-level path
- Runs for ALL agents, not just figma-fse-converter
Exit codes:
0— Path is valid, allow operation2— Path targets wp-content, block operation
Hook 2: figma-fse-post-template.sh (PostToolUse)
Purpose: Validates each FSE template after creation during Figma-to-FSE conversion.
Behavior:
- Only triggers for HTML files matching
themes/*/templates/*.html - Runs template validation, security scan, and coding standards checks
- Always exits 0 (warns, never blocks) to avoid interrupting conversion flow
- Delegates to
scripts/figma-fse/validate-template.sh,scripts/wordpress/security-scan.sh, andscripts/wordpress/check-coding-standards.shif they exist
Hook 3: figma-fse-completion.sh (PostToolUse / Manual)
Purpose: Runs after all Figma-to-FSE templates are complete. Generates a full conversion report.
Checks performed:
- Counts generated files (templates, parts, patterns)
- Validates zero hardcoded hex colors and pixel sizes in templates
- Checks block balance (open/close comment pairs)
- Validates theme.json design tokens (color count, font sizes, spacing)
- Runs security scan and coding standards check
- Generates a Markdown completion report in
.claude/reports/
Can run manually:
bash .claude/hooks/figma-fse-completion.sh themes/my-themeHook Types
| Hook Type | When It Runs | Exit Code Behavior |
| PreToolUse | Before tool execution | 0 = allow, 2 = block |
| PostToolUse | After tool execution | 0 = success (warnings OK), non-zero = report issue |
Creating New Hooks
Input Format
Hooks receive JSON on stdin from Claude Code:
{
"tool_name": "Write",
"tool_input": {
"file_path": "themes/my-theme/templates/index.html",
"content": "..."
}
}Extract values with jq:
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null)Pattern: Blocking Hook (PreToolUse)
#!/bin/bash
# Hook: PreToolUse - blocks invalid operations
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null)
# Skip if no file path
[ -z "$FILE_PATH" ] && exit 0
# Check condition
if [[ "$FILE_PATH" =~ some-bad-pattern ]]; then
echo "BLOCKED: Reason" >&2
exit 2
fi
exit 0Pattern: Warning Hook (PostToolUse)
#!/bin/bash
# Hook: PostToolUse - warns but does not block
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null)
# Only process relevant files
[[ ! "$FILE_PATH" =~ \.php$ ]] && exit 0
# Run check
echo "Running check on $FILE_PATH..." >&2
# ... validation logic ...
# Always exit 0 (warn, don't block)
exit 0Hook Best Practices
- Output to stderr — Use
>&2for all echo statements (stdout is reserved for Claude Code) - Fast execution — Hooks should complete in < 5 seconds
- Read from stdin — Claude Code passes tool input as JSON on stdin
- Use jq for parsing — Extract fields with
jq -r '.tool_input.field // empty' - Exit 0 for warnings — Only use exit 2 for hard blocks (PreToolUse)
- Filter by file path — Check patterns early and exit 0 if not relevant
- Idempotent — Safe to run multiple times on the same input
Integration with 19 Custom Agents
All hooks run for every agent. Use file path patterns and tool name checks to scope hooks to specific workflows:
# Only for figma-fse-converter output
[[ ! "$FILE_PATH" =~ themes/.*/templates/.*\.html$ ]] && exit 0
# Only for PHP pattern files
[[ ! "$FILE_PATH" =~ themes/.*/patterns/.*\.php$ ]] && exit 0
# Only for theme.json changes
[[ ! "$FILE_PATH" =~ theme\.json$ ]] && exit 0Testing Hooks
# Test validate-theme-location with a blocked path
echo '{"tool_input":{"file_path":"wp-content/themes/test/style.css"}}' | bash .claude/hooks/validate-theme-location.sh
echo $? # Should be 2
# Test with a valid path
echo '{"tool_input":{"file_path":"themes/test/style.css"}}' | bash .claude/hooks/validate-theme-location.sh
echo $? # Should be 0
# Test completion hook manually
bash .claude/hooks/figma-fse-completion.sh themes/my-themeNo Exceptions
NEVER create hooks that:
- Run for extended periods (> 10 seconds) without user notification
- Modify files without user knowledge
- Make network requests without disclosure
- Block critical operations silently
- Ignore error conditions
- Run destructive operations (delete, reset) without confirmation
Integration with This Template
This skill enables:
- Root-level path enforcement via validate-theme-location.sh
- Per-template validation via figma-fse-post-template.sh
- Conversion completion reports via figma-fse-completion.sh
Works with all 53 custom agents in this template.
Skill Version: 2.0.0 Last Updated: 2026-03-06
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

