xbp 10.17.1

XBP is a zero-config build pack that can also interact with proxies, kafka, sockets, synthetic monitors.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
---

title: CLI Reference

description: Complete reference for all XBP CLI commands

---


# CLI Reference


Complete reference for all XBP commands, options, and flags.


## Global Options


Available for all commands:


### `--debug`

Enable debug mode with verbose output.


```bash

xbp --debug diag

```


### `-l, --list`

List PM2 processes (shorthand).


```bash

xbp -l

```


### `-p, --port <PORT>`

Filter by port number (for ports command).


```bash

xbp -p 3000

```


## Commands


### Diagnostics


#### `xbp diag`

System diagnostics and health checks.


```bash

xbp diag [--nginx] [--ports <PORTS>] [--no-speed-test]

```


**Options:**

- `--nginx` - Check only Nginx

- `--ports <PORTS>` - Check specific ports (comma-separated)
- `--no-speed-test` - Skip internet speed test


[Full Documentation](/docs/commands/diag)

### Monitoring


#### `xbp monitor check`

Run single health check.


```bash

xbp monitor check

```


#### `xbp monitor start`

Start monitoring daemon.


```bash

xbp monitor start

```


### Kubernetes (Feature-Gated)


#### `xbp kubernetes issuer`

Create or update a cert-manager Let's Encrypt issuer.

```bash
xbp kubernetes issuer --email floris@xylex.group [--namespace default] [--context <CTX>] [--dry-run]
```

#### `xbp kubernetes addons`
List, enable, or disable MicroK8s addons.

```bash
xbp kubernetes addons list
xbp kubernetes addons enable cert-manager
xbp kubernetes addons disable ingress
```

#### `xbp kubernetes observability-creds`
Print decoded Grafana admin credentials from the observability secret.

```bash
xbp kubernetes observability-creds
```

[Full Documentation](/docs/commands/monitor)

### Logging

#### `xbp tail`
Tail log files.

```bash
xbp tail [--kafka] [--ship]
```

**Options:**
- `--kafka` - Tail from Kafka topic
- `--ship` - Ship logs to Kafka

[Full Documentation](/docs/commands/tail)

### Port Management

#### `xbp ports`
List and manage network ports.

```bash
xbp ports [-p <PORT>] [--kill] [-n] [--no-local] [--exposure]
```

**Options:**
- `-p, --port <PORT>` - Filter by port
- `--kill` - Kill processes on port
- `-n, --nginx` - Show only Nginx ports
- `--no-local` - Exclude connections where LocalAddr equals RemoteAddr
- `--exposure` - Show bind/firewall exposure diagnostics for the selected ports

[Full Documentation](/docs/commands/ports)

### Service Management

#### `xbp services`
List all services.

```bash
xbp services
```

#### `xbp service <COMMAND> <NAME>`
Run service command.

```bash
xbp service build api
xbp service install frontend
xbp service start worker
xbp service dev api
```

**Commands:**
- `build` - Build the service
- `install` - Install dependencies
- `start` - Start the service
- `dev` - Run in development mode
- `stop` - Stop the service

### Deployment

#### `xbp redeploy [SERVICE]`
Redeploy services.

```bash
xbp redeploy           # All services
xbp redeploy api       # Specific service
```

#### `xbp redeploy-v2`
Remote deployment.

```bash
xbp redeploy-v2 -u <USER> -h <HOST> -d <DIR> [-p <PASSWORD>]
```

**Options:**
- `-u, --username <USER>` - SSH username
- `-h, --host <HOST>` - SSH host
- `-d, --project-dir <DIR>` - Project directory
- `-p, --password <PASSWORD>` - SSH password (optional)

### Nginx Management

#### `xbp nginx setup`
Provision Nginx HTTPS reverse proxy and certificates.

```bash
xbp nginx setup --domain <DOMAIN> --port <PORT> --email <EMAIL>
```

**Options:**
- `-d, --domain <DOMAIN>` - Domain name (supports wildcard like `*.example.com`)
- `-p, --port <PORT>` - Port to proxy to
- `-e, --email <EMAIL>` - Let's Encrypt registration email
- `--dns-mode <manual|plugin>` - DNS mode for wildcard domains (default: `manual`)
- `--dns-plugin <NAME>` - DNS provider plugin for plugin mode (example: `cloudflare`)
- `--dns-creds <PATH>` - DNS plugin credentials file path
- `--include-base <true|false>` - Include base domain when issuing wildcard certs (default: `true`)

Examples:

```bash
# Standard domain (HTTP-01)
xbp nginx setup --domain api.example.com --port 3000 --email ops@example.com

# Wildcard domain (manual DNS challenge)
xbp nginx setup --domain '*.example.com' --port 3000 --email ops@example.com --dns-mode manual

# Wildcard domain (plugin DNS challenge)
xbp nginx setup --domain '*.example.com' --port 3000 --email ops@example.com --dns-mode plugin --dns-plugin cloudflare --dns-creds /root/.secrets/certbot/cloudflare.ini
```

#### `xbp nginx list`

List Nginx configurations.


```bash

xbp nginx list

```


#### `xbp nginx update`
Update Nginx configuration.

```bash
xbp nginx update --domain <DOMAIN> --port <PORT>
```

#### `xbp nginx show`
Show one or all detected Nginx site configs.

```bash
xbp nginx show
xbp nginx show api.example.com
```

### Network Management

#### `xbp network floating-ip add`
Add a persistent floating IP on the detected Linux network backend.

```bash
xbp network floating-ip add --ip <IP> [--cidr <N>] [--interface <IFACE>] [--label <NAME>] [--apply] [--dry-run]
```

Examples:

```bash
# IPv4 floating IP on auto-detected interface, write only
xbp network floating-ip add --ip 203.0.113.10

# IPv6 floating IP with explicit interface and immediate apply
xbp network floating-ip add --ip 2a01:4f9:0:2a1::2 --cidr 64 --interface eth0 --apply
```

#### `xbp network floating-ip list`
List floating IP entries discovered from runtime and persistent config.

```bash
xbp network floating-ip list
xbp network floating-ip list --json
```

#### `xbp network config list`
List discovered network config files and backend detection result.

```bash
xbp network config list
xbp network config list --json
```

### PM2 Management


#### `xbp list`

List PM2 processes.


```bash

xbp list

```


#### `xbp logs [PROJECT]`

View service logs. With the `docker` feature enabled, `PROJECT` may be a Docker container name or ID prefix; matching containers stream via `docker logs -f` (sudo fallback). Otherwise PM2 logs are shown.


```bash

xbp logs              # All logs (PM2)

xbp logs api          # PM2 service or Docker container named "api"

```


**Options:**

- `--ssh-host <HOST>` - SSH host to stream remote logs from.

- `--ssh-username <USER>` - SSH username for the remote server.

- `--ssh-password <PASSWORD>` - SSH password for the remote server.


### Utilities


#### `xbp config`
View configuration.

```bash
xbp config
```

Provider key management:

```bash
xbp config openrouter set-key [KEY]
xbp config openrouter show [--raw]
xbp config openrouter delete-key

xbp config github set-key [TOKEN]
xbp config github show [--raw]
xbp config github delete-key
```

#### `xbp setup`

Initial setup.


```bash

xbp setup

```


#### `xbp curl <URL>`

Make HTTP request.


```bash

xbp curl https://api.example.com/health

```


#### `xbp docker [ARGS...]`

Feature-gated pass-through wrapper around the Docker CLI. With no args it shows Docker help; otherwise arguments are forwarded verbatim.


```bash

xbp docker ps

xbp docker compose ls

xbp docker run -it ubuntu bash

```


#### `xbp install <PACKAGE>`
Install package.

```bash

xbp install docker

xbp install nginx

xbp install grafana
```

#### `xbp version release`
Create and push a version tag, then publish a GitHub release.

```bash
xbp version release
xbp version release --version 10.16.0
xbp version release --notes-file RELEASE_NOTES.md
xbp version release --allow-dirty
```

#### `xbp generate systemd`

Generate systemd service units from the current `.xbp/xbp.yaml`.


```bash

xbp generate systemd [--service <SERVICE>] [--output-dir /etc/systemd/system] [--api/--no-api]

```


**Options:**

- `--service <SERVICE>` - Only emit the unit for a single service name.

- `--output-dir <DIR>` - Write units to a custom directory (default `/etc/systemd/system`).

- `--api/--no-api` - Also generate the `xbp-api.service` unit that runs the built-in API (default: on).


> Running this command on Linux usually requires root privileges when targeting `/etc/systemd/system`. Review the generated files before enabling them with `systemctl daemon-reload` and `systemctl enable`.


## Command Chaining


### Sequential Execution


```bash

xbp diag && xbp service build api && xbp service start api

```


### Conditional Execution


```bash

xbp monitor check || echo "Health check failed"

```


### Background Execution


```bash

xbp monitor start &
xbp tail --ship &
```


## Environment Variables


### `PORT_XBP_API`

Start XBP in API mode.


```bash

export PORT_XBP_API=8080

xbp

```


### `RUST_LOG`

Set logging level.


```bash

export RUST_LOG=debug

xbp diag

```


### `XBP_DEBUG`

Enable debug mode.


```bash

export XBP_DEBUG=1

xbp services

```


## Exit Codes


- `0` - Success

- `1` - General error

- `2` - Configuration error

- `3` - Network error

- `4` - Service error


## Output Formats


### Standard Output


```
[component] message

```


### Success


```
[component]  Success message

```


### Warning


```
[component]  Warning message

```


### Error


```
[component]  Error message

```


## Piping and Redirection


### Save Output


```bash

xbp diag > diagnostics.txt

```


### Append to File


```bash

xbp monitor check >> health-checks.log

```


### Filter Output


```bash

xbp tail | grep ERROR

```


### Count Lines


```bash

xbp ports | wc -l

```


## Scripting Examples


### Bash Script


```bash

#!/bin/bash


# Health check script

if xbp monitor check; then
    echo "Service is healthy"

    exit 0

else
    echo "Service is down"

    xbp service start api

    exit 1

fi

```


### Python Script


```python

import subprocess

import sys


result = subprocess.run(['xbp', 'monitor', 'check'], 

                       capture_output=True)
if result.returncode == 0:

    print("Health check passed")
else:

    print("Health check failed")
    sys.exit(1)
```


### Node.js Script


```javascript

const { exec } = require('child_process');

exec('xbp monitor check', (error, stdout, stderr) => {
  if (error) {
    console.error('Health check failed');
    process.exit(1);
  }
  console.log('Health check passed');
});
```


## Aliases


Create shortcuts for common commands:


```bash

# Add to ~/.bashrc or ~/.zshrc

alias xd='xbp diag'

alias xm='xbp monitor check'

alias xl='xbp tail'

alias xp='xbp ports'

alias xs='xbp services'

```


## Tab Completion


### Bash


```bash

# Add to ~/.bashrc

eval "$(xbp --completion bash)"

```


### Zsh


```bash

# Add to ~/.zshrc

eval "$(xbp --completion zsh)"

```


### Fish


```bash

# Add to ~/.config/fish/config.fish

xbp --completion fish | source

```


## Tips and Tricks


1. **Use `--debug`** for troubleshooting

2. **Pipe to `jq`** for JSON formatting

3. **Combine with `watch`** for monitoring

4. **Use `&&` and `||`** for conditional execution

5. **Create aliases** for frequent commands

6. **Save output** for later analysis

7. **Use environment variables** for configuration


## Common Workflows


### Development


```bash

# Start development

xbp diag

xbp service dev api

xbp tail

```


### Deployment


```bash

# Deploy to production

xbp diag

xbp service build api

xbp service start api

xbp monitor start

```


### Troubleshooting


```bash

# Debug issues

xbp diag --debug

xbp ports -p 3000

xbp logs api

xbp monitor check

```


### Monitoring


```bash

# Set up monitoring

xbp monitor start &
xbp tail --ship &
watch xbp ports

```


### Architecture Snapshot (2026-03)


- Commands are dispatched via `src/cli/router.rs` into domain handlers under `src/cli/handlers/`.

- Shared CLI context lives in `src/cli/app.rs`; unified error type is `CliError` (`src/cli/error.rs`).

- Subprocess work should use `sdk::command::CommandRunner` (NGINX migrated; PM2 migration in progress).

- API management: `xbp api install --port 8080` writes/enables `xbp-api.service`; the API exposes `/routes`, `/proxy/{domain}/...`, and `/metrics` (Prometheus).


## See Also


- [Configuration Guide](/docs/configuration)
- [Installation Guide](/docs/installation)
- [Command Documentation](/docs/commands/diag)
- [Guides](/docs/guides/monitoring)