Skip to content
Back to skills

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
toolsgonoderailsapidocumentation

Works with

  • claude code
  • terminal
  • api

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 111-visual_e3648c1a --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 111 Visual E3648c1a?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 111 Visual E3648c1a
[![Security: A β€” Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-111-visual-e3648c1a/badge)](https://www.skillsdirectory.com/skills/tools-only-111-visual-e3648c1a)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
# 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

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…