@sandrinio/vdoc 3.6.2 → 3.7.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sandrinio/vdoc",
3
- "version": "3.6.2",
3
+ "version": "3.7.0",
4
4
  "description": "Documentation skills for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {
@@ -6,21 +6,38 @@
6
6
 
7
7
  ## Overview
8
8
 
9
- {What it does, why it exists, how it fits in the system.}
9
+ {What it does and why it exists. Start with the value proposition — what problem does this solve for the user? Then explain how it fits in the system.}
10
+
11
+ ---
12
+
13
+ ## User Workflows
14
+
15
+ {Step-by-step journeys for the 1-3 primary user actions. For each workflow:}
16
+
17
+ 1. **{Workflow Name}**
18
+ - **User action:** {What the user does}
19
+ - **System response:** {What the system does}
20
+ - **Result:** {What the user sees}
10
21
 
11
22
  ---
12
23
 
13
24
  ## How It Works
14
25
 
15
- {Core logic and flow.}
26
+ {Trace at least one complete request from user action to final effect. Show the full path through every service, database call, and external system involved. Don't skip intermediaries.}
16
27
 
17
- {Mermaid diagram(s)max 7-9 nodes per diagram, split into multiple if larger.}
28
+ {Use a sequence diagram for the primary flow show all actors. Use flowcharts for branching logic only. Max 7-9 nodes per diagram, split into multiple if larger.}
18
29
 
19
30
  ---
20
31
 
21
32
  ## Data Model
22
33
 
23
- {Entities this feature owns and their relationships. Mermaid ER diagram or table.}
34
+ {Primary tables this feature owns. Include actual column names, types, and purpose not just entity names.}
35
+
36
+ | Column | Type | Description |
37
+ |--------|------|-------------|
38
+ | `column_name` | `type` | What it stores |
39
+
40
+ {Mermaid ER diagram for relationships between tables.}
24
41
 
25
42
  ---
26
43
 
@@ -46,9 +63,17 @@
46
63
 
47
64
  ---
48
65
 
49
- ## Error Handling
66
+ ## Error Handling & Edge Cases
67
+
68
+ {Specific failure scenarios, not generic statements. For each:}
69
+
70
+ - **{Scenario}** — {What triggers it}. User sees: {what}. System does: {recovery/logging}.
71
+
72
+ ---
73
+
74
+ ## Security
50
75
 
51
- {Failure modes, what the user sees, retry logic. Mermaid diagram if the error flow is non-trivial.}
76
+ {Authentication and authorization patterns. Service roles, secrets, access control. What an attacker could exploit if this feature were misconfigured.}
52
77
 
53
78
  ---
54
79
 
@@ -84,19 +84,24 @@ Read the template from `.agents/vdoc/doc-template.md` once before starting.
84
84
  Then generate docs **one at a time, sequentially**. For each approved doc:
85
85
 
86
86
  1. Read ALL relevant source files for that feature — not just the main file, but helpers, types, middleware, tests
87
- 2. Write `vdocs/FEATURE_NAME_DOC.md` following the template exactly
88
- 3. Confirm the file was written before moving to the next doc
87
+ 2. **Trace the end-to-end flow** — pick the primary user action and follow it through every layer: frontend → API route → service/lib → database → external service → response. Read each file in the chain. Don't stop at the service layer.
88
+ 3. Write `vdocs/FEATURE_NAME_DOC.md` following the template exactly
89
+ 4. Confirm the file was written before moving to the next doc
89
90
 
90
- Do NOT attempt to generate multiple docs from memory. Each doc is a fresh cycle: read sources → write doc → next.
91
+ Do NOT attempt to generate multiple docs from memory. Each doc is a fresh cycle: read sources → trace flows → write doc → next.
91
92
 
92
93
  **Writing rules:**
93
94
 
94
- - **Mermaid diagrams are mandatory** in "How It Works". Show the actual flowrequest lifecycle, state transitions, data pipeline. If a flow has more than 7-9 nodes, split into multiple diagrams.
95
- - **Data Model** must show real entities from the code, not generic placeholders. Use mermaid ER diagrams for relational data, tables for simpler models.
95
+ - **Overview** must open with the value propositionwhat problem does this feature solve for the user? Not just "manages X" but "enables users to Y without Z."
96
+ - **User Workflows** describe 1-3 primary user journeys step by step: what the user does, what the system does, what the user sees. This grounds the doc in product reality.
97
+ - **"How It Works" must use sequence diagrams** for the primary flow — show every actor (user, frontend, API, service, database, external systems). Flowcharts are for branching logic only. Trace the COMPLETE path — if there's a cron job that calls an executor that calls an external API, show all three, not just "cron → external API."
98
+ - **Data Model** must show actual column names, types, and descriptions for primary tables — not just entity names in an ER diagram. Read the actual schema/types files. Include fields that carry important semantics (e.g., `session_id` for context continuity, `webhook_url` for per-config endpoints).
99
+ - **Error Handling & Edge Cases** — list specific failure scenarios: "If the user's OAuth token expires, the system does X. The user sees Y." Not generic "errors are logged." Think: what breaks at 2 AM with no user present?
100
+ - **Security** — document auth patterns, service roles, secrets, access control. If a background job bypasses RLS with a service role, say so. If an endpoint is guarded by a bearer token, document it.
96
101
  - **Constraints & Decisions** is the most valuable section. Dig into the code for non-obvious choices: "Uses polling instead of websockets because...", "Auth tokens expire in 15min because...". If you can't find the reason, state the constraint and mark it: `Reason: unknown — verify with team`.
97
102
  - **Related Features** must reference other docs by filename and explain the coupling: "Changes to the JWT schema will require updates to API_REFERENCE_DOC.md (auth middleware affects all endpoints)."
98
103
  - **Configuration** must list actual env vars/secrets from the code, not hypothetical ones.
99
- - **Error Handling** — trace what happens when things fail. What does the user see? What gets logged? Is there retry logic?
104
+ - **Key Files** — list every file in the execution path, not just the "main" files. If a cron handler, executor, service, and DB helper are all involved, list all of them.
100
105
 
101
106
  ## Step 4 — Manifest
102
107
 
@@ -127,3 +132,6 @@ Before finishing, verify:
127
132
  - [ ] Every doc's "Related Features" references other doc filenames
128
133
  - [ ] Manifest `description` is detailed enough for semantic routing
129
134
  - [ ] No doc is just a shallow restatement of file names — each explains WHY and HOW
135
+ - [ ] Every doc has "User Workflows" with at least one step-by-step journey
136
+ - [ ] Every doc has specific "Error Handling & Edge Cases" (not generic)
137
+ - [ ] Every doc has a "Security" section documenting auth/access patterns
@@ -9,6 +9,7 @@ Use the user's description to find the relevant source files:
9
9
  1. If `vdocs/_exploration_log.md` exists, read it first — it maps the codebase and may already have the feature signal you need
10
10
  2. Otherwise, search the codebase with Glob and Grep to find files matching the user's description
11
11
  3. Read ALL relevant source files — not just the main file, but helpers, types, middleware, tests, API routes, components
12
+ 4. **Trace the end-to-end flow** — pick the primary user action and follow it through every layer: frontend → API route → service/lib → database → external service → response. Read each file in the chain. Don't stop at the service layer.
12
13
 
13
14
  Do not skim. Understand how the feature actually works before writing.
14
15
 
@@ -19,12 +20,16 @@ Do not skim. Understand how the feature actually works before writing.
19
20
 
20
21
  **Writing rules:**
21
22
 
22
- - **Mermaid diagrams are mandatory** in "How It Works". Show the actual flowrequest lifecycle, state transitions, data pipeline. If a flow has more than 7-9 nodes, split into multiple diagrams.
23
- - **Data Model** must show real entities from the code, not generic placeholders. Use mermaid ER diagrams for relational data, tables for simpler models.
23
+ - **Overview** must open with the value propositionwhat problem does this feature solve for the user? Not just "manages X" but "enables users to Y without Z."
24
+ - **User Workflows** describe 1-3 primary user journeys step by step: what the user does, what the system does, what the user sees. This grounds the doc in product reality.
25
+ - **"How It Works" must use sequence diagrams** for the primary flow — show every actor (user, frontend, API, service, database, external systems). Flowcharts are for branching logic only. Trace the COMPLETE path — if there's a cron job that calls an executor that calls an external API, show all three, not just "cron → external API."
26
+ - **Data Model** must show actual column names, types, and descriptions for primary tables — not just entity names in an ER diagram. Read the actual schema/types files. Include fields that carry important semantics (e.g., `session_id` for context continuity, `webhook_url` for per-config endpoints).
27
+ - **Error Handling & Edge Cases** — list specific failure scenarios: "If the user's OAuth token expires, the system does X. The user sees Y." Not generic "errors are logged." Think: what breaks at 2 AM with no user present?
28
+ - **Security** — document auth patterns, service roles, secrets, access control. If a background job bypasses RLS with a service role, say so. If an endpoint is guarded by a bearer token, document it.
24
29
  - **Constraints & Decisions** is the most valuable section. Dig into the code for non-obvious choices. If you can't find the reason, state the constraint and mark it: `Reason: unknown — verify with team`.
25
30
  - **Related Features** must reference other docs by filename and explain the coupling.
26
31
  - **Configuration** must list actual env vars/secrets from the code, not hypothetical ones.
27
- - **Error Handling** — trace what happens when things fail. What does the user see? What gets logged? Is there retry logic?
32
+ - **Key Files** — list every file in the execution path, not just the "main" files. If a cron handler, executor, service, and DB helper are all involved, list all of them.
28
33
 
29
34
  ## Step 3 — Update Manifest
30
35
 
@@ -43,3 +48,6 @@ Before finishing, verify:
43
48
  - [ ] "Related Features" references other doc filenames (if other docs exist)
44
49
  - [ ] Manifest `description` is detailed enough for semantic routing
45
50
  - [ ] Doc explains WHY and HOW, not just WHAT
51
+ - [ ] Doc has "User Workflows" with at least one step-by-step journey
52
+ - [ ] Doc has specific "Error Handling & Edge Cases" (not generic)
53
+ - [ ] Doc has a "Security" section documenting auth/access patterns
@@ -6,21 +6,38 @@
6
6
 
7
7
  ## Overview
8
8
 
9
- {What it does, why it exists, how it fits in the system.}
9
+ {What it does and why it exists. Start with the value proposition — what problem does this solve for the user? Then explain how it fits in the system.}
10
+
11
+ ---
12
+
13
+ ## User Workflows
14
+
15
+ {Step-by-step journeys for the 1-3 primary user actions. For each workflow:}
16
+
17
+ 1. **{Workflow Name}**
18
+ - **User action:** {What the user does}
19
+ - **System response:** {What the system does}
20
+ - **Result:** {What the user sees}
10
21
 
11
22
  ---
12
23
 
13
24
  ## How It Works
14
25
 
15
- {Core logic and flow.}
26
+ {Trace at least one complete request from user action to final effect. Show the full path through every service, database call, and external system involved. Don't skip intermediaries.}
16
27
 
17
- {Mermaid diagram(s)max 7-9 nodes per diagram, split into multiple if larger.}
28
+ {Use a sequence diagram for the primary flow show all actors. Use flowcharts for branching logic only. Max 7-9 nodes per diagram, split into multiple if larger.}
18
29
 
19
30
  ---
20
31
 
21
32
  ## Data Model
22
33
 
23
- {Entities this feature owns and their relationships. Mermaid ER diagram or table.}
34
+ {Primary tables this feature owns. Include actual column names, types, and purpose not just entity names.}
35
+
36
+ | Column | Type | Description |
37
+ |--------|------|-------------|
38
+ | `column_name` | `type` | What it stores |
39
+
40
+ {Mermaid ER diagram for relationships between tables.}
24
41
 
25
42
  ---
26
43
 
@@ -46,9 +63,17 @@
46
63
 
47
64
  ---
48
65
 
49
- ## Error Handling
66
+ ## Error Handling & Edge Cases
67
+
68
+ {Specific failure scenarios, not generic statements. For each:}
69
+
70
+ - **{Scenario}** — {What triggers it}. User sees: {what}. System does: {recovery/logging}.
71
+
72
+ ---
73
+
74
+ ## Security
50
75
 
51
- {Failure modes, what the user sees, retry logic. Mermaid diagram if the error flow is non-trivial.}
76
+ {Authentication and authorization patterns. Service roles, secrets, access control. What an attacker could exploit if this feature were misconfigured.}
52
77
 
53
78
  ---
54
79
 
@@ -84,19 +84,24 @@ Read the template from [doc-template.md](./doc-template.md) once before starting
84
84
  Then generate docs **one at a time, sequentially**. For each approved doc:
85
85
 
86
86
  1. Read ALL relevant source files for that feature — not just the main file, but helpers, types, middleware, tests
87
- 2. Write `vdocs/FEATURE_NAME_DOC.md` following the template exactly
88
- 3. Confirm the file was written before moving to the next doc
87
+ 2. **Trace the end-to-end flow** — pick the primary user action and follow it through every layer: frontend → API route → service/lib → database → external service → response. Read each file in the chain. Don't stop at the service layer.
88
+ 3. Write `vdocs/FEATURE_NAME_DOC.md` following the template exactly
89
+ 4. Confirm the file was written before moving to the next doc
89
90
 
90
- Do NOT attempt to generate multiple docs from memory. Each doc is a fresh cycle: read sources → write doc → next.
91
+ Do NOT attempt to generate multiple docs from memory. Each doc is a fresh cycle: read sources → trace flows → write doc → next.
91
92
 
92
93
  **Writing rules:**
93
94
 
94
- - **Mermaid diagrams are mandatory** in "How It Works". Show the actual flowrequest lifecycle, state transitions, data pipeline. If a flow has more than 7-9 nodes, split into multiple diagrams.
95
- - **Data Model** must show real entities from the code, not generic placeholders. Use mermaid ER diagrams for relational data, tables for simpler models.
95
+ - **Overview** must open with the value propositionwhat problem does this feature solve for the user? Not just "manages X" but "enables users to Y without Z."
96
+ - **User Workflows** describe 1-3 primary user journeys step by step: what the user does, what the system does, what the user sees. This grounds the doc in product reality.
97
+ - **"How It Works" must use sequence diagrams** for the primary flow — show every actor (user, frontend, API, service, database, external systems). Flowcharts are for branching logic only. Trace the COMPLETE path — if there's a cron job that calls an executor that calls an external API, show all three, not just "cron → external API."
98
+ - **Data Model** must show actual column names, types, and descriptions for primary tables — not just entity names in an ER diagram. Read the actual schema/types files. Include fields that carry important semantics (e.g., `session_id` for context continuity, `webhook_url` for per-config endpoints).
99
+ - **Error Handling & Edge Cases** — list specific failure scenarios: "If the user's OAuth token expires, the system does X. The user sees Y." Not generic "errors are logged." Think: what breaks at 2 AM with no user present?
100
+ - **Security** — document auth patterns, service roles, secrets, access control. If a background job bypasses RLS with a service role, say so. If an endpoint is guarded by a bearer token, document it.
96
101
  - **Constraints & Decisions** is the most valuable section. Dig into the code for non-obvious choices: "Uses polling instead of websockets because...", "Auth tokens expire in 15min because...". If you can't find the reason, state the constraint and mark it: `Reason: unknown — verify with team`.
97
102
  - **Related Features** must reference other docs by filename and explain the coupling: "Changes to the JWT schema will require updates to API_REFERENCE_DOC.md (auth middleware affects all endpoints)."
98
103
  - **Configuration** must list actual env vars/secrets from the code, not hypothetical ones.
99
- - **Error Handling** — trace what happens when things fail. What does the user see? What gets logged? Is there retry logic?
104
+ - **Key Files** — list every file in the execution path, not just the "main" files. If a cron handler, executor, service, and DB helper are all involved, list all of them.
100
105
 
101
106
  ## Step 4 — Manifest
102
107
 
@@ -127,3 +132,6 @@ Before finishing, verify:
127
132
  - [ ] Every doc's "Related Features" references other doc filenames
128
133
  - [ ] Manifest `description` is detailed enough for semantic routing
129
134
  - [ ] No doc is just a shallow restatement of file names — each explains WHY and HOW
135
+ - [ ] Every doc has "User Workflows" with at least one step-by-step journey
136
+ - [ ] Every doc has specific "Error Handling & Edge Cases" (not generic)
137
+ - [ ] Every doc has a "Security" section documenting auth/access patterns
@@ -6,21 +6,38 @@
6
6
 
7
7
  ## Overview
8
8
 
9
- {What it does, why it exists, how it fits in the system.}
9
+ {What it does and why it exists. Start with the value proposition — what problem does this solve for the user? Then explain how it fits in the system.}
10
+
11
+ ---
12
+
13
+ ## User Workflows
14
+
15
+ {Step-by-step journeys for the 1-3 primary user actions. For each workflow:}
16
+
17
+ 1. **{Workflow Name}**
18
+ - **User action:** {What the user does}
19
+ - **System response:** {What the system does}
20
+ - **Result:** {What the user sees}
10
21
 
11
22
  ---
12
23
 
13
24
  ## How It Works
14
25
 
15
- {Core logic and flow.}
26
+ {Trace at least one complete request from user action to final effect. Show the full path through every service, database call, and external system involved. Don't skip intermediaries.}
16
27
 
17
- {Mermaid diagram(s)max 7-9 nodes per diagram, split into multiple if larger.}
28
+ {Use a sequence diagram for the primary flow show all actors. Use flowcharts for branching logic only. Max 7-9 nodes per diagram, split into multiple if larger.}
18
29
 
19
30
  ---
20
31
 
21
32
  ## Data Model
22
33
 
23
- {Entities this feature owns and their relationships. Mermaid ER diagram or table.}
34
+ {Primary tables this feature owns. Include actual column names, types, and purpose not just entity names.}
35
+
36
+ | Column | Type | Description |
37
+ |--------|------|-------------|
38
+ | `column_name` | `type` | What it stores |
39
+
40
+ {Mermaid ER diagram for relationships between tables.}
24
41
 
25
42
  ---
26
43
 
@@ -46,9 +63,17 @@
46
63
 
47
64
  ---
48
65
 
49
- ## Error Handling
66
+ ## Error Handling & Edge Cases
67
+
68
+ {Specific failure scenarios, not generic statements. For each:}
69
+
70
+ - **{Scenario}** — {What triggers it}. User sees: {what}. System does: {recovery/logging}.
71
+
72
+ ---
73
+
74
+ ## Security
50
75
 
51
- {Failure modes, what the user sees, retry logic. Mermaid diagram if the error flow is non-trivial.}
76
+ {Authentication and authorization patterns. Service roles, secrets, access control. What an attacker could exploit if this feature were misconfigured.}
52
77
 
53
78
  ---
54
79
 
@@ -84,19 +84,24 @@ Read the template from `references/doc-template.md` once before starting.
84
84
  Then generate docs **one at a time, sequentially**. For each approved doc:
85
85
 
86
86
  1. Read ALL relevant source files for that feature — not just the main file, but helpers, types, middleware, tests
87
- 2. Write `vdocs/FEATURE_NAME_DOC.md` following the template exactly
88
- 3. Confirm the file was written before moving to the next doc
87
+ 2. **Trace the end-to-end flow** — pick the primary user action and follow it through every layer: frontend → API route → service/lib → database → external service → response. Read each file in the chain. Don't stop at the service layer.
88
+ 3. Write `vdocs/FEATURE_NAME_DOC.md` following the template exactly
89
+ 4. Confirm the file was written before moving to the next doc
89
90
 
90
- Do NOT attempt to generate multiple docs from memory. Each doc is a fresh cycle: read sources → write doc → next.
91
+ Do NOT attempt to generate multiple docs from memory. Each doc is a fresh cycle: read sources → trace flows → write doc → next.
91
92
 
92
93
  **Writing rules:**
93
94
 
94
- - **Mermaid diagrams are mandatory** in "How It Works". Show the actual flowrequest lifecycle, state transitions, data pipeline. If a flow has more than 7-9 nodes, split into multiple diagrams.
95
- - **Data Model** must show real entities from the code, not generic placeholders. Use mermaid ER diagrams for relational data, tables for simpler models.
95
+ - **Overview** must open with the value propositionwhat problem does this feature solve for the user? Not just "manages X" but "enables users to Y without Z."
96
+ - **User Workflows** describe 1-3 primary user journeys step by step: what the user does, what the system does, what the user sees. This grounds the doc in product reality.
97
+ - **"How It Works" must use sequence diagrams** for the primary flow — show every actor (user, frontend, API, service, database, external systems). Flowcharts are for branching logic only. Trace the COMPLETE path — if there's a cron job that calls an executor that calls an external API, show all three, not just "cron → external API."
98
+ - **Data Model** must show actual column names, types, and descriptions for primary tables — not just entity names in an ER diagram. Read the actual schema/types files. Include fields that carry important semantics (e.g., `session_id` for context continuity, `webhook_url` for per-config endpoints).
99
+ - **Error Handling & Edge Cases** — list specific failure scenarios: "If the user's OAuth token expires, the system does X. The user sees Y." Not generic "errors are logged." Think: what breaks at 2 AM with no user present?
100
+ - **Security** — document auth patterns, service roles, secrets, access control. If a background job bypasses RLS with a service role, say so. If an endpoint is guarded by a bearer token, document it.
96
101
  - **Constraints & Decisions** is the most valuable section. Dig into the code for non-obvious choices: "Uses polling instead of websockets because...", "Auth tokens expire in 15min because...". If you can't find the reason, state the constraint and mark it: `Reason: unknown — verify with team`.
97
102
  - **Related Features** must reference other docs by filename and explain the coupling: "Changes to the JWT schema will require updates to API_REFERENCE_DOC.md (auth middleware affects all endpoints)."
98
103
  - **Configuration** must list actual env vars/secrets from the code, not hypothetical ones.
99
- - **Error Handling** — trace what happens when things fail. What does the user see? What gets logged? Is there retry logic?
104
+ - **Key Files** — list every file in the execution path, not just the "main" files. If a cron handler, executor, service, and DB helper are all involved, list all of them.
100
105
 
101
106
  ## Step 4 — Manifest
102
107
 
@@ -127,3 +132,6 @@ Before finishing, verify:
127
132
  - [ ] Every doc's "Related Features" references other doc filenames
128
133
  - [ ] Manifest `description` is detailed enough for semantic routing
129
134
  - [ ] No doc is just a shallow restatement of file names — each explains WHY and HOW
135
+ - [ ] Every doc has "User Workflows" with at least one step-by-step journey
136
+ - [ ] Every doc has specific "Error Handling & Edge Cases" (not generic)
137
+ - [ ] Every doc has a "Security" section documenting auth/access patterns
@@ -6,21 +6,38 @@
6
6
 
7
7
  ## Overview
8
8
 
9
- {What it does, why it exists, how it fits in the system.}
9
+ {What it does and why it exists. Start with the value proposition — what problem does this solve for the user? Then explain how it fits in the system.}
10
+
11
+ ---
12
+
13
+ ## User Workflows
14
+
15
+ {Step-by-step journeys for the 1-3 primary user actions. For each workflow:}
16
+
17
+ 1. **{Workflow Name}**
18
+ - **User action:** {What the user does}
19
+ - **System response:** {What the system does}
20
+ - **Result:** {What the user sees}
10
21
 
11
22
  ---
12
23
 
13
24
  ## How It Works
14
25
 
15
- {Core logic and flow.}
26
+ {Trace at least one complete request from user action to final effect. Show the full path through every service, database call, and external system involved. Don't skip intermediaries.}
16
27
 
17
- {Mermaid diagram(s)max 7-9 nodes per diagram, split into multiple if larger.}
28
+ {Use a sequence diagram for the primary flow show all actors. Use flowcharts for branching logic only. Max 7-9 nodes per diagram, split into multiple if larger.}
18
29
 
19
30
  ---
20
31
 
21
32
  ## Data Model
22
33
 
23
- {Entities this feature owns and their relationships. Mermaid ER diagram or table.}
34
+ {Primary tables this feature owns. Include actual column names, types, and purpose not just entity names.}
35
+
36
+ | Column | Type | Description |
37
+ |--------|------|-------------|
38
+ | `column_name` | `type` | What it stores |
39
+
40
+ {Mermaid ER diagram for relationships between tables.}
24
41
 
25
42
  ---
26
43
 
@@ -46,9 +63,17 @@
46
63
 
47
64
  ---
48
65
 
49
- ## Error Handling
66
+ ## Error Handling & Edge Cases
67
+
68
+ {Specific failure scenarios, not generic statements. For each:}
69
+
70
+ - **{Scenario}** — {What triggers it}. User sees: {what}. System does: {recovery/logging}.
71
+
72
+ ---
73
+
74
+ ## Security
50
75
 
51
- {Failure modes, what the user sees, retry logic. Mermaid diagram if the error flow is non-trivial.}
76
+ {Authentication and authorization patterns. Service roles, secrets, access control. What an attacker could exploit if this feature were misconfigured.}
52
77
 
53
78
  ---
54
79
 
@@ -84,19 +84,24 @@ Read the template from `references/doc-template.md` once before starting.
84
84
  Then generate docs **one at a time, sequentially**. For each approved doc:
85
85
 
86
86
  1. Read ALL relevant source files for that feature — not just the main file, but helpers, types, middleware, tests
87
- 2. Write `vdocs/FEATURE_NAME_DOC.md` following the template exactly
88
- 3. Confirm the file was written before moving to the next doc
87
+ 2. **Trace the end-to-end flow** — pick the primary user action and follow it through every layer: frontend → API route → service/lib → database → external service → response. Read each file in the chain. Don't stop at the service layer.
88
+ 3. Write `vdocs/FEATURE_NAME_DOC.md` following the template exactly
89
+ 4. Confirm the file was written before moving to the next doc
89
90
 
90
- Do NOT attempt to generate multiple docs from memory. Each doc is a fresh cycle: read sources → write doc → next.
91
+ Do NOT attempt to generate multiple docs from memory. Each doc is a fresh cycle: read sources → trace flows → write doc → next.
91
92
 
92
93
  **Writing rules:**
93
94
 
94
- - **Mermaid diagrams are mandatory** in "How It Works". Show the actual flowrequest lifecycle, state transitions, data pipeline. If a flow has more than 7-9 nodes, split into multiple diagrams.
95
- - **Data Model** must show real entities from the code, not generic placeholders. Use mermaid ER diagrams for relational data, tables for simpler models.
95
+ - **Overview** must open with the value propositionwhat problem does this feature solve for the user? Not just "manages X" but "enables users to Y without Z."
96
+ - **User Workflows** describe 1-3 primary user journeys step by step: what the user does, what the system does, what the user sees. This grounds the doc in product reality.
97
+ - **"How It Works" must use sequence diagrams** for the primary flow — show every actor (user, frontend, API, service, database, external systems). Flowcharts are for branching logic only. Trace the COMPLETE path — if there's a cron job that calls an executor that calls an external API, show all three, not just "cron → external API."
98
+ - **Data Model** must show actual column names, types, and descriptions for primary tables — not just entity names in an ER diagram. Read the actual schema/types files. Include fields that carry important semantics (e.g., `session_id` for context continuity, `webhook_url` for per-config endpoints).
99
+ - **Error Handling & Edge Cases** — list specific failure scenarios: "If the user's OAuth token expires, the system does X. The user sees Y." Not generic "errors are logged." Think: what breaks at 2 AM with no user present?
100
+ - **Security** — document auth patterns, service roles, secrets, access control. If a background job bypasses RLS with a service role, say so. If an endpoint is guarded by a bearer token, document it.
96
101
  - **Constraints & Decisions** is the most valuable section. Dig into the code for non-obvious choices: "Uses polling instead of websockets because...", "Auth tokens expire in 15min because...". If you can't find the reason, state the constraint and mark it: `Reason: unknown — verify with team`.
97
102
  - **Related Features** must reference other docs by filename and explain the coupling: "Changes to the JWT schema will require updates to API_REFERENCE_DOC.md (auth middleware affects all endpoints)."
98
103
  - **Configuration** must list actual env vars/secrets from the code, not hypothetical ones.
99
- - **Error Handling** — trace what happens when things fail. What does the user see? What gets logged? Is there retry logic?
104
+ - **Key Files** — list every file in the execution path, not just the "main" files. If a cron handler, executor, service, and DB helper are all involved, list all of them.
100
105
 
101
106
  ## Step 4 — Manifest
102
107
 
@@ -127,3 +132,6 @@ Before finishing, verify:
127
132
  - [ ] Every doc's "Related Features" references other doc filenames
128
133
  - [ ] Manifest `description` is detailed enough for semantic routing
129
134
  - [ ] No doc is just a shallow restatement of file names — each explains WHY and HOW
135
+ - [ ] Every doc has "User Workflows" with at least one step-by-step journey
136
+ - [ ] Every doc has specific "Error Handling & Edge Cases" (not generic)
137
+ - [ ] Every doc has a "Security" section documenting auth/access patterns
@@ -6,21 +6,38 @@
6
6
 
7
7
  ## Overview
8
8
 
9
- {What it does, why it exists, how it fits in the system.}
9
+ {What it does and why it exists. Start with the value proposition — what problem does this solve for the user? Then explain how it fits in the system.}
10
+
11
+ ---
12
+
13
+ ## User Workflows
14
+
15
+ {Step-by-step journeys for the 1-3 primary user actions. For each workflow:}
16
+
17
+ 1. **{Workflow Name}**
18
+ - **User action:** {What the user does}
19
+ - **System response:** {What the system does}
20
+ - **Result:** {What the user sees}
10
21
 
11
22
  ---
12
23
 
13
24
  ## How It Works
14
25
 
15
- {Core logic and flow.}
26
+ {Trace at least one complete request from user action to final effect. Show the full path through every service, database call, and external system involved. Don't skip intermediaries.}
16
27
 
17
- {Mermaid diagram(s)max 7-9 nodes per diagram, split into multiple if larger.}
28
+ {Use a sequence diagram for the primary flow show all actors. Use flowcharts for branching logic only. Max 7-9 nodes per diagram, split into multiple if larger.}
18
29
 
19
30
  ---
20
31
 
21
32
  ## Data Model
22
33
 
23
- {Entities this feature owns and their relationships. Mermaid ER diagram or table.}
34
+ {Primary tables this feature owns. Include actual column names, types, and purpose not just entity names.}
35
+
36
+ | Column | Type | Description |
37
+ |--------|------|-------------|
38
+ | `column_name` | `type` | What it stores |
39
+
40
+ {Mermaid ER diagram for relationships between tables.}
24
41
 
25
42
  ---
26
43
 
@@ -46,9 +63,17 @@
46
63
 
47
64
  ---
48
65
 
49
- ## Error Handling
66
+ ## Error Handling & Edge Cases
67
+
68
+ {Specific failure scenarios, not generic statements. For each:}
69
+
70
+ - **{Scenario}** — {What triggers it}. User sees: {what}. System does: {recovery/logging}.
71
+
72
+ ---
73
+
74
+ ## Security
50
75
 
51
- {Failure modes, what the user sees, retry logic. Mermaid diagram if the error flow is non-trivial.}
76
+ {Authentication and authorization patterns. Service roles, secrets, access control. What an attacker could exploit if this feature were misconfigured.}
52
77
 
53
78
  ---
54
79
 
@@ -84,19 +84,24 @@ Read the template from `references/doc-template.md` once before starting.
84
84
  Then generate docs **one at a time, sequentially**. For each approved doc:
85
85
 
86
86
  1. Read ALL relevant source files for that feature — not just the main file, but helpers, types, middleware, tests
87
- 2. Write `vdocs/FEATURE_NAME_DOC.md` following the template exactly
88
- 3. Confirm the file was written before moving to the next doc
87
+ 2. **Trace the end-to-end flow** — pick the primary user action and follow it through every layer: frontend → API route → service/lib → database → external service → response. Read each file in the chain. Don't stop at the service layer.
88
+ 3. Write `vdocs/FEATURE_NAME_DOC.md` following the template exactly
89
+ 4. Confirm the file was written before moving to the next doc
89
90
 
90
- Do NOT attempt to generate multiple docs from memory. Each doc is a fresh cycle: read sources → write doc → next.
91
+ Do NOT attempt to generate multiple docs from memory. Each doc is a fresh cycle: read sources → trace flows → write doc → next.
91
92
 
92
93
  **Writing rules:**
93
94
 
94
- - **Mermaid diagrams are mandatory** in "How It Works". Show the actual flowrequest lifecycle, state transitions, data pipeline. If a flow has more than 7-9 nodes, split into multiple diagrams.
95
- - **Data Model** must show real entities from the code, not generic placeholders. Use mermaid ER diagrams for relational data, tables for simpler models.
95
+ - **Overview** must open with the value propositionwhat problem does this feature solve for the user? Not just "manages X" but "enables users to Y without Z."
96
+ - **User Workflows** describe 1-3 primary user journeys step by step: what the user does, what the system does, what the user sees. This grounds the doc in product reality.
97
+ - **"How It Works" must use sequence diagrams** for the primary flow — show every actor (user, frontend, API, service, database, external systems). Flowcharts are for branching logic only. Trace the COMPLETE path — if there's a cron job that calls an executor that calls an external API, show all three, not just "cron → external API."
98
+ - **Data Model** must show actual column names, types, and descriptions for primary tables — not just entity names in an ER diagram. Read the actual schema/types files. Include fields that carry important semantics (e.g., `session_id` for context continuity, `webhook_url` for per-config endpoints).
99
+ - **Error Handling & Edge Cases** — list specific failure scenarios: "If the user's OAuth token expires, the system does X. The user sees Y." Not generic "errors are logged." Think: what breaks at 2 AM with no user present?
100
+ - **Security** — document auth patterns, service roles, secrets, access control. If a background job bypasses RLS with a service role, say so. If an endpoint is guarded by a bearer token, document it.
96
101
  - **Constraints & Decisions** is the most valuable section. Dig into the code for non-obvious choices: "Uses polling instead of websockets because...", "Auth tokens expire in 15min because...". If you can't find the reason, state the constraint and mark it: `Reason: unknown — verify with team`.
97
102
  - **Related Features** must reference other docs by filename and explain the coupling: "Changes to the JWT schema will require updates to API_REFERENCE_DOC.md (auth middleware affects all endpoints)."
98
103
  - **Configuration** must list actual env vars/secrets from the code, not hypothetical ones.
99
- - **Error Handling** — trace what happens when things fail. What does the user see? What gets logged? Is there retry logic?
104
+ - **Key Files** — list every file in the execution path, not just the "main" files. If a cron handler, executor, service, and DB helper are all involved, list all of them.
100
105
 
101
106
  ## Step 4 — Manifest
102
107
 
@@ -127,3 +132,6 @@ Before finishing, verify:
127
132
  - [ ] Every doc's "Related Features" references other doc filenames
128
133
  - [ ] Manifest `description` is detailed enough for semantic routing
129
134
  - [ ] No doc is just a shallow restatement of file names — each explains WHY and HOW
135
+ - [ ] Every doc has "User Workflows" with at least one step-by-step journey
136
+ - [ ] Every doc has specific "Error Handling & Edge Cases" (not generic)
137
+ - [ ] Every doc has a "Security" section documenting auth/access patterns
@@ -6,21 +6,38 @@
6
6
 
7
7
  ## Overview
8
8
 
9
- {What it does, why it exists, how it fits in the system.}
9
+ {What it does and why it exists. Start with the value proposition — what problem does this solve for the user? Then explain how it fits in the system.}
10
+
11
+ ---
12
+
13
+ ## User Workflows
14
+
15
+ {Step-by-step journeys for the 1-3 primary user actions. For each workflow:}
16
+
17
+ 1. **{Workflow Name}**
18
+ - **User action:** {What the user does}
19
+ - **System response:** {What the system does}
20
+ - **Result:** {What the user sees}
10
21
 
11
22
  ---
12
23
 
13
24
  ## How It Works
14
25
 
15
- {Core logic and flow.}
26
+ {Trace at least one complete request from user action to final effect. Show the full path through every service, database call, and external system involved. Don't skip intermediaries.}
16
27
 
17
- {Mermaid diagram(s)max 7-9 nodes per diagram, split into multiple if larger.}
28
+ {Use a sequence diagram for the primary flow show all actors. Use flowcharts for branching logic only. Max 7-9 nodes per diagram, split into multiple if larger.}
18
29
 
19
30
  ---
20
31
 
21
32
  ## Data Model
22
33
 
23
- {Entities this feature owns and their relationships. Mermaid ER diagram or table.}
34
+ {Primary tables this feature owns. Include actual column names, types, and purpose not just entity names.}
35
+
36
+ | Column | Type | Description |
37
+ |--------|------|-------------|
38
+ | `column_name` | `type` | What it stores |
39
+
40
+ {Mermaid ER diagram for relationships between tables.}
24
41
 
25
42
  ---
26
43
 
@@ -46,9 +63,17 @@
46
63
 
47
64
  ---
48
65
 
49
- ## Error Handling
66
+ ## Error Handling & Edge Cases
67
+
68
+ {Specific failure scenarios, not generic statements. For each:}
69
+
70
+ - **{Scenario}** — {What triggers it}. User sees: {what}. System does: {recovery/logging}.
71
+
72
+ ---
73
+
74
+ ## Security
50
75
 
51
- {Failure modes, what the user sees, retry logic. Mermaid diagram if the error flow is non-trivial.}
76
+ {Authentication and authorization patterns. Service roles, secrets, access control. What an attacker could exploit if this feature were misconfigured.}
52
77
 
53
78
  ---
54
79
 
@@ -84,19 +84,24 @@ Read the template from `.gemini/vdoc/doc-template.md` once before starting.
84
84
  Then generate docs **one at a time, sequentially**. For each approved doc:
85
85
 
86
86
  1. Read ALL relevant source files for that feature — not just the main file, but helpers, types, middleware, tests
87
- 2. Write `vdocs/FEATURE_NAME_DOC.md` following the template exactly
88
- 3. Confirm the file was written before moving to the next doc
87
+ 2. **Trace the end-to-end flow** — pick the primary user action and follow it through every layer: frontend → API route → service/lib → database → external service → response. Read each file in the chain. Don't stop at the service layer.
88
+ 3. Write `vdocs/FEATURE_NAME_DOC.md` following the template exactly
89
+ 4. Confirm the file was written before moving to the next doc
89
90
 
90
- Do NOT attempt to generate multiple docs from memory. Each doc is a fresh cycle: read sources → write doc → next.
91
+ Do NOT attempt to generate multiple docs from memory. Each doc is a fresh cycle: read sources → trace flows → write doc → next.
91
92
 
92
93
  **Writing rules:**
93
94
 
94
- - **Mermaid diagrams are mandatory** in "How It Works". Show the actual flowrequest lifecycle, state transitions, data pipeline. If a flow has more than 7-9 nodes, split into multiple diagrams.
95
- - **Data Model** must show real entities from the code, not generic placeholders. Use mermaid ER diagrams for relational data, tables for simpler models.
95
+ - **Overview** must open with the value propositionwhat problem does this feature solve for the user? Not just "manages X" but "enables users to Y without Z."
96
+ - **User Workflows** describe 1-3 primary user journeys step by step: what the user does, what the system does, what the user sees. This grounds the doc in product reality.
97
+ - **"How It Works" must use sequence diagrams** for the primary flow — show every actor (user, frontend, API, service, database, external systems). Flowcharts are for branching logic only. Trace the COMPLETE path — if there's a cron job that calls an executor that calls an external API, show all three, not just "cron → external API."
98
+ - **Data Model** must show actual column names, types, and descriptions for primary tables — not just entity names in an ER diagram. Read the actual schema/types files. Include fields that carry important semantics (e.g., `session_id` for context continuity, `webhook_url` for per-config endpoints).
99
+ - **Error Handling & Edge Cases** — list specific failure scenarios: "If the user's OAuth token expires, the system does X. The user sees Y." Not generic "errors are logged." Think: what breaks at 2 AM with no user present?
100
+ - **Security** — document auth patterns, service roles, secrets, access control. If a background job bypasses RLS with a service role, say so. If an endpoint is guarded by a bearer token, document it.
96
101
  - **Constraints & Decisions** is the most valuable section. Dig into the code for non-obvious choices: "Uses polling instead of websockets because...", "Auth tokens expire in 15min because...". If you can't find the reason, state the constraint and mark it: `Reason: unknown — verify with team`.
97
102
  - **Related Features** must reference other docs by filename and explain the coupling: "Changes to the JWT schema will require updates to API_REFERENCE_DOC.md (auth middleware affects all endpoints)."
98
103
  - **Configuration** must list actual env vars/secrets from the code, not hypothetical ones.
99
- - **Error Handling** — trace what happens when things fail. What does the user see? What gets logged? Is there retry logic?
104
+ - **Key Files** — list every file in the execution path, not just the "main" files. If a cron handler, executor, service, and DB helper are all involved, list all of them.
100
105
 
101
106
  ## Step 4 — Manifest
102
107
 
@@ -127,3 +132,6 @@ Before finishing, verify:
127
132
  - [ ] Every doc's "Related Features" references other doc filenames
128
133
  - [ ] Manifest `description` is detailed enough for semantic routing
129
134
  - [ ] No doc is just a shallow restatement of file names — each explains WHY and HOW
135
+ - [ ] Every doc has "User Workflows" with at least one step-by-step journey
136
+ - [ ] Every doc has specific "Error Handling & Edge Cases" (not generic)
137
+ - [ ] Every doc has a "Security" section documenting auth/access patterns
@@ -6,21 +6,38 @@
6
6
 
7
7
  ## Overview
8
8
 
9
- {What it does, why it exists, how it fits in the system.}
9
+ {What it does and why it exists. Start with the value proposition — what problem does this solve for the user? Then explain how it fits in the system.}
10
+
11
+ ---
12
+
13
+ ## User Workflows
14
+
15
+ {Step-by-step journeys for the 1-3 primary user actions. For each workflow:}
16
+
17
+ 1. **{Workflow Name}**
18
+ - **User action:** {What the user does}
19
+ - **System response:** {What the system does}
20
+ - **Result:** {What the user sees}
10
21
 
11
22
  ---
12
23
 
13
24
  ## How It Works
14
25
 
15
- {Core logic and flow.}
26
+ {Trace at least one complete request from user action to final effect. Show the full path through every service, database call, and external system involved. Don't skip intermediaries.}
16
27
 
17
- {Mermaid diagram(s)max 7-9 nodes per diagram, split into multiple if larger.}
28
+ {Use a sequence diagram for the primary flow show all actors. Use flowcharts for branching logic only. Max 7-9 nodes per diagram, split into multiple if larger.}
18
29
 
19
30
  ---
20
31
 
21
32
  ## Data Model
22
33
 
23
- {Entities this feature owns and their relationships. Mermaid ER diagram or table.}
34
+ {Primary tables this feature owns. Include actual column names, types, and purpose not just entity names.}
35
+
36
+ | Column | Type | Description |
37
+ |--------|------|-------------|
38
+ | `column_name` | `type` | What it stores |
39
+
40
+ {Mermaid ER diagram for relationships between tables.}
24
41
 
25
42
  ---
26
43
 
@@ -46,9 +63,17 @@
46
63
 
47
64
  ---
48
65
 
49
- ## Error Handling
66
+ ## Error Handling & Edge Cases
67
+
68
+ {Specific failure scenarios, not generic statements. For each:}
69
+
70
+ - **{Scenario}** — {What triggers it}. User sees: {what}. System does: {recovery/logging}.
71
+
72
+ ---
73
+
74
+ ## Security
50
75
 
51
- {Failure modes, what the user sees, retry logic. Mermaid diagram if the error flow is non-trivial.}
76
+ {Authentication and authorization patterns. Service roles, secrets, access control. What an attacker could exploit if this feature were misconfigured.}
52
77
 
53
78
  ---
54
79
 
@@ -84,19 +84,24 @@ Read the template from `.aiassistant/vdoc/doc-template.md` once before starting.
84
84
  Then generate docs **one at a time, sequentially**. For each approved doc:
85
85
 
86
86
  1. Read ALL relevant source files for that feature — not just the main file, but helpers, types, middleware, tests
87
- 2. Write `vdocs/FEATURE_NAME_DOC.md` following the template exactly
88
- 3. Confirm the file was written before moving to the next doc
87
+ 2. **Trace the end-to-end flow** — pick the primary user action and follow it through every layer: frontend → API route → service/lib → database → external service → response. Read each file in the chain. Don't stop at the service layer.
88
+ 3. Write `vdocs/FEATURE_NAME_DOC.md` following the template exactly
89
+ 4. Confirm the file was written before moving to the next doc
89
90
 
90
- Do NOT attempt to generate multiple docs from memory. Each doc is a fresh cycle: read sources → write doc → next.
91
+ Do NOT attempt to generate multiple docs from memory. Each doc is a fresh cycle: read sources → trace flows → write doc → next.
91
92
 
92
93
  **Writing rules:**
93
94
 
94
- - **Mermaid diagrams are mandatory** in "How It Works". Show the actual flowrequest lifecycle, state transitions, data pipeline. If a flow has more than 7-9 nodes, split into multiple diagrams.
95
- - **Data Model** must show real entities from the code, not generic placeholders. Use mermaid ER diagrams for relational data, tables for simpler models.
95
+ - **Overview** must open with the value propositionwhat problem does this feature solve for the user? Not just "manages X" but "enables users to Y without Z."
96
+ - **User Workflows** describe 1-3 primary user journeys step by step: what the user does, what the system does, what the user sees. This grounds the doc in product reality.
97
+ - **"How It Works" must use sequence diagrams** for the primary flow — show every actor (user, frontend, API, service, database, external systems). Flowcharts are for branching logic only. Trace the COMPLETE path — if there's a cron job that calls an executor that calls an external API, show all three, not just "cron → external API."
98
+ - **Data Model** must show actual column names, types, and descriptions for primary tables — not just entity names in an ER diagram. Read the actual schema/types files. Include fields that carry important semantics (e.g., `session_id` for context continuity, `webhook_url` for per-config endpoints).
99
+ - **Error Handling & Edge Cases** — list specific failure scenarios: "If the user's OAuth token expires, the system does X. The user sees Y." Not generic "errors are logged." Think: what breaks at 2 AM with no user present?
100
+ - **Security** — document auth patterns, service roles, secrets, access control. If a background job bypasses RLS with a service role, say so. If an endpoint is guarded by a bearer token, document it.
96
101
  - **Constraints & Decisions** is the most valuable section. Dig into the code for non-obvious choices: "Uses polling instead of websockets because...", "Auth tokens expire in 15min because...". If you can't find the reason, state the constraint and mark it: `Reason: unknown — verify with team`.
97
102
  - **Related Features** must reference other docs by filename and explain the coupling: "Changes to the JWT schema will require updates to API_REFERENCE_DOC.md (auth middleware affects all endpoints)."
98
103
  - **Configuration** must list actual env vars/secrets from the code, not hypothetical ones.
99
- - **Error Handling** — trace what happens when things fail. What does the user see? What gets logged? Is there retry logic?
104
+ - **Key Files** — list every file in the execution path, not just the "main" files. If a cron handler, executor, service, and DB helper are all involved, list all of them.
100
105
 
101
106
  ## Step 4 — Manifest
102
107
 
@@ -127,3 +132,6 @@ Before finishing, verify:
127
132
  - [ ] Every doc's "Related Features" references other doc filenames
128
133
  - [ ] Manifest `description` is detailed enough for semantic routing
129
134
  - [ ] No doc is just a shallow restatement of file names — each explains WHY and HOW
135
+ - [ ] Every doc has "User Workflows" with at least one step-by-step journey
136
+ - [ ] Every doc has specific "Error Handling & Edge Cases" (not generic)
137
+ - [ ] Every doc has a "Security" section documenting auth/access patterns
@@ -6,21 +6,38 @@
6
6
 
7
7
  ## Overview
8
8
 
9
- {What it does, why it exists, how it fits in the system.}
9
+ {What it does and why it exists. Start with the value proposition — what problem does this solve for the user? Then explain how it fits in the system.}
10
+
11
+ ---
12
+
13
+ ## User Workflows
14
+
15
+ {Step-by-step journeys for the 1-3 primary user actions. For each workflow:}
16
+
17
+ 1. **{Workflow Name}**
18
+ - **User action:** {What the user does}
19
+ - **System response:** {What the system does}
20
+ - **Result:** {What the user sees}
10
21
 
11
22
  ---
12
23
 
13
24
  ## How It Works
14
25
 
15
- {Core logic and flow.}
26
+ {Trace at least one complete request from user action to final effect. Show the full path through every service, database call, and external system involved. Don't skip intermediaries.}
16
27
 
17
- {Mermaid diagram(s)max 7-9 nodes per diagram, split into multiple if larger.}
28
+ {Use a sequence diagram for the primary flow show all actors. Use flowcharts for branching logic only. Max 7-9 nodes per diagram, split into multiple if larger.}
18
29
 
19
30
  ---
20
31
 
21
32
  ## Data Model
22
33
 
23
- {Entities this feature owns and their relationships. Mermaid ER diagram or table.}
34
+ {Primary tables this feature owns. Include actual column names, types, and purpose not just entity names.}
35
+
36
+ | Column | Type | Description |
37
+ |--------|------|-------------|
38
+ | `column_name` | `type` | What it stores |
39
+
40
+ {Mermaid ER diagram for relationships between tables.}
24
41
 
25
42
  ---
26
43
 
@@ -46,9 +63,17 @@
46
63
 
47
64
  ---
48
65
 
49
- ## Error Handling
66
+ ## Error Handling & Edge Cases
67
+
68
+ {Specific failure scenarios, not generic statements. For each:}
69
+
70
+ - **{Scenario}** — {What triggers it}. User sees: {what}. System does: {recovery/logging}.
71
+
72
+ ---
73
+
74
+ ## Security
50
75
 
51
- {Failure modes, what the user sees, retry logic. Mermaid diagram if the error flow is non-trivial.}
76
+ {Authentication and authorization patterns. Service roles, secrets, access control. What an attacker could exploit if this feature were misconfigured.}
52
77
 
53
78
  ---
54
79
 
@@ -84,19 +84,24 @@ Read the template from `.junie/vdoc/doc-template.md` once before starting.
84
84
  Then generate docs **one at a time, sequentially**. For each approved doc:
85
85
 
86
86
  1. Read ALL relevant source files for that feature — not just the main file, but helpers, types, middleware, tests
87
- 2. Write `vdocs/FEATURE_NAME_DOC.md` following the template exactly
88
- 3. Confirm the file was written before moving to the next doc
87
+ 2. **Trace the end-to-end flow** — pick the primary user action and follow it through every layer: frontend → API route → service/lib → database → external service → response. Read each file in the chain. Don't stop at the service layer.
88
+ 3. Write `vdocs/FEATURE_NAME_DOC.md` following the template exactly
89
+ 4. Confirm the file was written before moving to the next doc
89
90
 
90
- Do NOT attempt to generate multiple docs from memory. Each doc is a fresh cycle: read sources → write doc → next.
91
+ Do NOT attempt to generate multiple docs from memory. Each doc is a fresh cycle: read sources → trace flows → write doc → next.
91
92
 
92
93
  **Writing rules:**
93
94
 
94
- - **Mermaid diagrams are mandatory** in "How It Works". Show the actual flowrequest lifecycle, state transitions, data pipeline. If a flow has more than 7-9 nodes, split into multiple diagrams.
95
- - **Data Model** must show real entities from the code, not generic placeholders. Use mermaid ER diagrams for relational data, tables for simpler models.
95
+ - **Overview** must open with the value propositionwhat problem does this feature solve for the user? Not just "manages X" but "enables users to Y without Z."
96
+ - **User Workflows** describe 1-3 primary user journeys step by step: what the user does, what the system does, what the user sees. This grounds the doc in product reality.
97
+ - **"How It Works" must use sequence diagrams** for the primary flow — show every actor (user, frontend, API, service, database, external systems). Flowcharts are for branching logic only. Trace the COMPLETE path — if there's a cron job that calls an executor that calls an external API, show all three, not just "cron → external API."
98
+ - **Data Model** must show actual column names, types, and descriptions for primary tables — not just entity names in an ER diagram. Read the actual schema/types files. Include fields that carry important semantics (e.g., `session_id` for context continuity, `webhook_url` for per-config endpoints).
99
+ - **Error Handling & Edge Cases** — list specific failure scenarios: "If the user's OAuth token expires, the system does X. The user sees Y." Not generic "errors are logged." Think: what breaks at 2 AM with no user present?
100
+ - **Security** — document auth patterns, service roles, secrets, access control. If a background job bypasses RLS with a service role, say so. If an endpoint is guarded by a bearer token, document it.
96
101
  - **Constraints & Decisions** is the most valuable section. Dig into the code for non-obvious choices: "Uses polling instead of websockets because...", "Auth tokens expire in 15min because...". If you can't find the reason, state the constraint and mark it: `Reason: unknown — verify with team`.
97
102
  - **Related Features** must reference other docs by filename and explain the coupling: "Changes to the JWT schema will require updates to API_REFERENCE_DOC.md (auth middleware affects all endpoints)."
98
103
  - **Configuration** must list actual env vars/secrets from the code, not hypothetical ones.
99
- - **Error Handling** — trace what happens when things fail. What does the user see? What gets logged? Is there retry logic?
104
+ - **Key Files** — list every file in the execution path, not just the "main" files. If a cron handler, executor, service, and DB helper are all involved, list all of them.
100
105
 
101
106
  ## Step 4 — Manifest
102
107
 
@@ -127,3 +132,6 @@ Before finishing, verify:
127
132
  - [ ] Every doc's "Related Features" references other doc filenames
128
133
  - [ ] Manifest `description` is detailed enough for semantic routing
129
134
  - [ ] No doc is just a shallow restatement of file names — each explains WHY and HOW
135
+ - [ ] Every doc has "User Workflows" with at least one step-by-step journey
136
+ - [ ] Every doc has specific "Error Handling & Edge Cases" (not generic)
137
+ - [ ] Every doc has a "Security" section documenting auth/access patterns
@@ -6,21 +6,38 @@
6
6
 
7
7
  ## Overview
8
8
 
9
- {What it does, why it exists, how it fits in the system.}
9
+ {What it does and why it exists. Start with the value proposition — what problem does this solve for the user? Then explain how it fits in the system.}
10
+
11
+ ---
12
+
13
+ ## User Workflows
14
+
15
+ {Step-by-step journeys for the 1-3 primary user actions. For each workflow:}
16
+
17
+ 1. **{Workflow Name}**
18
+ - **User action:** {What the user does}
19
+ - **System response:** {What the system does}
20
+ - **Result:** {What the user sees}
10
21
 
11
22
  ---
12
23
 
13
24
  ## How It Works
14
25
 
15
- {Core logic and flow.}
26
+ {Trace at least one complete request from user action to final effect. Show the full path through every service, database call, and external system involved. Don't skip intermediaries.}
16
27
 
17
- {Mermaid diagram(s)max 7-9 nodes per diagram, split into multiple if larger.}
28
+ {Use a sequence diagram for the primary flow show all actors. Use flowcharts for branching logic only. Max 7-9 nodes per diagram, split into multiple if larger.}
18
29
 
19
30
  ---
20
31
 
21
32
  ## Data Model
22
33
 
23
- {Entities this feature owns and their relationships. Mermaid ER diagram or table.}
34
+ {Primary tables this feature owns. Include actual column names, types, and purpose not just entity names.}
35
+
36
+ | Column | Type | Description |
37
+ |--------|------|-------------|
38
+ | `column_name` | `type` | What it stores |
39
+
40
+ {Mermaid ER diagram for relationships between tables.}
24
41
 
25
42
  ---
26
43
 
@@ -46,9 +63,17 @@
46
63
 
47
64
  ---
48
65
 
49
- ## Error Handling
66
+ ## Error Handling & Edge Cases
67
+
68
+ {Specific failure scenarios, not generic statements. For each:}
69
+
70
+ - **{Scenario}** — {What triggers it}. User sees: {what}. System does: {recovery/logging}.
71
+
72
+ ---
73
+
74
+ ## Security
50
75
 
51
- {Failure modes, what the user sees, retry logic. Mermaid diagram if the error flow is non-trivial.}
76
+ {Authentication and authorization patterns. Service roles, secrets, access control. What an attacker could exploit if this feature were misconfigured.}
52
77
 
53
78
  ---
54
79
 
@@ -84,19 +84,24 @@ Read the template from [doc-template.md](./doc-template.md) once before starting
84
84
  Then generate docs **one at a time, sequentially**. For each approved doc:
85
85
 
86
86
  1. Read ALL relevant source files for that feature — not just the main file, but helpers, types, middleware, tests
87
- 2. Write `vdocs/FEATURE_NAME_DOC.md` following the template exactly
88
- 3. Confirm the file was written before moving to the next doc
87
+ 2. **Trace the end-to-end flow** — pick the primary user action and follow it through every layer: frontend → API route → service/lib → database → external service → response. Read each file in the chain. Don't stop at the service layer.
88
+ 3. Write `vdocs/FEATURE_NAME_DOC.md` following the template exactly
89
+ 4. Confirm the file was written before moving to the next doc
89
90
 
90
- Do NOT attempt to generate multiple docs from memory. Each doc is a fresh cycle: read sources → write doc → next.
91
+ Do NOT attempt to generate multiple docs from memory. Each doc is a fresh cycle: read sources → trace flows → write doc → next.
91
92
 
92
93
  **Writing rules:**
93
94
 
94
- - **Mermaid diagrams are mandatory** in "How It Works". Show the actual flowrequest lifecycle, state transitions, data pipeline. If a flow has more than 7-9 nodes, split into multiple diagrams.
95
- - **Data Model** must show real entities from the code, not generic placeholders. Use mermaid ER diagrams for relational data, tables for simpler models.
95
+ - **Overview** must open with the value propositionwhat problem does this feature solve for the user? Not just "manages X" but "enables users to Y without Z."
96
+ - **User Workflows** describe 1-3 primary user journeys step by step: what the user does, what the system does, what the user sees. This grounds the doc in product reality.
97
+ - **"How It Works" must use sequence diagrams** for the primary flow — show every actor (user, frontend, API, service, database, external systems). Flowcharts are for branching logic only. Trace the COMPLETE path — if there's a cron job that calls an executor that calls an external API, show all three, not just "cron → external API."
98
+ - **Data Model** must show actual column names, types, and descriptions for primary tables — not just entity names in an ER diagram. Read the actual schema/types files. Include fields that carry important semantics (e.g., `session_id` for context continuity, `webhook_url` for per-config endpoints).
99
+ - **Error Handling & Edge Cases** — list specific failure scenarios: "If the user's OAuth token expires, the system does X. The user sees Y." Not generic "errors are logged." Think: what breaks at 2 AM with no user present?
100
+ - **Security** — document auth patterns, service roles, secrets, access control. If a background job bypasses RLS with a service role, say so. If an endpoint is guarded by a bearer token, document it.
96
101
  - **Constraints & Decisions** is the most valuable section. Dig into the code for non-obvious choices: "Uses polling instead of websockets because...", "Auth tokens expire in 15min because...". If you can't find the reason, state the constraint and mark it: `Reason: unknown — verify with team`.
97
102
  - **Related Features** must reference other docs by filename and explain the coupling: "Changes to the JWT schema will require updates to API_REFERENCE_DOC.md (auth middleware affects all endpoints)."
98
103
  - **Configuration** must list actual env vars/secrets from the code, not hypothetical ones.
99
- - **Error Handling** — trace what happens when things fail. What does the user see? What gets logged? Is there retry logic?
104
+ - **Key Files** — list every file in the execution path, not just the "main" files. If a cron handler, executor, service, and DB helper are all involved, list all of them.
100
105
 
101
106
  ## Step 4 — Manifest
102
107
 
@@ -127,3 +132,6 @@ Before finishing, verify:
127
132
  - [ ] Every doc's "Related Features" references other doc filenames
128
133
  - [ ] Manifest `description` is detailed enough for semantic routing
129
134
  - [ ] No doc is just a shallow restatement of file names — each explains WHY and HOW
135
+ - [ ] Every doc has "User Workflows" with at least one step-by-step journey
136
+ - [ ] Every doc has specific "Error Handling & Edge Cases" (not generic)
137
+ - [ ] Every doc has a "Security" section documenting auth/access patterns
@@ -6,21 +6,38 @@
6
6
 
7
7
  ## Overview
8
8
 
9
- {What it does, why it exists, how it fits in the system.}
9
+ {What it does and why it exists. Start with the value proposition — what problem does this solve for the user? Then explain how it fits in the system.}
10
+
11
+ ---
12
+
13
+ ## User Workflows
14
+
15
+ {Step-by-step journeys for the 1-3 primary user actions. For each workflow:}
16
+
17
+ 1. **{Workflow Name}**
18
+ - **User action:** {What the user does}
19
+ - **System response:** {What the system does}
20
+ - **Result:** {What the user sees}
10
21
 
11
22
  ---
12
23
 
13
24
  ## How It Works
14
25
 
15
- {Core logic and flow.}
26
+ {Trace at least one complete request from user action to final effect. Show the full path through every service, database call, and external system involved. Don't skip intermediaries.}
16
27
 
17
- {Mermaid diagram(s)max 7-9 nodes per diagram, split into multiple if larger.}
28
+ {Use a sequence diagram for the primary flow show all actors. Use flowcharts for branching logic only. Max 7-9 nodes per diagram, split into multiple if larger.}
18
29
 
19
30
  ---
20
31
 
21
32
  ## Data Model
22
33
 
23
- {Entities this feature owns and their relationships. Mermaid ER diagram or table.}
34
+ {Primary tables this feature owns. Include actual column names, types, and purpose not just entity names.}
35
+
36
+ | Column | Type | Description |
37
+ |--------|------|-------------|
38
+ | `column_name` | `type` | What it stores |
39
+
40
+ {Mermaid ER diagram for relationships between tables.}
24
41
 
25
42
  ---
26
43
 
@@ -46,9 +63,17 @@
46
63
 
47
64
  ---
48
65
 
49
- ## Error Handling
66
+ ## Error Handling & Edge Cases
67
+
68
+ {Specific failure scenarios, not generic statements. For each:}
69
+
70
+ - **{Scenario}** — {What triggers it}. User sees: {what}. System does: {recovery/logging}.
71
+
72
+ ---
73
+
74
+ ## Security
50
75
 
51
- {Failure modes, what the user sees, retry logic. Mermaid diagram if the error flow is non-trivial.}
76
+ {Authentication and authorization patterns. Service roles, secrets, access control. What an attacker could exploit if this feature were misconfigured.}
52
77
 
53
78
  ---
54
79
 
@@ -84,19 +84,24 @@ Read the template from `resources/doc-template.md` once before starting.
84
84
  Then generate docs **one at a time, sequentially**. For each approved doc:
85
85
 
86
86
  1. Read ALL relevant source files for that feature — not just the main file, but helpers, types, middleware, tests
87
- 2. Write `vdocs/FEATURE_NAME_DOC.md` following the template exactly
88
- 3. Confirm the file was written before moving to the next doc
87
+ 2. **Trace the end-to-end flow** — pick the primary user action and follow it through every layer: frontend → API route → service/lib → database → external service → response. Read each file in the chain. Don't stop at the service layer.
88
+ 3. Write `vdocs/FEATURE_NAME_DOC.md` following the template exactly
89
+ 4. Confirm the file was written before moving to the next doc
89
90
 
90
- Do NOT attempt to generate multiple docs from memory. Each doc is a fresh cycle: read sources → write doc → next.
91
+ Do NOT attempt to generate multiple docs from memory. Each doc is a fresh cycle: read sources → trace flows → write doc → next.
91
92
 
92
93
  **Writing rules:**
93
94
 
94
- - **Mermaid diagrams are mandatory** in "How It Works". Show the actual flowrequest lifecycle, state transitions, data pipeline. If a flow has more than 7-9 nodes, split into multiple diagrams.
95
- - **Data Model** must show real entities from the code, not generic placeholders. Use mermaid ER diagrams for relational data, tables for simpler models.
95
+ - **Overview** must open with the value propositionwhat problem does this feature solve for the user? Not just "manages X" but "enables users to Y without Z."
96
+ - **User Workflows** describe 1-3 primary user journeys step by step: what the user does, what the system does, what the user sees. This grounds the doc in product reality.
97
+ - **"How It Works" must use sequence diagrams** for the primary flow — show every actor (user, frontend, API, service, database, external systems). Flowcharts are for branching logic only. Trace the COMPLETE path — if there's a cron job that calls an executor that calls an external API, show all three, not just "cron → external API."
98
+ - **Data Model** must show actual column names, types, and descriptions for primary tables — not just entity names in an ER diagram. Read the actual schema/types files. Include fields that carry important semantics (e.g., `session_id` for context continuity, `webhook_url` for per-config endpoints).
99
+ - **Error Handling & Edge Cases** — list specific failure scenarios: "If the user's OAuth token expires, the system does X. The user sees Y." Not generic "errors are logged." Think: what breaks at 2 AM with no user present?
100
+ - **Security** — document auth patterns, service roles, secrets, access control. If a background job bypasses RLS with a service role, say so. If an endpoint is guarded by a bearer token, document it.
96
101
  - **Constraints & Decisions** is the most valuable section. Dig into the code for non-obvious choices: "Uses polling instead of websockets because...", "Auth tokens expire in 15min because...". If you can't find the reason, state the constraint and mark it: `Reason: unknown — verify with team`.
97
102
  - **Related Features** must reference other docs by filename and explain the coupling: "Changes to the JWT schema will require updates to API_REFERENCE_DOC.md (auth middleware affects all endpoints)."
98
103
  - **Configuration** must list actual env vars/secrets from the code, not hypothetical ones.
99
- - **Error Handling** — trace what happens when things fail. What does the user see? What gets logged? Is there retry logic?
104
+ - **Key Files** — list every file in the execution path, not just the "main" files. If a cron handler, executor, service, and DB helper are all involved, list all of them.
100
105
 
101
106
  ## Step 4 — Manifest
102
107
 
@@ -127,3 +132,6 @@ Before finishing, verify:
127
132
  - [ ] Every doc's "Related Features" references other doc filenames
128
133
  - [ ] Manifest `description` is detailed enough for semantic routing
129
134
  - [ ] No doc is just a shallow restatement of file names — each explains WHY and HOW
135
+ - [ ] Every doc has "User Workflows" with at least one step-by-step journey
136
+ - [ ] Every doc has specific "Error Handling & Edge Cases" (not generic)
137
+ - [ ] Every doc has a "Security" section documenting auth/access patterns