Skip to content

Commit cf3f5cf

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

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

COMMANDS.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Custom Commands in Crush
2+
3+
Crush supports custom commands (sometimes called saved prompts) that can be
4+
created by users to quickly send 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
28+
(without the extension) becomes the name of the command.
29+
30+
For example, creating a file at `~/.config/crush/commands/carrot-cake.md` with
31+
the following content:
32+
33+
```markdown
34+
RUN git ls-files
35+
READ README.md
36+
```
37+
38+
...creates a command called `user:carrot-cake`.
39+
40+
### Command Arguments
41+
42+
Crush supports named arguments in custom commands using placeholders in the
43+
format `$NAME` (where NAME consists of uppercase letters, numbers, and
44+
underscores, and must start with a letter).
45+
46+
For example:
47+
48+
```markdown
49+
# Fetch Context for Issue $ISSUE_NUMBER
50+
51+
RUN gh issue view $ISSUE_NUMBER --json title,body,comments
52+
RUN git grep --author="$AUTHOR_NAME" -n .
53+
RUN grep -R "$SEARCH_PATTERN" $DIRECTORY
54+
```
55+
56+
When you run a command with arguments, crush will prompt you to enter values
57+
for each unique placeholder.
58+
59+
### Organizing Commands
60+
61+
Commands can be organized into sub-directories:
62+
63+
```
64+
~/.config/crush/commands/git/commit.md
65+
```
66+
67+
This creates a command with ID `user:git:commit`.
68+
69+
### Using Custom Commands
70+
71+
1. Press <kbd>Ctrl+p</kbd> to open the command dialog
72+
2. Press <kbd>Tab</kbd> to switch to User Commands
73+
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)