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