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| `GEMINI_API_KEY` | Google Gemini |
184| `CEREBRAS_API_KEY` | Cerebras |
185| `HF_TOKEN` | Huggingface Inference |
186| `VERTEXAI_PROJECT` | Google Cloud VertexAI (Gemini) |
187| `VERTEXAI_LOCATION` | Google Cloud VertexAI (Gemini) |
188| `GROQ_API_KEY` | Groq |
189| `AWS_ACCESS_KEY_ID` | Amazon Bedrock (Claude) |
190| `AWS_SECRET_ACCESS_KEY` | Amazon Bedrock (Claude) |
191| `AWS_REGION` | Amazon Bedrock (Claude) |
192| `AWS_PROFILE` | Amazon Bedrock (Custom Profile) |
193| `AWS_BEARER_TOKEN_BEDROCK` | Amazon Bedrock |
194| `AZURE_OPENAI_API_ENDPOINT` | Azure OpenAI models |
195| `AZURE_OPENAI_API_KEY` | Azure OpenAI models (optional when using Entra ID) |
196| `AZURE_OPENAI_API_VERSION` | Azure OpenAI models |
197
198### By the Way
199
200Is there a provider you’d like to see in Crush? Is there an existing model that needs an update?
201
202Crush’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.
203
204<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>
205
206## Configuration
207
208Crush runs great with no configuration. That said, if you do need or want to
209customize Crush, configuration can be added either local to the project itself,
210or globally, with the following priority:
211
2121. `.crush.json`
2132. `crush.json`
2143. `$HOME/.config/crush/crush.json`
215
216Configuration itself is stored as a JSON object:
217
218```json
219{
220 "this-setting": { "this": "that" },
221 "that-setting": ["ceci", "cela"]
222}
223```
224
225As an additional note, Crush also stores ephemeral data, such as application state, in one additional location:
226
227```bash
228# Unix
229$HOME/.local/share/crush/crush.json
230
231# Windows
232%LOCALAPPDATA%\crush\crush.json
233```
234
235> [!TIP]
236> You can override the user and data config locations by setting:
237> * `CRUSH_GLOBAL_CONFIG`
238> * `CRUSH_GLOBAL_DATA`
239
240### LSPs
241
242Crush can use LSPs for additional context to help inform its decisions, just
243like you would. LSPs can be added manually like so:
244
245```json
246{
247 "$schema": "https://charm.land/crush.json",
248 "lsp": {
249 "go": {
250 "command": "gopls",
251 "env": {
252 "GOTOOLCHAIN": "go1.24.5"
253 }
254 },
255 "typescript": {
256 "command": "typescript-language-server",
257 "args": ["--stdio"]
258 },
259 "nix": {
260 "command": "nil"
261 }
262 }
263}
264```
265
266### MCPs
267
268Crush also supports Model Context Protocol (MCP) servers through three
269transport types: `stdio` for command-line servers, `http` for HTTP endpoints,
270and `sse` for Server-Sent Events. Environment variable expansion is supported
271using `$(echo $VAR)` syntax.
272
273```json
274{
275 "$schema": "https://charm.land/crush.json",
276 "mcp": {
277 "filesystem": {
278 "type": "stdio",
279 "command": "node",
280 "args": ["/path/to/mcp-server.js"],
281 "timeout": 120,
282 "disabled": false,
283 "disabled_tools": ["some-tool-name"],
284 "env": {
285 "NODE_ENV": "production"
286 }
287 },
288 "github": {
289 "type": "http",
290 "url": "https://api.githubcopilot.com/mcp/",
291 "timeout": 120,
292 "disabled": false,
293 "disabled_tools": ["create_issue", "create_pull_request"],
294 "headers": {
295 "Authorization": "Bearer $GH_PAT"
296 }
297 },
298 "streaming-service": {
299 "type": "sse",
300 "url": "https://example.com/mcp/sse",
301 "timeout": 120,
302 "disabled": false,
303 "headers": {
304 "API-Key": "$(echo $API_KEY)"
305 }
306 }
307 }
308}
309```
310
311### Ignoring Files
312
313Crush respects `.gitignore` files by default, but you can also create a
314`.crushignore` file to specify additional files and directories that Crush
315should ignore. This is useful for excluding files that you want in version
316control but don't want Crush to consider when providing context.
317
318The `.crushignore` file uses the same syntax as `.gitignore` and can be placed
319in the root of your project or in subdirectories.
320
321### Allowing Tools
322
323By default, Crush will ask you for permission before running tool calls. If
324you'd like, you can allow tools to be executed without prompting you for
325permissions. Use this with care.
326
327```json
328{
329 "$schema": "https://charm.land/crush.json",
330 "permissions": {
331 "allowed_tools": [
332 "view",
333 "ls",
334 "grep",
335 "edit",
336 "mcp_context7_get-library-doc"
337 ]
338 }
339}
340```
341
342You can also skip all permission prompts entirely by running Crush with the
343`--yolo` flag. Be very, very careful with this feature.
344
345### Disabling Built-In Tools
346
347If you'd like to prevent Crush from using certain built-in tools entirely, you
348can disable them via the `options.disabled_tools` list. Disabled tools are
349completely hidden from the agent.
350
351```json
352{
353 "$schema": "https://charm.land/crush.json",
354 "options": {
355 "disabled_tools": [
356 "bash",
357 "sourcegraph"
358 ]
359 }
360}
361```
362
363To disable tools from MCP servers, see the [MCP config section](#mcps).
364
365### Agent Skills
366
367Crush supports the [Agent Skills](https://agentskills.io) open standard for
368extending agent capabilities with reusable skill packages. Skills are folders
369containing a `SKILL.md` file with instructions that Crush can discover and
370activate on demand.
371
372Skills are discovered from:
373
374- `~/.config/crush/skills/` on Unix (default, can be overridden with `CRUSH_SKILLS_DIR`)
375- `%LOCALAPPDATA%\crush\skills\` on Windows (default, can be overridden with `CRUSH_SKILLS_DIR`)
376- Additional paths configured via `options.skills_paths`
377
378```jsonc
379{
380 "$schema": "https://charm.land/crush.json",
381 "options": {
382 "skills_paths": [
383 "~/.config/crush/skills", // Windows: "%LOCALAPPDATA%\\crush\\skills",
384 "./project-skills"
385 ]
386 }
387}
388```
389
390You can get started with example skills from [anthropics/skills](https://github.com/anthropics/skills):
391
392```bash
393# Unix
394mkdir -p ~/.config/crush/skills
395cd ~/.config/crush/skills
396git clone https://github.com/anthropics/skills.git _temp
397mv _temp/skills/* . && rm -rf _temp
398```
399
400```powershell
401# Windows (PowerShell)
402mkdir -Force "$env:LOCALAPPDATA\crush\skills"
403cd "$env:LOCALAPPDATA\crush\skills"
404git clone https://github.com/anthropics/skills.git _temp
405mv _temp/skills/* . ; rm -r -force _temp
406```
407
408### Initialization
409
410When you initialize a project, Crush analyzes your codebase and creates
411a context file that helps it work more effectively in future sessions.
412By default, this file is named `AGENTS.md`, but you can customize the
413name and location with the `initialize_as` option:
414
415```json
416{
417 "$schema": "https://charm.land/crush.json",
418 "options": {
419 "initialize_as": "AGENTS.md"
420 }
421}
422```
423
424This is useful if you prefer a different naming convention or want to
425place the file in a specific directory (e.g., `CRUSH.md` or
426`docs/LLMs.md`). Crush will fill the file with project-specific context
427like build commands, code patterns, and conventions it discovered during
428initialization.
429
430### Attribution Settings
431
432By default, Crush adds attribution information to Git commits and pull requests
433it creates. You can customize this behavior with the `attribution` option:
434
435```json
436{
437 "$schema": "https://charm.land/crush.json",
438 "options": {
439 "attribution": {
440 "trailer_style": "co-authored-by",
441 "generated_with": true
442 }
443 }
444}
445```
446
447- `trailer_style`: Controls the attribution trailer added to commit messages
448 (default: `assisted-by`)
449 - `assisted-by`: Adds `Assisted-by: [Model Name] via Crush <crush@charm.land>`
450 (includes the model name)
451 - `co-authored-by`: Adds `Co-Authored-By: Crush <crush@charm.land>`
452 - `none`: No attribution trailer
453- `generated_with`: When true (default), adds `💘 Generated with Crush` line to
454 commit messages and PR descriptions
455
456### Custom Providers
457
458Crush supports custom provider configurations for both OpenAI-compatible and
459Anthropic-compatible APIs.
460
461> [!NOTE]
462> Note that we support two "types" for OpenAI. Make sure to choose the right one
463> to ensure the best experience!
464> * `openai` should be used when proxying or routing requests through OpenAI.
465> * `openai-compat` should be used when using non-OpenAI providers that have OpenAI-compatible APIs.
466
467#### OpenAI-Compatible APIs
468
469Here’s an example configuration for Deepseek, which uses an OpenAI-compatible
470API. Don't forget to set `DEEPSEEK_API_KEY` in your environment.
471
472```json
473{
474 "$schema": "https://charm.land/crush.json",
475 "providers": {
476 "deepseek": {
477 "type": "openai-compat",
478 "base_url": "https://api.deepseek.com/v1",
479 "api_key": "$DEEPSEEK_API_KEY",
480 "models": [
481 {
482 "id": "deepseek-chat",
483 "name": "Deepseek V3",
484 "cost_per_1m_in": 0.27,
485 "cost_per_1m_out": 1.1,
486 "cost_per_1m_in_cached": 0.07,
487 "cost_per_1m_out_cached": 1.1,
488 "context_window": 64000,
489 "default_max_tokens": 5000
490 }
491 ]
492 }
493 }
494}
495```
496
497#### Anthropic-Compatible APIs
498
499Custom Anthropic-compatible providers follow this format:
500
501```json
502{
503 "$schema": "https://charm.land/crush.json",
504 "providers": {
505 "custom-anthropic": {
506 "type": "anthropic",
507 "base_url": "https://api.anthropic.com/v1",
508 "api_key": "$ANTHROPIC_API_KEY",
509 "extra_headers": {
510 "anthropic-version": "2023-06-01"
511 },
512 "models": [
513 {
514 "id": "claude-sonnet-4-20250514",
515 "name": "Claude Sonnet 4",
516 "cost_per_1m_in": 3,
517 "cost_per_1m_out": 15,
518 "cost_per_1m_in_cached": 3.75,
519 "cost_per_1m_out_cached": 0.3,
520 "context_window": 200000,
521 "default_max_tokens": 50000,
522 "can_reason": true,
523 "supports_attachments": true
524 }
525 ]
526 }
527 }
528}
529```
530
531### Amazon Bedrock
532
533Crush currently supports running Anthropic models through Bedrock, with caching disabled.
534
535- A Bedrock provider will appear once you have AWS configured, i.e. `aws configure`
536- Crush also expects the `AWS_REGION` or `AWS_DEFAULT_REGION` to be set
537- To use a specific AWS profile set `AWS_PROFILE` in your environment, i.e. `AWS_PROFILE=myprofile crush`
538- Alternatively to `aws configure`, you can also just set `AWS_BEARER_TOKEN_BEDROCK`
539
540### Vertex AI Platform
541
542Vertex AI will appear in the list of available providers when `VERTEXAI_PROJECT` and `VERTEXAI_LOCATION` are set. You will also need to be authenticated:
543
544```bash
545gcloud auth application-default login
546```
547
548To add specific models to the configuration, configure as such:
549
550```json
551{
552 "$schema": "https://charm.land/crush.json",
553 "providers": {
554 "vertexai": {
555 "models": [
556 {
557 "id": "claude-sonnet-4@20250514",
558 "name": "VertexAI Sonnet 4",
559 "cost_per_1m_in": 3,
560 "cost_per_1m_out": 15,
561 "cost_per_1m_in_cached": 3.75,
562 "cost_per_1m_out_cached": 0.3,
563 "context_window": 200000,
564 "default_max_tokens": 50000,
565 "can_reason": true,
566 "supports_attachments": true
567 }
568 ]
569 }
570 }
571}
572```
573
574### Local Models
575
576Local models can also be configured via OpenAI-compatible API. Here are two common examples:
577
578#### Ollama
579
580```json
581{
582 "providers": {
583 "ollama": {
584 "name": "Ollama",
585 "base_url": "http://localhost:11434/v1/",
586 "type": "openai-compat",
587 "models": [
588 {
589 "name": "Qwen 3 30B",
590 "id": "qwen3:30b",
591 "context_window": 256000,
592 "default_max_tokens": 20000
593 }
594 ]
595 }
596 }
597}
598```
599
600#### LM Studio
601
602```json
603{
604 "providers": {
605 "lmstudio": {
606 "name": "LM Studio",
607 "base_url": "http://localhost:1234/v1/",
608 "type": "openai-compat",
609 "models": [
610 {
611 "name": "Qwen 3 30B",
612 "id": "qwen/qwen3-30b-a3b-2507",
613 "context_window": 256000,
614 "default_max_tokens": 20000
615 }
616 ]
617 }
618 }
619}
620```
621
622## Logging
623
624Sometimes you need to look at logs. Luckily, Crush logs all sorts of
625stuff. Logs are stored in `./.crush/logs/crush.log` relative to the project.
626
627The CLI also contains some helper commands to make perusing recent logs easier:
628
629```bash
630# Print the last 1000 lines
631crush logs
632
633# Print the last 500 lines
634crush logs --tail 500
635
636# Follow logs in real time
637crush logs --follow
638```
639
640Want more logging? Run `crush` with the `--debug` flag, or enable it in the
641config:
642
643```json
644{
645 "$schema": "https://charm.land/crush.json",
646 "options": {
647 "debug": true,
648 "debug_lsp": true
649 }
650}
651```
652
653## Provider Auto-Updates
654
655By default, Crush automatically checks for the latest and greatest list of
656providers and models from [Catwalk](https://github.com/charmbracelet/catwalk),
657the open source Crush provider database. This means that when new providers and
658models are available, or when model metadata changes, Crush automatically
659updates your local configuration.
660
661### Disabling automatic provider updates
662
663For those with restricted internet access, or those who prefer to work in
664air-gapped environments, this might not be want you want, and this feature can
665be disabled.
666
667To disable automatic provider updates, set `disable_provider_auto_update` into
668your `crush.json` config:
669
670```json
671{
672 "$schema": "https://charm.land/crush.json",
673 "options": {
674 "disable_provider_auto_update": true
675 }
676}
677```
678
679Or set the `CRUSH_DISABLE_PROVIDER_AUTO_UPDATE` environment variable:
680
681```bash
682export CRUSH_DISABLE_PROVIDER_AUTO_UPDATE=1
683```
684
685### Manually updating providers
686
687Manually updating providers is possible with the `crush update-providers`
688command:
689
690```bash
691# Update providers remotely from Catwalk.
692crush update-providers
693
694# Update providers from a custom Catwalk base URL.
695crush update-providers https://example.com/
696
697# Update providers from a local file.
698crush update-providers /path/to/local-providers.json
699
700# Reset providers to the embedded version, embedded at crush at build time.
701crush update-providers embedded
702
703# For more info:
704crush update-providers --help
705```
706
707## Metrics
708
709Crush records pseudonymous usage metrics (tied to a device-specific hash),
710which maintainers rely on to inform development and support priorities. The
711metrics include solely usage metadata; prompts and responses are NEVER
712collected.
713
714Details on exactly what’s collected are in the source code ([here](https://github.com/charmbracelet/crush/tree/main/internal/event)
715and [here](https://github.com/charmbracelet/crush/blob/main/internal/llm/agent/event.go)).
716
717You can opt out of metrics collection at any time by setting the environment
718variable by setting the following in your environment:
719
720```bash
721export CRUSH_DISABLE_METRICS=1
722```
723
724Or by setting the following in your config:
725
726```json
727{
728 "options": {
729 "disable_metrics": true
730 }
731}
732```
733
734Crush also respects the [`DO_NOT_TRACK`](https://consoledonottrack.com)
735convention which can be enabled via `export DO_NOT_TRACK=1`.
736
737## Contributing
738
739See the [contributing guide](https://github.com/charmbracelet/crush?tab=contributing-ov-file#contributing).
740
741## Whatcha think?
742
743We’d love to hear your thoughts on this project. Need help? We gotchu. You can find us on:
744
745- [Twitter](https://twitter.com/charmcli)
746- [Slack](https://charm.land/slack)
747- [Discord][discord]
748- [The Fediverse](https://mastodon.social/@charmcli)
749- [Bluesky](https://bsky.app/profile/charm.land)
750
751[discord]: https://charm.land/discord
752
753## License
754
755[FSL-1.1-MIT](https://github.com/charmbracelet/crush/raw/main/LICENSE.md)
756
757---
758
759Part of [Charm](https://charm.land).
760
761<a href="https://charm.land/"><img alt="The Charm logo" width="400" src="https://stuff.charm.sh/charm-banner-next.jpg" /></a>
762
763<!--prettier-ignore-->
764Charm热爱开源 • Charm loves open source