# sindresorhus/fkill-cli architecture

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

- Interactive diagram: https://gitdiagram.com/sindresorhus/fkill-cli
- Repository: https://github.com/sindresorhus/fkill-cli

## Overview

fkill-cli is a cross-platform process-killing command-line app. A user supplies process IDs, names, or colon-prefixed ports for direct termination, or runs it without arguments to browse and search a live process list, select a process, and confirm termination. The interactive path enriches process records with port ownership, filters and sorts them, and can prompt to force-kill survivors. The graph reflects the supplied CLI and interactive source; process discovery and termination are external dependencies, so their internal behavior is not expanded.

Main entry points: [`interactive.js`](https://github.com/sindresorhus/fkill-cli/blob/main/interactive.js) (Interactive setup), [`cli.js`](https://github.com/sindresorhus/fkill-cli/blob/main/cli.js) (CLI dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI entry"]
  node_cli["CLI dispatcher<br/>[cli.js]"]
end

subgraph group_interactive["Interactive workflow"]
  node_interactive_init["Interactive setup<br/>[interactive.js]"]
  node_process_inventory["Process inventory<br/>[interactive.js]"]
  node_port_enrichment["Port enrichment<br/>[interactive.js]"]
  node_search_filter["Search and sort<br/>[interactive.js]"]
  node_process_picker["Process picker<br/>[interactive.js]"]
  node_kill_sequence["Kill sequence<br/>[interactive.js]"]
  node_exit_poll["Exit polling<br/>[interactive.js]"]
  node_force_prompt["Force prompt<br/>[interactive.js]"]
end

subgraph group_integrations["Runtime integrations"]
  node_arg_parser["Argument parser"]
  node_fkill_api["fkill engine"]
  node_ps_list["Process listing"]
  node_port_lookup["Port lookup"]
  node_search_ui["Search prompt"]
  node_process_check["Process existence"]
  node_terminal["Terminal UI"]
end

node_user(("CLI user"))

node_user -->|"invokes"| node_cli
node_cli -->|"parses arguments"| node_arg_parser
node_cli -->|"kills requested targets"| node_fkill_api
node_cli -->|"starts without targets"| node_interactive_init
node_cli -->|"delegates kill errors"| node_interactive_init
node_interactive_init -->|"lists processes"| node_ps_list
node_interactive_init -->|"maps ports to PIDs"| node_port_lookup
node_interactive_init -->|"enriches process records"| node_port_enrichment
node_port_enrichment -->|"passes enriched records"| node_process_inventory
node_interactive_init -->|"provides process records"| node_process_inventory
node_process_inventory -->|"filters and sorts"| node_search_filter
node_search_filter -->|"supplies matching choices"| node_process_picker
node_process_picker -->|"prompts for selection"| node_search_ui
node_process_picker -->|"submits selected PID"| node_kill_sequence
node_kill_sequence -->|"attempts termination"| node_fkill_api
node_kill_sequence -->|"checks survivors"| node_exit_poll
node_exit_poll -->|"checks PID existence"| node_process_check
node_kill_sequence -->|"asks about force kill"| node_force_prompt
node_force_prompt -->|"prompts or reports"| node_terminal
node_force_prompt -->|"force-kills if confirmed"| node_fkill_api

click node_cli "https://github.com/sindresorhus/fkill-cli/blob/main/cli.js"
click node_interactive_init "https://github.com/sindresorhus/fkill-cli/blob/main/interactive.js"
click node_process_inventory "https://github.com/sindresorhus/fkill-cli/blob/main/interactive.js"
click node_port_enrichment "https://github.com/sindresorhus/fkill-cli/blob/main/interactive.js"
click node_search_filter "https://github.com/sindresorhus/fkill-cli/blob/main/interactive.js"
click node_process_picker "https://github.com/sindresorhus/fkill-cli/blob/main/interactive.js"
click node_kill_sequence "https://github.com/sindresorhus/fkill-cli/blob/main/interactive.js"
click node_exit_poll "https://github.com/sindresorhus/fkill-cli/blob/main/interactive.js"
click node_force_prompt "https://github.com/sindresorhus/fkill-cli/blob/main/interactive.js"

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_user toneBlue
class node_interactive_init,node_process_inventory,node_port_enrichment,node_search_filter,node_process_picker,node_kill_sequence,node_exit_poll,node_force_prompt toneAmber
class node_arg_parser,node_fkill_api,node_ps_list,node_port_lookup,node_search_ui,node_process_check,node_terminal toneMint
```

## Components

### CLI entry

- [CLI dispatcher](https://github.com/sindresorhus/fkill-cli/blob/main/cli.js): `cli.js`

### Interactive workflow

- [Interactive setup](https://github.com/sindresorhus/fkill-cli/blob/main/interactive.js): `interactive.js`
- [Process inventory](https://github.com/sindresorhus/fkill-cli/blob/main/interactive.js): `interactive.js`
- [Port enrichment](https://github.com/sindresorhus/fkill-cli/blob/main/interactive.js): `interactive.js`
- [Search and sort](https://github.com/sindresorhus/fkill-cli/blob/main/interactive.js): `interactive.js`
- [Process picker](https://github.com/sindresorhus/fkill-cli/blob/main/interactive.js): `interactive.js`
- [Kill sequence](https://github.com/sindresorhus/fkill-cli/blob/main/interactive.js): `interactive.js`
- [Exit polling](https://github.com/sindresorhus/fkill-cli/blob/main/interactive.js): `interactive.js`
- [Force prompt](https://github.com/sindresorhus/fkill-cli/blob/main/interactive.js): `interactive.js`

### Runtime integrations

- **Argument parser**
- **fkill engine**
- **Process listing**
- **Port lookup**
- **Search prompt**
- **Process existence**
- **Terminal UI**

### Other components

- **CLI user**

## Connections

- CLI user → CLI dispatcher: invokes
- CLI dispatcher → Argument parser: parses arguments
- CLI dispatcher → fkill engine: kills requested targets
- CLI dispatcher → Interactive setup: starts without targets
- CLI dispatcher → Interactive setup: delegates kill errors
- Interactive setup → Process listing: lists processes
- Interactive setup → Port lookup: maps ports to PIDs
- Interactive setup → Port enrichment: enriches process records
- Port enrichment → Process inventory: passes enriched records
- Interactive setup → Process inventory: provides process records
- Process inventory → Search and sort: filters and sorts
- Search and sort → Process picker: supplies matching choices
- Process picker → Search prompt: prompts for selection
- Process picker → Kill sequence: submits selected PID
- Kill sequence → fkill engine: attempts termination
- Kill sequence → Exit polling: checks survivors
- Exit polling → Process existence: checks PID existence
- Kill sequence → Force prompt: asks about force kill
- Force prompt → Terminal UI: prompts or reports
- Force prompt → fkill engine: force-kills if confirmed
