Skip to content

Commit 4e71de9

Browse files
committed
docs: add info on custom commands (i.e. saved prompts)
1 parent d66dfa2 commit 4e71de9

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

COMMANDS.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Custom Commands (aka saved prompts) in Crush
2+
3+
Crush supports custom commands that can be created by users to quickly send
4+
predefined prompts to the AI assistant.
5+
6+
## Creating Custom Commands
7+
8+
Custom commands are predefined prompts stored as Markdown files in one of three
9+
locations:
10+
11+
1. User Commands:
12+
13+
```bash
14+
# Unix-like systems (Linux, macOS, FreeBSD, etc.)
15+
$XDG_CONFIG_HOME/crush/commands/
16+
17+
# Windows
18+
%USERPROFILE%\AppData\Local\crush\commands\
19+
```
20+
21+
2. Project Commands:
22+
23+
```bash
24+
<PROJECT DIR>/.crush/commands/
25+
```
26+
27+
Each Markdown file in these directories becomes a custom command. The file name (without the extension) becomes the name of the command.
28+
29+
For example, creating a file at `~/.config/crush/commands/carrot-cake.md` with content:
30+
31+
```markdown
32+
RUN git ls-files
33+
READ README.md
34+
```
35+
36+
This creates a command called `user:carrot-cake`.
37+
38+
### Command Arguments
39+
40+
Crush supports named arguments in custom commands using placeholders in the format `$NAME` (where NAME consists of uppercase letters, numbers, and underscores, and must start with a letter).
41+
42+
For example:
43+
44+
```markdown
45+
# Fetch Context for Issue $ISSUE_NUMBER
46+
47+
RUN gh issue view $ISSUE_NUMBER --json title,body,comments
48+
RUN git grep --author="$AUTHOR_NAME" -n .
49+
RUN grep -R "$SEARCH_PATTERN" $DIRECTORY
50+
```
51+
52+
When you run a command with arguments, crush will prompt you to enter values for each unique placeholder.
53+
54+
### Organizing Commands
55+
56+
You can organize commands in subdirectories:
57+
58+
```
59+
~/.config/crush/commands/git/commit.md
60+
```
61+
62+
This creates a command with ID `user:git:commit`.
63+
64+
### Using Custom Commands
65+
66+
1. Press <kbd>Ctrl+p</kbd> to open the command dialog
67+
2. Press <kbd>Tab</kbd> to switch to User Commands
68+
3. Select your custom command

CRUSH.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,12 @@ func TestYourFunction(t *testing.T) {
6363
## Committing
6464

6565
- ALWAYS use semantic commits (`fix:`, `feat:`, `chore:`, `refactor:`, `docs:`, `sec:`, etc).
66+
67+
---
68+
69+
Part of [Charm](https://charm.land).
70+
71+
<a href="https://charm.land/"><img alt="The Charm logo" width="400" src="https://stuff.charm.sh/charm-banner-next.jpg" /></a>
72+
73+
<!--prettier-ignore-->
74+
Charm热爱开源 • Charm loves open source

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,11 @@ To add specific models to the configuration, configure as such:
449449
}
450450
```
451451

452+
## Custom Commands (a.k.a. Saved Prompts)
453+
454+
Crush has first-class support for this. See [COMMANDS.md](COMMANDS.md) for more
455+
information.
456+
452457
## Logging
453458

454459
Sometimes you need to look at logs. Luckily, Crush logs all sorts of

0 commit comments

Comments
 (0)