checkmate-cli 0.4.1

Checkmate - API Testing Framework CLI
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
# CLI Reference

Complete command reference for Checkmate.

## Global Options

```
-h, --help     Print help
-V, --version  Print version
```

## Commands Overview

| Command | Description |
|---------|-------------|
| `cm init` | Initialize Checkmate in current directory |
| `cm test` | Run API tests |
| `cm config` | Configuration management |
| `cm history` | Show test run history |
| `cm show` | Show details of a specific run |
| `cm docs` | Show documentation overview |
| `cm doc` | Show category-specific documentation |
| `cm onboard` | Quick-start guide for AI agents |
| `cm prime` | Output project context (for hooks) |
| `cm clove` | JSON query language operations |
| `cm spec` | Manage test specifications |
| `cm report` | Report generation |

---

## cm init

Initialize Checkmate in current directory.

```bash
cm init [OPTIONS]
```

### Options

| Option | Description |
|--------|-------------|
| `-L, --url <URL>` | Base URL for API tests (required in non-interactive mode) |
| `--stealth` | Add .checkmate/ to .git/info/exclude |

### Examples

```bash
# Interactive mode (prompts for URL)
cm init

# Non-interactive mode
cm init --url http://localhost:8080

# Stealth mode (local only, not tracked in git)
cm init --url http://localhost:8080 --stealth
```

### Behavior

- **TTY mode**: Prompts for base URL interactively
- **Non-TTY mode**: Requires `--url` flag, shows error with instructions otherwise

### Created Structure

```
.checkmate/
├── config.toml    # Project configuration
├── tests/         # Test specifications
├── runs/          # Test run history
└── hooks/         # Lifecycle hook scripts
```

---

## cm test

Run API tests.

### cm test run

Run test specifications.

```bash
cm test run [OPTIONS] [SPECS]...
```

#### Arguments

| Argument | Description |
|----------|-------------|
| `[SPECS]...` | Test spec files to run (optional) |

#### Options

| Option | Description |
|--------|-------------|
| `-t, --test <TEST>` | Run specific test by name |
| `-v, --verbose` | Verbose output |

#### Examples

```bash
# Run all discovered specs
cm test run

# Run specific spec by name
cm test run users

# Run specific spec by path
cm test run ./custom/test.yaml

# Run multiple specs
cm test run users orders payments

# Run with verbose output
cm test run -v

# Run specific test within a spec
cm test run users --test user_creation
```

#### Auto-Discovery

When no specs provided:
1. Discovers `.checkmate/` by walking up directory tree
2. Finds all `.yaml`/`.yml` files in `.checkmate/tests/`
3. Runs them in alphabetical order

#### Name Resolution

Spec names are resolved in order:
1. If path exists, use as-is
2. Try `.checkmate/tests/{name}.yaml`
3. Try `.checkmate/tests/{name}.yml`

### cm test list

List available tests in spec files.

```bash
cm test list [SPECS]...
```

#### Examples

```bash
# List all tests
cm test list

# List tests in specific spec
cm test list users
```

### cm test validate

Validate test specs without running.

```bash
cm test validate [SPECS]...
```

Checks YAML syntax and schema without making HTTP requests.

---

## cm config

Configuration management.

### cm config show

Show current configuration.

```bash
cm config show [OPTIONS]
```

#### Options

| Option | Description |
|--------|-------------|
| `--json` | Output as JSON instead of TOML |

#### Examples

```bash
# Show as TOML
cm config show

# Show as JSON
cm config show --json
```

### cm config sources

Show configuration sources and which are active.

```bash
cm config sources
```

Output:
```
Configuration sources (in priority order):

  [ ] User:    ~/.config/checkmate/config.toml (not found)
  [✓] Project: /path/to/.checkmate/config.toml

  Environment variables: CM_* (e.g., CM_ENV__BASE_URL)
```

---

## cm history

Show test run history.

```bash
cm history [OPTIONS]
```

### Options

| Option | Description |
|--------|-------------|
| `--commit <COMMIT>` | Filter by git commit |
| `--spec <SPEC>` | Filter by spec file name |
| `-n, --limit <LIMIT>` | Maximum results [default: 10] |

### Examples

```bash
# Recent runs
cm history

# More results
cm history -n 20

# Filter by spec
cm history --spec users

# Filter by commit
cm history --commit abc123
```

### Output Format

```
✓ cm-run-a3f 2024-01-15 5/5 passed @ abc1234*
✗ cm-run-b7c 2024-01-14 3/5 passed @ def5678
```

- `` = all passed, `` = failures
- `*` after commit = dirty working directory

---

## cm show

Show details of a specific run.

```bash
cm show <RUN_ID>
```

### Example

```bash
cm show cm-run-a3f
```

Output:
```
Run: cm-run-a3f
Time: 2024-01-15T10:30:00Z
Spec: users.yaml
Results: 5/5 passed, 0 failed, 0 errors (1234ms)

Git Context:
  Commit: abc1234
  Branch: main
  Dirty: no
  Message: Add user validation
```

---

## cm docs

Show documentation overview.

```bash
cm docs
```

Lists all available documentation categories.

---

## cm doc

Show category-specific documentation.

```bash
cm doc <CATEGORY>
```

### Categories

| Category | Description |
|----------|-------------|
| `assertions` | Assertion types and examples |
| `requests` | Request definition format |
| `env` | Environment and configuration |
| `scopes` | Clove query scopes |
| `examples` | Complete examples |
| `cli` | CLI reference |

### Example

```bash
cm doc assertions
```

---

## cm onboard

Quick-start guide for AI agents.

```bash
cm onboard
```

Outputs a condensed reference for AI agents covering test spec format, running tests, and common patterns.

---

## cm prime

Output project context for AI agents.

```bash
cm prime
```

Used by SessionStart hooks to inject context. Outputs:
- Project location and base URL
- Available test specs with test counts
- Recent run history
- Quick reference commands

Silently exits if no `.checkmate/` found.

---

## cm clove

JSON query language operations.

```bash
cm clove <COMMAND>
```

### cm clove eval

Evaluate a Clove expression against JSON.

```bash
cm clove eval '<expression>' '<json>'
```

### cm clove parse

Parse and display AST of a Clove expression.

```bash
cm clove parse '<expression>'
```

---

## Environment Variables

Override configuration with `CM_` prefix:

| Variable | Description |
|----------|-------------|
| `CM_ENV__BASE_URL` | Override base URL |
| `CM_ENV__TIMEOUT_MS` | Override timeout |
| `CM_DEFAULTS__FAIL_FAST` | Stop on first failure |
| `CM_DEFAULTS__EXPECT_STATUS` | Default expected status |

Note: Use double underscore (`__`) for nested keys.

---

## Exit Codes

| Code | Meaning |
|------|---------|
| 0 | Success |
| 1 | Test failures or errors |

---

## See Also

- [Quick Start]QUICKSTART.md
- [Test Specs]TEST_SPECS.md
- [Configuration]CONFIG.md