chiltepin 0.47.0

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.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +249 -0
  3. package/dist/bin.js +3582 -0
  4. package/dist/bin.js.map +1 -0
  5. package/package.json +93 -0
  6. package/templates/chiltepin.config.json +5 -0
  7. package/templates/demo.md +2161 -0
  8. package/templates/docs/getting-started.md +155 -0
  9. package/templates/docs/tutorial.md +559 -0
  10. package/templates/skill/SKILL.md +172 -0
  11. package/templates/skill/reference/blocks/INDEX.md +141 -0
  12. package/templates/skill/reference/blocks/agentic.md +63 -0
  13. package/templates/skill/reference/blocks/algorithms.md +49 -0
  14. package/templates/skill/reference/blocks/api.md +40 -0
  15. package/templates/skill/reference/blocks/architecture.md +94 -0
  16. package/templates/skill/reference/blocks/business.md +70 -0
  17. package/templates/skill/reference/blocks/charts-overviews.md +74 -0
  18. package/templates/skill/reference/blocks/data-model.md +34 -0
  19. package/templates/skill/reference/blocks/design-system.md +50 -0
  20. package/templates/skill/reference/blocks/flows.md +74 -0
  21. package/templates/skill/reference/blocks/narrative.md +65 -0
  22. package/templates/skill/reference/blocks/planning.md +74 -0
  23. package/templates/skill/reference/blocks/quality.md +43 -0
  24. package/templates/skill/reference/blocks/tables-data.md +55 -0
  25. package/templates/skill/reference/check.md +62 -0
  26. package/templates/skill/reference/decks.md +198 -0
  27. package/templates/skill/reference/exemplars/adr.md +87 -0
  28. package/templates/skill/reference/exemplars/agent-system.md +113 -0
  29. package/templates/skill/reference/exemplars/api-reference.md +110 -0
  30. package/templates/skill/reference/exemplars/backend-arch.md +117 -0
  31. package/templates/skill/reference/exemplars/data-pipeline.md +107 -0
  32. package/templates/skill/reference/exemplars/frontend-arch.md +93 -0
  33. package/templates/skill/reference/exemplars/incident-postmortem.md +93 -0
  34. package/templates/skill/reference/exemplars/migration-plan.md +95 -0
  35. package/templates/skill/reference/exemplars/onboarding.md +78 -0
  36. package/templates/skill/reference/exemplars/product-spec.md +81 -0
  37. package/templates/skill/reference/intake.md +140 -0
  38. package/templates/skill/reference/mermaid.md +216 -0
  39. package/templates/skill/reference/organizing.md +118 -0
  40. package/templates/skill/reference/patterns-design.md +59 -0
  41. package/templates/skill/reference/patterns.md +167 -0
  42. package/templates/skill/reference/recipes.md +153 -0
  43. package/templates/skill/reference/style-ste.md +119 -0
  44. package/templates/skill/reference/system-design.md +161 -0
  45. package/templates/skill/reference/writing.md +132 -0
@@ -0,0 +1,140 @@
1
+ # Intake checklists — what to ask before writing
2
+
3
+ Part of the **chiltepin** skill (the hub is `SKILL.md`, one folder up). Use
4
+ this in move 1 (*Understand the ask — and ask back*) of every new document.
5
+
6
+ ## The ask-back protocol
7
+
8
+ 1. **Identify the document type.** Match the ask to a checklist below (they
9
+ mirror the *Document playbooks* table in `SKILL.md`). No match → fall back to
10
+ the four generic questions: reader & moment · job · scope · form.
11
+ 2. **Collect the checklist and diff it against the ask.** Note which items the
12
+ user already answered — never ask for something they told you.
13
+ 3. **Ask everything at once.** Ask for every missing **CRITICAL** item in ONE
14
+ batched message of 2-6 pointed questions — never drip one question per turn.
15
+ Fold in a nice-to-have only when its answer would change the outline.
16
+ 4. **If the user is unavailable** (or the gaps are minor), proceed with explicit
17
+ assumptions. Add a `callout` (`tone: note`, title *Assumptions*) near the top
18
+ of the doc, listing each guess so every one is visible and correctable.
19
+
20
+ Each checklist marks items **CRITICAL** (the document is wrong without them)
21
+ vs *nice-to-have* (improves it, but safely assumable).
22
+
23
+ > **Raw tabular data?** When the source material is a spreadsheet/CSV export,
24
+ > don't hand-transcribe it into YAML — import it. `chiltepin sync csv <file>` prints
25
+ > a ready-made `table` / `statustable` / `chart` fence (it auto-picks the
26
+ > block and says why), and dropping the `.csv` onto the studio canvas inserts
27
+ > the block in place. Ask for the export, not a screenshot of it.
28
+
29
+ ## API / endpoint spec
30
+
31
+ - **CRITICAL** — the routes + methods to document (all of them, or which subset?).
32
+ - **CRITICAL** — the auth model: scheme, token type, scopes/permissions per route.
33
+ - Request/response examples — real payloads beat invented ones.
34
+ - Error codes and what each means to the caller.
35
+ - Rate limits (per key? per IP? headers exposed?).
36
+ - Versioning scheme (URL, header, none).
37
+
38
+ ## System design
39
+
40
+ - **CRITICAL** — functional requirements: what must the system do, for whom?
41
+ - **CRITICAL** — scale numbers: DAU, writes/day, reads/day, data size and growth.
42
+ - **CRITICAL** — latency and consistency targets (p95/p99; strong vs eventual, where).
43
+ - Existing stack and constraints (languages, cloud, what's already built).
44
+ - Budget envelope (infra spend, buy-vs-build appetite).
45
+ - Team size and skill mix (shapes how much operational complexity is affordable).
46
+
47
+ ## Agent system
48
+
49
+ - **CRITICAL** — the model(s) used, and where in the loop.
50
+ - **CRITICAL** — the tools: each tool's name and what it actually does.
51
+ - **CRITICAL** — stop conditions: when does the loop end, and what bounds it?
52
+ - Memory strategy (none, scratchpad, vector store, summaries — and eviction).
53
+ - One real transcript of a representative episode (for the `trace` block).
54
+ - Eval criteria — how is "it works" measured?
55
+ - Guardrails: input/output filtering, permissioning, human-in-the-loop points.
56
+
57
+ ## Architecture overview / onboarding
58
+
59
+ - **CRITICAL** — the system inventory: the services/components and one line each.
60
+ - **CRITICAL** — the one key request path a new joiner will touch most.
61
+ - Owners — which team/person owns each piece.
62
+ - Deploy topology (where it runs: regions, clusters, environments).
63
+
64
+ ## Runbook
65
+
66
+ - **CRITICAL** — the trigger: which alert/symptom puts you in this runbook?
67
+ - **CRITICAL** — the exact commands to run, verbatim (no "restart the service" hand-waving).
68
+ - **CRITICAL** — the verification step: how do you know it worked?
69
+ - Access needed (VPN, roles, break-glass credentials) before you start.
70
+ - Escalation path — who to page when the runbook doesn't resolve it.
71
+ - Rollback — how to undo the intervention if it makes things worse.
72
+
73
+ ## ADR
74
+
75
+ - **CRITICAL** — the options actually considered (not a padded strawman list).
76
+ - **CRITICAL** — the deciding constraint: which force actually picked the winner?
77
+ - **CRITICAL** — status: proposed, accepted, superseded?
78
+ - Consequences observed so far (if the decision already shipped).
79
+
80
+ ## Roadmap
81
+
82
+ - **CRITICAL** — the horizon (quarter? half? year?).
83
+ - **CRITICAL** — the milestones and what "done" means for each.
84
+ - **CRITICAL** — current status per milestone/phase.
85
+ - Owners per workstream.
86
+ - Dependencies between items (and on other teams).
87
+
88
+ ## Design system
89
+
90
+ - **CRITICAL** — the token source: actual color values, type sizes/weights, spacing.
91
+ - **CRITICAL** — the component list with a status per component (stable/beta/…).
92
+ - Usage rules — the do/don't guidance per token or component.
93
+ - Contribution process — how a new component gets in.
94
+
95
+ ## Deck
96
+
97
+ - **CRITICAL** — the audience (engineers? leadership? customers?).
98
+ - **CRITICAL** — the time slot (5 minutes and 30 need different decks).
99
+ - **CRITICAL** — the decision sought — what should the room say yes to?
100
+ - The 3 numbers that matter (the exhibits hang off them).
101
+ - Appendix depth — how much backup material to prepare.
102
+
103
+ ## Data model
104
+
105
+ - **CRITICAL** — the entities and their relationships (with cardinality).
106
+ - **CRITICAL** — lifecycle states: which records have a state machine, and what is it?
107
+ - Volumes per table (rows now, growth rate).
108
+ - Retention — what gets deleted/archived, and when.
109
+
110
+ ## Postmortem / incident
111
+
112
+ - **CRITICAL** — the timeline: detection → mitigation → resolution, with times.
113
+ - **CRITICAL** — the impact: who/what was affected, how badly, for how long.
114
+ - **CRITICAL** — the root cause (the real one, not the first symptom).
115
+ - Action items with owners (and due dates if agreed).
116
+
117
+ ## Reviewing an existing doc
118
+
119
+ When asked to review (not write) a doc, walk this checklist top to bottom and
120
+ report findings per item — worst first. Fix only what you were asked to fix.
121
+
122
+ 1. **Skim test.** Read only the `meta` title and the `##` headings: do they
123
+ tell one story (orient → big picture → detail → plan)? Headings that could
124
+ sit on any document mean it was templated.
125
+ 2. **One lens per beat.** No two blocks drawing the same boxes; no three
126
+ tables in a row where one wants to be a `matrix`, `list`, or diagram.
127
+ 3. **Thin blocks.** A block with fewer than ~3 rows/nodes should fold into
128
+ prose or a `callout`. An empty block is a `W_EMPTY_BLOCK` waiting to fire.
129
+ 4. **YAML pitfalls scan.** Unquoted `,` `:` `#` in `desc`/`note`/`summary`
130
+ fields, unquoted hex colors, unquoted `1:N` cardinality, numeric-looking
131
+ strings (`version: 1.0`, `delta: 0`) — the usual parse traps.
132
+ 5. **Refs.** Every `ref:` points at an id that exists; same-doc refs use bare
133
+ `#id`; blocks other docs might need carry an `id:`.
134
+ 6. **Title/heading agreement.** Each block's `title` and its `##` heading
135
+ sound like one author; the `meta` cover matches the doc's actual content.
136
+ 7. **Stale facts.** Counts, versions, dates, and status fields
137
+ (`timeline`/`statustable`/`inventory`) that no longer match reality — flag
138
+ them even when you can't verify the correction.
139
+ 8. **Close with `chiltepin check`.** A review isn't done until the doc validates
140
+ clean — report any diagnostic verbatim.
@@ -0,0 +1,216 @@
1
+ # Input dialects — Mermaid, DBML, Prisma
2
+
3
+ Part of the **chiltepin** skill (the hub is `SKILL.md`, one folder up).
4
+
5
+ Three fence tags hold a body that is not YAML. The parser converts the body
6
+ into a typed block at read time; validation and rendering are the same as
7
+ for a YAML block. The Markdown file keeps the dialect text until an editor
8
+ changes the block; an edit writes the block back as YAML under its
9
+ canonical tag.
10
+
11
+ | Fence | Block | Subset |
12
+ |---|---|---|
13
+ | ` ```mermaid ` + `sequenceDiagram` | `sequence` | below |
14
+ | ` ```mermaid ` + `flowchart` / `graph` | `flow` | below |
15
+ | ` ```mermaid ` + `erDiagram` | `erd` | below |
16
+ | ` ```mermaid ` + `stateDiagram` / `stateDiagram-v2` | `state` | below |
17
+ | ` ```mermaid ` + `pie` | `chart` (`kind: donut`) | below |
18
+ | ` ```dbml ` | `erd` | [DBML](#dbml) |
19
+ | ` ```prisma ` | `erd` | [Prisma](#prisma) |
20
+
21
+ SQL DDL is **not** a fence dialect (a ` ```sql ` fence is usually a code
22
+ sample). Convert a schema file with `chiltepin sync sql schema.sql --out
23
+ docs/data-model.md`; `chiltepin sync dbml` and `chiltepin sync prisma` do the same for
24
+ files.
25
+
26
+ ## The rule
27
+
28
+ Write a dialect fence when you already have the text in that grammar and
29
+ the diagram needs only what the subset can say. Switch to the typed YAML
30
+ block when you need a field the dialect cannot say: `endpoint`, `foot`,
31
+ `summary` / `code` / `note` on a message, `groups`, `guard`, node `kind`
32
+ overrides, `accent`, `description`, `lede`, or an erd `dir` / relation
33
+ `label`. Never mix: one fence is either dialect text or YAML.
34
+
35
+ # Mermaid
36
+
37
+ A ` ```mermaid ` fence whose first non-comment line is one of the five
38
+ keywords above converts. Any other first line (`gantt`, `classDiagram`,
39
+ `mindmap`, `gitGraph`, …) is not converted: the fence stays prose and
40
+ renders as a plain code block, with no diagnostic. `%%` comment lines are
41
+ ignored in every grammar.
42
+
43
+ ## sequenceDiagram
44
+
45
+ - `participant A`, `participant A as Name`, `actor A as Name` → an actor
46
+ `{ id, name }`. Without `as`, the id is the name. An id used in a message
47
+ but never declared is added at its first use, in order, as Mermaid does.
48
+ - Messages: `A->>B: text` sync · `A-->>B: text` response · `A-)B: text`
49
+ async · `A--)B: text` response · `A-xB: text` and `A--xB: text` error ·
50
+ `A->B:` sync · `A-->B:` response. The text after `:` is the label.
51
+ - `Note over A,B: text`, `Note right of A: text`, `Note left of A: text` →
52
+ a message `{ from: A, to: B, kind: note }` (`to` is `A` for a one-actor
53
+ note).
54
+ - `title Text` → `title`.
55
+ - Fragments: `alt text` / `opt text` / `loop text` / `par text` /
56
+ `critical text` / `break text` → a frame open `{ frame, label }`; `else
57
+ text`, `and text`, `option text` → `{ else: text }`; `end` → `{ end: true }`.
58
+ The frame renders as a UML frame around its messages.
59
+ - `A->>+B: text` sets `activate: true` on the message (a bar opens on B);
60
+ `B-->>-A: text` sets `deactivate: true` (the bar on B, the sender, closes).
61
+ - Ignored: `autonumber`, standalone `activate X` / `deactivate X` lines, and
62
+ `rect` / `box` … `end` (the messages inside are kept; the coloured box is
63
+ lost).
64
+ - Any other line is an error (`E_PARSE_MERMAID`, with the line number).
65
+
66
+ ## flowchart / graph
67
+
68
+ - Direction: `TD` and `TB` → `dir: TB`; `LR`, `RL`, `BT` → `dir: LR`; none →
69
+ `TB`. The renderer lays the nodes out; Mermaid positions are not kept.
70
+ - Node shapes: `A[text]`, `A(text)`, `A[/text/]`, `A[\text\]`, `A>text]`,
71
+ `A[(text)]`, `A[[text]]` → process. `A{text}`, `A{{text}}` → `decision`.
72
+ `A([text])`, `A((text))` → `start` when the node has no incoming edge,
73
+ `end` when it has no outgoing edge, otherwise process. A bare `A` uses the
74
+ id as its label. Quotes around a label are removed. Ids keep their Mermaid
75
+ spelling.
76
+ - Edges: `A --> B`, `A -->|label| B`, `A -- label --> B`, `A -.-> B`,
77
+ `A -. label .-> B`, `A ==> B`, `A --- B`. A dotted edge (`-.->`) becomes
78
+ `kind: dashed`; a thick edge (`==>`) renders as a plain edge. `A --x B` →
79
+ `kind: error`. `A <--> B` is one edge from A to B.
80
+ - Chains `A --> B --> C` and fans `A & B --> C` expand to one edge per pair.
81
+ `;` separates statements on one line.
82
+ - Lost: `subgraph … end` framing. The nodes inside are kept; the box is
83
+ dropped, because `flow` groups need grid coordinates and the auto layout
84
+ has none. Add `groups` with `col` / `row` in a YAML `flow` block instead.
85
+ - Ignored: `style`, `classDef`, `class`, `click`, `linkStyle`, `direction`
86
+ inside a subgraph, and `:::class` suffixes.
87
+
88
+ ## erDiagram
89
+
90
+ - `A ||--o{ B : label` → a relation. Left ends `||` `|o` (one) and `}o` `}|`
91
+ (many); right ends `||` `o|` (one) and `o{` `|{` (many). One–one → `1:1`,
92
+ one–many → `1:N`, many–one → `N:1`, many–many → `N:M`. A `..` body sets
93
+ `identifying: false` (dashed); `--` is identifying. The label loses its
94
+ quotes; `""` means no label.
95
+ - `A { type name PK "comment" }` → an entity with `columns: [{ name, type,
96
+ pk }]`. `FK` → `fk: true`, `UK` → `unique: true`, the `"comment"` →
97
+ `note`. An entity named only in a relation is added with no columns.
98
+ Names may be quoted: `"Order Line"`.
99
+ - Ignored: `direction`.
100
+
101
+ ## stateDiagram / stateDiagram-v2
102
+
103
+ - `[*]` becomes a pseudo-state node: `_start` (`kind: start`, the filled
104
+ dot) or `_end` (`kind: terminal`, the bullseye). `[*] --> A : event` and
105
+ `A --> [*]` are ordinary transitions from or to that node.
106
+ - `A --> B : event` → `{ from, to, event }`. Without `: event` the event is
107
+ the empty string, which renders as an unlabelled arrow.
108
+ - `state "Long name" as A` → `{ id: A, name: "Long name" }`. `A : text` sets
109
+ the name of A. A bare `state A` or an id used only in a transition is named
110
+ by its id.
111
+ - `direction LR|TB` at the top level → `dir`.
112
+ - Lost: composite states `state A { … }` are flattened. The inner states and
113
+ transitions are kept; the container box is dropped. An inner `[*]` gets
114
+ its own pseudo-state, `_start_A` / `_end_A`.
115
+ - Ignored: `note … end note` blocks, one-line `note right of A : text`, `--`
116
+ concurrency separators, `<<fork>>`-style stereotypes, `classDef`, `class`.
117
+
118
+ ## pie
119
+
120
+ - `pie`, optionally followed by `showData` and/or `title Text` on the same
121
+ line. `title Text` on its own line also works.
122
+ - `"Label" : 42` → an item `{ label, value }`. Decimals are accepted.
123
+ - Result: `{ kind: donut, title?, items }`.
124
+
125
+ # DBML
126
+
127
+ A ` ```dbml ` fence always converts to an `erd`. The subset:
128
+
129
+ - `Table [schema.]name [as Alias] { … }` → an entity. A `schema.` prefix
130
+ sets `schema` (the renderer draws a panel per schema). Header settings
131
+ (`[headercolor: …]`) are dropped.
132
+ - Column line `name type [settings]`. Settings: `pk` / `primary key` →
133
+ `pk`; `unique` → `unique`; `not null` → `nullable: false`; `null` →
134
+ `nullable: true`; `default: value` → `default` (quotes and backticks
135
+ removed: `` `now()` `` → `now()`); `note: '…'` → `note`; `ref: > t.c` /
136
+ `< t.c` / `- t.c` / `<> t.c` → a relation (below). `increment` and any
137
+ other `key: value` setting are dropped. A type with spaces must be
138
+ quoted (`"double precision"`); `varchar(255)` and `decimal(10, 2)` work.
139
+ - `Note: '…'` (or a `Note: '''…'''` block) inside a table → the entity
140
+ `note`.
141
+ - `indexes { (a, b) [unique, name: '…'] }` → `indexes` on the entity; a
142
+ single-column index sets `index` (or `unique`) on the column; `[pk]`
143
+ marks a composite primary key.
144
+ - `Ref [name]: a.b > c.d` and the `Ref { … }` block: `>` many-to-one (`a.b`
145
+ is the foreign key, relation `N:1` from `a` to `c`), `<` one-to-many (the
146
+ key is on `c.d`), `-` one-to-one (`1:1`; the key goes on the side whose
147
+ column is not the primary key), `<>` many-to-many (`N:M`, no key).
148
+ Composite ends: `t.(a, b)`. Ref settings (`[delete: cascade]`) are
149
+ dropped. A referenced table that is never declared becomes an `external`
150
+ entity.
151
+ - `Enum [schema.]name { value [note: '…'] }` → `enums` (value notes are
152
+ dropped).
153
+ - `TableGroup name { t1 t2 }` → `groups`.
154
+ - Skipped: `Project { … }`, sticky `Note x { … }`, `TablePartial`; `//` and
155
+ `/* … */` comments.
156
+ - Any other line is an error (`E_PARSE_DBML`, with the line number).
157
+
158
+ # Prisma
159
+
160
+ A ` ```prisma ` fence always converts to an `erd`. The subset:
161
+
162
+ - `model X { … }` → an entity; `view X { … }` → `kind: view`. A `///` doc
163
+ comment before the block → the entity `note`.
164
+ - Field line `name Type[?|[]] @attrs`. A scalar or enum type → a column
165
+ (`String`, `Int`, `DateTime`, … as written; `String[]` keeps the `[]`;
166
+ `Unsupported("x")` → `x`). `?` → `nullable: true`. `@id` → `pk`;
167
+ `@unique` → `unique`; `@default(v)` → `default` (`uuid()`, `now()`,
168
+ `autoincrement()`, `"str"` unquoted, `dbgenerated("…")` unwrapped). A
169
+ `///` doc comment before the field → `note`.
170
+ - A field whose type is another model is a relation field, never a column.
171
+ `@relation(fields: [a], references: [b])` marks `a` as the foreign key
172
+ (`ref: Model.b`) and adds the relation `N:1` from this model — `1:1` when
173
+ the key columns are unique. An optional relation field (`User?`) makes
174
+ the key column nullable. A relation `"name"` becomes the `label`. A list
175
+ on both sides with no `fields` (implicit many-to-many) → one `N:M`. The
176
+ back side of an explicit relation adds nothing.
177
+ - `@@id([a, b])` → composite `pk`; `@@unique([...])` / `@@index([...])` →
178
+ `indexes` (single-column ones set `unique` / `index` on the column);
179
+ `@@schema("x")` → `schema`.
180
+ - Dropped: `@map` / `@@map`, `@db.*`, `@updatedAt`, `@ignore` / `@@ignore`,
181
+ `onDelete` / `onUpdate`; `datasource`, `generator` and composite `type`
182
+ blocks; `//` comments.
183
+ - Any other line is an error (`E_PARSE_PRISMA`, with the line number).
184
+
185
+ # SQL DDL (`chiltepin sync sql`)
186
+
187
+ Not a fence. `chiltepin sync sql schema.sql` prints an ` ```erd ` fence; add
188
+ `--out docs/data-model.md` to write a doc and validate it. The subset:
189
+
190
+ - `CREATE TABLE [IF NOT EXISTS] [schema.]name ( … )` with column
191
+ definitions: `name type` (multi-word and parenthesised types work:
192
+ `timestamp with time zone`, `numeric(10, 2)`, `int unsigned`, `text[]`),
193
+ then `NOT NULL` / `NULL`, `PRIMARY KEY`, `UNIQUE`, `DEFAULT expr` (kept
194
+ as text: `now()`, `'open'::order_status`, `CURRENT_TIMESTAMP`),
195
+ `REFERENCES t (c) [ON DELETE …]`, MySQL `COMMENT '…'` → `note`, MySQL
196
+ `ENUM('a','b')` → `enum`. Table constraints: `[CONSTRAINT n] PRIMARY KEY
197
+ (…)`, `UNIQUE (…)`, `FOREIGN KEY (…) REFERENCES t (…)`, MySQL `KEY` /
198
+ `INDEX (…)`. A table `COMMENT = '…'` option → `note`.
199
+ - `CREATE [UNIQUE] INDEX … ON t (cols)`, `ALTER TABLE t ADD [CONSTRAINT]
200
+ PRIMARY KEY | UNIQUE | FOREIGN KEY …`, `CREATE TYPE t AS ENUM (…)` →
201
+ `enums`, `CREATE [MATERIALIZED] VIEW v [(cols)] AS SELECT …` → a `view`
202
+ entity (columns from the list or a simple select list), `COMMENT ON
203
+ TABLE | COLUMN … IS '…'` → `note`.
204
+ - Postgres `"x"`, MySQL `` `x` `` and SQL Server `[x]` quoting; `--`, `#`
205
+ and `/* … */` comments; `$$` bodies. The `public` / `dbo` schema prefix
206
+ is dropped; any other prefix sets `schema`.
207
+ - Dropped: `CHECK`, `AUTO_INCREMENT`, `GENERATED … AS IDENTITY`, `COLLATE`,
208
+ `CHARACTER SET`, `ON DELETE` actions, storage options. Every other
209
+ statement (`INSERT`, `GRANT`, `CREATE FUNCTION`, …) is skipped.
210
+ - A `CREATE TABLE` the subset cannot read fails with its line.
211
+
212
+ # Errors
213
+
214
+ `E_PARSE_MERMAID`, `E_PARSE_DBML` and `E_PARSE_PRISMA` name the body line
215
+ the subset cannot read. Fix the line to match the subset above, or rewrite
216
+ the block as typed YAML. A dialect fence never produces `W_ALIAS_TYPE`.
@@ -0,0 +1,118 @@
1
+ # Organizing a documentation set
2
+
3
+ Part of the **chiltepin** skill (the hub is `SKILL.md`, one folder up). One
4
+ doc is a story; a docs folder is a *library*. Use this when a project outgrows
5
+ a single file — or when you're deciding whether it has.
6
+
7
+ ## Where files live
8
+
9
+ | Path | What it holds |
10
+ | --- | --- |
11
+ | `docs/` (or the configured `docsDir`) | All docs. One group level: `docs/<area>/<doc>.md`. Deeper nesting is drift. |
12
+ | `dist/` (the build default) | Generated output. Never commit it. |
13
+ | `.chiltepin/` | Tooling state — `skill/` is the authoring skill. |
14
+ | `chiltepin.config.json` | Project config, at the root. |
15
+ | `resources/` (or any folder outside `docsDir`) | Demo and fixture docs. Not part of the built site. |
16
+
17
+ Doc filenames are kebab-case slugs: lowercase a-z, 0-9, hyphens, `.md`. The
18
+ path is the reference prefix (`doc#id`), so slugs are load-bearing. Put a new
19
+ doc at `docs/<area>/<doc>.md` — `chiltepin check` warns (`W_DOC_CONVENTION`) when a
20
+ name is not kebab-case or a doc sits deeper than one group level.
21
+
22
+ ## Four kinds of document
23
+
24
+ Readers arrive with one of four needs, and a page that serves two of them
25
+ serves neither (the Diátaxis split, used by Canonical, Python, and
26
+ Cloudflare). Name the kind in `meta.tag` and keep each doc to one:
27
+
28
+ | Kind | Reader need | Typical blocks |
29
+ | --- | --- | --- |
30
+ | Tutorial | learn by doing, start to finish | `steps`, `code`, `callout` |
31
+ | How-to | get one task done now | `steps`, `flow`, `checklist` items, `table` |
32
+ | Reference | look a fact up | `endpoint`, `table`, `erd`, `spec`, `glossary` |
33
+ | Explanation | understand why it is this way | `c4`, `sequence`, `options`, `scqa`, `timeline` |
34
+
35
+ A runbook is a how-to. An architecture overview is an explanation. An API
36
+ doc is a reference; its "getting started" section is a tutorial and wants
37
+ its own page once it passes three steps.
38
+
39
+ ## When to split into multiple docs
40
+
41
+ One document = **one system (or one job) for one audience**. Split when any of
42
+ these hold; otherwise stay in one file — a 4-block doc doesn't need a folder.
43
+
44
+ - **Two audiences.** An integrator reference and a new-joiner explainer about
45
+ the same service are two docs, not two halves of one.
46
+ - **Two systems.** The orders service and the notification pipeline each get a
47
+ doc, even if they talk to each other — connect them with refs, not by merging.
48
+ - **Two jobs.** "How it works" (overview) and "what to do at 3am" (runbook)
49
+ read at different speeds. A runbook buried in an architecture doc won't be
50
+ found during the incident.
51
+ - **The skim breaks.** If reading only the `##` headings no longer tells one
52
+ story (see move 2 in `SKILL.md`), the extra beats want their own doc.
53
+
54
+ ## Slugs — the path *is* the reference prefix
55
+
56
+ A doc's **slug** is its path under the docs root without `.md`:
57
+ `docs/payments/api.md` → slug `payments/api` → its blocks are referenced as
58
+ `payments/api#some-id`. Renaming a file renames every ref to it, so:
59
+
60
+ - **kebab-case** file and folder names (`getting-started.md`, not
61
+ `GettingStarted.md`).
62
+ - **Folders are domains**, not types: `docs/payments/`, `docs/identity/` —
63
+ never `docs/diagrams/` or `docs/misc/`.
64
+ - Name for the subject, not the format: `orders-api.md`, not `api-doc-v2.md`.
65
+ - Avoid ids named like `section-*` — the renderer uses those for its own
66
+ section anchors.
67
+
68
+ ## The index / overview doc
69
+
70
+ Give a multi-doc set a landing page — `docs/overview.md` (or
71
+ `docs/<domain>/overview.md` per domain). It holds a `meta` block, 2-4
72
+ sentences of prose on what the set covers, and one big-picture block (`c4`
73
+ context or `archmap`). When the set is large, add a `table` or `list` of the
74
+ other docs and the job each does. It's the doc a new reader opens first and the
75
+ natural home for ids that many docs reference.
76
+
77
+ ## Cross-doc references
78
+
79
+ - Ids are **repo-global unique** — `id: seq-place-order` can exist once across
80
+ the whole docs tree, so a ref always has exactly one target.
81
+ - **Same doc → prefer `#id`** (survives file renames). Other doc →
82
+ `slug#id` (`payments/api#seq-charge`).
83
+ - Point stories at the diagrams that realize them
84
+ (`userstory.links[].ref` / `stories.items[].links[].ref` — the ref-bearing
85
+ fields), rather than redrawing the diagram in the second doc.
86
+ - Draw each diagram in the doc that *owns* it; every other doc links. When a
87
+ system changes, one block changes.
88
+ - `chiltepin check` fails on dangling refs and duplicate ids across the whole set —
89
+ run it after any rename or move.
90
+
91
+ ## How `chiltepin build` and `chiltepin studio` (Site mode) consume the set
92
+
93
+ The layout above is exactly what the site generator reads:
94
+
95
+ - **`chiltepin build`** renders every doc under the docs root into a static site.
96
+ `index.html` is a card grid built from each doc's `meta` (title · subtitle ·
97
+ tag — another reason `meta` is never optional). Each doc becomes
98
+ `<slug>.html` (folders keep their nesting), and a sidebar lists every doc
99
+ with the current doc's sections expanded.
100
+ - **Refs become links.** A `userstory`/`stories` link chip navigates to its
101
+ target block — same page or `other-doc.html#id` across pages. A dangling ref
102
+ degrades to a plain chip (and `chiltepin check` will name it).
103
+ - **`chiltepin studio` Site mode** is the authoring loop: the studio mounts the
104
+ same site from memory under `/site/…` and rebuilds + reloads it on every
105
+ save. Switch the top bar to Site to browse it while you edit.
106
+
107
+ So the organizing rules pay rent twice: a tidy tree reads well in the repo
108
+ *and* ships as a navigable site with no extra configuration.
109
+
110
+ ## Importing instead of transcribing
111
+
112
+ When a doc's data-table already exists elsewhere, import it rather than
113
+ retype it. `chiltepin sync csv <file>` turns a CSV export into a ready-made
114
+ `table` / `statustable` / `chart` block (`--out docs/<slug>.md` wraps it in a
115
+ new doc). `chiltepin sync openapi <spec> -o docs/api.md` generates a whole API
116
+ doc — with `--check` keeping it drift-free in CI. The studio accepts the same
117
+ files by drag-drop. The imported result is a normal doc on disk: edit it,
118
+ ref it, `chiltepin check` it like anything hand-written.
@@ -0,0 +1,59 @@
1
+ # Design patterns — which blocks document them
2
+
3
+ Part of the **chiltepin** skill (the hub is `SKILL.md`, one folder up). Read
4
+ this when the request names a design pattern or asks "how is X structured".
5
+ Every pattern here is the same stack, in this order:
6
+
7
+ 1. `pattern` — the card: intent, forces, participants, consequences. One
8
+ per pattern, always first.
9
+ 2. `uml` — the structure: participants as classes, the relation `kind`
10
+ carrying the meaning (`implements` for the interface, `composition` for
11
+ ownership, `dependency` for a call).
12
+ 3. `sequence` — the behaviour, only when the order of calls IS the pattern.
13
+ 4. `code` — the smallest real example, when the doc is for implementers.
14
+
15
+ Fields: `chiltepin block pattern`, `chiltepin block uml`. Never draw a pattern as a
16
+ `flow`: a pattern is a set of roles and their relations, not a procedure.
17
+
18
+ ## Gang of Four
19
+
20
+ | Pattern | The structural fact `uml` must show | Add |
21
+ |---|---|---|
22
+ | Singleton | one class, a private constructor, a static `instance()` | — |
23
+ | Factory Method | creator ↔ product interfaces, concrete pairs `implements` | — |
24
+ | Abstract Factory | one factory interface, one family per concrete factory | `table` of families × products |
25
+ | Builder | director `dependency` builder; builder `implements`; product built | `sequence` (build steps) |
26
+ | Prototype | `clone()` on the interface, concretes `implements` | — |
27
+ | Adapter | client → target interface; adapter `implements` target, `composition` adaptee | — |
28
+ | Bridge | abstraction `composition` implementor; both have hierarchies | — |
29
+ | Composite | component interface; leaf and composite `implements`; composite `composition` component (the self-reference) | `tree` of a real instance |
30
+ | Decorator | decorator `implements` component AND `composition` component | `sequence` (the wrapping chain) |
31
+ | Facade | facade `dependency` on each subsystem class; client sees one | `c4` component when it is a service boundary |
32
+ | Flyweight | factory returns shared intrinsic state; extrinsic passed in | `envelope` (memory saved) |
33
+ | Proxy | proxy `implements` subject, `composition` real subject | `sequence` (lazy load / access check) |
34
+ | Chain of Responsibility | handler `composition` next handler (self) | `sequence` (one request through the chain) |
35
+ | Command | command interface; invoker `composition` command; receiver | `sequence` (undo) |
36
+ | Interpreter | expression interface; terminal / non-terminal `implements` | `tree` (a parsed expression) |
37
+ | Iterator | iterator interface; aggregate creates it | — |
38
+ | Mediator | colleagues `dependency` mediator, never each other | `sequence` |
39
+ | Memento | originator creates memento; caretaker `composition` memento | `sequence` (save / restore) |
40
+ | Observer | subject `composition` observers; `notify()` | `sequence` (one change, N updates); at system scale → `reference/patterns.md` pub/sub |
41
+ | State | context `composition` state; concretes `implements` | `state` (the machine itself) |
42
+ | Strategy | context `composition` strategy interface; concretes `implements` | `options` when the choice of strategy is the decision |
43
+ | Template Method | abstract class with the skeleton; hooks overridden in subclasses | `steps` (the fixed order) |
44
+ | Visitor | visitor interface with one `visit` per element; elements `accept` | `matrix` of visitors × elements |
45
+
46
+ ## Architectural and distributed
47
+
48
+ | Pattern | Stack | Trap |
49
+ |---|---|---|
50
+ | Layered / Clean / Hexagonal | `pkg` (allowed `deps` between layers, `dependency` arrows only inward) → `block` for the runtime | `c4` alone hides the dependency rule |
51
+ | Repository / Unit of Work | `uml` (interface + implementation) → `sequence` for one transaction | `erd` (that is the data, not the pattern) |
52
+ | CQRS, Event sourcing, Saga, Outbox | `reference/patterns.md` | — |
53
+ | Circuit breaker, Retry, Bulkhead | `state` (closed → open → half-open) or `timing` (breaker vs downstream over time) → `spec` for the numbers | prose only |
54
+ | Cache-aside / Read-through | `sequence` with an `alt` (hit / miss) → `spec` for TTL and invalidation | `flow` |
55
+ | Sidecar / Ambassador | `cluster` or `block` (`preset: k8s`) with the sidecar in the pod | — |
56
+ | Strangler fig | `block` (facade in front of legacy + new) → `roadmap` for the migration by theme | `timeline` |
57
+ | BFF (backend for frontend) | `c4` container view with one BFF per client → `endpoint` per BFF | — |
58
+ | Microkernel / Plugin | `pkg` (core + plugin packages, `deps` inward) → `uml` for the plugin interface | — |
59
+ | Pipes and filters | `flow` (`variant: dag`) → `dfd` when data shape matters | `sequence` |