# typicode/husky architecture

> Architecture diagram of the GitHub repository typicode/husky, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/typicode/husky
- Repository: https://github.com/typicode/husky

## Overview

Husky is a lightweight Git-hook installer. A developer can run its CLI `init` command to add a prepare script and starter pre-commit hook, or invoke installation directly; the installer configures Git’s `core.hooksPath` and creates executable shims for supported hooks. Git then dispatches hooks through that directory. The sampled code shows shim generation but not the contents of the `husky` shell helper or how user hook commands are executed, so that runtime link is marked unverified. Branch-specific hooks and shell scripting are documented capabilities, not independently inspected implementations.

Main entry points: [`index.js`](https://github.com/typicode/husky/blob/main/index.js) (Hook installer), [`bin.js`](https://github.com/typicode/husky/blob/main/bin.js) (Husky CLI), [`husky`](https://github.com/typicode/husky/blob/main/husky) (Shell helper), [`.husky`](https://github.com/typicode/husky/tree/main/.husky) (User hook scripts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Setup and installation"]
  node_cli["Husky CLI<br/>[bin.js]"]
  node_installer["Hook installer<br/>[index.js]"]
end

subgraph group_hooks["Git hook runtime"]
  node_git["Git"]
  node_hook_shims["Hook shims<br/>[index.js]"]
  node_shell_helper["Shell helper"]
  node_user_hooks["User hook scripts<br/>[.husky]"]
end

node_developer(("Developer"))

node_developer -->|"runs command"| node_cli
node_cli -->|"invokes setup"| node_installer
node_installer -->|"sets hooks path"| node_git
node_installer -->|"writes shims"| node_hook_shims
node_git -.->|"dispatches hooks"| node_hook_shims
node_hook_shims -->|"sources helper"| node_shell_helper
node_shell_helper -.->|"runs hook scripts"| node_user_hooks

click node_cli "https://github.com/typicode/husky/blob/main/bin.js"
click node_installer "https://github.com/typicode/husky/blob/main/index.js"
click node_hook_shims "https://github.com/typicode/husky/blob/main/index.js"
click node_shell_helper "https://github.com/typicode/husky/blob/main/husky"
click node_user_hooks "https://github.com/typicode/husky/tree/main/.husky"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_installer toneBlue
class node_git,node_hook_shims,node_shell_helper,node_user_hooks toneAmber
class node_developer toneIndigo
```

## Components

### Setup and installation

- [Husky CLI](https://github.com/typicode/husky/blob/main/bin.js): `bin.js`
- [Hook installer](https://github.com/typicode/husky/blob/main/index.js): `index.js`

### Git hook runtime

- **Git**
- [Hook shims](https://github.com/typicode/husky/blob/main/index.js): `index.js`
- [Shell helper](https://github.com/typicode/husky/blob/main/husky): `husky`
- [User hook scripts](https://github.com/typicode/husky/tree/main/.husky): `.husky`

### Other components

- **Developer**

## Connections

- Developer → Husky CLI: runs command (evidence: `bin.js`)
- Husky CLI → Hook installer: invokes setup (evidence: `bin.js`)
- Hook installer → Git: sets hooks path (evidence: `index.js`)
- Hook installer → Hook shims: writes shims (evidence: `index.js`)
- Git → Hook shims: dispatches hooks (evidence: `README.md`)
- Hook shims → Shell helper: sources helper (evidence: `index.js`)
- Shell helper → User hook scripts: runs hook scripts
