command-code 0.52.5 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2541 -0
- package/dist/bundled/command-code-knowledge/SKILL.md +52 -0
- package/dist/bundled/command-code-knowledge/reference/checkpoints.md +366 -0
- package/dist/bundled/command-code-knowledge/reference/custom-agents.md +91 -0
- package/dist/bundled/command-code-knowledge/reference/custom-slash-commands.md +345 -0
- package/dist/bundled/command-code-knowledge/reference/headless.md +234 -0
- package/dist/bundled/command-code-knowledge/reference/hooks.md +1097 -0
- package/dist/bundled/command-code-knowledge/reference/mcp.md +626 -0
- package/dist/bundled/command-code-knowledge/reference/memory.md +98 -0
- package/dist/bundled/command-code-knowledge/reference/models.md +81 -0
- package/dist/bundled/command-code-knowledge/reference/permissions.md +412 -0
- package/dist/bundled/command-code-knowledge/reference/plan-mode.md +101 -0
- package/dist/bundled/command-code-knowledge/reference/product-help.md +421 -0
- package/dist/bundled/command-code-knowledge/reference/skills.md +993 -0
- package/dist/bundled/mod-builder/SKILL.md +128 -0
- package/dist/bundled/mod-builder/examples/block-dangerous-commands.ts +41 -0
- package/dist/bundled/mod-builder/examples/custom-entry-renderer.ts +32 -0
- package/dist/bundled/mod-builder/examples/custom-tool.ts +53 -0
- package/dist/bundled/mod-builder/examples/flags-and-options.ts +29 -0
- package/dist/bundled/mod-builder/examples/input-shortcuts.ts +41 -0
- package/dist/bundled/mod-builder/examples/kitchen-sink.ts +110 -0
- package/dist/bundled/mod-builder/examples/lifecycle-hooks.ts +64 -0
- package/dist/bundled/mod-builder/examples/observe-events.ts +30 -0
- package/dist/bundled/mod-builder/examples/slash-command.ts +33 -0
- package/dist/bundled/mod-builder/reference/api.md +81 -0
- package/dist/bundled/mod-builder/reference/hooks-and-events.md +308 -0
- package/dist/bundled/mod-builder/reference/overview.md +161 -0
- package/dist/bundled/mod-builder/reference/packaging.md +63 -0
- package/dist/bundled/mod-builder/reference/ui.md +63 -0
- package/dist/bundled/mod-builder/reference/verify.md +58 -0
- package/dist/bundled/skill-builder/SKILL.md +104 -0
- package/dist/cli.mjs +5 -5
- package/package.json +35 -26
- package/vsix/commandcode-vscode.vsix +0 -0
- /package/{skills → dist/bundled}/agent-browser/SKILL.md +0 -0
- /package/{skills → dist/bundled}/design/SKILL.md +0 -0
- /package/{skills → dist/bundled}/design/references/border.md +0 -0
- /package/{skills → dist/bundled}/design/references/button.md +0 -0
- /package/{skills → dist/bundled}/design/references/checkup.md +0 -0
- /package/{skills → dist/bundled}/design/references/color.md +0 -0
- /package/{skills → dist/bundled}/design/references/create.md +0 -0
- /package/{skills → dist/bundled}/design/references/design-html.md +0 -0
- /package/{skills → dist/bundled}/design/references/deslop.md +0 -0
- /package/{skills → dist/bundled}/design/references/finish.md +0 -0
- /package/{skills → dist/bundled}/design/references/interaction.md +0 -0
- /package/{skills → dist/bundled}/design/references/layout.md +0 -0
- /package/{skills → dist/bundled}/design/references/motion.md +0 -0
- /package/{skills → dist/bundled}/design/references/redesign.md +0 -0
- /package/{skills → dist/bundled}/design/references/refine.md +0 -0
- /package/{skills → dist/bundled}/design/references/relayout.md +0 -0
- /package/{skills → dist/bundled}/design/references/report-html.md +0 -0
- /package/{skills → dist/bundled}/design/references/responsive.md +0 -0
- /package/{skills → dist/bundled}/design/references/review.md +0 -0
- /package/{skills → dist/bundled}/design/references/setup.md +0 -0
- /package/{skills → dist/bundled}/design/references/shadow.md +0 -0
- /package/{skills → dist/bundled}/design/references/smell.md +0 -0
- /package/{skills → dist/bundled}/design/references/surface.md +0 -0
- /package/{skills → dist/bundled}/design/references/tokenize.md +0 -0
- /package/{skills → dist/bundled}/design/references/typeset.md +0 -0
- /package/{skills → dist/bundled}/design/references/voice.md +0 -0
- /package/{skills → dist/bundled}/design/references/writing.md +0 -0
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
<!-- GENERATED FILE — do not edit. Source: packages/docs/src/app/core-concepts/slash-commands/page.mdx. Regenerate: pnpm generate:knowledge -->
|
|
2
|
+
|
|
3
|
+
# Slash Commands
|
|
4
|
+
|
|
5
|
+
Command Code includes built-in slash commands for interactive workflows, and also supports custom slash commands from markdown files.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Built-in Slash Commands
|
|
10
|
+
|
|
11
|
+
For the full list of built-in slash commands, see [Interactive Mode — Slash Commands](https://commandcode.ai/docs/reference/cli#cli-slash-commands).
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Custom Slash Commands
|
|
16
|
+
|
|
17
|
+
Custom slash commands let you save frequently used prompts as markdown files. Define a command once, then run it anytime with dynamic arguments. Commands can be project-level or user-level (shared across all projects).
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Syntax
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
/<command-name> [arguments]
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
| **Parameter** | **Description** |
|
|
28
|
+
| ---------------- | ----------------------------------------------------------------- |
|
|
29
|
+
| `<command-name>` | Name derived from the markdown filename (without `.md` extension) |
|
|
30
|
+
| `[arguments]` | Optional arguments passed to the command |
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Command Types
|
|
35
|
+
|
|
36
|
+
There are two types of commands:
|
|
37
|
+
|
|
38
|
+
### Project-Level Commands
|
|
39
|
+
|
|
40
|
+
Commands saved directly in your project. When shown in `/help`, they appear with “(project)” after their description.
|
|
41
|
+
|
|
42
|
+
**Location:** `.commandcode/commands/`
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Create a project-level command
|
|
46
|
+
mkdir -p .commandcode/commands
|
|
47
|
+
echo "Generate unit tests for this code following our testing conventions" > .commandcode/commands/test.md
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
This makes `/test` command available only within this project.
|
|
51
|
+
|
|
52
|
+
### User-Level Commands
|
|
53
|
+
|
|
54
|
+
Commands that are available across all your projects. In the command menu, they appear with “(user)” after their description.
|
|
55
|
+
|
|
56
|
+
**Location:** `~/.commandcode/commands/`
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Create a user-level command
|
|
60
|
+
mkdir -p ~/.commandcode/commands
|
|
61
|
+
echo "I am currently being onboarded on this project, help me understand it." > ~/.commandcode/commands/understand.md
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
This makes `/understand` command available in all your projects.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Namespacing
|
|
69
|
+
|
|
70
|
+
Organize commands in subdirectories. The subdirectories appear in the command description but do not affect the command name.
|
|
71
|
+
|
|
72
|
+
| **File Location** | **Command** | **Description Shows** |
|
|
73
|
+
| --------------------------------------------- | ------------ | --------------------- |
|
|
74
|
+
| `.commandcode/commands/frontend/component.md` | `/component` | `(project: frontend)` |
|
|
75
|
+
| `~/.commandcode/commands/git/commit.md` | `/commit` | `(user: git)` |
|
|
76
|
+
| `.commandcode/commands/simple.md` | `/simple` | `(project)` |
|
|
77
|
+
|
|
78
|
+
### Unlimited Nesting Depth
|
|
79
|
+
|
|
80
|
+
You can organize commands as deeply as needed:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
.commandcode/commands/
|
|
84
|
+
├── frontend/
|
|
85
|
+
│ ├── react/
|
|
86
|
+
│ │ ├── hooks/
|
|
87
|
+
│ │ │ └── use-auth.md → /use-auth (project: frontend/react/hooks)
|
|
88
|
+
│ │ └── components/
|
|
89
|
+
│ │ └── button.md → /button (project: frontend/react/components)
|
|
90
|
+
│ └── vue/
|
|
91
|
+
│ └── composable.md → /composable (project: frontend/vue)
|
|
92
|
+
├── backend/
|
|
93
|
+
│ └── api/
|
|
94
|
+
│ └── endpoint.md → /endpoint (project: backend/api)
|
|
95
|
+
└── simple.md → /simple (project)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The command name comes from the filename only, not the folder path. So
|
|
99
|
+
`frontend/button.md` and `backend/button.md` both create `/button`, they
|
|
100
|
+
will conflict. Use unique filenames like `frontend-button.md` and
|
|
101
|
+
`backend-button.md` instead.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Arguments
|
|
106
|
+
|
|
107
|
+
Pass dynamic values to commands using argument placeholders.
|
|
108
|
+
|
|
109
|
+
### All Arguments with `$ARGUMENTS` (or `$@`)
|
|
110
|
+
|
|
111
|
+
The `$ARGUMENTS` placeholder captures all arguments as a single string. `$@` is
|
|
112
|
+
a shorthand alias for the same value, and the braced forms `${ARGUMENTS}` and
|
|
113
|
+
`${@}` work too:
|
|
114
|
+
|
|
115
|
+
**Command definition** (`.commandcode/commands/explain.md`):
|
|
116
|
+
|
|
117
|
+
```markdown
|
|
118
|
+
Explain the following concept in simple terms: $ARGUMENTS
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Usage:**
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
/explain how async await works in JavaScript
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Result:** `$ARGUMENTS` becomes `"how async await works in JavaScript"`
|
|
128
|
+
|
|
129
|
+
### Positional Arguments with `$1`, `$2`, etc.
|
|
130
|
+
|
|
131
|
+
Access specific arguments using positional parameters. Arguments start at `$1` (there is no `$0`):
|
|
132
|
+
|
|
133
|
+
**Command definition** (`.commandcode/commands/create-component.md`):
|
|
134
|
+
|
|
135
|
+
```markdown
|
|
136
|
+
Create a $1 component named $2 with the following features: $3
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Usage:**
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
/create-component React Button "onClick and disabled props"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Result:**
|
|
146
|
+
|
|
147
|
+
- `$1` → `"React"`
|
|
148
|
+
- `$2` → `"Button"`
|
|
149
|
+
- `$3` → `"onClick and disabled props"`
|
|
150
|
+
|
|
151
|
+
Positional arguments also support the braced form `${1}`, `${2}`, etc. Use it
|
|
152
|
+
when a placeholder sits directly next to other characters, for example
|
|
153
|
+
`v${1}.0` or `${1}px`, so the parser knows where the number ends.
|
|
154
|
+
|
|
155
|
+
### Default Values with `${N:-default}`
|
|
156
|
+
|
|
157
|
+
Wrap a placeholder in `${...}` and add `:-default` to fall back to a default
|
|
158
|
+
value when that argument is missing or empty. This is handy for optional
|
|
159
|
+
arguments:
|
|
160
|
+
|
|
161
|
+
**Command definition** (`.commandcode/commands/summarize.md`):
|
|
162
|
+
|
|
163
|
+
```markdown
|
|
164
|
+
Summarize the current state in ${1:-7} bullet points.
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**Usage:**
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
/summarize # → "Summarize the current state in 7 bullet points."
|
|
171
|
+
/summarize 3 # → "Summarize the current state in 3 bullet points."
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Defaults work with `$@`/`$ARGUMENTS` as well — `${@:-the current diff}` uses all
|
|
175
|
+
arguments when provided, otherwise the literal text `the current diff`.
|
|
176
|
+
|
|
177
|
+
### Argument Slices with `${@:N}` and `${@:N:L}`
|
|
178
|
+
|
|
179
|
+
Select a range of positional arguments (1-indexed) and join them with spaces:
|
|
180
|
+
|
|
181
|
+
- `${@:N}` — every argument from the Nth position to the end
|
|
182
|
+
- `${@:N:L}` — `L` arguments starting at the Nth position
|
|
183
|
+
|
|
184
|
+
**Command definition** (`.commandcode/commands/commit.md`):
|
|
185
|
+
|
|
186
|
+
```markdown
|
|
187
|
+
Write a commit of type "$1" with message: ${@:2}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**Usage:**
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
/commit fix resolve the flaky login test
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**Result:**
|
|
197
|
+
|
|
198
|
+
- `$1` → `"fix"`
|
|
199
|
+
- `${@:2}` → `"resolve the flaky login test"`
|
|
200
|
+
|
|
201
|
+
An out-of-range slice (e.g. `${@:9}` when only three arguments were passed)
|
|
202
|
+
expands to an empty string.
|
|
203
|
+
|
|
204
|
+
### Quoted Strings
|
|
205
|
+
|
|
206
|
+
Arguments containing spaces can be wrapped in quotes:
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
/create-component React "Login Form" "email validation and submit handler"
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**Result:**
|
|
213
|
+
|
|
214
|
+
- `$1` → `"React"`
|
|
215
|
+
- `$2` → `"Login Form"`
|
|
216
|
+
- `$3` → `"email validation and submit handler"`
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Edge Cases
|
|
221
|
+
|
|
222
|
+
| **Scenario** | **Behavior** |
|
|
223
|
+
| ---------------------------------------------- | --------------------------------------------------------------- |
|
|
224
|
+
| Missing argument (e.g., `$3` with only 2 args) | Replaced with empty string (use `${3:-default}` for a fallback) |
|
|
225
|
+
| Extra arguments | Captured in `$ARGUMENTS`/`$@`, ignored by unused `$N` |
|
|
226
|
+
| No arguments provided | `$ARGUMENTS` = `""`, all `$N` = `""` |
|
|
227
|
+
| Command without placeholders | Template passed through unchanged |
|
|
228
|
+
| Missing or empty arg with `${N:-default}` | Replaced with `default` |
|
|
229
|
+
| Out-of-range slice (e.g. `${@:9}`) | Replaced with empty string |
|
|
230
|
+
| Slice length past the end (e.g. `${@:2:99}`) | Clamped to the available arguments |
|
|
231
|
+
| Unrecognized `${...}` (e.g. `${HOME}`) | Left untouched, so shell/env-style text is preserved |
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Examples
|
|
236
|
+
|
|
237
|
+
### Test Generator Command
|
|
238
|
+
|
|
239
|
+
**File:** `.commandcode/commands/test.md`
|
|
240
|
+
|
|
241
|
+
```markdown
|
|
242
|
+
Write $1 tests for the following code using $2.
|
|
243
|
+
|
|
244
|
+
Requirements:
|
|
245
|
+
|
|
246
|
+
- Cover edge cases and error scenarios
|
|
247
|
+
- Add descriptive test names
|
|
248
|
+
- Follow testing best practices
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
**Usage:**
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
/test unit Jest
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Documentation Command
|
|
258
|
+
|
|
259
|
+
**File:** `~/.commandcode/commands/docs.md`
|
|
260
|
+
|
|
261
|
+
```markdown
|
|
262
|
+
Generate documentation for this $1.
|
|
263
|
+
|
|
264
|
+
Include:
|
|
265
|
+
|
|
266
|
+
- Description and purpose
|
|
267
|
+
- Parameters/props with types
|
|
268
|
+
- Usage examples
|
|
269
|
+
- Return values if applicable
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**Usage:**
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
/docs function
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## How It Works
|
|
281
|
+
|
|
282
|
+
1. **Type `/`** to open the interactive command menu
|
|
283
|
+
2. **Select a command** from the dropdown (e.g., `/test`)
|
|
284
|
+
3. **Command is inserted** into the input field with a trailing space
|
|
285
|
+
4. **Type your arguments** (e.g., `unit Jest`)
|
|
286
|
+
5. **Press Enter** to execute
|
|
287
|
+
6. **Placeholders are replaced** with your arguments
|
|
288
|
+
7. **Processed prompt** is sent to the AI
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
Custom commands cannot override built-in commands. If you create a command
|
|
293
|
+
with the same name as a built-in, the built-in takes precedence.
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## Quick Reference
|
|
298
|
+
|
|
299
|
+
### Placeholders
|
|
300
|
+
|
|
301
|
+
| **Placeholder** | **Description** | **Example Input** | **Result** |
|
|
302
|
+
| ------------------- | --------------------------------------------- | ----------------- | ----------------- |
|
|
303
|
+
| `$ARGUMENTS` / `$@` | All arguments as string | `unit Jest async` | `unit Jest async` |
|
|
304
|
+
| `$1` | First argument | `unit Jest` | `unit` |
|
|
305
|
+
| `$2` | Second argument | `unit Jest` | `Jest` |
|
|
306
|
+
| `$N` | Nth argument | — | — |
|
|
307
|
+
| `${N}` | Braced Nth argument (safe next to other text) | `unit Jest` | `unit` |
|
|
308
|
+
| `${N:-default}` | Nth argument, or `default` when missing/empty | `` (none) | `default` |
|
|
309
|
+
| `${@:N}` | Arguments from the Nth position to the end | `a b c` | `b c` (N=2) |
|
|
310
|
+
| `${@:N:L}` | `L` arguments starting at the Nth position | `a b c d` | `b c` (N=2, L=2) |
|
|
311
|
+
|
|
312
|
+
### Command Locations
|
|
313
|
+
|
|
314
|
+
| **Type** | **Location** | **Description Label** |
|
|
315
|
+
| ---------------- | --------------------------------- | --------------------- |
|
|
316
|
+
| Project | `.commandcode/commands/` | `(project)` |
|
|
317
|
+
| Project (nested) | `.commandcode/commands/subdir/` | `(project: subdir)` |
|
|
318
|
+
| User | `~/.commandcode/commands/` | `(user)` |
|
|
319
|
+
| User (nested) | `~/.commandcode/commands/subdir/` | `(user: subdir)` |
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
## Troubleshooting
|
|
324
|
+
|
|
325
|
+
### Command not appearing in menu
|
|
326
|
+
|
|
327
|
+
1. Ensure the file has `.md` extension
|
|
328
|
+
2. Check file is in correct directory (`.commandcode/commands/` or `~/.commandcode/commands/`)
|
|
329
|
+
3. Verify file permissions allow reading
|
|
330
|
+
|
|
331
|
+
### Arguments not being replaced
|
|
332
|
+
|
|
333
|
+
1. Use `$1`, `$2`, etc. for positional args (not `$0`)
|
|
334
|
+
2. Use `$ARGUMENTS` (or `$@`) for all args as a string
|
|
335
|
+
3. Check for typos in placeholder names (case-sensitive)
|
|
336
|
+
4. For defaults and slices, keep the braces and syntax exact: `${1:-default}`,
|
|
337
|
+
`${@:2}`, `${@:2:3}`. A malformed `${...}` expression is left in the prompt
|
|
338
|
+
unchanged rather than replaced.
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## Next steps
|
|
343
|
+
|
|
344
|
+
- Create your first custom slash command and try it out
|
|
345
|
+
- Join our [Discord community](https://commandcode.ai/discord) for feedback, requests, and support.
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
<!-- GENERATED FILE — do not edit. Source: packages/docs/src/app/core-concepts/headless/page.mdx. Regenerate: pnpm generate:knowledge -->
|
|
2
|
+
|
|
3
|
+
# Headless Mode
|
|
4
|
+
|
|
5
|
+
Run Command Code non-interactively in scripts, CI/CD pipelines, and automation workflows. Headless mode executes a single query, outputs the response to stdout, and exits.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Basic Usage
|
|
10
|
+
|
|
11
|
+
Use the `-p` (or `--print`) flag to run in headless mode:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
cmd -p "explain this file"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Always wrap your query in quotes. Unquoted multi-word queries cause argument parsing errors.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Input Methods
|
|
22
|
+
|
|
23
|
+
### Direct Argument
|
|
24
|
+
|
|
25
|
+
Pass your query directly after the `-p` flag:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
cmd -p "refactor the auth module"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Piped Stdin
|
|
32
|
+
|
|
33
|
+
Pipe input from another command or file:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
echo "explain this error" | cmd -p
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
cat prompt.txt | cmd -p
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Command Code auto-detects piped input when no query argument is provided. If stdin is a TTY and no query is given, it exits with an error.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Permissions
|
|
48
|
+
|
|
49
|
+
By default, headless mode **blocks tools that modify your system** — file writes, file edits, and shell commands are denied. This keeps automated runs safe.
|
|
50
|
+
|
|
51
|
+
To enable all tools, pass `--yolo`:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
cmd -p "fix the lint errors" --yolo
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
> `--dangerously-skip-permissions` is also accepted as an alias.
|
|
58
|
+
|
|
59
|
+
| **Tool** | **Default (no flag)** | **With `--yolo`** |
|
|
60
|
+
| -------- | --------------------- | ----------------------------------------- |
|
|
61
|
+
| File reads, grep, glob | Allowed | Allowed |
|
|
62
|
+
| File edits and writes | Blocked | Allowed |
|
|
63
|
+
| Shell commands | Blocked | Allowed |
|
|
64
|
+
|
|
65
|
+
Only use `--yolo` in trusted environments. It allows Command Code to modify files and run shell commands without confirmation.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Tool Calls
|
|
70
|
+
|
|
71
|
+
Headless mode supports multi-turn tool execution. Command Code can read files, search code, and (with permissions) edit files and run commands, just like [interactive mode](https://commandcode.ai/docs/core-concepts/interactive-mode).
|
|
72
|
+
|
|
73
|
+
The conversation loop runs for up to **10 turns**. If the limit is reached, a warning is printed to stderr and the partial response is returned.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Sessions & Resuming
|
|
78
|
+
|
|
79
|
+
Each headless run persists its transcript to disk, so you can chain follow-up queries that keep prior context. Headless sessions are tagged separately and stay **hidden** from the interactive `/resume` menu and from interactive `--continue` — automation never pollutes your interactive history.
|
|
80
|
+
|
|
81
|
+
### Continue the most recent run
|
|
82
|
+
|
|
83
|
+
`--continue` (or `-c`) resumes the most recent headless session in the current directory:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
cmd -p "find the slowest test"
|
|
87
|
+
cmd -p --continue "now suggest a fix" # carries the previous turn's context
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
If no headless session exists yet, `--continue` starts a fresh one — so a `-p --continue` loop works from the first iteration.
|
|
91
|
+
|
|
92
|
+
### Resume a specific session
|
|
93
|
+
|
|
94
|
+
Print the session id with `--verbose` (written to **stderr**, so stdout stays clean for piping):
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
cmd -p --verbose "start a code review" # stderr → session: 9f4e1c0a-...
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Then resume that exact session by id:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
cmd -p --resume 9f4e1c0a-... "continue the review"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
A bare `--resume` with no id errors in headless mode — there is no interactive picker. Use `--continue` to pick up the latest run instead.
|
|
107
|
+
|
|
108
|
+
### Open a headless session in interactive mode
|
|
109
|
+
|
|
110
|
+
Pass a headless session id to plain `cmd --resume <id>` (without `-p`) to load that transcript into a full interactive session:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
cmd --resume 9f4e1c0a-...
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Exit Codes
|
|
119
|
+
|
|
120
|
+
Use exit codes to handle results in scripts and CI/CD:
|
|
121
|
+
|
|
122
|
+
| **Code** | **Meaning** | **Constant** |
|
|
123
|
+
| -------- | ----------- | ------------ |
|
|
124
|
+
| `0` | Success | `EXIT_SUCCESS` |
|
|
125
|
+
| `1` | General error | `EXIT_ERROR` |
|
|
126
|
+
| `3` | Not authenticated | `EXIT_AUTH_ERROR` |
|
|
127
|
+
| `4` | Permission denied | `EXIT_PERMISSION_DENIED` |
|
|
128
|
+
| `5` | Rate limit exceeded | `EXIT_RATE_LIMITED` |
|
|
129
|
+
| `6` | Network failure | `EXIT_CONNECTION_ERROR` |
|
|
130
|
+
| `7` | API server error (5xx) | `EXIT_SERVER_ERROR` |
|
|
131
|
+
| `8` | Max turns reached before final answer | `EXIT_MAX_TURNS_REACHED` |
|
|
132
|
+
| `9` | Model produced no response | `EXIT_NO_RESPONSE` |
|
|
133
|
+
| `10` | Insufficient credits | `EXIT_INSUFFICIENT_CREDITS` |
|
|
134
|
+
| `130` | Interrupted (SIGINT/SIGTERM) | `EXIT_INTERRUPTED` |
|
|
135
|
+
|
|
136
|
+
Example usage in a script:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
cmd -p "check for security issues" --yolo
|
|
140
|
+
if [ $? -ne 0 ]; then
|
|
141
|
+
echo "Command Code failed"
|
|
142
|
+
exit 1
|
|
143
|
+
fi
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Shell Script
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
#!/bin/bash
|
|
152
|
+
set -e
|
|
153
|
+
|
|
154
|
+
# Generate docs for changed files
|
|
155
|
+
CHANGED=$(git diff --name-only HEAD~1)
|
|
156
|
+
echo "Document these changed files: $CHANGED" | cmd -p --skip-onboarding
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Piping Output
|
|
160
|
+
|
|
161
|
+
Headless mode is pipe-friendly. Output goes to stdout, errors and warnings go to stderr:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# Save response to a file
|
|
165
|
+
cmd -p "generate a README for this project" > README.md
|
|
166
|
+
|
|
167
|
+
# Pipe to another command
|
|
168
|
+
cmd -p "list all TODO comments" | grep "critical"
|
|
169
|
+
|
|
170
|
+
# Use in command substitution
|
|
171
|
+
SUMMARY=$(cmd -p "summarize this codebase in one paragraph")
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Related Flags
|
|
177
|
+
|
|
178
|
+
Flags useful for headless and automated workflows:
|
|
179
|
+
|
|
180
|
+
| **Flag** | **Description** |
|
|
181
|
+
| -------- | --------------- |
|
|
182
|
+
| `-p, --print [query]` | Run in headless mode |
|
|
183
|
+
| `-c, --continue` | Resume the most recent headless session in this directory |
|
|
184
|
+
| `-r, --resume <id>` | Resume a specific headless session by id (no bare picker in print mode) |
|
|
185
|
+
| `--verbose` | Print the resolved session id to stderr (for chaining `--resume`) |
|
|
186
|
+
| `--max-turns <number>` | Maximum conversation turns in print mode (default: `100`, no upper bound) |
|
|
187
|
+
| `-m, --model <model>` | Run on a specific model this session |
|
|
188
|
+
| `--effort <level>` | Set reasoning effort (`low`, `medium`, `high`, …) |
|
|
189
|
+
| `--theme <theme>` | Set the color theme (`dark` or `light`) |
|
|
190
|
+
| `--config <key=value>` | Set any setting headlessly (repeatable) — see below |
|
|
191
|
+
| `--yolo` | Allow file writes and shell commands |
|
|
192
|
+
| `--auto-accept` | Start in auto-accept mode (alias for `--permission-mode auto-accept`) |
|
|
193
|
+
| `--skip-onboarding` | Skip taste onboarding (for CI/automated runs) |
|
|
194
|
+
| `-t, --trust` | Auto-trust project (skip initial permission prompt) |
|
|
195
|
+
| `--plan` | Start in plan mode (read-only exploration) |
|
|
196
|
+
| `--permission-mode <mode>` | Set permission mode: `standard`, `plan`, `auto-accept` |
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Configuring settings
|
|
201
|
+
|
|
202
|
+
Slash commands are interactive-only, but the settings behind them are available as **flags** —
|
|
203
|
+
never as a `/slash` string on the command line. The common ones have dedicated flags
|
|
204
|
+
(`--model`, `--effort`, `--theme`), and `--config key=value` reaches any setting the `/config`
|
|
205
|
+
UI can change:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# Set your model + reasoning effort for this run
|
|
209
|
+
cmd -p "review this diff" --model claude-sonnet-4-6 --effort high
|
|
210
|
+
|
|
211
|
+
# Set any setting; repeatable. Invalid keys/values exit non-zero.
|
|
212
|
+
cmd --config theme=dark --config compact-mode=fast
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
`--config` is the headless equivalent of the interactive `/config` UI, so a new setting becomes
|
|
216
|
+
scriptable automatically. Confirmations print to stderr, keeping `-p` stdout clean.
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Limitations
|
|
221
|
+
|
|
222
|
+
| **Limitation** | **Details** |
|
|
223
|
+
| -------------- | ----------- |
|
|
224
|
+
| **No interactive prompts** | No keyboard shortcuts or interactive UI. Slash commands aren't typed here — use flags instead (see [Configuring settings](#configuring-settings)); session-lifecycle commands like `/clear` and `/reload` have no meaning in one-shot mode |
|
|
225
|
+
| **No resume picker** | A bare `--resume` errors in print mode; resume by explicit id or use `--continue` |
|
|
226
|
+
| **Stdin timeout** | Piped stdin times out after 30 seconds if no data is received |
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Next steps
|
|
231
|
+
|
|
232
|
+
- See [CLI Reference](https://commandcode.ai/docs/reference/cli) for the full list of flags and commands
|
|
233
|
+
- Learn about [Interactive Mode](https://commandcode.ai/docs/core-concepts/interactive-mode) for full-featured sessions
|
|
234
|
+
- Join our [Discord community](https://commandcode.ai/discord) for support
|