1# Crush
2
3<p align="center">
4 <a href="https://stuff.charm.sh/crush/charm-crush.png"><img width="450" alt="Charm Crush Logo" src="https://github.com/user-attachments/assets/adc1a6f4-b284-4603-836c-59038caa2e8b" /></a><br />
5 <a href="https://github.com/charmbracelet/crush/releases"><img src="https://img.shields.io/github/release/charmbracelet/crush" alt="Latest Release"></a>
6 <a href="https://github.com/charmbracelet/crush/actions"><img src="https://github.com/charmbracelet/crush/actions/workflows/build.yml/badge.svg" alt="Build Status"></a>
7</p>
8
9<p align="center">Your new coding bestie, now available in your favourite terminal.<br />Your tools, your code, and your workflows, wired into your LLM of choice.</p>
10<p align="center">你的新编程伙伴,现在就在你最爱的终端中。<br />你的工具、代码和工作流,都与您选择的 LLM 模型紧密相连。</p>
11
12<p align="center"><img width="800" alt="Crush Demo" src="https://github.com/user-attachments/assets/58280caf-851b-470a-b6f7-d5c4ea8a1968" /></p>
13
14## Features
15
16- **Multi-Model:** choose from a wide range of LLMs or add your own via OpenAI- or Anthropic-compatible APIs
17- **Flexible:** switch LLMs mid-session while preserving context
18- **Session-Based:** maintain multiple work sessions and contexts per project
19- **LSP-Enhanced:** Crush uses LSPs for additional context, just like you do
20- **Extensible:** add capabilities via MCPs (`http`, `stdio`, and `sse`)
21- **Works Everywhere:** first-class support in every terminal on macOS, Linux, Windows (PowerShell and WSL), FreeBSD, OpenBSD, and NetBSD
22
23## Installation
24
25Use a package manager:
26
27```bash
28# Homebrew
29brew install charmbracelet/tap/crush
30
31# NPM
32npm install -g @charmland/crush
33
34# Arch Linux (btw)
35yay -S crush-bin
36
37# Nix
38nix run github:numtide/nix-ai-tools#crush
39```
40
41Windows users:
42
43```bash
44# Winget
45winget install charmbracelet.crush
46
47# Scoop
48scoop bucket add charm https://github.com/charmbracelet/scoop-bucket.git
49scoop install crush
50```
51
52<details>
53<summary><strong>Nix (NUR)</strong></summary>
54
55Crush is available via [NUR](https://github.com/nix-community/NUR) in `nur.repos.charmbracelet.crush`.
56
57You can also try out Crush via `nix-shell`:
58
59```bash
60# Add the NUR channel.
61nix-channel --add https://github.com/nix-community/NUR/archive/main.tar.gz nur
62nix-channel --update
63
64# Get Crush in a Nix shell.
65nix-shell -p '(import <nur> { pkgs = import <nixpkgs> {}; }).repos.charmbracelet.crush'
66```
67
68### NixOS & Home Manager Module Usage via NUR
69
70Crush provides NixOS and Home Manager modules via NUR.
71You can use these modules directly in your flake by importing them from NUR. Since it auto detects whether its a home manager or nixos context you can use the import the exact same way :)
72
73```nix
74{
75 inputs = {
76 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
77 nur.url = "github:nix-community/NUR";
78 };
79
80 outputs = { self, nixpkgs, nur, ... }: {
81 nixosConfigurations.your-hostname = nixpkgs.lib.nixosSystem {
82 system = "x86_64-linux";
83 modules = [
84 nur.modules.nixos.default
85 nur.repos.charmbracelet.modules.crush
86 {
87 programs.crush = {
88 enable = true;
89 settings = {
90 providers = {
91 openai = {
92 id = "openai";
93 name = "OpenAI";
94 base_url = "https://api.openai.com/v1";
95 type = "openai";
96 api_key = "sk-fake123456789abcdef...";
97 models = [
98 {
99 id = "gpt-4";
100 name = "GPT-4";
101 }
102 ];
103 };
104 };
105 lsp = {
106 go = { command = "gopls"; enabled = true; };
107 nix = { command = "nil"; enabled = true; };
108 };
109 options = {
110 context_paths = [ "/etc/nixos/configuration.nix" ];
111 tui = { compact_mode = true; };
112 debug = false;
113 };
114 };
115 };
116 }
117 ];
118 };
119 };
120}
121```
122
123</details>
124
125<details>
126<summary><strong>Debian/Ubuntu</strong></summary>
127
128```bash
129sudo mkdir -p /etc/apt/keyrings
130curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/charm.gpg
131echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list
132sudo apt update && sudo apt install crush
133```
134
135</details>
136
137<details>
138<summary><strong>Fedora/RHEL</strong></summary>
139
140```bash
141echo '[charm]
142name=Charm
143baseurl=https://repo.charm.sh/yum/
144enabled=1
145gpgcheck=1
146gpgkey=https://repo.charm.sh/yum/gpg.key' | sudo tee /etc/yum.repos.d/charm.repo
147sudo yum install crush
148```
149
150</details>
151
152Or, download it:
153
154- [Packages][releases] are available in Debian and RPM formats
155- [Binaries][releases] are available for Linux, macOS, Windows, FreeBSD, OpenBSD, and NetBSD
156
157[releases]: https://github.com/charmbracelet/crush/releases
158
159Or just install it with Go:
160
161```
162go install github.com/charmbracelet/crush@latest
163```
164
165> [!WARNING]
166> Productivity may increase when using Crush and you may find yourself nerd
167> sniped when first using the application. If the symptoms persist, join the
168> [Discord][discord] and nerd snipe the rest of us.
169
170## Getting Started
171
172The quickest way to get started is to grab an API key for your preferred
173provider such as Anthropic, OpenAI, Groq, or OpenRouter and just start
174Crush. You'll be prompted to enter your API key.
175
176That said, you can also set environment variables for preferred providers.
177
178| Environment Variable | Provider |
179| --------------------------- | -------------------------------------------------- |
180| `ANTHROPIC_API_KEY` | Anthropic |
181| `OPENAI_API_KEY` | OpenAI |
182| `OPENROUTER_API_KEY` | OpenRouter |
183| `CEREBRAS_API_KEY` | Cerebras |
184| `GEMINI_API_KEY` | Google Gemini |
185| `VERTEXAI_PROJECT` | Google Cloud VertexAI (Gemini) |
186| `VERTEXAI_LOCATION` | Google Cloud VertexAI (Gemini) |
187| `GROQ_API_KEY` | Groq |
188| `AWS_ACCESS_KEY_ID` | AWS Bedrock (Claude) |
189| `AWS_SECRET_ACCESS_KEY` | AWS Bedrock (Claude) |
190| `AWS_REGION` | AWS Bedrock (Claude) |
191| `AWS_PROFILE` | Custom AWS Profile |
192| `AWS_REGION` | AWS Region |
193| `AZURE_OPENAI_API_ENDPOINT` | Azure OpenAI models |
194| `AZURE_OPENAI_API_KEY` | Azure OpenAI models (optional when using Entra ID) |
195| `AZURE_OPENAI_API_VERSION` | Azure OpenAI models |
196
197### By the Way
198
199Is there a provider you’d like to see in Crush? Is there an existing model that needs an update?
200
201Crush’s default model listing is managed in [Catwalk](https://github.com/charmbracelet/catwalk), a community-supported, open source repository of Crush-compatible models, and you’re welcome to contribute.
202
203<a href="https://github.com/charmbracelet/catwalk"><img width="174" height="174" alt="Catwalk Badge" src="https://github.com/user-attachments/assets/95b49515-fe82-4409-b10d-5beb0873787d" /></a>
204
205## Configuration
206
207Crush runs great with no configuration. That said, if you do need or want to
208customize Crush, configuration can be added either local to the project itself,
209or globally, with the following priority:
210
2111. `.crush.json`
2122. `crush.json`
2133. `$HOME/.config/crush/crush.json` (Windows: `%USERPROFILE%\AppData\Local\crush\crush.json`)
214
215Configuration itself is stored as a JSON object:
216
217```json
218{
219 "this-setting": { "this": "that" },
220 "that-setting": ["ceci", "cela"]
221}
222```
223
224As an additional note, Crush also stores ephemeral data, such as application state, in one additional location:
225
226```bash
227# Unix
228$HOME/.local/share/crush/crush.json
229
230# Windows
231%LOCALAPPDATA%\crush\crush.json
232```
233
234### LSPs
235
236Crush can use LSPs for additional context to help inform its decisions, just
237like you would. LSPs can be added manually like so:
238
239```json
240{
241 "$schema": "https://charm.land/crush.json",
242 "lsp": {
243 "go": {
244 "command": "gopls",
245 "env": {
246 "GOTOOLCHAIN": "go1.24.5"
247 }
248 },
249 "typescript": {
250 "command": "typescript-language-server",
251 "args": ["--stdio"]
252 },
253 "nix": {
254 "command": "nil"
255 }
256 }
257}
258```
259
260### MCPs
261
262Crush also supports Model Context Protocol (MCP) servers through three
263transport types: `stdio` for command-line servers, `http` for HTTP endpoints,
264and `sse` for Server-Sent Events. Environment variable expansion is supported
265using `$(echo $VAR)` syntax.
266
267```json
268{
269 "$schema": "https://charm.land/crush.json",
270 "mcp": {
271 "filesystem": {
272 "type": "stdio",
273 "command": "node",
274 "args": ["/path/to/mcp-server.js"],
275 "timeout": 120,
276 "disabled": false,
277 "env": {
278 "NODE_ENV": "production"
279 }
280 },
281 "github": {
282 "type": "http",
283 "url": "https://example.com/mcp/",
284 "timeout": 120,
285 "disabled": false,
286 "headers": {
287 "Authorization": "$(echo Bearer $EXAMPLE_MCP_TOKEN)"
288 }
289 },
290 "streaming-service": {
291 "type": "sse",
292 "url": "https://example.com/mcp/sse",
293 "timeout": 120,
294 "disabled": false,
295 "headers": {
296 "API-Key": "$(echo $API_KEY)"
297 }
298 }
299 }
300}
301```
302
303### Ignoring Files
304
305Crush respects `.gitignore` files by default, but you can also create a
306`.crushignore` file to specify additional files and directories that Crush
307should ignore. This is useful for excluding files that you want in version
308control but don't want Crush to consider when providing context.
309
310The `.crushignore` file uses the same syntax as `.gitignore` and can be placed
311in the root of your project or in subdirectories.
312
313### Allowing Tools
314
315By default, Crush will ask you for permission before running tool calls. If
316you'd like, you can allow tools to be executed without prompting you for
317permissions. Use this with care.
318
319```json
320{
321 "$schema": "https://charm.land/crush.json",
322 "permissions": {
323 "allowed_tools": [
324 "view",
325 "ls",
326 "grep",
327 "edit",
328 "mcp_context7_get-library-doc"
329 ]
330 }
331}
332```
333
334You can also skip all permission prompts entirely by running Crush with the
335`--yolo` flag. Be very, very careful with this feature.
336
337### Attribution Settings
338
339By default, Crush adds attribution information to Git commits and pull requests
340it creates. You can customize this behavior with the `attribution` option:
341
342```json
343{
344 "$schema": "https://charm.land/crush.json",
345 "options": {
346 "attribution": {
347 "co_authored_by": true,
348 "generated_with": true
349 }
350 }
351}
352```
353
354- `co_authored_by`: When true (default), adds `Co-Authored-By: Crush <crush@charm.land>` to commit messages
355- `generated_with`: When true (default), adds `💘 Generated with Crush` line to commit messages and PR descriptions
356
357### Local Models
358
359Local models can also be configured via OpenAI-compatible API. Here are two common examples:
360
361#### Ollama
362
363```json
364{
365 "providers": {
366 "ollama": {
367 "name": "Ollama",
368 "base_url": "http://localhost:11434/v1/",
369 "type": "openai",
370 "models": [
371 {
372 "name": "Qwen 3 30B",
373 "id": "qwen3:30b",
374 "context_window": 256000,
375 "default_max_tokens": 20000
376 }
377 ]
378 }
379 }
380}
381```
382
383#### LM Studio
384
385```json
386{
387 "providers": {
388 "lmstudio": {
389 "name": "LM Studio",
390 "base_url": "http://localhost:1234/v1/",
391 "type": "openai",
392 "models": [
393 {
394 "name": "Qwen 3 30B",
395 "id": "qwen/qwen3-30b-a3b-2507",
396 "context_window": 256000,
397 "default_max_tokens": 20000
398 }
399 ]
400 }
401 }
402}
403```
404
405### Custom Providers
406
407Crush supports custom provider configurations for both OpenAI-compatible and
408Anthropic-compatible APIs.
409
410#### OpenAI-Compatible APIs
411
412Here’s an example configuration for Deepseek, which uses an OpenAI-compatible
413API. Don't forget to set `DEEPSEEK_API_KEY` in your environment.
414
415```json
416{
417 "$schema": "https://charm.land/crush.json",
418 "providers": {
419 "deepseek": {
420 "type": "openai",
421 "base_url": "https://api.deepseek.com/v1",
422 "api_key": "$DEEPSEEK_API_KEY",
423 "models": [
424 {
425 "id": "deepseek-chat",
426 "name": "Deepseek V3",
427 "cost_per_1m_in": 0.27,
428 "cost_per_1m_out": 1.1,
429 "cost_per_1m_in_cached": 0.07,
430 "cost_per_1m_out_cached": 1.1,
431 "context_window": 64000,
432 "default_max_tokens": 5000
433 }
434 ]
435 }
436 }
437}
438```
439
440#### Anthropic-Compatible APIs
441
442Custom Anthropic-compatible providers follow this format:
443
444```json
445{
446 "$schema": "https://charm.land/crush.json",
447 "providers": {
448 "custom-anthropic": {
449 "type": "anthropic",
450 "base_url": "https://api.anthropic.com/v1",
451 "api_key": "$ANTHROPIC_API_KEY",
452 "extra_headers": {
453 "anthropic-version": "2023-06-01"
454 },
455 "models": [
456 {
457 "id": "claude-sonnet-4-20250514",
458 "name": "Claude Sonnet 4",
459 "cost_per_1m_in": 3,
460 "cost_per_1m_out": 15,
461 "cost_per_1m_in_cached": 3.75,
462 "cost_per_1m_out_cached": 0.3,
463 "context_window": 200000,
464 "default_max_tokens": 50000,
465 "can_reason": true,
466 "supports_attachments": true
467 }
468 ]
469 }
470 }
471}
472```
473
474### Amazon Bedrock
475
476Crush currently supports running Anthropic models through Bedrock, with caching disabled.
477
478- A Bedrock provider will appear once you have AWS configured, i.e. `aws configure`
479- Crush also expects the `AWS_REGION` or `AWS_DEFAULT_REGION` to be set
480- To use a specific AWS profile set `AWS_PROFILE` in your environment, i.e. `AWS_PROFILE=myprofile crush`
481
482### Vertex AI Platform
483
484Vertex AI will appear in the list of available providers when `VERTEXAI_PROJECT` and `VERTEXAI_LOCATION` are set. You will also need to be authenticated:
485
486```bash
487gcloud auth application-default login
488```
489
490To add specific models to the configuration, configure as such:
491
492```json
493{
494 "$schema": "https://charm.land/crush.json",
495 "providers": {
496 "vertexai": {
497 "models": [
498 {
499 "id": "claude-sonnet-4@20250514",
500 "name": "VertexAI Sonnet 4",
501 "cost_per_1m_in": 3,
502 "cost_per_1m_out": 15,
503 "cost_per_1m_in_cached": 3.75,
504 "cost_per_1m_out_cached": 0.3,
505 "context_window": 200000,
506 "default_max_tokens": 50000,
507 "can_reason": true,
508 "supports_attachments": true
509 }
510 ]
511 }
512 }
513}
514```
515
516## Logging
517
518Sometimes you need to look at logs. Luckily, Crush logs all sorts of
519stuff. Logs are stored in `./.crush/logs/crush.log` relative to the project.
520
521The CLI also contains some helper commands to make perusing recent logs easier:
522
523```bash
524# Print the last 1000 lines
525crush logs
526
527# Print the last 500 lines
528crush logs --tail 500
529
530# Follow logs in real time
531crush logs --follow
532```
533
534Want more logging? Run `crush` with the `--debug` flag, or enable it in the
535config:
536
537```json
538{
539 "$schema": "https://charm.land/crush.json",
540 "options": {
541 "debug": true,
542 "debug_lsp": true
543 }
544}
545```
546
547## Disabling Provider Auto-Updates
548
549By default, Crush automatically checks for the latest and greatest list of
550providers and models from [Catwalk](https://github.com/charmbracelet/catwalk),
551the open source Crush provider database. This means that when new providers and
552models are available, or when model metadata changes, Crush automatically
553updates your local configuration.
554
555For those with restricted internet access, or those who prefer to work in
556air-gapped environments, this might not be want you want, and this feature can
557be disabled.
558
559To disable automatic provider updates, set `disable_provider_auto_update` into
560your `crush.json` config:
561
562```json
563{
564 "$schema": "https://charm.land/crush.json",
565 "options": {
566 "disable_provider_auto_update": true
567 }
568}
569```
570
571Or set the `CRUSH_DISABLE_PROVIDER_AUTO_UPDATE` environment variable:
572
573```bash
574export CRUSH_DISABLE_PROVIDER_AUTO_UPDATE=1
575```
576
577### Manually updating providers
578
579Manually updating providers is possible with the `crush update-providers`
580command:
581
582```bash
583# Update providers remotely from Catwalk.
584crush update-providers
585
586# Update providers from a custom Catwalk base URL.
587crush update-providers https://example.com/
588
589# Update providers from a local file.
590crush update-providers /path/to/local-providers.json
591
592# Reset providers to the embedded version, embedded at crush at build time.
593crush update-providers embedded
594
595# For more info:
596crush update-providers --help
597```
598
599## A Note on Claude Max and GitHub Copilot
600
601Crush only supports model providers through official, compliant APIs. We do not
602support or endorse any methods that rely on personal Claude Max and GitHub
603Copilot accounts or OAuth workarounds, which violate Anthropic and
604Microsoft’s Terms of Service.
605
606We’re committed to building sustainable, trusted integrations with model
607providers. If you’re a provider interested in working with us,
608[reach out](mailto:vt100@charm.sh).
609
610## Contributing
611
612See the [contributing guide](https://github.com/charmbracelet/crush?tab=contributing-ov-file#contributing).
613
614## Whatcha think?
615
616We’d love to hear your thoughts on this project. Need help? We gotchu. You can find us on:
617
618- [Twitter](https://twitter.com/charmcli)
619- [Discord][discord]
620- [Slack](https://charm.land/slack)
621- [The Fediverse](https://mastodon.social/@charmcli)
622- [Bluesky](https://bsky.app/profile/charm.land)
623
624[discord]: https://charm.land/discord
625
626## License
627
628[FSL-1.1-MIT](https://github.com/charmbracelet/crush/raw/main/LICENSE.md)
629
630---
631
632Part of [Charm](https://charm.land).
633
634<a href="https://charm.land/"><img alt="The Charm logo" width="400" src="https://stuff.charm.sh/charm-banner-next.jpg" /></a>
635
636<!--prettier-ignore-->
637Charm热爱开源 • Charm loves open source