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/cf8ca3ce-8b02-43f0-9d0f-5a331488da4b" /></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), Android, FreeBSD, OpenBSD, and NetBSD
22- **Industrial Grade:** built on the Charm ecosystem, powering 25k+ applications, from leading open source projects to business-critical infrastructure
23
24## Installation
25
26Use a package manager:
27
28```bash
29# Homebrew
30brew install charmbracelet/tap/crush
31
32# NPM
33npm install -g @charmland/crush
34
35# Arch Linux (btw)
36yay -S crush-bin
37
38# Nix
39nix run github:numtide/nix-ai-tools#crush
40
41# FreeBSD
42pkg install crush
43```
44
45Windows users:
46
47```bash
48# Winget
49winget install charmbracelet.crush
50
51# Scoop
52scoop bucket add charm https://github.com/charmbracelet/scoop-bucket.git
53scoop install crush
54```
55
56<details>
57<summary><strong>Nix (NUR)</strong></summary>
58
59Crush is available via the official Charm [NUR](https://github.com/nix-community/NUR) in `nur.repos.charmbracelet.crush`, which is the most up-to-date way to get Crush in Nix.
60
61You can also try out Crush via the NUR with `nix-shell`:
62
63```bash
64# Add the NUR channel.
65nix-channel --add https://github.com/nix-community/NUR/archive/main.tar.gz nur
66nix-channel --update
67
68# Get Crush in a Nix shell.
69nix-shell -p '(import <nur> { pkgs = import <nixpkgs> {}; }).repos.charmbracelet.crush'
70```
71
72### NixOS & Home Manager Module Usage via NUR
73
74Crush provides NixOS and Home Manager modules via NUR.
75You 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 :)
76
77```nix
78{
79 inputs = {
80 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
81 nur.url = "github:nix-community/NUR";
82 };
83
84 outputs = { self, nixpkgs, nur, ... }: {
85 nixosConfigurations.your-hostname = nixpkgs.lib.nixosSystem {
86 system = "x86_64-linux";
87 modules = [
88 nur.modules.nixos.default
89 nur.repos.charmbracelet.modules.crush
90 {
91 programs.crush = {
92 enable = true;
93 settings = {
94 providers = {
95 openai = {
96 id = "openai";
97 name = "OpenAI";
98 base_url = "https://api.openai.com/v1";
99 type = "openai";
100 api_key = "sk-fake123456789abcdef...";
101 models = [
102 {
103 id = "gpt-4";
104 name = "GPT-4";
105 }
106 ];
107 };
108 };
109 lsp = {
110 go = { command = "gopls"; enabled = true; };
111 nix = { command = "nil"; enabled = true; };
112 };
113 options = {
114 context_paths = [ "/etc/nixos/configuration.nix" ];
115 tui = { compact_mode = true; };
116 debug = false;
117 };
118 };
119 };
120 }
121 ];
122 };
123 };
124}
125```
126
127</details>
128
129<details>
130<summary><strong>Debian/Ubuntu</strong></summary>
131
132```bash
133sudo mkdir -p /etc/apt/keyrings
134curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/charm.gpg
135echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list
136sudo apt update && sudo apt install crush
137```
138
139</details>
140
141<details>
142<summary><strong>Fedora/RHEL</strong></summary>
143
144```bash
145echo '[charm]
146name=Charm
147baseurl=https://repo.charm.sh/yum/
148enabled=1
149gpgcheck=1
150gpgkey=https://repo.charm.sh/yum/gpg.key' | sudo tee /etc/yum.repos.d/charm.repo
151sudo yum install crush
152```
153
154</details>
155
156Or, download it:
157
158- [Packages][releases] are available in Debian and RPM formats
159- [Binaries][releases] are available for Linux, macOS, Windows, FreeBSD, OpenBSD, and NetBSD
160
161[releases]: https://github.com/charmbracelet/crush/releases
162
163Or just install it with Go:
164
165```
166go install github.com/charmbracelet/crush@latest
167```
168
169> [!WARNING]
170> Productivity may increase when using Crush and you may find yourself nerd
171> sniped when first using the application. If the symptoms persist, join the
172> [Discord][discord] and nerd snipe the rest of us.
173
174## Getting Started
175
176The quickest way to get started is to grab an API key for your preferred
177provider such as Anthropic, OpenAI, Groq, OpenRouter, or Vercel AI Gateway and just start
178Crush. You'll be prompted to enter your API key.
179
180That said, you can also set environment variables for preferred providers.
181
182| Environment Variable | Provider |
183| --------------------------- | -------------------------------------------------- |
184| `ANTHROPIC_API_KEY` | Anthropic |
185| `OPENAI_API_KEY` | OpenAI |
186| `VERCEL_API_KEY` | Vercel AI Gateway |
187| `GEMINI_API_KEY` | Google Gemini |
188| `SYNTHETIC_API_KEY` | Synthetic |
189| `ZAI_API_KEY` | Z.ai |
190| `HF_TOKEN` | Hugging Face Inference |
191| `CEREBRAS_API_KEY` | Cerebras |
192| `OPENROUTER_API_KEY` | OpenRouter |
193| `GROQ_API_KEY` | Groq |
194| `VERTEXAI_PROJECT` | Google Cloud VertexAI (Gemini) |
195| `VERTEXAI_LOCATION` | Google Cloud VertexAI (Gemini) |
196| `AWS_ACCESS_KEY_ID` | Amazon Bedrock (Claude) |
197| `AWS_SECRET_ACCESS_KEY` | Amazon Bedrock (Claude) |
198| `AWS_REGION` | Amazon Bedrock (Claude) |
199| `AWS_PROFILE` | Amazon Bedrock (Custom Profile) |
200| `AWS_BEARER_TOKEN_BEDROCK` | Amazon Bedrock |
201| `AZURE_OPENAI_API_ENDPOINT` | Azure OpenAI models |
202| `AZURE_OPENAI_API_KEY` | Azure OpenAI models (optional when using Entra ID) |
203| `AZURE_OPENAI_API_VERSION` | Azure OpenAI models |
204
205### By the Way
206
207Is there a provider you’d like to see in Crush? Is there an existing model that needs an update?
208
209Crush’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.
210
211<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>
212
213## Configuration
214
215Crush runs great with no configuration. That said, if you do need or want to
216customize Crush, configuration can be added either local to the project itself,
217or globally, with the following priority:
218
2191. `.crush.json`
2202. `crush.json`
2213. `$HOME/.config/crush/crush.json`
222
223Configuration itself is stored as a JSON object:
224
225```json
226{
227 "this-setting": { "this": "that" },
228 "that-setting": ["ceci", "cela"]
229}
230```
231
232As an additional note, Crush also stores ephemeral data, such as application state, in one additional location:
233
234```bash
235# Unix
236$HOME/.local/share/crush/crush.json
237
238# Windows
239%LOCALAPPDATA%\crush\crush.json
240```
241
242> [!TIP]
243> You can override the user and data config locations by setting:
244> * `CRUSH_GLOBAL_CONFIG`
245> * `CRUSH_GLOBAL_DATA`
246
247### LSPs
248
249Crush can use LSPs for additional context to help inform its decisions, just
250like you would. LSPs can be added manually like so:
251
252```json
253{
254 "$schema": "https://charm.land/crush.json",
255 "lsp": {
256 "go": {
257 "command": "gopls",
258 "env": {
259 "GOTOOLCHAIN": "go1.24.5"
260 }
261 },
262 "typescript": {
263 "command": "typescript-language-server",
264 "args": ["--stdio"]
265 },
266 "nix": {
267 "command": "nil"
268 }
269 }
270}
271```
272
273### MCPs
274
275Crush also supports Model Context Protocol (MCP) servers through three
276transport types: `stdio` for command-line servers, `http` for HTTP endpoints,
277and `sse` for Server-Sent Events. Environment variable expansion is supported
278using `$(echo $VAR)` syntax.
279
280```json
281{
282 "$schema": "https://charm.land/crush.json",
283 "mcp": {
284 "filesystem": {
285 "type": "stdio",
286 "command": "node",
287 "args": ["/path/to/mcp-server.js"],
288 "timeout": 120,
289 "disabled": false,
290 "disabled_tools": ["some-tool-name"],
291 "env": {
292 "NODE_ENV": "production"
293 }
294 },
295 "github": {
296 "type": "http",
297 "url": "https://api.githubcopilot.com/mcp/",
298 "timeout": 120,
299 "disabled": false,
300 "disabled_tools": ["create_issue", "create_pull_request"],
301 "headers": {
302 "Authorization": "Bearer $GH_PAT"
303 }
304 },
305 "streaming-service": {
306 "type": "sse",
307 "url": "https://example.com/mcp/sse",
308 "timeout": 120,
309 "disabled": false,
310 "headers": {
311 "API-Key": "$(echo $API_KEY)"
312 }
313 }
314 }
315}
316```
317
318### Ignoring Files
319
320Crush respects `.gitignore` files by default, but you can also create a
321`.crushignore` file to specify additional files and directories that Crush
322should ignore. This is useful for excluding files that you want in version
323control but don't want Crush to consider when providing context.
324
325The `.crushignore` file uses the same syntax as `.gitignore` and can be placed
326in the root of your project or in subdirectories.
327
328### Allowing Tools
329
330By default, Crush will ask you for permission before running tool calls. If
331you'd like, you can allow tools to be executed without prompting you for
332permissions. Use this with care.
333
334```json
335{
336 "$schema": "https://charm.land/crush.json",
337 "permissions": {
338 "allowed_tools": [
339 "view",
340 "ls",
341 "grep",
342 "edit",
343 "mcp_context7_get-library-doc"
344 ]
345 }
346}
347```
348
349You can also skip all permission prompts entirely by running Crush with the
350`--yolo` flag. Be very, very careful with this feature.
351
352### Disabling Built-In Tools
353
354If you'd like to prevent Crush from using certain built-in tools entirely, you
355can disable them via the `options.disabled_tools` list. Disabled tools are
356completely hidden from the agent.
357
358```json
359{
360 "$schema": "https://charm.land/crush.json",
361 "options": {
362 "disabled_tools": [
363 "bash",
364 "sourcegraph"
365 ]
366 }
367}
368```
369
370To disable tools from MCP servers, see the [MCP config section](#mcps).
371
372### Agent Skills
373
374Crush supports the [Agent Skills](https://agentskills.io) open standard for
375extending agent capabilities with reusable skill packages. Skills are folders
376containing a `SKILL.md` file with instructions that Crush can discover and
377activate on demand.
378
379Skills are discovered from:
380
381- `~/.config/crush/skills/` on Unix (default, can be overridden with `CRUSH_SKILLS_DIR`)
382- `%LOCALAPPDATA%\crush\skills\` on Windows (default, can be overridden with `CRUSH_SKILLS_DIR`)
383- Additional paths configured via `options.skills_paths`
384
385```jsonc
386{
387 "$schema": "https://charm.land/crush.json",
388 "options": {
389 "skills_paths": [
390 "~/.config/crush/skills", // Windows: "%LOCALAPPDATA%\\crush\\skills",
391 "./project-skills"
392 ]
393 }
394}
395```
396
397You can get started with example skills from [anthropics/skills](https://github.com/anthropics/skills):
398
399```bash
400# Unix
401mkdir -p ~/.config/crush/skills
402cd ~/.config/crush/skills
403git clone https://github.com/anthropics/skills.git _temp
404mv _temp/skills/* . && rm -rf _temp
405```
406
407```powershell
408# Windows (PowerShell)
409mkdir -Force "$env:LOCALAPPDATA\crush\skills"
410cd "$env:LOCALAPPDATA\crush\skills"
411git clone https://github.com/anthropics/skills.git _temp
412mv _temp/skills/* . ; rm -r -force _temp
413```
414
415### Initialization
416
417When you initialize a project, Crush analyzes your codebase and creates
418a context file that helps it work more effectively in future sessions.
419By default, this file is named `AGENTS.md`, but you can customize the
420name and location with the `initialize_as` option:
421
422```json
423{
424 "$schema": "https://charm.land/crush.json",
425 "options": {
426 "initialize_as": "AGENTS.md"
427 }
428}
429```
430
431This is useful if you prefer a different naming convention or want to
432place the file in a specific directory (e.g., `CRUSH.md` or
433`docs/LLMs.md`). Crush will fill the file with project-specific context
434like build commands, code patterns, and conventions it discovered during
435initialization.
436
437### Attribution Settings
438
439By default, Crush adds attribution information to Git commits and pull requests
440it creates. You can customize this behavior with the `attribution` option:
441
442```json
443{
444 "$schema": "https://charm.land/crush.json",
445 "options": {
446 "attribution": {
447 "trailer_style": "co-authored-by",
448 "generated_with": true
449 }
450 }
451}
452```
453
454- `trailer_style`: Controls the attribution trailer added to commit messages
455 (default: `assisted-by`)
456 - `assisted-by`: Adds `Assisted-by: [Model Name] via Crush <crush@charm.land>`
457 (includes the model name)
458 - `co-authored-by`: Adds `Co-Authored-By: Crush <crush@charm.land>`
459 - `none`: No attribution trailer
460- `generated_with`: When true (default), adds `💘 Generated with Crush` line to
461 commit messages and PR descriptions
462
463### Custom Providers
464
465Crush supports custom provider configurations for both OpenAI-compatible and
466Anthropic-compatible APIs.
467
468> [!NOTE]
469> Note that we support two "types" for OpenAI. Make sure to choose the right one
470> to ensure the best experience!
471> * `openai` should be used when proxying or routing requests through OpenAI.
472> * `openai-compat` should be used when using non-OpenAI providers that have OpenAI-compatible APIs.
473
474#### OpenAI-Compatible APIs
475
476Here’s an example configuration for Deepseek, which uses an OpenAI-compatible
477API. Don't forget to set `DEEPSEEK_API_KEY` in your environment.
478
479```json
480{
481 "$schema": "https://charm.land/crush.json",
482 "providers": {
483 "deepseek": {
484 "type": "openai-compat",
485 "base_url": "https://api.deepseek.com/v1",
486 "api_key": "$DEEPSEEK_API_KEY",
487 "models": [
488 {
489 "id": "deepseek-chat",
490 "name": "Deepseek V3",
491 "cost_per_1m_in": 0.27,
492 "cost_per_1m_out": 1.1,
493 "cost_per_1m_in_cached": 0.07,
494 "cost_per_1m_out_cached": 1.1,
495 "context_window": 64000,
496 "default_max_tokens": 5000
497 }
498 ]
499 }
500 }
501}
502```
503
504#### Anthropic-Compatible APIs
505
506Custom Anthropic-compatible providers follow this format:
507
508```json
509{
510 "$schema": "https://charm.land/crush.json",
511 "providers": {
512 "custom-anthropic": {
513 "type": "anthropic",
514 "base_url": "https://api.anthropic.com/v1",
515 "api_key": "$ANTHROPIC_API_KEY",
516 "extra_headers": {
517 "anthropic-version": "2023-06-01"
518 },
519 "models": [
520 {
521 "id": "claude-sonnet-4-20250514",
522 "name": "Claude Sonnet 4",
523 "cost_per_1m_in": 3,
524 "cost_per_1m_out": 15,
525 "cost_per_1m_in_cached": 3.75,
526 "cost_per_1m_out_cached": 0.3,
527 "context_window": 200000,
528 "default_max_tokens": 50000,
529 "can_reason": true,
530 "supports_attachments": true
531 }
532 ]
533 }
534 }
535}
536```
537
538### Amazon Bedrock
539
540Crush currently supports running Anthropic models through Bedrock, with caching disabled.
541
542- A Bedrock provider will appear once you have AWS configured, i.e. `aws configure`
543- Crush also expects the `AWS_REGION` or `AWS_DEFAULT_REGION` to be set
544- To use a specific AWS profile set `AWS_PROFILE` in your environment, i.e. `AWS_PROFILE=myprofile crush`
545- Alternatively to `aws configure`, you can also just set `AWS_BEARER_TOKEN_BEDROCK`
546
547### Vertex AI Platform
548
549Vertex AI will appear in the list of available providers when `VERTEXAI_PROJECT` and `VERTEXAI_LOCATION` are set. You will also need to be authenticated:
550
551```bash
552gcloud auth application-default login
553```
554
555To add specific models to the configuration, configure as such:
556
557```json
558{
559 "$schema": "https://charm.land/crush.json",
560 "providers": {
561 "vertexai": {
562 "models": [
563 {
564 "id": "claude-sonnet-4@20250514",
565 "name": "VertexAI Sonnet 4",
566 "cost_per_1m_in": 3,
567 "cost_per_1m_out": 15,
568 "cost_per_1m_in_cached": 3.75,
569 "cost_per_1m_out_cached": 0.3,
570 "context_window": 200000,
571 "default_max_tokens": 50000,
572 "can_reason": true,
573 "supports_attachments": true
574 }
575 ]
576 }
577 }
578}
579```
580
581### Local Models
582
583Local models can also be configured via OpenAI-compatible API. Here are two common examples:
584
585#### Ollama
586
587```json
588{
589 "providers": {
590 "ollama": {
591 "name": "Ollama",
592 "base_url": "http://localhost:11434/v1/",
593 "type": "openai-compat",
594 "models": [
595 {
596 "name": "Qwen 3 30B",
597 "id": "qwen3:30b",
598 "context_window": 256000,
599 "default_max_tokens": 20000
600 }
601 ]
602 }
603 }
604}
605```
606
607#### LM Studio
608
609```json
610{
611 "providers": {
612 "lmstudio": {
613 "name": "LM Studio",
614 "base_url": "http://localhost:1234/v1/",
615 "type": "openai-compat",
616 "models": [
617 {
618 "name": "Qwen 3 30B",
619 "id": "qwen/qwen3-30b-a3b-2507",
620 "context_window": 256000,
621 "default_max_tokens": 20000
622 }
623 ]
624 }
625 }
626}
627```
628
629## Logging
630
631Sometimes you need to look at logs. Luckily, Crush logs all sorts of
632stuff. Logs are stored in `./.crush/logs/crush.log` relative to the project.
633
634The CLI also contains some helper commands to make perusing recent logs easier:
635
636```bash
637# Print the last 1000 lines
638crush logs
639
640# Print the last 500 lines
641crush logs --tail 500
642
643# Follow logs in real time
644crush logs --follow
645```
646
647Want more logging? Run `crush` with the `--debug` flag, or enable it in the
648config:
649
650```json
651{
652 "$schema": "https://charm.land/crush.json",
653 "options": {
654 "debug": true,
655 "debug_lsp": true
656 }
657}
658```
659
660## Provider Auto-Updates
661
662By default, Crush automatically checks for the latest and greatest list of
663providers and models from [Catwalk](https://github.com/charmbracelet/catwalk),
664the open source Crush provider database. This means that when new providers and
665models are available, or when model metadata changes, Crush automatically
666updates your local configuration.
667
668### Disabling automatic provider updates
669
670For those with restricted internet access, or those who prefer to work in
671air-gapped environments, this might not be want you want, and this feature can
672be disabled.
673
674To disable automatic provider updates, set `disable_provider_auto_update` into
675your `crush.json` config:
676
677```json
678{
679 "$schema": "https://charm.land/crush.json",
680 "options": {
681 "disable_provider_auto_update": true
682 }
683}
684```
685
686Or set the `CRUSH_DISABLE_PROVIDER_AUTO_UPDATE` environment variable:
687
688```bash
689export CRUSH_DISABLE_PROVIDER_AUTO_UPDATE=1
690```
691
692### Manually updating providers
693
694Manually updating providers is possible with the `crush update-providers`
695command:
696
697```bash
698# Update providers remotely from Catwalk.
699crush update-providers
700
701# Update providers from a custom Catwalk base URL.
702crush update-providers https://example.com/
703
704# Update providers from a local file.
705crush update-providers /path/to/local-providers.json
706
707# Reset providers to the embedded version, embedded at crush at build time.
708crush update-providers embedded
709
710# For more info:
711crush update-providers --help
712```
713
714## Metrics
715
716Crush records pseudonymous usage metrics (tied to a device-specific hash),
717which maintainers rely on to inform development and support priorities. The
718metrics include solely usage metadata; prompts and responses are NEVER
719collected.
720
721Details on exactly what’s collected are in the source code ([here](https://github.com/charmbracelet/crush/tree/main/internal/event)
722and [here](https://github.com/charmbracelet/crush/blob/main/internal/llm/agent/event.go)).
723
724You can opt out of metrics collection at any time by setting the environment
725variable by setting the following in your environment:
726
727```bash
728export CRUSH_DISABLE_METRICS=1
729```
730
731Or by setting the following in your config:
732
733```json
734{
735 "options": {
736 "disable_metrics": true
737 }
738}
739```
740
741Crush also respects the `DO_NOT_TRACK` convention which can be enabled via
742`export DO_NOT_TRACK=1`.
743
744## Contributing
745
746See the [contributing guide](https://github.com/charmbracelet/crush?tab=contributing-ov-file#contributing).
747
748## Whatcha think?
749
750We’d love to hear your thoughts on this project. Need help? We gotchu. You can find us on:
751
752- [Twitter](https://twitter.com/charmcli)
753- [Slack](https://charm.land/slack)
754- [Discord][discord]
755- [The Fediverse](https://mastodon.social/@charmcli)
756- [Bluesky](https://bsky.app/profile/charm.land)
757
758[discord]: https://charm.land/discord
759
760## License
761
762[FSL-1.1-MIT](https://github.com/charmbracelet/crush/raw/main/LICENSE.md)
763
764---
765
766Part of [Charm](https://charm.land).
767
768<a href="https://charm.land/"><img alt="The Charm logo" width="400" src="https://stuff.charm.sh/charm-banner-next.jpg" /></a>
769
770<!--prettier-ignore-->
771Charm热爱开源 • Charm loves open source