command-code 1.93.1 → 1.93.2
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 +7 -1
- package/dist/bundled/agent-browser/SKILL.md +73 -0
- package/dist/bundled/command-code-knowledge/SKILL.md +68 -0
- package/dist/bundled/command-code-knowledge/live-models.ts +284 -0
- package/dist/bundled/command-code-knowledge/reference/byok.md +389 -0
- package/dist/bundled/command-code-knowledge/reference/custom-agents.md +341 -0
- package/dist/bundled/command-code-knowledge/reference/custom-slash-commands.md +423 -0
- package/dist/bundled/command-code-knowledge/reference/headless.md +381 -0
- package/dist/bundled/command-code-knowledge/reference/hooks.md +1107 -0
- package/dist/bundled/command-code-knowledge/reference/mcp.md +648 -0
- package/dist/bundled/command-code-knowledge/reference/memory.md +137 -0
- package/dist/bundled/command-code-knowledge/reference/models.md +145 -0
- package/dist/bundled/command-code-knowledge/reference/permissions.md +486 -0
- package/dist/bundled/command-code-knowledge/reference/plan-mode.md +283 -0
- package/dist/bundled/command-code-knowledge/reference/plans.md +16 -0
- package/dist/bundled/command-code-knowledge/reference/product-help.md +490 -0
- package/dist/bundled/command-code-knowledge/reference/sessions.md +377 -0
- package/dist/bundled/command-code-knowledge/reference/skills.md +1009 -0
- package/dist/bundled/command-code-knowledge/reference/tools.md +522 -0
- package/dist/bundled/config/SKILL.md +18 -0
- package/dist/bundled/config/references/permissions.md +27 -0
- package/dist/bundled/config/references/settings.md +50 -0
- package/dist/bundled/design/SKILL.md +448 -0
- package/dist/bundled/design/references/accessibility.md +404 -0
- package/dist/bundled/design/references/border.md +161 -0
- package/dist/bundled/design/references/button.md +192 -0
- package/dist/bundled/design/references/checkup.md +164 -0
- package/dist/bundled/design/references/color.md +245 -0
- package/dist/bundled/design/references/create.md +291 -0
- package/dist/bundled/design/references/design-html.md +227 -0
- package/dist/bundled/design/references/deslop.md +285 -0
- package/dist/bundled/design/references/finish.md +156 -0
- package/dist/bundled/design/references/interaction.md +186 -0
- package/dist/bundled/design/references/layout.md +216 -0
- package/dist/bundled/design/references/media.md +112 -0
- package/dist/bundled/design/references/motion.md +237 -0
- package/dist/bundled/design/references/redesign.md +197 -0
- package/dist/bundled/design/references/refine.md +193 -0
- package/dist/bundled/design/references/reflexes.md +132 -0
- package/dist/bundled/design/references/relayout.md +207 -0
- package/dist/bundled/design/references/report-html.md +235 -0
- package/dist/bundled/design/references/responsive.md +233 -0
- package/dist/bundled/design/references/review.md +164 -0
- package/dist/bundled/design/references/setup.md +119 -0
- package/dist/bundled/design/references/severity.md +111 -0
- package/dist/bundled/design/references/shadow.md +164 -0
- package/dist/bundled/design/references/smell.md +213 -0
- package/dist/bundled/design/references/style-3d.md +23 -0
- package/dist/bundled/design/references/style-bento.md +21 -0
- package/dist/bundled/design/references/style-editorial.md +23 -0
- package/dist/bundled/design/references/style-futuristic.md +21 -0
- package/dist/bundled/design/references/style-glassmorphism.md +52 -0
- package/dist/bundled/design/references/style-maximalism.md +20 -0
- package/dist/bundled/design/references/style-minimalism.md +21 -0
- package/dist/bundled/design/references/style-neo-brutalism.md +21 -0
- package/dist/bundled/design/references/style-retro-futurism.md +21 -0
- package/dist/bundled/design/references/style-swiss.md +20 -0
- package/dist/bundled/design/references/style.md +77 -0
- package/dist/bundled/design/references/surface.md +163 -0
- package/dist/bundled/design/references/system.md +73 -0
- package/dist/bundled/design/references/typeset.md +210 -0
- package/dist/bundled/design/references/variants.md +193 -0
- package/dist/bundled/design/references/voice.md +184 -0
- package/dist/bundled/design/references/writing.md +174 -0
- package/dist/bundled/design/scripts/check/color.mjs +213 -0
- package/dist/bundled/design/scripts/check/contrast.mjs +141 -0
- package/dist/bundled/design/scripts/check/css.mjs +223 -0
- package/dist/bundled/design/scripts/check/named-colors.mjs +152 -0
- package/dist/bundled/design/scripts/check/pair.mjs +61 -0
- package/dist/bundled/design/scripts/check/preview.mjs +27 -0
- package/dist/bundled/design/scripts/check/reflexes.mjs +257 -0
- package/dist/bundled/design/scripts/check/sources.mjs +237 -0
- package/dist/bundled/design/scripts/check.mjs +165 -0
- package/dist/bundled/loop/SKILL.md +16 -0
- package/dist/bundled/mod-builder/SKILL.md +135 -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 +129 -0
- package/dist/bundled/mod-builder/examples/lifecycle-hooks.ts +64 -0
- package/dist/bundled/mod-builder/examples/model-router.ts +43 -0
- package/dist/bundled/mod-builder/examples/observe-events.ts +30 -0
- package/dist/bundled/mod-builder/examples/pane-and-buttons.ts +60 -0
- package/dist/bundled/mod-builder/examples/pane-form.ts +68 -0
- package/dist/bundled/mod-builder/examples/permission-policy.ts +34 -0
- package/dist/bundled/mod-builder/examples/redact-secrets.ts +46 -0
- package/dist/bundled/mod-builder/examples/slash-command.ts +33 -0
- package/dist/bundled/mod-builder/examples/spinner-count.ts +47 -0
- package/dist/bundled/mod-builder/examples/stream-filter.ts +70 -0
- package/dist/bundled/mod-builder/reference/api.md +140 -0
- package/dist/bundled/mod-builder/reference/hooks-and-events.md +347 -0
- package/dist/bundled/mod-builder/reference/overview.md +271 -0
- package/dist/bundled/mod-builder/reference/packaging.md +187 -0
- package/dist/bundled/mod-builder/reference/ui.md +253 -0
- package/dist/bundled/mod-builder/reference/verify.md +67 -0
- package/dist/bundled/skill-builder/SKILL.md +104 -0
- package/dist/cli.mjs +16 -0
- package/dist/index.mjs +2 -0
- package/package.json +1 -1
- package/vsix/commandcode-vscode.vsix +0 -0
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
<!-- Generated from the Command Code docs: https://commandcode.ai/docs -->
|
|
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
|
+
stdin ──┐
|
|
9
|
+
├──► cmd -p "query" ──┬──► stdout
|
|
10
|
+
argv ──┘ │ │ text, or
|
|
11
|
+
│ │ JSON frames
|
|
12
|
+
│ └──► stderr
|
|
13
|
+
│ --verbose
|
|
14
|
+
▼ progress
|
|
15
|
+
exit code
|
|
16
|
+
0 ok · 8 max-turns hit
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Basic usage
|
|
22
|
+
|
|
23
|
+
Use the `-p` (or `--print`) flag to run in headless mode:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
cmd -p "explain this file"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Always wrap your query in quotes. Unquoted multi-word queries cause argument parsing errors.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Authentication
|
|
34
|
+
|
|
35
|
+
On your own machine, `cmd login` once and headless runs reuse that login. For non-interactive environments (CI pipelines, Docker images, scheduled jobs, SSH boxes without a browser), [create an API key](https://commandcode.ai/docs/studio#api-keys) and export it as the `COMMAND_CODE_API_KEY` environment variable. The CLI reads the env var at startup and uses it as the auth token. No need to run `cmd login` or pre-write an `auth.json` file.
|
|
36
|
+
|
|
37
|
+
**Set the API key**
|
|
38
|
+
|
|
39
|
+
```bash {{ title: 'macOS / Linux' }}
|
|
40
|
+
export COMMAND_CODE_API_KEY="" # add your API key here
|
|
41
|
+
cmd -p "Run my workflow" # already logged in
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```bash {{ title: 'Windows' }}
|
|
45
|
+
$env:COMMAND_CODE_API_KEY = "" # PowerShell: add your API key here
|
|
46
|
+
cmdc -p "Run my workflow" # already logged in
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The env var takes precedence over `~/.commandcode/auth.json`. It overrides any local authentication method.
|
|
50
|
+
|
|
51
|
+
Run `cmd status` to confirm. The output shows `Source: $COMMAND_CODE_API_KEY` when the env var is the active credential.
|
|
52
|
+
|
|
53
|
+
### GitHub Actions
|
|
54
|
+
|
|
55
|
+
Store the key as a repository secret and pass it through `env`:
|
|
56
|
+
|
|
57
|
+
```yaml
|
|
58
|
+
- name: Install Command Code
|
|
59
|
+
run: npm i -g command-code@latest
|
|
60
|
+
|
|
61
|
+
- name: Run Command Code
|
|
62
|
+
run: cmd -p "review the changes in this PR"
|
|
63
|
+
env:
|
|
64
|
+
COMMAND_CODE_API_KEY: ${{ secrets.COMMAND_CODE_API_KEY }}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Treat the key as a secret: use your CI provider's encrypted-secrets store (GitHub Actions secrets, GitLab CI variables, etc.) rather than committing it to the repo.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Input methods
|
|
72
|
+
|
|
73
|
+
### Direct argument
|
|
74
|
+
|
|
75
|
+
Pass your query directly after the `-p` flag:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
cmd -p "refactor the auth module"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Piped stdin
|
|
82
|
+
|
|
83
|
+
Pipe input from another command or file:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
echo "explain this error" | cmd -p
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
cat prompt.txt | cmd -p
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
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.
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Permissions
|
|
98
|
+
|
|
99
|
+
By default, headless mode **blocks tools that modify your system** - file writes, file edits, and shell commands are denied. This keeps automated runs safe.
|
|
100
|
+
|
|
101
|
+
To enable all tools, pass `--yolo`:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
cmd -p "fix the lint errors" --yolo
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
> `--dangerously-skip-permissions` is also accepted as an alias. `--permission-mode yolo` does not lift the block in headless mode. Pass `--yolo`.
|
|
108
|
+
|
|
109
|
+
| **Tool** | **Default (no flag)** | **With `--yolo`** |
|
|
110
|
+
| -------- | --------------------- | ----------------------------------------- |
|
|
111
|
+
| File reads, grep, glob | Allowed | Allowed |
|
|
112
|
+
| File edits and writes | Blocked | Allowed |
|
|
113
|
+
| Shell commands | Blocked | Allowed |
|
|
114
|
+
|
|
115
|
+
Only use `--yolo` in trusted environments. It allows Command Code to modify files and run shell commands without confirmation.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
**Permissions**
|
|
120
|
+
Headless runs still go through the permission engine. The complete guide
|
|
121
|
+
covers `dont-ask`, the fail-closed allowlist mode built for CI, plus rule
|
|
122
|
+
syntax and the decision ladder.
|
|
123
|
+
|
|
124
|
+
## Tool calls
|
|
125
|
+
|
|
126
|
+
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/interactive-mode).
|
|
127
|
+
|
|
128
|
+
The conversation loop runs for up to **100 turns** by default. Raise or lower it with `--max-turns`. If the limit is reached, a warning is printed to stderr and the partial response is returned.
|
|
129
|
+
|
|
130
|
+
A few tools are disabled from headless runs. These tools are not useful in headless context, and usually are useful with a person
|
|
131
|
+
at the keyboard, such as asking you a question or opening a plan for approval.
|
|
132
|
+
|
|
133
|
+
You can enable these tools if you want:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# Everything
|
|
137
|
+
cmd -p "..." --tools-all
|
|
138
|
+
CMD_TOOLS_ALL_ENABLE=true cmd -p "..."
|
|
139
|
+
|
|
140
|
+
# Only enable the ones you name (comma-separated, repeatable)
|
|
141
|
+
cmd -p "..." --tools-enable ask_user_question
|
|
142
|
+
CMD_TOOLS_ASK_USER_QUESTION_ENABLE=true cmd -p "..."
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## JSON output
|
|
148
|
+
|
|
149
|
+
`--output-format json` turns print mode into a machine-readable stream. Use it when a script needs to react to the run, not just read the final answer.
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
cmd -p "summarize the auth module" --output-format json
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
The stream is **newline-delimited JSON** (NDJSON), one object per line, in two shapes.
|
|
156
|
+
|
|
157
|
+
**Event frames**, one per `AgentEvent` as the run progresses:
|
|
158
|
+
|
|
159
|
+
```json
|
|
160
|
+
{"type": "event", "event": {"type": "tool_running", "toolCallId": "…", "toolName": "read_file", "description": "…"}}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**One final result line**, always last:
|
|
164
|
+
|
|
165
|
+
```json
|
|
166
|
+
{"type": "result", "subtype": "success", "sessionId": "…", "stopReason": "end_turn", "usage": {…}, "durationMs": 8421, "finalText": "…"}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
| **Field** | **Always present?** | **Notes** |
|
|
170
|
+
| --------- | ------------------- | --------- |
|
|
171
|
+
| `subtype` | yes | `success`, `error`, or `max_turns` - comes first so a consumer can peek the outcome cheaply |
|
|
172
|
+
| `usage` | yes | Token usage totals for the run |
|
|
173
|
+
| `durationMs` | yes | Wall-clock duration |
|
|
174
|
+
| `finalText` | yes | The assistant's final answer, same text `--output-format text` would print. Empty string on an error result |
|
|
175
|
+
| `sessionId` | **optional** | Omitted when the run fails before a session is resolved (bad input, auth failure) |
|
|
176
|
+
| `stopReason` | **optional** | Why the loop ended (`end_turn`, `max_turns`, …). Omitted entirely on an error result |
|
|
177
|
+
| `error` | **optional** | Present only when `subtype` is `error` - stderr keeps the human-readable copy |
|
|
178
|
+
|
|
179
|
+
Treat `sessionId` and `stopReason` as optional. A run that fails early (auth, invalid input, session setup) emits `subtype: "error"` with neither field, so a script that indexes them unconditionally will break on exactly the cases it most needs to handle.
|
|
180
|
+
|
|
181
|
+
`--output-format text` (the default) keeps the classic behavior: just the final answer on stdout.
|
|
182
|
+
|
|
183
|
+
Parse line by line rather than buffering the whole stream. The event list grows over time, so treat unknown `event.type` values as forward-compatible and ignore them.
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Sessions & resuming
|
|
188
|
+
|
|
189
|
+
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.
|
|
190
|
+
|
|
191
|
+
### Continue the most recent run
|
|
192
|
+
|
|
193
|
+
`--continue` (or `-c`) resumes the most recent headless session in the current directory:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
cmd -p "find the slowest test"
|
|
197
|
+
cmd -p --continue "now suggest a fix" # carries the previous turn's context
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
If no headless session exists yet, `--continue` starts a fresh one - so a `-p --continue` loop works from the first iteration.
|
|
201
|
+
|
|
202
|
+
### Resume a specific session
|
|
203
|
+
|
|
204
|
+
Print the session id with `--verbose` (written to **stderr**, so stdout stays clean for piping):
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
cmd -p --verbose "start a code review" # stderr → session: 9f4e1c0a-...
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Then resume that exact session by id:
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
cmd -p --resume 9f4e1c0a-... "continue the review"
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
A bare `--resume` with no id errors in headless mode - there is no interactive picker. Use `--continue` to pick up the latest run instead.
|
|
217
|
+
|
|
218
|
+
### Open a headless session in interactive mode
|
|
219
|
+
|
|
220
|
+
Pass a headless session id to plain `cmd --resume <id>` (without `-p`) to load that transcript into a full interactive session:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
cmd --resume 9f4e1c0a-...
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Exit codes
|
|
229
|
+
|
|
230
|
+
Use exit codes to handle results in scripts and CI/CD:
|
|
231
|
+
|
|
232
|
+
| **Code** | **Meaning** | **Constant** |
|
|
233
|
+
| -------- | ----------- | ------------ |
|
|
234
|
+
| `0` | Success | `EXIT_SUCCESS` |
|
|
235
|
+
| `1` | General error | `EXIT_ERROR` |
|
|
236
|
+
| `3` | Not authenticated | `EXIT_AUTH_ERROR` |
|
|
237
|
+
| `4` | Permission denied | `EXIT_PERMISSION_DENIED` |
|
|
238
|
+
| `5` | Rate limit exceeded | `EXIT_RATE_LIMITED` |
|
|
239
|
+
| `6` | Network failure | `EXIT_CONNECTION_ERROR` |
|
|
240
|
+
| `7` | API server error (5xx) | `EXIT_SERVER_ERROR` |
|
|
241
|
+
| `8` | Max turns reached before final answer | `EXIT_MAX_TURNS_REACHED` |
|
|
242
|
+
| `9` | Model produced no response | `EXIT_NO_RESPONSE` |
|
|
243
|
+
| `10` | Insufficient credits | `EXIT_INSUFFICIENT_CREDITS` |
|
|
244
|
+
| `130` | Interrupted (SIGINT/SIGTERM) | `EXIT_INTERRUPTED` |
|
|
245
|
+
|
|
246
|
+
Example usage in a script:
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
cmd -p "check for security issues" --yolo
|
|
250
|
+
if [ $? -ne 0 ]; then
|
|
251
|
+
echo "Command Code failed"
|
|
252
|
+
exit 1
|
|
253
|
+
fi
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Decision models (typesafe/jev)
|
|
259
|
+
|
|
260
|
+
`typesafe/jev` is available on the headless mode as a decision model. It runs headless, on your normal login, and it bills $0.042 per 1M input tokens at cost; everything else is free.
|
|
261
|
+
|
|
262
|
+
It answers typed questions about a **state** with **probabilities** instead of text, so a script can branch on the number. The headless prompt is typesafe/jev's request as JSON. Request and response follow TypeSafe's [official shape](https://docs.typesafe.ai/api).
|
|
263
|
+
|
|
264
|
+
Here is an example of how to run it headlessly with cmd:
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
cmd -p '{
|
|
268
|
+
"state": {"diff": "- if (user.isAdmin)\n+ if (true)"},
|
|
269
|
+
"questions": {
|
|
270
|
+
"risky": {"type": "noul", "instructions": "Does this weaken an authorization check?"},
|
|
271
|
+
"category": {"type": "choice", "instructions": "Which kind of change is this?", "criteria": {"security": "auth or secrets", "bugfix": "wrong behavior", "refactor": "no behavior change"}}
|
|
272
|
+
}
|
|
273
|
+
}' -m typesafe/jev
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
```json
|
|
277
|
+
{
|
|
278
|
+
"model": "typesafe/jev",
|
|
279
|
+
"answers": {
|
|
280
|
+
"risky": {"type": "noul", "noul": 0.93},
|
|
281
|
+
"category": {"type": "choice", "choice": "security", "confidence": 0.81, "probabilities": {"security": 0.8, "bugfix": 0.15, "refactor": 0.05}}
|
|
282
|
+
},
|
|
283
|
+
"usage": {"input_tokens": 360, "output_tokens": 57}
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Interactive use is refused, since Jev is not a chat model. You can find the full request and response reference on the [Provider API page](https://commandcode.ai/docs/provider#decision-models-typesafe-jev).
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## Shell script
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
#!/bin/bash
|
|
295
|
+
set -e
|
|
296
|
+
|
|
297
|
+
# Generate docs for changed files
|
|
298
|
+
CHANGED=$(git diff --name-only HEAD~1)
|
|
299
|
+
echo "Document these changed files: $CHANGED" | cmd -p --skip-onboarding
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
## Piping output
|
|
303
|
+
|
|
304
|
+
Headless mode is pipe-friendly. Output goes to stdout, errors and warnings go to stderr:
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
# Save response to a file
|
|
308
|
+
cmd -p "generate a README for this project" > README.md
|
|
309
|
+
|
|
310
|
+
# Pipe to another command
|
|
311
|
+
cmd -p "list all TODO comments" | grep "critical"
|
|
312
|
+
|
|
313
|
+
# Use in command substitution
|
|
314
|
+
SUMMARY=$(cmd -p "summarize this codebase in one paragraph")
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## Related flags
|
|
320
|
+
|
|
321
|
+
Flags useful for headless and automated workflows:
|
|
322
|
+
|
|
323
|
+
| **Flag** | **Description** |
|
|
324
|
+
| -------- | --------------- |
|
|
325
|
+
| `-p, --print [query]` | Run in headless mode |
|
|
326
|
+
| `--output-format <format>` | Print-mode output: `text` (default) or `json` - see [JSON output](#json-output) |
|
|
327
|
+
| `-c, --continue` | Resume the most recent headless session in this directory |
|
|
328
|
+
| `-r, --resume <id>` | Resume a specific headless session by id (no bare picker in print mode) |
|
|
329
|
+
| `--verbose` | Print the resolved session id to stderr (for chaining `--resume`) |
|
|
330
|
+
| `--max-turns <number>` | Maximum conversation turns in print mode (default: `100`, no upper bound) |
|
|
331
|
+
| `--tools-all` | Enable every tool, including the ones headless runs disable - see [Tool calls](#tool-calls) |
|
|
332
|
+
| `--tools-enable <names>` | Enable specific withheld tools by name (comma-separated, repeatable) |
|
|
333
|
+
| `-m, --model <model>` | Run on a specific model this session |
|
|
334
|
+
| `--effort <level>` | Set reasoning effort (`low`, `medium`, `high`, …) |
|
|
335
|
+
| `--theme <theme>` | Set the color theme (`dark`, `light`, or `auto` to match the terminal background) |
|
|
336
|
+
| `--config <key=value>` | Set any setting headlessly (repeatable) - see below |
|
|
337
|
+
| `--yolo` | Allow file writes and shell commands |
|
|
338
|
+
| `--accept-edits` | Start in accept edits mode (alias for `--permission-mode accept-edits`) |
|
|
339
|
+
| `--skip-onboarding` | Skip taste onboarding (for CI/automated runs) |
|
|
340
|
+
| `-t, --trust` | Auto-trust project (skip initial permission prompt) |
|
|
341
|
+
| `--plan` | Start in plan mode (read-only exploration) |
|
|
342
|
+
| `--permission-mode <mode>` | Set permission mode: `default`, `plan`, `accept-edits`, `yolo`, `dont-ask` (`auto-accept`, `bypass`, and legacy `standard` accepted as aliases) |
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
## Configuring settings
|
|
347
|
+
|
|
348
|
+
Slash commands are interactive-only, but the settings behind them are available as **flags** -
|
|
349
|
+
never as a `/slash` string on the command line. The common ones have dedicated flags
|
|
350
|
+
(`--model`, `--effort`, `--theme`), and `--config key=value` reaches any setting the `/config`
|
|
351
|
+
UI can change:
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
# Set your model + reasoning effort for this run
|
|
355
|
+
cmd -p "review this diff" --model claude-sonnet-4-6 --effort high
|
|
356
|
+
|
|
357
|
+
# Set any setting; repeatable. Invalid keys/values exit non-zero.
|
|
358
|
+
cmd --config theme=dark --config compact-mode=fast
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
`--config` is the headless equivalent of the interactive `/config` UI, so a new setting becomes
|
|
362
|
+
scriptable automatically. Confirmations print to stderr, keeping `-p` stdout clean.
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
## Limitations
|
|
367
|
+
|
|
368
|
+
| **Limitation** | **Details** |
|
|
369
|
+
| -------------- | ----------- |
|
|
370
|
+
| **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 |
|
|
371
|
+
| **No resume picker** | A bare `--resume` errors in print mode; resume by explicit id or use `--continue` |
|
|
372
|
+
| **Stdin timeout** | Piped stdin times out after 30 seconds if no data is received |
|
|
373
|
+
| **Decision models are headless only** | `typesafe/jev` answers typed questions, not chat, so it runs with `-p` only (see [Decision model: Jev](#decision-models-typesafe-jev)) |
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## Next steps
|
|
378
|
+
|
|
379
|
+
- See [CLI Reference](https://commandcode.ai/docs/reference/cli) for the full list of flags and commands
|
|
380
|
+
- Learn about [Interactive Mode](https://commandcode.ai/docs/interactive-mode) for full-featured sessions
|
|
381
|
+
- Join our [Discord community](https://commandcode.ai/discord) for support
|