Skip to content

Commit 3fdd29b

Browse files
VdustRclaude
andcommitted
docs: improve custom commands spec clarity
- Fix {name} description: "branch name" not "folder name" - Clarify {path} and {dir} are absolute paths - Add env validation to error handling section - Add env usage example Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8928b20 commit 3fdd29b

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

docs/spec/custom-commands.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,24 @@ Same variables as repository/worktree templates:
2929

3030
| Variable | Value |
3131
|---|---|
32-
| `{name}` | Worktree folder name |
33-
| `{branch}` | Git branch (empty if detached HEAD) |
34-
| `{ref}` | Branch or short commit hash (always non-empty) |
32+
| `{name}` | Branch name, or `HEAD` if detached |
33+
| `{branch}` | Full branch name (empty if detached HEAD) |
34+
| `{ref}` | Branch name or short commit hash (always non-empty) |
3535
| `{head}` | Short commit hash (8 chars) |
36-
| `{path}` | Filesystem path |
36+
| `{path}` | Absolute worktree directory path |
3737

3838
### Workspace items (`customCommands.workspace`)
3939

4040
Same variables as worktree workspace templates, plus `{dir}`:
4141

4242
| Variable | Value |
4343
|---|---|
44-
| `{name}` | File name (without `.code-workspace`) |
44+
| `{name}` | File name (without `.code-workspace` extension) |
4545
| `{branch}` | Parent worktree branch (empty if detached HEAD) |
46-
| `{ref}` | Branch or short commit hash (always non-empty) |
46+
| `{ref}` | Branch name or short commit hash (always non-empty) |
4747
| `{head}` | Short commit hash (8 chars) |
48-
| `{path}` | Workspace file path |
49-
| `{dir}` | Parent directory of workspace file path |
48+
| `{path}` | Absolute workspace file path |
49+
| `{dir}` | Absolute parent directory of workspace file |
5050
| `{worktree}` | Parent worktree folder name |
5151

5252
Template syntax (fallback, conditional) is the same as display templates. See [templates.md](../../docs/templates.md) for syntax reference.
@@ -107,7 +107,7 @@ Same logic as Open in Terminal (see [open-in-terminal.md](open-in-terminal.md)):
107107

108108
- **Spawn failure** (synchronous): try/catch around `spawn()` — shows error via `showErrorMessage`
109109
- **Process error** (asynchronous): `child.on("error")` — shows error with "Show Logs" action
110-
- **Settings validation**: Invalid entries (missing `label`, empty `command`) are skipped with a log message
110+
- **Settings validation**: Invalid entries are skipped with a log message. Checks: `label` must be a non-empty string, `command` must be a non-empty string array, and `env` values (if present) must all be strings
111111
- **Template rendering**: Uses the same `renderTemplate` function as display templates — unknown variables remain as-is
112112

113113
## Examples
@@ -175,6 +175,20 @@ Common terminal emulators:
175175
}
176176
```
177177

178+
### Using environment variables
179+
180+
```json
181+
{
182+
"git-work-grove.customCommands.directory": [
183+
{
184+
"command": ["open", "-a", "Ghostty", "--args", "--working-directory={path}"],
185+
"env": { "GHOSTTY_TITLE": "{ref}" },
186+
"label": "Open in Ghostty"
187+
}
188+
]
189+
}
190+
```
191+
178192
### Multiple commands
179193

180194
```json

0 commit comments

Comments
 (0)