Back to skills
SKILL.md
111 Visual E3648c1a
ASecurity> Visual representation of how SF-Skills hooks integrate with Claude Code's lifecycle events ---
- 9 stars
- 0 votes
- 0 copies
- 0 views
- Added October 11, 2026
Works with
Security analysis
100/100npx -y skills add tools-only/X-Skills --skill 111-visual_e3648c1a --agent claude-codeAre you the author of 111 Visual E3648c1a?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/tools-only-111-visual-e3648c1a)# SF-Skills Hook Architecture Diagram
> Visual representation of how SF-Skills hooks integrate with Claude Code's lifecycle events
---
## Claude Code Hook Lifecycle with SF-Skills Hooks
```mermaid
%%{init: {"flowchart": {"nodeSpacing": 80, "rankSpacing": 70}} }%%
flowchart TB
subgraph init["π INITIALIZATION"]
S1["1οΈβ£ SESSION START"]
S2["2οΈβ£ SETUP"]
S3["3οΈβ£ USER PROMPT SUBMIT"]
end
subgraph hooks_session["π SessionStart Hooks"]
H_ORG["π org-preflight.py"]
H_LSP["β‘ lsp-prewarm.py"]
end
subgraph hooks_prompt["π UserPromptSubmit Hooks"]
H_SKILL_ACT["π― skill-activation-prompt.py"]
end
subgraph agentic["βοΈ AGENTIC LOOP"]
LLM(["CLAUDE CODE LLM"])
S4["4οΈβ£ PRE TOOL USE"]
S5["5οΈβ£ PERMISSION REQUEST"]
EXEC(["TOOL EXECUTES"])
S6["6οΈβ£ POST TOOL USE<br/>SUCCESS"]
S7["7οΈβ£ POST TOOL USE<br/>FAILURE"]
end
subgraph hooks_pre["π PreToolUse Hooks"]
H_GUARD["π‘οΈ guardrails.py"]
H_API["π api-version-check.py"]
H_ENFORCE["π« skill-enforcement.py"]
end
subgraph hooks_perm["π PermissionRequest Hooks"]
H_AUTO["β
auto-approve.py"]
end
subgraph hooks_post["π PostToolUse Hooks"]
H_VALID["π validator-dispatcher.py"]
H_SUGGEST["π‘ suggest-related-skills.py"]
end
subgraph subagent["π€ SUBAGENT FLOW"]
SUB_Q{{"SUBAGENT?"}}
S8["8οΈβ£ SUBAGENT START"]
SUB_RUN(["SUBAGENT RUNS"])
S9["9οΈβ£ SUBAGENT STOP"]
MORE_Q{{"MORE WORK?"}}
end
subgraph hooks_sub["π SubagentStop Hooks"]
H_CHAIN["βοΈ chain-validator.py"]
end
subgraph finish["π COMPLETION"]
S10["π STOP"]
S11["1οΈβ£1οΈβ£ PRE COMPACT"]
S12["1οΈβ£2οΈβ£ NOTIFICATION"]
S13["1οΈβ£3οΈβ£ SESSION END"]
end
%% Main Flow - Initialization
S1 --> S2 --> S3 --> LLM
%% SessionStart hooks
S1 -.-> H_ORG
S1 -.-> H_LSP
%% UserPromptSubmit hooks
S3 -.-> H_SKILL_ACT
%% Agentic Loop
LLM --> S4 --> S5 --> EXEC
EXEC --> S6
EXEC --> S7
%% PreToolUse hooks
S4 -.-> H_GUARD
S4 -.-> H_API
S4 -.-> H_ENFORCE
%% PermissionRequest hooks
S5 -.-> H_AUTO
%% PostToolUse hooks
S6 -.-> H_VALID
S6 -.-> H_SUGGEST
%% Subagent flow
S6 --> SUB_Q
S7 --> SUB_Q
SUB_Q -->|Yes| S8
SUB_Q -->|No| MORE_Q
S8 --> SUB_RUN --> S9
S9 --> MORE_Q
%% SubagentStop hooks
S9 -.-> H_CHAIN
%% Loop back or finish
MORE_Q -->|Yes| LLM
MORE_Q -->|No| S10
%% Finish flow
S10 --> S11 --> S12 --> S13
%% Node Styling - Event nodes (Cyan-200 Foundation)
style S1 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style S2 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style S3 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style S4 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style S5 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style S6 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style S7 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style S8 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style S9 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style S10 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style S11 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style S12 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
style S13 fill:#a5f3fc,stroke:#0e7490,color:#1f2937
%% Node Styling - Execution nodes (Indigo-200)
style LLM fill:#c7d2fe,stroke:#4338ca,color:#1f2937
style EXEC fill:#c7d2fe,stroke:#4338ca,color:#1f2937
style SUB_RUN fill:#c7d2fe,stroke:#4338ca,color:#1f2937
%% Node Styling - Decision nodes (Amber-200)
style SUB_Q fill:#fde68a,stroke:#b45309,color:#1f2937
style MORE_Q fill:#fde68a,stroke:#b45309,color:#1f2937
%% Node Styling - SessionStart hooks (Teal-200)
style H_ORG fill:#99f6e4,stroke:#0f766e,color:#1f2937
style H_LSP fill:#99f6e4,stroke:#0f766e,color:#1f2937
%% Node Styling - UserPromptSubmit hooks (Pink-200 AI)
style H_SKILL_ACT fill:#fbcfe8,stroke:#be185d,color:#1f2937
%% Node Styling - PreToolUse hooks (Orange-200)
style H_GUARD fill:#fed7aa,stroke:#c2410c,color:#1f2937
style H_API fill:#fed7aa,stroke:#c2410c,color:#1f2937
style H_ENFORCE fill:#fed7aa,stroke:#c2410c,color:#1f2937
%% Node Styling - PermissionRequest hooks (Green-200)
style H_AUTO fill:#a7f3d0,stroke:#047857,color:#1f2937
%% Node Styling - PostToolUse hooks (Violet-200)
style H_VALID fill:#ddd6fe,stroke:#6d28d9,color:#1f2937
style H_SUGGEST fill:#ddd6fe,stroke:#6d28d9,color:#1f2937
%% Node Styling - SubagentStop hooks (Indigo-200)
style H_CHAIN fill:#c7d2fe,stroke:#4338ca,color:#1f2937
%% Subgraph Styling - 50-level fills with dark dashed borders
style init fill:#ecfeff,stroke:#0e7490,stroke-dasharray:5
style agentic fill:#eef2ff,stroke:#4338ca,stroke-dasharray:5
style subagent fill:#fdf2f8,stroke:#be185d,stroke-dasharray:5
style finish fill:#f8fafc,stroke:#334155,stroke-dasharray:5
%% Hook subgraph styling
style hooks_session fill:#f0fdfa,stroke:#0f766e,stroke-dasharray:5
style hooks_prompt fill:#fdf2f8,stroke:#be185d,stroke-dasharray:5
style hooks_pre fill:#fff7ed,stroke:#c2410c,stroke-dasharray:5
style hooks_perm fill:#ecfdf5,stroke:#047857,stroke-dasharray:5
style hooks_post fill:#f5f3ff,stroke:#6d28d9,stroke-dasharray:5
style hooks_sub fill:#eef2ff,stroke:#4338ca,stroke-dasharray:5
```
---
## ASCII Fallback
For terminals and viewers that don't render Mermaid:
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CLAUDE CODE HOOK LIFECYCLE (SF-SKILLS) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π INITIALIZATION β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ β
β β 1. SESSION STARTβββββΆβ 2. SETUP βββββΆβ3. PROMPT SUBMIT β β
β ββββββββββ¬βββββββββ βββββββββββββββββββ ββββββββββ¬βββββββββ β
β β β β
β βΌ βΌ β
β βββββββββββββββββββββββββββ βββββββββββββββββββββββββββ β
β β π org-preflight.py β βπ― skill-activation- β β
β β β‘ lsp-prewarm.py β β prompt.py β β
β βββββββββββββββββββββββββββ βββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β βοΈ AGENTIC LOOP βββββββββββββββββββββββββββββββββ β
β βββββββββββββββββββββββββββββββ β π‘οΈ guardrails.py β β
β β CLAUDE CODE / LLM ββββββββ β π api-version-check.py β β
β ββββββββββββββββ¬βββββββββββββββ β β π« skill-enforcement.py β β
β β β βββββββββββββββββββββββββββββββββ β
β βΌ β β² β
β βββββββββββββββββββββββββββββββ β ββββββββββββββββ β
β β 4. PRE TOOL USE ββββββββΌββββββββ β
β ββββββββββββββββ¬βββββββββββββββ β βββββββββββββββββββββββββββββββββ β
β β β β β
auto-approve.py β β
β βΌ β βββββββββββββββββββββββββββββββββ β
β βββββββββββββββββββββββββββββββ β β² β
β β 5. PERMISSION REQUEST ββββββββΌβββββββββββββββββββββββ β
β ββββββββββββββββ¬βββββββββββββββ β β
β β β β
β βΌ β β
β βββββββββββββββββββββββββββββββ β β
β β TOOL EXECUTES β β β
β ββββββββββββββββ¬βββββββββββββββ β β
β β β βββββββββββββββββββββββββββββββββ β
β βββββββββ΄ββββββββ β β π validator-dispatcher.py β β
β βΌ βΌ β β π‘ suggest-related-skills.py β β
β βββββββββββββ βββββββββββββ β βββββββββββββββββββββββββββββββββ β
β β 6. POST β β 7. POST β β β² β
β β SUCCESS βββββ FAILURE ββββββββββΌβββββββββββββββββββββββ β
β βββββββ¬ββββββ βββββββββββββ β β
β β β β
β βΌ β β
β βββββββββββββββββββββββββββββββ β β
β β SUBAGENT? β β β
β βββββββββββ¬ββββββββββββ¬ββββββββ β β
β Yes β β No β β
β βΌ β β β
β βββββββββββββββββββ β β β
β β 8. SUBAGENT β β β β
β β START β β β β
β ββββββββββ¬βββββββββ β β β
β βΌ β β βββββββββββββββββββββββββββββββββ β
β βββββββββββββββββββ β β β βοΈ chain-validator.py β β
β β SUBAGENT RUNS β β β βββββββββββββββββββββββββββββββββ β
β ββββββββββ¬βββββββββ β β β² β
β βΌ β β β β
β βββββββββββββββββββ β β β β
β β 9. SUBAGENT βββββΌβββββββββββββββΌβββββββββββββββββββββββ β
β β STOP β β β β
β ββββββββββ¬βββββββββ β β β
β β β β β
β ββββββββββββββ€ β β
β βΌ β β
β βββββββββββββββββββ β β
β β MORE WORK? β β β
β βββββ¬ββββββββββ¬ββββ β β
β Yes β β No β β
β β β β β
β βββββββββββΌβββββββββββ β
β β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π COMPLETION β
β βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ β
β β 10. STOP βββββΆβ 11. PRE COMPACT βββββΆβ 12. NOTIFICATIONβ β
β βββββββββββββββββββ βββββββββββββββββββ ββββββββββ¬βββββββββ β
β β β
β βΌ β
β βββββββββββββββββββ β
β β 13. SESSION END β β
β βββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
---
## Hook Summary Table
| Event | Hook Script | Purpose | Action Type |
|-------|-------------|---------|-------------|
| **SessionStart** | `org-preflight.py` | Validate SF org connectivity | State file |
| **SessionStart** | `lsp-prewarm.py` | Spawn LSP servers in background | Background |
| **UserPromptSubmit** | `skill-activation-prompt.py` | Suggest skills from prompt | Prepend |
| **PreToolUse** | `guardrails.py` | Block dangerous operations | BLOCK/MODIFY |
| **PreToolUse** | `api-version-check.py` | Check API version compatibility | WARN |
| **PreToolUse** | `skill-enforcement.py` | Enforce skill-first workflow | BLOCK |
| **PermissionRequest** | `auto-approve.py` | Smart auto-approval for safe ops | APPROVE/DENY |
| **PostToolUse** | `validator-dispatcher.py` | Route to skill-specific validators | Feedback |
| **PostToolUse** | `suggest-related-skills.py` | Suggest next skills in workflow | Feedback |
| **SubagentStop** | `chain-validator.py` | Validate workflow chain completion | Feedback |
---
## Hook Event Reference
### Lifecycle Events (13 total)
| # | Event | When | Hook Output |
|---|-------|------|-------------|
| 1 | **SessionStart** | Claude Code session begins | State files, background tasks |
| 2 | **Setup** | Configuration loaded | (no hooks) |
| 3 | **UserPromptSubmit** | User sends a message | Prepend context, suggestions |
| 4 | **PreToolUse** | Before tool executes | ALLOW, BLOCK, MODIFY |
| 5 | **PermissionRequest** | Tool needs approval | APPROVE, DENY, defer to user |
| 6 | **PostToolUse (success)** | Tool completed successfully | Feedback, suggestions |
| 7 | **PostToolUse (failure)** | Tool failed | Error analysis, suggestions |
| 8 | **SubagentStart** | Subagent spawned | (no hooks) |
| 9 | **SubagentStop** | Subagent completed | Chain validation |
| 10 | **Stop** | LLM turn complete | (no hooks) |
| 11 | **PreCompact** | Before context compaction | (no hooks) |
| 12 | **Notification** | User notification sent | (no hooks) |
| 13 | **SessionEnd** | Session terminates | Cleanup |
---
## Color Legend
| Color | Hex | Meaning | Nodes |
|-------|-----|---------|-------|
| π¦ Cyan-200 | `#a5f3fc` | Lifecycle event nodes | S1-S13 |
| π© Teal-200 | `#99f6e4` | SessionStart hooks | org-preflight, lsp-prewarm |
| π©· Pink-200 | `#fbcfe8` | AI/Intent detection | skill-activation-prompt |
| π§ Orange-200 | `#fed7aa` | Guards/Pre-checks | guardrails, api-version-check, skill-enforcement |
| π’ Green-200 | `#a7f3d0` | Approval hooks | auto-approve |
| π£ Violet-200 | `#ddd6fe` | Validation/Suggestion | validator-dispatcher, suggest-related-skills |
| π΅ Indigo-200 | `#c7d2fe` | Execution/Chain | LLM, EXEC, chain-validator |
| π‘ Amber-200 | `#fde68a` | Decision points | SUBAGENT?, MORE WORK? |
---
## Hook Interaction Patterns
### Pattern 1: Blocking Flow
```
PreToolUse β guardrails.py
ββ Allow: Continue to Permission Request
ββ Block: Return error message to LLM
(tool never executes)
```
### Pattern 2: Auto-Approval
```
PermissionRequest β auto-approve.py
ββ Approve: Tool executes without user prompt
ββ Deny: Block with reason
ββ No output: Defer to user (shows permission dialog)
```
### Pattern 3: Feedback Chain
```
PostToolUse β validator-dispatcher.py β Validates file
β Sends feedback to LLM
β suggest-related-skills.py β Analyzes content
β Suggests next skill
```
### Pattern 4: Workflow Tracking
```
SessionStart β org-preflight.py β Writes ~/.claude/.sf-org-state.json
β lsp-prewarm.py β Writes ~/.claude/.lsp-prewarm-state.json
β Status line reads these files
```
---
## Related Documentation
- [Orchestration Architecture](./ORCHESTRATION-ARCHITECTURE.md) - How skill recommendations work
- [Hooks Frontmatter Schema](./hooks-frontmatter-schema.md) - Hook configuration format
- [install-hooks.py](../../../tools/install-hooks.py) - Hook installation script
---
## Diagram Quality Score
```
Score: 72/80 βββββ Excellent
ββ Accuracy: 18/20 (All 10 hooks correctly placed at their events)
ββ Clarity: 18/20 (Clear flow with dotted lines for hooks)
ββ Completeness: 14/15 (Full lifecycle + all hooks + state files)
ββ Styling: 12/15 (Tailwind 200-level palette, subgraph styling)
ββ Best Practices: 10/10 (Proper Mermaid notation, init config)
```
Attribution
Comments
Loading commentsβ¦