on 7aa191d help sign in
crush/README.md
783 lines 23 kB history raw
1# Crush
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>
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>
12<p align="center"><img width="800" alt="Crush Demo" src="https://github.com/user-attachments/assets/58280caf-851b-470a-b6f7-d5c4ea8a1968" /></p>
14## Features
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
24## Installation
26Use a package manager:
28```bash
29# Homebrew
30brew install charmbracelet/tap/crush
32# NPM
33npm install -g @charmland/crush
35# Arch Linux (btw)
36yay -S crush-bin
38# Nix
39nix run github:numtide/nix-ai-tools#crush
41# FreeBSD
42pkg install crush
43```
45Windows users:
47```bash
48# Winget
49winget install charmbracelet.crush
51# Scoop
52scoop bucket add charm https://github.com/charmbracelet/scoop-bucket.git
53scoop install crush
54```
56<details>
57<summary><strong>Nix (NUR)</strong></summary>
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.
61You can also try out Crush via the NUR with `nix-shell`:
63```bash
64# Add the NUR channel.
65nix-channel --add https://github.com/nix-community/NUR/archive/main.tar.gz nur
66nix-channel --update
68# Get Crush in a Nix shell.
69nix-shell -p '(import <nur> { pkgs = import <nixpkgs> {}; }).repos.charmbracelet.crush'
70```
72### NixOS & Home Manager Module Usage via NUR
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 :)
77```nix
79 inputs = {
80 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
81 nur.url = "github:nix-community/NUR";
82 };
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 };
125```
127</details>
129<details>
130<summary><strong>Debian/Ubuntu</strong></summary>
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```
139</details>
141<details>
142<summary><strong>Fedora/RHEL</strong></summary>
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```
154</details>
156Or, download it:
158- [Packages][releases] are available in Debian and RPM formats
159- [Binaries][releases] are available for Linux, macOS, Windows, FreeBSD, OpenBSD, and NetBSD
161[releases]: https://github.com/charmbracelet/crush/releases
163Or just install it with Go:
165```
166go install github.com/charmbracelet/crush@latest
167```
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.
174## Getting Started
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.
180That said, you can also set environment variables for preferred providers.
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| `MINIMAX_API_KEY` | MiniMax |
191| `HF_TOKEN` | Hugging Face Inference |
192| `CEREBRAS_API_KEY` | Cerebras |
193| `OPENROUTER_API_KEY` | OpenRouter |
194| `IONET_API_KEY` | io.net |
195| `GROQ_API_KEY` | Groq |
196| `VERTEXAI_PROJECT` | Google Cloud VertexAI (Gemini) |
197| `VERTEXAI_LOCATION` | Google Cloud VertexAI (Gemini) |
198| `AWS_ACCESS_KEY_ID` | Amazon Bedrock (Claude) |
199| `AWS_SECRET_ACCESS_KEY` | Amazon Bedrock (Claude) |
200| `AWS_REGION` | Amazon Bedrock (Claude) |
201| `AWS_PROFILE` | Amazon Bedrock (Custom Profile) |
202| `AWS_BEARER_TOKEN_BEDROCK` | Amazon Bedrock |
203| `AZURE_OPENAI_API_ENDPOINT` | Azure OpenAI models |
204| `AZURE_OPENAI_API_KEY` | Azure OpenAI models (optional when using Entra ID) |
205| `AZURE_OPENAI_API_VERSION` | Azure OpenAI models |
207### Subscriptions
209If you prefer subscription-based usage, here are some plans that work well in
210Crush:
212- [Synthetic](https://synthetic.new/pricing)
213- [GLM Coding Plan](https://z.ai/subscribe)
214- [Kimi Code](https://www.kimi.com/membership/pricing)
215- [MiniMax Coding Plan](https://platform.minimax.io/subscribe/coding-plan)
217### By the Way
219Is there a provider you’d like to see in Crush? Is there an existing model that needs an update?
221Crush’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.
223<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>
225## Configuration
227Crush runs great with no configuration. That said, if you do need or want to
228customize Crush, configuration can be added either local to the project itself,
229or globally, with the following priority:
2311. `.crush.json`
2322. `crush.json`
2333. `$HOME/.config/crush/crush.json`
235Configuration itself is stored as a JSON object:
237```json
239 "this-setting": { "this": "that" },
240 "that-setting": ["ceci", "cela"]
242```
244As an additional note, Crush also stores ephemeral data, such as application state, in one additional location:
246```bash
247# Unix
248$HOME/.local/share/crush/crush.json
250# Windows
251%LOCALAPPDATA%\crush\crush.json
252```
254> [!TIP]
255> You can override the user and data config locations by setting:
256> * `CRUSH_GLOBAL_CONFIG`
257> * `CRUSH_GLOBAL_DATA`
259### LSPs
261Crush can use LSPs for additional context to help inform its decisions, just
262like you would. LSPs can be added manually like so:
264```json
266 "$schema": "https://charm.land/crush.json",
267 "lsp": {
268 "go": {
269 "command": "gopls",
270 "env": {
271 "GOTOOLCHAIN": "go1.24.5"
272 }
273 },
274 "typescript": {
275 "command": "typescript-language-server",
276 "args": ["--stdio"]
277 },
278 "nix": {
279 "command": "nil"
280 }
281 }
283```
285### MCPs
287Crush also supports Model Context Protocol (MCP) servers through three
288transport types: `stdio` for command-line servers, `http` for HTTP endpoints,
289and `sse` for Server-Sent Events. Environment variable expansion is supported
290using `$(echo $VAR)` syntax.
292```json
294 "$schema": "https://charm.land/crush.json",
295 "mcp": {
296 "filesystem": {
297 "type": "stdio",
298 "command": "node",
299 "args": ["/path/to/mcp-server.js"],
300 "timeout": 120,
301 "disabled": false,
302 "disabled_tools": ["some-tool-name"],
303 "env": {
304 "NODE_ENV": "production"
305 }
306 },
307 "github": {
308 "type": "http",
309 "url": "https://api.githubcopilot.com/mcp/",
310 "timeout": 120,
311 "disabled": false,
312 "disabled_tools": ["create_issue", "create_pull_request"],
313 "headers": {
314 "Authorization": "Bearer $GH_PAT"
315 }
316 },
317 "streaming-service": {
318 "type": "sse",
319 "url": "https://example.com/mcp/sse",
320 "timeout": 120,
321 "disabled": false,
322 "headers": {
323 "API-Key": "$(echo $API_KEY)"
324 }
325 }
326 }
328```
330### Ignoring Files
332Crush respects `.gitignore` files by default, but you can also create a
333`.crushignore` file to specify additional files and directories that Crush
334should ignore. This is useful for excluding files that you want in version
335control but don't want Crush to consider when providing context.
337The `.crushignore` file uses the same syntax as `.gitignore` and can be placed
338in the root of your project or in subdirectories.
340### Allowing Tools
342By default, Crush will ask you for permission before running tool calls. If
343you'd like, you can allow tools to be executed without prompting you for
344permissions. Use this with care.
346```json
348 "$schema": "https://charm.land/crush.json",
349 "permissions": {
350 "allowed_tools": [
351 "view",
352 "ls",
353 "grep",
354 "edit",
355 "mcp_context7_get-library-doc"
356 ]
357 }
359```
361You can also skip all permission prompts entirely by running Crush with the
362`--yolo` flag. Be very, very careful with this feature.
364### Disabling Built-In Tools
366If you'd like to prevent Crush from using certain built-in tools entirely, you
367can disable them via the `options.disabled_tools` list. Disabled tools are
368completely hidden from the agent.
370```json
372 "$schema": "https://charm.land/crush.json",
373 "options": {
374 "disabled_tools": [
375 "bash",
376 "sourcegraph"
377 ]
378 }
380```
382To disable tools from MCP servers, see the [MCP config section](#mcps).
384### Agent Skills
386Crush supports the [Agent Skills](https://agentskills.io) open standard for
387extending agent capabilities with reusable skill packages. Skills are folders
388containing a `SKILL.md` file with instructions that Crush can discover and
389activate on demand.
391Skills are discovered from:
393- `~/.config/crush/skills/` on Unix (default, can be overridden with `CRUSH_SKILLS_DIR`)
394- `%LOCALAPPDATA%\crush\skills\` on Windows (default, can be overridden with `CRUSH_SKILLS_DIR`)
395- Additional paths configured via `options.skills_paths`
397```jsonc
399 "$schema": "https://charm.land/crush.json",
400 "options": {
401 "skills_paths": [
402 "~/.config/crush/skills", // Windows: "%LOCALAPPDATA%\\crush\\skills",
403 "./project-skills"
404 ]
405 }
407```
409You can get started with example skills from [anthropics/skills](https://github.com/anthropics/skills):
411```bash
412# Unix
413mkdir -p ~/.config/crush/skills
414cd ~/.config/crush/skills
415git clone https://github.com/anthropics/skills.git _temp
416mv _temp/skills/* . && rm -rf _temp
417```
419```powershell
420# Windows (PowerShell)
421mkdir -Force "$env:LOCALAPPDATA\crush\skills"
422cd "$env:LOCALAPPDATA\crush\skills"
423git clone https://github.com/anthropics/skills.git _temp
424mv _temp/skills/* . ; rm -r -force _temp
425```
427### Initialization
429When you initialize a project, Crush analyzes your codebase and creates
430a context file that helps it work more effectively in future sessions.
431By default, this file is named `AGENTS.md`, but you can customize the
432name and location with the `initialize_as` option:
434```json
436 "$schema": "https://charm.land/crush.json",
437 "options": {
438 "initialize_as": "AGENTS.md"
439 }
441```
443This is useful if you prefer a different naming convention or want to
444place the file in a specific directory (e.g., `CRUSH.md` or
445`docs/LLMs.md`). Crush will fill the file with project-specific context
446like build commands, code patterns, and conventions it discovered during
447initialization.
449### Attribution Settings
451By default, Crush adds attribution information to Git commits and pull requests
452it creates. You can customize this behavior with the `attribution` option:
454```json
456 "$schema": "https://charm.land/crush.json",
457 "options": {
458 "attribution": {
459 "trailer_style": "co-authored-by",
460 "generated_with": true
461 }
462 }
464```
466- `trailer_style`: Controls the attribution trailer added to commit messages
467 (default: `assisted-by`)
468 - `assisted-by`: Adds `Assisted-by: [Model Name] via Crush <crush@charm.land>`
469 (includes the model name)
470 - `co-authored-by`: Adds `Co-Authored-By: Crush <crush@charm.land>`
471 - `none`: No attribution trailer
472- `generated_with`: When true (default), adds `💘 Generated with Crush` line to
473 commit messages and PR descriptions
475### Custom Providers
477Crush supports custom provider configurations for both OpenAI-compatible and
478Anthropic-compatible APIs.
480> [!NOTE]
481> Note that we support two "types" for OpenAI. Make sure to choose the right one
482> to ensure the best experience!
483> * `openai` should be used when proxying or routing requests through OpenAI.
484> * `openai-compat` should be used when using non-OpenAI providers that have OpenAI-compatible APIs.
486#### OpenAI-Compatible APIs
488Here’s an example configuration for Deepseek, which uses an OpenAI-compatible
489API. Don't forget to set `DEEPSEEK_API_KEY` in your environment.
491```json
493 "$schema": "https://charm.land/crush.json",
494 "providers": {
495 "deepseek": {
496 "type": "openai-compat",
497 "base_url": "https://api.deepseek.com/v1",
498 "api_key": "$DEEPSEEK_API_KEY",
499 "models": [
500 {
501 "id": "deepseek-chat",
502 "name": "Deepseek V3",
503 "cost_per_1m_in": 0.27,
504 "cost_per_1m_out": 1.1,
505 "cost_per_1m_in_cached": 0.07,
506 "cost_per_1m_out_cached": 1.1,
507 "context_window": 64000,
508 "default_max_tokens": 5000
509 }
510 ]
511 }
512 }
514```
516#### Anthropic-Compatible APIs
518Custom Anthropic-compatible providers follow this format:
520```json
522 "$schema": "https://charm.land/crush.json",
523 "providers": {
524 "custom-anthropic": {
525 "type": "anthropic",
526 "base_url": "https://api.anthropic.com/v1",
527 "api_key": "$ANTHROPIC_API_KEY",
528 "extra_headers": {
529 "anthropic-version": "2023-06-01"
530 },
531 "models": [
532 {
533 "id": "claude-sonnet-4-20250514",
534 "name": "Claude Sonnet 4",
535 "cost_per_1m_in": 3,
536 "cost_per_1m_out": 15,
537 "cost_per_1m_in_cached": 3.75,
538 "cost_per_1m_out_cached": 0.3,
539 "context_window": 200000,
540 "default_max_tokens": 50000,
541 "can_reason": true,
542 "supports_attachments": true
543 }
544 ]
545 }
546 }
548```
550### Amazon Bedrock
552Crush currently supports running Anthropic models through Bedrock, with caching disabled.
554- A Bedrock provider will appear once you have AWS configured, i.e. `aws configure`
555- Crush also expects the `AWS_REGION` or `AWS_DEFAULT_REGION` to be set
556- To use a specific AWS profile set `AWS_PROFILE` in your environment, i.e. `AWS_PROFILE=myprofile crush`
557- Alternatively to `aws configure`, you can also just set `AWS_BEARER_TOKEN_BEDROCK`
559### Vertex AI Platform
561Vertex AI will appear in the list of available providers when `VERTEXAI_PROJECT` and `VERTEXAI_LOCATION` are set. You will also need to be authenticated:
563```bash
564gcloud auth application-default login
565```
567To add specific models to the configuration, configure as such:
569```json
571 "$schema": "https://charm.land/crush.json",
572 "providers": {
573 "vertexai": {
574 "models": [
575 {
576 "id": "claude-sonnet-4@20250514",
577 "name": "VertexAI Sonnet 4",
578 "cost_per_1m_in": 3,
579 "cost_per_1m_out": 15,
580 "cost_per_1m_in_cached": 3.75,
581 "cost_per_1m_out_cached": 0.3,
582 "context_window": 200000,
583 "default_max_tokens": 50000,
584 "can_reason": true,
585 "supports_attachments": true
586 }
587 ]
588 }
589 }
591```
593### Local Models
595Local models can also be configured via OpenAI-compatible API. Here are two common examples:
597#### Ollama
599```json
601 "providers": {
602 "ollama": {
603 "name": "Ollama",
604 "base_url": "http://localhost:11434/v1/",
605 "type": "openai-compat",
606 "models": [
607 {
608 "name": "Qwen 3 30B",
609 "id": "qwen3:30b",
610 "context_window": 256000,
611 "default_max_tokens": 20000
612 }
613 ]
614 }
615 }
617```
619#### LM Studio
621```json
623 "providers": {
624 "lmstudio": {
625 "name": "LM Studio",
626 "base_url": "http://localhost:1234/v1/",
627 "type": "openai-compat",
628 "models": [
629 {
630 "name": "Qwen 3 30B",
631 "id": "qwen/qwen3-30b-a3b-2507",
632 "context_window": 256000,
633 "default_max_tokens": 20000
634 }
635 ]
636 }
637 }
639```
641## Logging
643Sometimes you need to look at logs. Luckily, Crush logs all sorts of
644stuff. Logs are stored in `./.crush/logs/crush.log` relative to the project.
646The CLI also contains some helper commands to make perusing recent logs easier:
648```bash
649# Print the last 1000 lines
650crush logs
652# Print the last 500 lines
653crush logs --tail 500
655# Follow logs in real time
656crush logs --follow
657```
659Want more logging? Run `crush` with the `--debug` flag, or enable it in the
660config:
662```json
664 "$schema": "https://charm.land/crush.json",
665 "options": {
666 "debug": true,
667 "debug_lsp": true
668 }
670```
672## Provider Auto-Updates
674By default, Crush automatically checks for the latest and greatest list of
675providers and models from [Catwalk](https://github.com/charmbracelet/catwalk),
676the open source Crush provider database. This means that when new providers and
677models are available, or when model metadata changes, Crush automatically
678updates your local configuration.
680### Disabling automatic provider updates
682For those with restricted internet access, or those who prefer to work in
683air-gapped environments, this might not be want you want, and this feature can
684be disabled.
686To disable automatic provider updates, set `disable_provider_auto_update` into
687your `crush.json` config:
689```json
691 "$schema": "https://charm.land/crush.json",
692 "options": {
693 "disable_provider_auto_update": true
694 }
696```
698Or set the `CRUSH_DISABLE_PROVIDER_AUTO_UPDATE` environment variable:
700```bash
701export CRUSH_DISABLE_PROVIDER_AUTO_UPDATE=1
702```
704### Manually updating providers
706Manually updating providers is possible with the `crush update-providers`
707command:
709```bash
710# Update providers remotely from Catwalk.
711crush update-providers
713# Update providers from a custom Catwalk base URL.
714crush update-providers https://example.com/
716# Update providers from a local file.
717crush update-providers /path/to/local-providers.json
719# Reset providers to the embedded version, embedded at crush at build time.
720crush update-providers embedded
722# For more info:
723crush update-providers --help
724```
726## Metrics
728Crush records pseudonymous usage metrics (tied to a device-specific hash),
729which maintainers rely on to inform development and support priorities. The
730metrics include solely usage metadata; prompts and responses are NEVER
731collected.
733Details on exactly what’s collected are in the source code ([here](https://github.com/charmbracelet/crush/tree/main/internal/event)
734and [here](https://github.com/charmbracelet/crush/blob/main/internal/llm/agent/event.go)).
736You can opt out of metrics collection at any time by setting the environment
737variable by setting the following in your environment:
739```bash
740export CRUSH_DISABLE_METRICS=1
741```
743Or by setting the following in your config:
745```json
747 "options": {
748 "disable_metrics": true
749 }
751```
753Crush also respects the `DO_NOT_TRACK` convention which can be enabled via
754`export DO_NOT_TRACK=1`.
756## Contributing
758See the [contributing guide](https://github.com/charmbracelet/crush?tab=contributing-ov-file#contributing).
760## Whatcha think?
762We’d love to hear your thoughts on this project. Need help? We gotchu. You can find us on:
764- [Twitter](https://twitter.com/charmcli)
765- [Slack](https://charm.land/slack)
766- [Discord][discord]
767- [The Fediverse](https://mastodon.social/@charmcli)
768- [Bluesky](https://bsky.app/profile/charm.land)
770[discord]: https://charm.land/discord
772## License
774[FSL-1.1-MIT](https://github.com/charmbracelet/crush/raw/main/LICENSE.md)
776---
778Part of [Charm](https://charm.land).
780<a href="https://charm.land/"><img alt="The Charm logo" width="400" src="https://stuff.charm.sh/charm-banner-next.jpg" /></a>
782<!--prettier-ignore-->
783Charm热爱开源 • Charm loves open source