Skip to content

Commit 1380dfb

Browse files
committed
ai(rules[AGENTS]): Add shell command formatting rules for docs
why: Standardize shell code blocks for copy-pastability and readability what: - Add console language tag + $ prefix rule - Add line continuation rule for wide multi-flag commands - Scope to documentation shell examples, not doctests
1 parent fb1d763 commit 1380dfb

1 file changed

Lines changed: 37 additions & 1 deletion

File tree

AGENTS.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ EOF
404404

405405
When writing documentation (README, CHANGES, docs/), follow these rules for code blocks:
406406

407-
**One command per code block.** This makes commands individually copyable.
407+
**One command per code block.** This makes commands individually copyable. For sequential commands, either use separate code blocks or chain them with `&&` or `;` and `\` continuations (keeping it one logical command).
408408

409409
**Put explanations outside the code block**, not as comments inside.
410410

@@ -432,6 +432,42 @@ $ uv run pytest
432432
$ uv run pytest --cov
433433
```
434434

435+
### Shell Command Formatting
436+
437+
These rules apply to shell commands in documentation (README, CHANGES, docs/), **not** to Python doctests.
438+
439+
**Use `console` language tag with `$ ` prefix.** This distinguishes interactive commands from scripts and enables prompt-aware copy in many terminals.
440+
441+
Good:
442+
443+
```console
444+
$ uv run pytest
445+
```
446+
447+
Bad:
448+
449+
```bash
450+
uv run pytest
451+
```
452+
453+
**Split long commands with `\` for readability.** Each flag or flag+value pair gets its own continuation line, indented. Positional parameters go on the final line.
454+
455+
Good:
456+
457+
```console
458+
$ pipx install \
459+
--suffix=@next \
460+
--pip-args '\--pre' \
461+
--force \
462+
'libvcs'
463+
```
464+
465+
Bad:
466+
467+
```console
468+
$ pipx install --suffix=@next --pip-args '\--pre' --force 'libvcs'
469+
```
470+
435471
## Debugging Tips
436472

437473
When stuck in debugging loops:

0 commit comments

Comments
 (0)