Skip to content

Commit 6b2ef71

Browse files
committed
📝 Write down the Executable.md style guide
The bootstrap document was rewritten twice: once because the source read like a shell script wearing Markdown, and again because the rendered output narrated its own architecture while the most consequential action it took — granting a repository npm publish rights — printed nothing at all. Both rewrites came from one idea worth stating once: an executable document is read twice, as source by someone deciding whether to trust it and as output by the person running it, and both readings are designed. The rules that follow from it, and the Markdown > JavaScript/TypeScript > Bash/SH ordering that keeps each step at the level a reader can audit, now live beside the writing guide rather than in a review comment.
1 parent 807f7ff commit 6b2ef71

1 file changed

Lines changed: 50 additions & 1 deletion

File tree

‎AGENTS.md‎

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ here:
261261
`local/no-section-divider-comments` Oxlint rule
262262
(`scripts/oxlint-rules/`), which autofixes with `oxlint --fix`.
263263
11. Prefer expanding Executable.md capabilities over using JavaScript; Do not
264-
use JavaScript in MD without verifying with the user or planner agent.
264+
use JavaScript in MD without verifying with the user or planner agent. The
265+
Executable.md Style Guide governs how an executable document is written.
265266
12. Use contextual APIs for environment-specific behavior in production code.
266267
Shared production modules must not access host-specific APIs or detect the
267268
active runtime. Runtime-named entrypoints and adapters install
@@ -302,6 +303,54 @@ here:
302303
alternatives, defensive qualifications, and exhaustive detail that does not
303304
help a reader understand or use the design.
304305

306+
## Executable.md Style Guide
307+
308+
An executable document is read twice: as source, by someone deciding whether to
309+
trust what it does, and as output, by the person running it. Both readings are
310+
designed. `scripts/BootstrapNpmPackage.md` is the worked example.
311+
312+
1. **Write prose that executes, not a script with comments.** Each step explains
313+
why it is necessary, performs it, and shows a useful result. The explanation
314+
is the document's content, not commentary around it.
315+
2. **Explain a term where it first appears.** A document run once a year is run
316+
by someone who has not learned its vocabulary. Do not assume — educate.
317+
3. **Lead with the practical consequence** rather than the principle, and
318+
address the reader as `you`.
319+
4. **Report a completed action in the past tense.** A step that writes says that
320+
it wrote, and what. Announcing an intention beforehand does not replace it.
321+
5. **Explain a refusal before it can happen**, and make it actionable: name the
322+
command that resolves it, filled in with what the run actually found.
323+
6. **Keep machinery out of the output.** Captures, schemas, classifiers and
324+
bindings render nothing. A command whose own chatter reads worse than the
325+
document's sentence runs `silent`, and a command's raw output appears only
326+
where that output is the evidence.
327+
7. **Put in `<Output>` only what the reader of a run can still act on.** How to
328+
invoke the document is read before it runs, so it belongs outside the region.
329+
330+
### Markdown > JavaScript/TypeScript > Bash/SH
331+
332+
Express each step at the highest level that can carry it, and say why when
333+
dropping a level:
334+
335+
- **Markdown** for control flow, I/O and composition — `<If>`, `<Each>`,
336+
`<File>`, `<Parse>`, `<Capture>`, `<TempDir>`, and components. It is the layer
337+
a reader can audit and the engine can journal and replay.
338+
- **TypeScript** in `eval` blocks for comparison, classification and formatting.
339+
Typed, testable, and visible to the reader as a value rather than as text.
340+
- **Shell** to invoke a program, and for little else. Parsing, branching and
341+
string assembly in shell are quoting hazards a reader cannot audit and a test
342+
cannot reach.
343+
344+
A document that needs a value from a command captures the command's output and
345+
decides in TypeScript; it does not decide in the shell and report the verdict.
346+
347+
### Verifying a document
348+
349+
Render the output and read it as the person running it before calling the
350+
document done. In a test, install `useNormalizedOutput()` — the CLI installs it
351+
and `execute()` does not, so a raw capture shows whitespace the operator never
352+
sees.
353+
305354
## PR Process
306355

307356
1. Use .github/pull_request_template.md

0 commit comments

Comments
 (0)