clive-llm 0.1.0

A local-first coding-assistant CLI that wraps Ollama, making open-source LLMs easy to chat with, run in sessions, and safely edit code from your terminal.
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
# Clive — a friendly CLI for local LLMs

![Clive mascot](docs/clive-mascot.png)

[![CI](https://github.com/SedarOlmez94/clive/actions/workflows/ci.yml/badge.svg)](https://github.com/SedarOlmez94/clive/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![Rust](https://img.shields.io/badge/rust-1.85%2B-orange.svg)](https://www.rust-lang.org/)
[![Ollama](https://img.shields.io/badge/Ollama-Local%20LLM-black.svg)](https://ollama.com/)
[![Contributions Welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg)](CONTRIBUTING.md)

Clive is a local-first coding-assistant CLI powered by [Ollama](https://ollama.com/).
It makes open-source LLMs easy to use from the terminal: streaming chat, interactive
coding sessions, model management, safe file editing, and autonomous multi-file agent
workflows — all running on your own machine, with no data leaving your computer.

> **New here?** Jump to [Quick Start]#quick-start to be chatting with a local model in under five minutes.

## Table of Contents

- [Features]#features
- [Quick Start]#quick-start
- [Prerequisites]#prerequisites
- [Installation]#installation
- [One-Terminal Onboarding]#one-terminal-onboarding-recommended
- [Core Commands]#core-commands
  - [Persistent Configuration]#persistent-configuration
  - [Ollama Management]#ollama-management-from-clive
  - [Chat]#chat-single-prompt
  - [Interactive Session]#interactive-session-multi-turn
  - [Agent Workflow]#agent-workflow-phase-1-2-3
  - [Edit & Patch]#patch-mode-unified-diff
  - [Shell Completions]#professional-cli-features-clap
- [Configuration Reference]#ollama-host-configuration
- [How It Works]#how-it-works
- [Troubleshooting & FAQ]#troubleshooting--faq
- [Contributing]#contributing
- [Roadmap]#roadmap
- [Security]#security
- [License]#license
- [Acknowledgements]#acknowledgements

## Features

- ASCII art banner at startup
- Chat with local Ollama models
- Stream tokens in real time (chat and session)
- Interactive multi-turn coding sessions
- Autonomous multi-file agent workflows
- Manage Ollama from Clive (serve, pull/install, remove)
- Get curated model recommendations by profile
- List installed models and verify connectivity
- Edit source files with preview/apply flow
- Generate unified patches and optionally apply
- Optional git safety checks and auto-stage on write
- Shell completions for bash, zsh, fish, powershell, and elvish
- Non-interactive JSON reports for automation
- Persistent configuration (default model, Ollama URL, system prompt)
- Pipe file contents or command output straight into `chat` via stdin
- Save and reload interactive session history
- Progress spinner while waiting for non-streamed responses

## Quick Start

```bash
# 1. Install Clive from source (not yet published to crates.io)
cargo install --path .

# 2. Start Ollama in the background
clive ollama serve --detach

# 3. Pull a coding model
clive ollama pull qwen2.5-coder:latest

# 4. Chat!
clive chat "Explain Rust's ownership model in two sentences"

# 5. Or start an interactive session
clive session --model qwen2.5-coder:latest
```

That's it — everything runs locally against your own Ollama instance.

## Prerequisites

- Rust toolchain (`cargo`, `rustc`) — **1.85 or newer**
- [Ollama]https://ollama.com/ installed on your machine

You do not need a separate terminal for Ollama setup once Clive is installed.

## Installation

### From source

```bash
git clone https://github.com/SedarOlmez94/clive.git
cd clive
cargo install --path .
```

### From crates.io

Not yet available. Once published, install with:

```bash
cargo install clive-llm
```

The `clive` crate name is already taken by an unrelated project, so Clive will
publish under the package name `clive-llm` instead. The GitHub repo and the
installed binary are both still named `clive`. This README will be updated
once the crates.io release exists.

The binary is installed to (usually):

```bash
~/.cargo/bin/clive
```

Make sure `~/.cargo/bin` is on your `PATH`.

### Updating

```bash
cargo install --path . --force
```

> **Reinstall after building from source.** The `clive` on your `PATH` is a
> compiled binary — editing the source does not change it until you re-run
> `cargo install --path . --force`.

### Uninstalling

```bash
cargo uninstall clive
```

## One-Terminal Onboarding (Recommended)

1) Start Ollama from Clive in background:

```bash
clive ollama serve --detach
```

2) Verify connection:

```bash
clive doctor
```

3) Install a coding model (example):

```bash
clive ollama pull qwen2.5-coder:latest
```

Clive uses the local Ollama CLI for pulls, so long model downloads stay attached to the terminal and do not time out over HTTP.

4) Confirm model is available:

```bash
clive models
```

5) Start using Clive:

```bash
clive session --model qwen2.5-coder:latest
```

6) Optional: check curated recommendations:

```bash
clive ollama recommend --profile rust
```

## Core Commands

Show help:

```bash
clive --help
```

Set a global default model for all commands:

```bash
export CLIVE_MODEL=qwen2.5-coder:latest
```

Or pass it directly:

```bash
clive -m qwen2.5-coder:latest session
```

If no model is provided, Clive auto-selects your first installed local model. If none are installed, it falls back to `llama3.1`.

Hide startup ASCII art:

```bash
clive --no-banner doctor
```

### Persistent Configuration

Clive can remember your defaults so you don't have to pass flags every time.
Values are stored as JSON at:

- Linux/macOS: `$XDG_CONFIG_HOME/clive/config.json` or `~/.config/clive/config.json`
- Windows: `%APPDATA%\clive\config.json`
- Override with the `CLIVE_CONFIG` environment variable

Precedence for any setting is: CLI flag > environment variable > config file > built-in default.

```bash
# Set persistent defaults
clive config set model qwen2.5-coder:latest
clive config set ollama_url http://127.0.0.1:11434
clive config set system "Be concise and production-focused"

# Inspect current configuration and its location
clive config show
clive config path

# Remove a stored value
clive config unset system
```

### Ollama Management from Clive

Start Ollama in foreground:

```bash
clive ollama serve
```

Start Ollama in background:

```bash
clive ollama serve --detach
```

Install a model:

```bash
clive ollama pull llama3.1
clive ollama pull qwen2.5-coder:latest
```

Recommended models by use-case profile:

```bash
clive ollama recommend --profile coding
clive ollama recommend --profile rust
clive ollama recommend --profile fast
clive ollama recommend --profile reasoning
```

Only show recommendations that are already installed:

```bash
clive ollama recommend --profile coding --installed-only
```

Remove an installed model:

```bash
clive ollama rm qwen2.5-coder:latest
```

List installed models:

```bash
clive models
```

Health check:

```bash
clive doctor
```

### Chat (Single Prompt)

```bash
clive chat "Explain Rust ownership in simple terms"
clive chat "Refactor this function" --model qwen2.5-coder:latest
```

By default, chat streams tokens as they are generated. Disable streaming:

```bash
clive chat "Summarize this module" --no-stream
```

> **Thinking models** (e.g. `qwen3`, `deepseek-r1`) emit their reasoning in a
> separate stream before the final answer. Clive shows this live on stderr as a
> dimmed `[thinking] ...` block so long reasoning phases don't look like a hang,
> then prints the answer on stdout. Redirect stderr (`2>/dev/null`) if you only
> want the final answer.

Optional system prompt:

```bash
clive chat "Create tests for this module" --system "Be concise and production-focused"
```

Pipe file contents or command output directly into the model via stdin.

When you pipe input without a prompt, the piped text becomes the prompt:

```bash
git diff | clive chat "" # or simply: clive chat < notes.txt
clive chat < notes.txt
```

To combine your own prompt with piped input, add the `--stdin` flag (this
keeps the normal `clive chat "message"` case from ever waiting on stdin):

```bash
cat src/main.rs | clive chat "Review this file and suggest improvements" --stdin
git diff | clive chat "Write a concise commit message for this diff" --stdin
```

### Interactive Session (Multi-Turn)

```bash
clive session --model qwen2.5-coder:latest
```

Disable streaming in session mode:

```bash
clive session --model qwen2.5-coder:latest --no-stream
```

Session commands:

- /help shows available commands
- /clear resets conversation context (keeps system instruction)
- /save &lt;file&gt; writes the conversation history to a JSON file
- /load &lt;file&gt; restores a previously saved conversation
- /exit exits the session

### Agent Workflow (Phase 1, 2, 3)

Run an autonomous workflow over specific files:

```bash
clive agent "Refactor error handling and add tests" \
	--files src/main.rs \
	--verify "cargo check -q" \
	--apply
```

Key options:

- `--files` required allow-list of files Clive may edit
- `--verify` repeatable verification commands after apply
- `--apply` writes edits to disk (otherwise preview only)
- `--rollback-on-fail` restores originals if verification never passes
- `--require-clean-git` refuses writes when target files are dirty
- `--profile quick|balanced|strict` adjusts default iteration and verification behavior
- `--max-iterations` overrides profile default loop depth
- `--json` prints machine-readable run report for CI/automation
- `--allow-agent-commands` allows `run_command` actions from the model (disabled by default for safety)

Strict profile example:

```bash
clive agent "Harden CLI argument validation" \
	--files src/main.rs \
	--apply \
	--rollback-on-fail \
	--profile strict
```

Automation-friendly JSON mode:

```bash
clive --no-banner agent "Improve docs" \
	--files README.md \
	--json
```

Enable command actions when you explicitly trust the run context:

```bash
clive agent "Run formatter and fix lint issues" \
        --files src/main.rs \
        --apply \
        --allow-agent-commands \
        --verify "cargo check -q"
```
Apply changes:

```bash
clive edit src/main.rs "Add structured logging and stronger error handling" --write
```

Create backup before write:

```bash
clive edit src/main.rs "Add structured logging" --write --backup
```

Git-aware write protection:

```bash
clive edit src/main.rs "Refactor parsing logic" --write --require-clean-git
```

Auto-stage after write:

```bash
clive edit src/main.rs "Refactor parsing logic" --write --stage
```

### Patch Mode (Unified Diff)

Show unified patch instead of line-marked diff:

```bash
clive patch src/main.rs "Extract helper functions"
```

Apply patch result to file:

```bash
clive patch src/main.rs "Extract helper functions" --write
```

## Professional CLI Features (Clap)

Clive uses a polished Clap configuration with:

- command aliases (for example: ask, ls, health, repl)
- inferred subcommands
- strict help behavior when commands are missing
- global model selection via `-m` and `CLIVE_MODEL`
- typed shell completion generation

Generate shell completions:

```bash
clive completions bash > ~/.clive-complete.bash
clive completions zsh > ~/.clive-complete.zsh
clive completions fish > ~/.config/fish/completions/clive.fish
```

## Verification Before Release

Run these checks before cutting a release:

```bash
cargo fmt --check
cargo check
cargo test
```

## Ollama Host Configuration

Default:

- http://127.0.0.1:11434

Override per command:

```bash
clive --ollama-url http://127.0.0.1:11434 chat "hello"
```

Or via environment variable:

```bash
export OLLAMA_HOST=http://127.0.0.1:11434
```

## VS Code Workflow Notes

Run Clive from your project root for best relative path behavior.

When you run edit or patch with --write, Clive updates files directly and VS Code reflects changes automatically.

## How It Works

Clive is a thin, safety-focused wrapper around a local Ollama server:

```text
┌──────────┐    JSON / streaming     ┌──────────────┐    inference    ┌─────────────┐
│  clive   │ ─────────────────────▶  │ Ollama server │ ───────────────▶│ local model │
│  (CLI)   │ ◀─────────────────────  │ (HTTP :11434) │ ◀───────────────│ e.g. qwen3  │
└──────────┘   tokens / thinking      └──────────────┘                 └─────────────┘
```

- **Chat & session** call Ollama's `/api/chat` endpoint. Responses stream token
  by token; reasoning ("thinking") models are surfaced live so long thinking
  phases never look like a hang.
- **Model management** (`serve`, `pull`, `rm`, `models`) shells out to the local
  `ollama` CLI or talks to the HTTP API, whichever is more reliable for the task.
- **Edit / patch / agent** load your files, ask the model for a full updated
  version, show a diff, and only write when you explicitly pass `--write` /
  `--apply`. Optional git checks and rollback keep changes reversible.

Everything runs on your machine. No prompts, code, or files are sent to any
third-party service.

## Troubleshooting & FAQ

**Clive seems to hang with no output when I send a message.**
You are almost certainly using a *thinking* model (e.g. `qwen3`, `deepseek-r1`).
These models stream their reasoning before the final answer. Clive shows this as
a dimmed `[thinking] …` block on stderr. If you want only the answer, redirect
stderr: `clive chat "…" 2>/dev/null`. If you built from source, also make sure
you reinstalled: `cargo install --path . --force`.

**`clive: command not found`.**
Ensure `~/.cargo/bin` is on your `PATH`. Add this to your shell profile:
`export PATH="$HOME/.cargo/bin:$PATH"`.

**`Ollama not reachable` / connection refused.**
Start the server with `clive ollama serve --detach`, then verify with
`clive doctor`. If you run Ollama on a non-default host or port, set
`--ollama-url` or the `OLLAMA_HOST` environment variable.

**How do I set a default model so I don't pass `--model` every time?**
`clive config set model qwen2.5-coder:latest`, or export `CLIVE_MODEL`.

**Which models should I use?**
Run `clive ollama recommend --profile coding` (or `rust`, `fast`, `reasoning`).

**Can I pipe input into Clive?**
Yes: `git diff | clive chat "write a commit message" --stdin`, or
`clive chat < notes.txt`.

**Does Clive send my data anywhere?**
No. Clive only talks to your local Ollama server.

## Contributing

Contributions are very welcome — bug reports, feature ideas, docs, and code.

1. Read the [Contributing Guide]CONTRIBUTING.md and
   [Code of Conduct]CODE_OF_CONDUCT.md.
2. Fork the repo and create a feature branch.
3. Make your change with tests where practical.
4. Run the full check suite before opening a PR:

```bash
cargo fmt --all
cargo clippy --all-targets -- -D warnings
cargo test
```

5. Open a pull request describing the change and its motivation.

Good first issues are labelled [`good first issue`](https://github.com/SedarOlmez94/clive/labels/good%20first%20issue).

## Roadmap

Planned and under consideration (feedback welcome via issues):

- [ ] Publish to crates.io as `clive-llm` (the `clive` name is taken by an unrelated crate; the `clive` binary name is unaffected)
- [ ] VS Code Copilot Chat participant (`@clive`) to run the agent workflow with a chosen local model from inside the editor
- [ ] Configurable model parameters (temperature, context length, `num_ctx`)
- [ ] Multi-file context in `chat`/`session` (attach files as context)
- [ ] Prebuilt release binaries via GitHub Releases (no Rust toolchain needed)
- [ ] Homebrew formula and other package-manager distributions
- [ ] Session transcripts in Markdown, not just JSON
- [ ] Pluggable prompt templates / personas

See the [open issues](https://github.com/SedarOlmez94/clive/issues) for the
current list.

## Security

Clive edits files and can run shell commands (only with `--apply` +
`--allow-agent-commands`). Please review the [Security Policy](SECURITY.md)
before reporting a vulnerability, and **do not** open public issues for security
problems.

## License

Licensed under the [MIT License](LICENSE).

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in Clive by you shall be licensed as MIT, without any additional
terms or conditions.

## Acknowledgements

- [Ollama]https://ollama.com/ for making local model hosting effortless.
- [clap]https://github.com/clap-rs/clap for the ergonomic CLI framework.
- [reqwest]https://github.com/seanmonstar/reqwest, [serde]https://serde.rs/,
  [anyhow]https://github.com/dtolnay/anyhow, and
  [similar]https://github.com/mitsuhiko/similar for doing the heavy lifting.
- Everyone building and sharing open-source models. ❤️

---

If Clive is useful to you, please consider giving the repo a ⭐ — it helps others
discover the project.