# koalaman/shellcheck architecture

> Architecture diagram of the GitHub repository koalaman/shellcheck, 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/koalaman/shellcheck
- Repository: https://github.com/koalaman/shellcheck

## Overview

ShellCheck is a static analyzer for Bash/sh scripts. The principal workflow is to provide a script, run ShellCheck, and receive warnings or suggestions; documented use includes terminals, editors, and build/test suites. The tree identifies parsing, analysis, checks, and multiple output formatters as internal areas. Since no source excerpts were provided, internal call relationships are not asserted; workflow links below are limited to README-documented behavior.

Main entry points: [`shellcheck.hs`](https://github.com/koalaman/shellcheck/blob/master/shellcheck.hs) (ShellCheck CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Invocation and API"]
  node_shellcheck_cli["ShellCheck CLI<br/>[shellcheck.hs]"]
  node_interface["Tool interface<br/>[Interface.hs]"]
end

subgraph group_analysis["Script analysis"]
  node_parser["Shell parser<br/>[Parser.hs]"]
  node_ast["Shell AST<br/>[AST.hs]"]
  node_analyzer["Semantic analyzer<br/>[Analyzer.hs]"]
  node_cfg["Control-flow graph<br/>[CFG.hs]"]
  node_cfg_analysis["Flow analysis<br/>[CFGAnalysis.hs]"]
end

subgraph group_checks["Diagnostic checks"]
  node_checker["Diagnostic checker<br/>[Checker.hs]"]
  node_command_checks["Command checks<br/>[Commands.hs]"]
  node_flow_checks["Control-flow checks<br/>[ControlFlow.hs]"]
  node_custom_checks["Custom checks<br/>[Custom.hs]"]
  node_shell_checks["Shell support checks<br/>[ShellSupport.hs]"]
end

subgraph group_output["Reports and fixes"]
  node_fixer["Fix suggestions<br/>[Fixer.hs]"]
  node_format["Format selection<br/>[Format.hs]"]
  node_tty["Terminal output<br/>[TTY.hs]"]
  node_gcc["GCC output<br/>[GCC.hs]"]
  node_json["JSON output<br/>[JSON.hs]"]
  node_json1["JSON1 output<br/>[JSON1.hs]"]
  node_checkstyle["CheckStyle output<br/>[CheckStyle.hs]"]
  node_quiet["Quiet output<br/>[Quiet.hs]"]
  node_diff["Diff output<br/>[Diff.hs]"]
end

node_script_author(("Script author"))

node_script_author -->|"runs on script"| node_shellcheck_cli
node_shellcheck_cli -->|"reports findings"| node_script_author

click node_shellcheck_cli "https://github.com/koalaman/shellcheck/blob/master/shellcheck.hs"
click node_interface "https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Interface.hs"
click node_parser "https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Parser.hs"
click node_ast "https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/AST.hs"
click node_analyzer "https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Analyzer.hs"
click node_cfg "https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/CFG.hs"
click node_cfg_analysis "https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/CFGAnalysis.hs"
click node_checker "https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Checker.hs"
click node_command_checks "https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Checks/Commands.hs"
click node_flow_checks "https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Checks/ControlFlow.hs"
click node_custom_checks "https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Checks/Custom.hs"
click node_shell_checks "https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Checks/ShellSupport.hs"
click node_fixer "https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Fixer.hs"
click node_format "https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Formatter/Format.hs"
click node_tty "https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Formatter/TTY.hs"
click node_gcc "https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Formatter/GCC.hs"
click node_json "https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Formatter/JSON.hs"
click node_json1 "https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Formatter/JSON1.hs"
click node_checkstyle "https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Formatter/CheckStyle.hs"
click node_quiet "https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Formatter/Quiet.hs"
click node_diff "https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Formatter/Diff.hs"

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_shellcheck_cli,node_interface toneBlue
class node_parser,node_ast,node_analyzer,node_cfg,node_cfg_analysis toneAmber
class node_checker,node_command_checks,node_flow_checks,node_custom_checks,node_shell_checks toneMint
class node_fixer,node_format,node_tty,node_gcc,node_json,node_json1,node_checkstyle,node_quiet,node_diff toneRose
class node_script_author toneIndigo
```

## Components

### Invocation and API

- [ShellCheck CLI](https://github.com/koalaman/shellcheck/blob/master/shellcheck.hs): `shellcheck.hs`
- [Tool interface](https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Interface.hs): `src/ShellCheck/Interface.hs`

### Script analysis

- [Shell parser](https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Parser.hs): `src/ShellCheck/Parser.hs`
- [Shell AST](https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/AST.hs): `src/ShellCheck/AST.hs`
- [Semantic analyzer](https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Analyzer.hs): `src/ShellCheck/Analyzer.hs`
- [Control-flow graph](https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/CFG.hs): `src/ShellCheck/CFG.hs`
- [Flow analysis](https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/CFGAnalysis.hs): `src/ShellCheck/CFGAnalysis.hs`

### Diagnostic checks

- [Diagnostic checker](https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Checker.hs): `src/ShellCheck/Checker.hs`
- [Command checks](https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Checks/Commands.hs): `src/ShellCheck/Checks/Commands.hs`
- [Control-flow checks](https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Checks/ControlFlow.hs): `src/ShellCheck/Checks/ControlFlow.hs`
- [Custom checks](https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Checks/Custom.hs): `src/ShellCheck/Checks/Custom.hs`
- [Shell support checks](https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Checks/ShellSupport.hs): `src/ShellCheck/Checks/ShellSupport.hs`

### Reports and fixes

- [Fix suggestions](https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Fixer.hs): `src/ShellCheck/Fixer.hs`
- [Format selection](https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Formatter/Format.hs): `src/ShellCheck/Formatter/Format.hs`
- [Terminal output](https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Formatter/TTY.hs): `src/ShellCheck/Formatter/TTY.hs`
- [GCC output](https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Formatter/GCC.hs): `src/ShellCheck/Formatter/GCC.hs`
- [JSON output](https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Formatter/JSON.hs): `src/ShellCheck/Formatter/JSON.hs`
- [JSON1 output](https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Formatter/JSON1.hs): `src/ShellCheck/Formatter/JSON1.hs`
- [CheckStyle output](https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Formatter/CheckStyle.hs): `src/ShellCheck/Formatter/CheckStyle.hs`
- [Quiet output](https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Formatter/Quiet.hs): `src/ShellCheck/Formatter/Quiet.hs`
- [Diff output](https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Formatter/Diff.hs): `src/ShellCheck/Formatter/Diff.hs`

### Other components

- **Script author**

## Connections

- Script author → ShellCheck CLI: runs on script (evidence: `README.md`)
- ShellCheck CLI → Script author: reports findings (evidence: `README.md`)
