Skip to content

Commit 1c4372d

Browse files
committed
ai(rules[AGENTS]) Unify code block rules
why: Code block guidance drifted into four variants across repos. what: - Merge the code block and shell command sections - Lead with the paste-and-run contract
1 parent 9089df0 commit 1c4372d

1 file changed

Lines changed: 22 additions & 56 deletions

File tree

AGENTS.md

Lines changed: 22 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -437,72 +437,38 @@ EOF
437437

438438
## Documentation Standards
439439

440-
### Code Blocks in Documentation
441-
442-
When writing documentation (README, CHANGES, docs/), follow these rules for code blocks:
443-
444-
**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).
445-
446-
**Put explanations outside the code block**, not as comments inside.
440+
### Code Blocks
441+
442+
Code blocks are paste-and-run units: pasting one block runs exactly one
443+
intended action. Doctests and other executed examples are exempt — the test
444+
suite runs them, nobody pastes them.
445+
446+
- **One command per block.** Multiple steps may share a block only when
447+
explicitly chained with `&&`, `;`, or `\` continuations — the chain is
448+
then one logical command.
449+
- **Explanations go in prose above the block**, never as `#` comments inside it.
450+
- **Command menus are per-command blocks with prose lead-ins**, not tables.
451+
- **Shell commands use the `console` tag with a `$ ` prefix.** This separates
452+
interactive commands from scripts and enables prompt-aware copy.
453+
- **Split long commands with `\`** — one flag or flag+value pair per indented
454+
continuation line, positional arguments last.
447455

448456
Good:
449457

450-
Run the tests:
451-
452-
```console
453-
$ uv run pytest
454-
```
455-
456-
Run with coverage:
457-
458-
```console
459-
$ uv run pytest --cov
460-
```
461-
462-
Bad:
463-
464-
```console
465-
# Run the tests
466-
$ uv run pytest
467-
468-
# Run with coverage
469-
$ uv run pytest --cov
470-
```
471-
472-
### Shell Command Formatting
473-
474-
These rules apply to shell commands in documentation (README, CHANGES, docs/), **not** to Python doctests.
475-
476-
**Use `console` language tag with `$ ` prefix.** This distinguishes interactive commands from scripts and enables prompt-aware copy in many terminals.
477-
478-
Good:
479-
480-
```console
481-
$ uv run pytest
482-
```
483-
484-
Bad:
485-
486-
```bash
487-
uv run pytest
488-
```
489-
490-
**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.
491-
492-
Good:
458+
Show the last ten commits as a graph:
493459

494460
```console
495-
$ pipx install \
496-
--suffix=@next \
497-
--pip-args '\--pre' \
498-
--force \
499-
'libvcs'
461+
$ git log \
462+
--max-count=10 \
463+
--graph \
464+
--oneline
500465
```
501466

502467
Bad:
503468

504469
```console
505-
$ pipx install --suffix=@next --pip-args '\--pre' --force 'libvcs'
470+
# Show the last ten commits as a graph
471+
$ git log --max-count=10 --graph --oneline
506472
```
507473

508474
### Changelog Conventions

0 commit comments

Comments
 (0)