Skip to content

Commit 5515774

Browse files
authored
Merge pull request #512 from signalwire/fern/prompt-guardrails
Reframe prompt guardrails, document the SWAIG wire protocol, and replace AI diagrams with themed SVGs
2 parents 8072a8f + 6f9db3d commit 5515774

36 files changed

Lines changed: 1704 additions & 938 deletions

File tree

.claude/docs/mdx-style-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MDX style — deep reference
22

3-
The five rules in `.claude/rules/` (`mdx-style`, `mdx-mechanics`, `mdx-components`, `mdx-reference-pages`, `docs-conventions`) are the binding contract and auto-load on MDX work. This file is the rationale and depth behind them: read it when doing dedicated style work (polishing a page, writing a new guide from scratch, adjudicating a style dispute), not for routine edits. Nothing in `.claude/docs/` auto-loads. Built 2026-07-21 from a five-track research pass (Claude Code docs, this repo's 2,801-page corpus, Fern's docs source, and external style-guide research); the full source-evaluation and per-rule provenance tables are recorded in the PR that introduced these rules.
3+
The rules in `.claude/rules/` are the binding contract: `mdx-style`, `mdx-mechanics`, `mdx-components`, `mdx-reference-pages`, and `docs-conventions` load on work under `fern/`; `spec-conventions` loads on TypeSpec under `specs/`; and root `CLAUDE.md` carries the repo-wide facts every session. Path-scoped rules fire when a matching file is read, so open the matching rule yourself when you create a file from scratch. This file is the rationale and depth behind them: read it when doing dedicated style work (polishing a page, writing a new guide from scratch, adjudicating a style dispute), not for routine edits. Nothing in `.claude/docs/` auto-loads. Built 2026-07-21 from a five-track research pass (Claude Code docs, this repo's 2,801-page corpus, Fern's docs source, and external style-guide research); the full source-evaluation and per-rule provenance tables are recorded in the PR that introduced these rules.
44

55
## Diátaxis in depth
66

.claude/rules/docs-conventions.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
paths:
33
- "fern/**/*.mdx"
44
- "fern/**/*.md"
5+
- "fern/**/*.yml"
6+
- "fern/**/*.yaml"
57
---
68

79
# Doc types — what you may edit
@@ -14,7 +16,7 @@ paths:
1416
| Guides, tutorials, concepts | `fern/products/*/pages/**` | Yes |
1517
| Snippets/partials | `fern/snippets/**` | Yes — re-check every page that includes them |
1618

17-
Generated artifacts — `fern/apis/**` and `specs/**/tsp-output/**` — are never hand-edited; the next build overwrites them.
19+
Generated artifacts — `specs/**/tsp-output/**` and the OpenAPI files it emits (`fern/apis/signalwire-rest/openapi.yaml`, `fern/apis/compatibility/openapi.yaml`) — are never hand-edited; the next build overwrites them. Not all of `fern/apis/` is generated: `calling-rpc/openrpc.yaml` has no generator and is hand-maintained (currently commented out of `fern/products/apis/apis.yml`). TypeSpec conventions live in `spec-conventions`.
1820

1921
## Applying audit findings
2022

.claude/rules/mdx-mechanics.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
paths:
33
- "fern/**/*.mdx"
44
- "fern/**/*.md"
5+
- "fern/**/*.yml"
6+
- "fern/**/*.yaml"
57
---
68

79
# MDX mechanics — Fern
@@ -57,6 +59,7 @@ Every page is also served as plain Markdown (append `.md` to its URL to preview)
5759
## Checks
5860

5961
- After MDX edits: `yarn fern-md-check`. If you touched any nav yml: `yarn fern-check`.
62+
- The MDX check only validates pages the nav references — it runs over the whole site and takes no file argument. Wire a new page into its `<product>.yml` before checking, or nothing validates it, CI included.
6063
- Hand-verify `#anchor` fragments in links you touched — no CI check covers them (lychee skips fragments).
6164
- Never run `yarn start:dev` (dev server) — ask the user to preview, and hand them the changed page URLs.
6265
- Propose commits via diff; don't commit unasked.

.claude/rules/mdx-style.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,18 @@ One page, one type. Smells: a tutorial or how-to that keeps stopping to explain
3434
- No emoji — not in headings, tab/card titles, or prose. Say good/bad in words. [SW]
3535
- Terminology: "Server SDKs" (never "Agents SDK"); tokens are *created*/*issued* (never *minted*); "resource addresses" (never "Fabric addresses"); expand every acronym at first use. [SW]
3636

37+
## Accessibility and inclusive language [G][MS]
38+
39+
- Link text names its destination and stands alone out of context — readers using screen readers scan link-to-link. Never "click here", "this page", "read more", or a bare URL as the label.
40+
- Don't identify anything by sight alone. Name the control by its label, not its position or color ("the green button on the right").
41+
- Bias-free wording: no ableist idioms (crazy, insane, blind to, dumb), no military or political metaphors, and no culture-bound idioms that won't survive translation. Describe people, not conditions.
42+
3743
## Grounding [SW]
3844

3945
- Every fact traces to specs, source, the dashboard, or a ticket. Can't verify? Write `[NEEDS SOURCE: what's missing]` — never guess. Never invent params, endpoints, components, or behavior.
4046
- Customer-facing only: no internal implementation detail (backend endpoints, transports, engine-side params). Placeholder data only — no real names, emails, or domains.
4147
- Examples do real work: tool call → your server → system of record → response. No knowledge-trivia bots.
48+
- Examples run as written: real imports, every required parameter, and only placeholders the reader can obviously fill. Verify each against the spec or SDK source — and against an actual run when the page ships a whole flow.
4249
- Don't cite other vendors' docs as authority; never disparage anyone's product.
4350

4451
## Modes

.claude/rules/spec-conventions.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
paths:
3+
- "specs/**/*.tsp"
4+
- "specs/**/*.ts"
5+
---
6+
7+
# Spec conventions — TypeSpec
8+
9+
`specs/` generates the REST reference (`signalwire-rest`, `compatibility-api`) and the SWML schemas. There are no MDX pages for any of it. Build with `yarn build:specs`, and commit the `.tsp` source together with the regenerated output; `specs/**/tsp-output/**` and the OpenAPI files under `fern/apis/` are artifacts the next build overwrites.
10+
11+
## Modeling
12+
13+
- Model the real API. Verify every field, type, default, and enum against backend source before adding it, and never invent one to make a shape tidy. Can't verify it? Leave it out and say so.
14+
- Source-verified is not the same as public. A field the engine reads belongs in a public spec only once a customer can actually obtain and set it.
15+
- Prefer structural modeling over magic decorators. Standards-first: keep any workaround quarantined and removable, with a comment naming what it works around.
16+
- No discriminated union when the discriminator is optional — OpenAPI requires the discriminator field to be required, and backends usually default it. Keep the params flat and cover the variants in prose.
17+
- When a payload is byte-identical to one that already exists, reference the canonical model instead of forking it for a separate nav entry.
18+
19+
## Editing
20+
21+
- `Unknown decorator` means a missing import, not a decorator to delete — the semantics differ (`@oneOf` is not implicit `anyOf`). Fix the import.
22+
- Apply repetitive edits by hand, one block at a time. No bulk scripts over spec files.
23+
- Decorator semantics belong in the emitter: wrap the stock emitter and delegate to it (`$onEmit` is exported). Never post-process emitted YAML in the build.
24+
25+
## Prose inside specs
26+
27+
`@doc` and `@example` text ships to customers, so the voice, grounding, and no-internal-details rules in `mdx-style` govern it.
28+
29+
## Checks
30+
31+
`yarn build:specs` must succeed, and the spec format's own validator or CLI is the conformance gate — schema-valid is not the same as idiomatic. Never write off a pre-existing build or CI error as out of scope; it usually marks real drift.

CLAUDE.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SignalWire docs
2+
3+
Fern-powered documentation site. Two sources of truth: MDX pages under `fern/products/**/pages/`, and TypeSpec under `specs/` that generates the REST and SWML reference.
4+
5+
## Authoring rules
6+
7+
`.claude/rules/` holds the binding conventions. They are path-scoped and fire when a matching file is read — so when you create a file from scratch, open the matching rule first: `mdx-style`, `mdx-mechanics`, `mdx-components`, `mdx-reference-pages`, `docs-conventions` for anything under `fern/`; `spec-conventions` for `specs/`. Rationale and depth behind the style rules: `.claude/docs/mdx-style-reference.md` (read on demand, never auto-loads).
8+
9+
## Don't hand-edit generated output
10+
11+
`specs/**/tsp-output/**` and the OpenAPI files it produces (`fern/apis/signalwire-rest/openapi.yaml`, `fern/apis/compatibility/openapi.yaml`) are build artifacts. The REST reference has no MDX at all: change the `.tsp` under `specs/`, run `yarn build:specs`, and commit source plus regenerated output together. When a rendered page is wrong, fix the generator or its source — never patch the output, which the next build overwrites.
12+
13+
## Everything here is customer-facing
14+
15+
Assume no prior knowledge, and never expose internal implementation detail — backend endpoints, transports, engine-side params. Every fact traces to source, a spec, the dashboard, or a ticket; if you can't verify one, write `[NEEDS SOURCE: what's missing]` instead of guessing.
16+
17+
## Verify
18+
19+
| Change | Run |
20+
|---|---|
21+
| MDX pages | `yarn fern-md-check` |
22+
| Nav yml (`fern/docs.yml`, `fern/products/*/*.yml`) | `yarn fern-check` |
23+
| TypeSpec under `specs/` | `yarn build:specs` |
24+
25+
CI runs `fern-check` and `fern-md-check` on every PR. No check covers `#anchor` fragments — verify by hand any link you touch.
26+
27+
Never start the dev server (`yarn start`, `yarn start:dev`, `fern docs dev`). Ask the user to preview, and hand them the URLs of the pages you changed.

0 commit comments

Comments
 (0)