@brainfish-ai/devdoc 0.1.37 → 0.1.38
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/ai-agents/.claude/skills/bootstrap-docs/SKILL.md +382 -434
- package/ai-agents/.claude/skills/create-doc/SKILL.md +47 -10
- package/ai-agents/.claude/skills/update-doc/SKILL.md +40 -15
- package/ai-agents/.cursor/rules/devdoc-bootstrap.mdc +211 -153
- package/ai-agents/.cursor/rules/devdoc-create.mdc +17 -5
- package/ai-agents/.cursor/rules/devdoc-update.mdc +29 -12
- package/ai-agents/schemas/code-graph.schema.json +413 -0
- package/ai-agents/schemas/context.schema.json +20 -0
- package/package.json +1 -1
|
@@ -1,492 +1,437 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: bootstrap-docs
|
|
3
|
-
description: Analyze repository and generate documentation
|
|
3
|
+
description: Analyze repository and generate documentation with user-driven preferences and comprehensive code memory.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
## Instructions
|
|
7
7
|
|
|
8
8
|
When bootstrapping documentation from a repository:
|
|
9
9
|
|
|
10
|
-
### Step 1: Check Context
|
|
10
|
+
### Step 1: Check Existing Context & Codebase
|
|
11
11
|
|
|
12
|
-
**First,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
**If context.json is empty or doesn't exist:**
|
|
20
|
-
- Proceed to Step 2 (Discovery Flow)
|
|
12
|
+
**First, detect if there's a codebase to scan:**
|
|
13
|
+
```
|
|
14
|
+
Look for:
|
|
15
|
+
- package.json, pyproject.toml, Cargo.toml, go.mod
|
|
16
|
+
- src/, lib/, app/ directories
|
|
17
|
+
- Any source code files
|
|
18
|
+
```
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
**If NO codebase found:**
|
|
21
|
+
- Tell user: "No codebase detected. Creating docs-only project."
|
|
22
|
+
- Skip code-graph generation entirely
|
|
23
|
+
- Proceed to Step 2 for preferences, then Step 6 for structure
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
**If codebase exists, check git state:**
|
|
26
|
+
```bash
|
|
27
|
+
git rev-parse HEAD # Current commit hash
|
|
28
|
+
git rev-parse --abbrev-ref HEAD # Current branch
|
|
29
|
+
```
|
|
25
30
|
|
|
26
|
-
**If
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
**If `.devdoc/code-graph.json` exists:**
|
|
32
|
+
1. Read `git.commitHash` from the file
|
|
33
|
+
2. Compare to current HEAD:
|
|
34
|
+
- **Same commit** → "Code graph up to date (commit: {short_hash})"
|
|
35
|
+
- Skip to Step 6 (Plan Documentation)
|
|
36
|
+
- **Different commit** → Changes detected
|
|
37
|
+
- Run: `git diff {old_hash}..HEAD --name-only`
|
|
38
|
+
- Tell user: "{N} files changed since last scan"
|
|
39
|
+
- Ask: "1. Full rescan 2. Incremental (changed files only) 3. Skip"
|
|
40
|
+
|
|
41
|
+
**If `.devdoc/context.json` exists and is populated:**
|
|
42
|
+
- Read the context file
|
|
43
|
+
- Tell user: "Found existing product context."
|
|
44
|
+
- If code-graph needs refresh → Go to Step 4
|
|
45
|
+
- If code-graph is current → Skip to Step 6
|
|
29
46
|
|
|
30
|
-
**If
|
|
31
|
-
-
|
|
32
|
-
- Create docs in `./docs/` subfolder
|
|
47
|
+
**If neither exists:**
|
|
48
|
+
- Proceed to Step 2 (Ask User Preferences)
|
|
33
49
|
|
|
34
|
-
|
|
35
|
-
- Ask user for the source code path
|
|
50
|
+
### Step 2: Ask User Preferences First
|
|
36
51
|
|
|
37
|
-
|
|
52
|
+
**Don't scan yet - ask the user what they want:**
|
|
38
53
|
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
openapi.json, openapi.yaml, openapi.yml
|
|
42
|
-
swagger.json, swagger.yaml, swagger.yml
|
|
43
|
-
api-spec.json, api-spec.yaml
|
|
44
|
-
**/openapi.*, **/swagger.*
|
|
54
|
+
#### Question 1: Documentation Type
|
|
45
55
|
```
|
|
56
|
+
What type of documentation are you creating?
|
|
46
57
|
|
|
47
|
-
**
|
|
58
|
+
1. **API Docs** - REST/GraphQL API reference for developers
|
|
59
|
+
2. **Product Docs** - Feature guides and tutorials for end users
|
|
60
|
+
3. **Internal Docs** - Team setup, architecture, contribution guides
|
|
48
61
|
```
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
**/schema.graphql
|
|
62
|
+
|
|
63
|
+
#### Question 2: Codebase Connection (if codebase detected)
|
|
52
64
|
```
|
|
65
|
+
I detected a codebase. Would you like me to:
|
|
53
66
|
|
|
54
|
-
**
|
|
67
|
+
1. **Scan codebase** - Build code-graph for accurate docs (recommended)
|
|
68
|
+
2. **Skip scanning** - I'll write docs without code analysis
|
|
69
|
+
```
|
|
55
70
|
|
|
56
|
-
####
|
|
71
|
+
#### Question 3: API Type (if API Docs selected)
|
|
72
|
+
```
|
|
73
|
+
What type of API do you have?
|
|
57
74
|
|
|
58
|
-
|
|
75
|
+
1. **OpenAPI/REST** - I have an OpenAPI/Swagger spec
|
|
76
|
+
2. **GraphQL** - I have a GraphQL schema
|
|
77
|
+
3. **Both** - REST and GraphQL APIs
|
|
78
|
+
4. **Manual** - I'll document the API manually (no spec file)
|
|
79
|
+
```
|
|
59
80
|
|
|
81
|
+
#### Question 3: Target Audience
|
|
82
|
+
```
|
|
83
|
+
Who is your primary audience?
|
|
84
|
+
(e.g., "Backend developers integrating our payment API", "Internal engineering team")
|
|
60
85
|
```
|
|
61
|
-
From README.md:
|
|
62
|
-
- Product name
|
|
63
|
-
- Description
|
|
64
|
-
- Key features
|
|
65
86
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
87
|
+
#### Question 4: Code Examples Language
|
|
88
|
+
```
|
|
89
|
+
What language should code examples use?
|
|
90
|
+
(e.g., TypeScript, Python, curl, Go)
|
|
91
|
+
```
|
|
70
92
|
|
|
71
|
-
|
|
72
|
-
- API style: REST
|
|
73
|
-
- Base URL
|
|
74
|
-
- Authentication type
|
|
75
|
-
- Endpoints count
|
|
76
|
-
- Common patterns
|
|
93
|
+
### Step 3: Locate & Import API Specs (if applicable)
|
|
77
94
|
|
|
78
|
-
|
|
79
|
-
- API style: GraphQL
|
|
80
|
-
- Types count
|
|
81
|
-
- Queries/Mutations
|
|
95
|
+
**Only if user selected OpenAPI or GraphQL:**
|
|
82
96
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
97
|
+
For OpenAPI:
|
|
98
|
+
```
|
|
99
|
+
Do you have an OpenAPI spec file? Please provide the path, or I can search for:
|
|
100
|
+
- openapi.json / openapi.yaml
|
|
101
|
+
- swagger.json / swagger.yaml
|
|
86
102
|
```
|
|
87
103
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
"What type of documentation are you creating?
|
|
94
|
-
1. **internal** - For your team: setup guides, architecture, contribution guidelines
|
|
95
|
-
2. **api** - For developers using your product: API reference, SDKs, integration guides
|
|
96
|
-
3. **product** - For end users: feature guides, tutorials, FAQs"
|
|
104
|
+
For GraphQL:
|
|
105
|
+
```
|
|
106
|
+
Do you have a GraphQL schema? Please provide the path, or I can search for:
|
|
107
|
+
- schema.graphql / schema.gql
|
|
108
|
+
```
|
|
97
109
|
|
|
98
|
-
|
|
110
|
+
**After locating spec:**
|
|
111
|
+
1. Copy to `api-reference/` folder
|
|
112
|
+
2. Validate the spec
|
|
113
|
+
3. Extract metadata (endpoints, types, auth)
|
|
99
114
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
**If OpenAPI spec found:**
|
|
103
|
-
"I found an OpenAPI specification at `{path}`:
|
|
104
|
-
- {endpoint_count} endpoints
|
|
105
|
-
- Base URL: {base_url}
|
|
106
|
-
- Auth: {auth_type}
|
|
107
|
-
|
|
108
|
-
Would you like me to:
|
|
109
|
-
1. **Import it** - Copy to `api-reference/openapi.json` and generate API Reference tab
|
|
110
|
-
2. **Reference it** - Point docs.json to existing location: `{path}`
|
|
111
|
-
3. **Skip** - Don't include API reference (I'll create manual docs instead)"
|
|
112
|
-
|
|
113
|
-
**If GraphQL schema found:**
|
|
114
|
-
"I found a GraphQL schema at `{path}`:
|
|
115
|
-
- {types_count} types
|
|
116
|
-
- {queries_count} queries
|
|
117
|
-
- {mutations_count} mutations
|
|
118
|
-
|
|
119
|
-
Would you like me to:
|
|
120
|
-
1. **Import it** - Copy to `api-reference/schema.graphql` and generate GraphQL tab
|
|
121
|
-
2. **Reference it** - Point docs.json to existing location: `{path}`
|
|
122
|
-
3. **Skip** - Don't include GraphQL playground"
|
|
123
|
-
|
|
124
|
-
**If multiple specs found:**
|
|
125
|
-
"I found multiple API specifications:
|
|
126
|
-
- OpenAPI: `{openapi_path}`
|
|
127
|
-
- GraphQL: `{graphql_path}`
|
|
128
|
-
|
|
129
|
-
Which would you like to use for the API Reference?
|
|
130
|
-
1. **OpenAPI (REST)** - Interactive REST API playground
|
|
131
|
-
2. **GraphQL** - GraphQL playground with schema explorer
|
|
132
|
-
3. **Both** - Create separate tabs for each
|
|
133
|
-
4. **Skip** - Manual documentation only"
|
|
115
|
+
### Step 4: Build Code Graph (Optional)
|
|
134
116
|
|
|
135
|
-
|
|
117
|
+
**Skip this step if:**
|
|
118
|
+
- No codebase detected
|
|
119
|
+
- User chose "Skip scanning" in Question 2
|
|
120
|
+
- User is creating docs-only project
|
|
136
121
|
|
|
137
|
-
**
|
|
138
|
-
"Who is your primary audience?
|
|
139
|
-
(e.g., 'Backend developers integrating our payment API', 'Internal engineering team', 'Non-technical business users')"
|
|
122
|
+
**If scanning, comprehensively analyze the codebase and build `.devdoc/code-graph.json`:**
|
|
140
123
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
124
|
+
#### 4a. Project Metadata
|
|
125
|
+
```
|
|
126
|
+
Scan and extract:
|
|
127
|
+
├── README.md → Product name, description, features
|
|
128
|
+
├── package.json → Language, framework, dependencies
|
|
129
|
+
├── LICENSE → License type
|
|
130
|
+
└── .env.example → Required environment variables
|
|
131
|
+
```
|
|
148
132
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
133
|
+
#### 4b. Source Code Structure
|
|
134
|
+
```
|
|
135
|
+
Map all directories:
|
|
136
|
+
├── src/
|
|
137
|
+
│ ├── api/ → API routes, controllers
|
|
138
|
+
│ ├── models/ → Data models, schemas
|
|
139
|
+
│ ├── services/ → Business logic
|
|
140
|
+
│ ├── utils/ → Helper functions
|
|
141
|
+
│ └── types/ → Type definitions
|
|
142
|
+
├── tests/ → Test files (for code examples)
|
|
143
|
+
└── examples/ → Example usage
|
|
144
|
+
```
|
|
152
145
|
|
|
153
|
-
####
|
|
146
|
+
#### 4c. Deep Code Analysis
|
|
147
|
+
```
|
|
148
|
+
For each module, extract:
|
|
149
|
+
- All public functions with FULL signatures
|
|
150
|
+
- Class definitions with methods
|
|
151
|
+
- Interface/type definitions
|
|
152
|
+
- Exported constants
|
|
153
|
+
- Error types and codes
|
|
154
|
+
- Configuration options
|
|
155
|
+
```
|
|
154
156
|
|
|
155
|
-
|
|
157
|
+
#### 4d. Create Code Graph File
|
|
156
158
|
|
|
159
|
+
Save to `.devdoc/code-graph.json`:
|
|
157
160
|
```json
|
|
158
161
|
{
|
|
159
|
-
"$schema": "https://devdoc.sh/schemas/
|
|
162
|
+
"$schema": "https://devdoc.sh/schemas/code-graph.json",
|
|
160
163
|
"version": "1.0",
|
|
161
|
-
"
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
"
|
|
165
|
-
"
|
|
166
|
-
"
|
|
167
|
-
"
|
|
168
|
-
"
|
|
164
|
+
"generatedAt": "2026-01-24T10:00:00Z",
|
|
165
|
+
|
|
166
|
+
"git": {
|
|
167
|
+
"commitHash": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0",
|
|
168
|
+
"commitShort": "a1b2c3d",
|
|
169
|
+
"branch": "main",
|
|
170
|
+
"commitMessage": "feat: add user authentication",
|
|
171
|
+
"commitDate": "2026-01-24T09:30:00Z",
|
|
172
|
+
"isDirty": false
|
|
169
173
|
},
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
"
|
|
173
|
-
"
|
|
174
|
+
|
|
175
|
+
"project": {
|
|
176
|
+
"name": "Project Name",
|
|
177
|
+
"description": "From README",
|
|
178
|
+
"language": "TypeScript",
|
|
179
|
+
"framework": "Express",
|
|
180
|
+
"rootDir": "src/"
|
|
174
181
|
},
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
"
|
|
178
|
-
"
|
|
179
|
-
"
|
|
180
|
-
|
|
181
|
-
"headerName": "",
|
|
182
|
-
"description": ""
|
|
183
|
-
},
|
|
184
|
-
"conventions": {},
|
|
185
|
-
"commonPatterns": []
|
|
186
|
-
},
|
|
187
|
-
"codebase": {
|
|
188
|
-
"language": "[from package.json]",
|
|
189
|
-
"framework": "[from dependencies]",
|
|
190
|
-
"sourceLocation": "../"
|
|
182
|
+
|
|
183
|
+
"structure": {
|
|
184
|
+
"sourceDir": "src/",
|
|
185
|
+
"testsDir": "tests/",
|
|
186
|
+
"examplesDir": "examples/",
|
|
187
|
+
"docsDir": "docs/"
|
|
191
188
|
},
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
"
|
|
197
|
-
"
|
|
189
|
+
|
|
190
|
+
"modules": [
|
|
191
|
+
{
|
|
192
|
+
"name": "auth",
|
|
193
|
+
"path": "src/auth/",
|
|
194
|
+
"description": "Authentication and authorization",
|
|
195
|
+
"files": ["index.ts", "jwt.ts", "middleware.ts"],
|
|
196
|
+
"exports": [
|
|
197
|
+
{
|
|
198
|
+
"name": "login",
|
|
199
|
+
"type": "function",
|
|
200
|
+
"signature": "login(email: string, password: string): Promise<AuthToken>",
|
|
201
|
+
"description": "Authenticate user and return JWT",
|
|
202
|
+
"params": [
|
|
203
|
+
{ "name": "email", "type": "string", "description": "User email" },
|
|
204
|
+
{ "name": "password", "type": "string", "description": "User password" }
|
|
205
|
+
],
|
|
206
|
+
"returns": { "type": "Promise<AuthToken>", "description": "JWT token" },
|
|
207
|
+
"async": true
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"name": "verifyToken",
|
|
211
|
+
"type": "function",
|
|
212
|
+
"signature": "verifyToken(token: string): Promise<User>",
|
|
213
|
+
"async": true
|
|
214
|
+
}
|
|
215
|
+
],
|
|
216
|
+
"dependencies": ["users", "config"],
|
|
217
|
+
"docPriority": "high"
|
|
218
|
+
}
|
|
219
|
+
],
|
|
220
|
+
|
|
221
|
+
"types": [
|
|
222
|
+
{
|
|
223
|
+
"name": "User",
|
|
224
|
+
"path": "src/types/user.ts",
|
|
225
|
+
"kind": "interface",
|
|
226
|
+
"definition": "interface User { id: string; email: string; name: string; }",
|
|
227
|
+
"properties": [
|
|
228
|
+
{ "name": "id", "type": "string" },
|
|
229
|
+
{ "name": "email", "type": "string" },
|
|
230
|
+
{ "name": "name", "type": "string" }
|
|
231
|
+
]
|
|
198
232
|
},
|
|
199
|
-
|
|
200
|
-
"
|
|
201
|
-
"
|
|
202
|
-
"
|
|
203
|
-
"
|
|
204
|
-
"troubleshooting": ".devdoc/templates/troubleshooting.md"
|
|
233
|
+
{
|
|
234
|
+
"name": "AuthToken",
|
|
235
|
+
"path": "src/types/auth.ts",
|
|
236
|
+
"kind": "interface",
|
|
237
|
+
"definition": "interface AuthToken { token: string; expiresAt: Date; }"
|
|
205
238
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
"
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
"
|
|
218
|
-
- Product: {name}
|
|
219
|
-
- Type: {docType}
|
|
220
|
-
- API: {REST/GraphQL} (imported from {spec_path})
|
|
221
|
-
- Audience: {targetAudience}
|
|
222
|
-
- Code examples: {primaryLanguage}
|
|
223
|
-
|
|
224
|
-
This context will be used for consistent documentation generation."
|
|
225
|
-
|
|
226
|
-
### Step 3: Import API Spec (if selected)
|
|
227
|
-
|
|
228
|
-
**For OpenAPI (Import option):**
|
|
229
|
-
1. Copy spec to `api-reference/openapi.json` (or `.yaml`)
|
|
230
|
-
2. Validate the spec is valid OpenAPI 3.x
|
|
231
|
-
3. Extract key info for context.json
|
|
232
|
-
|
|
233
|
-
**For OpenAPI (Reference option):**
|
|
234
|
-
1. Note the relative path for docs.json
|
|
235
|
-
2. Extract key info for context.json
|
|
236
|
-
|
|
237
|
-
**For GraphQL (Import option):**
|
|
238
|
-
1. Copy schema to `api-reference/schema.graphql`
|
|
239
|
-
2. Validate the schema
|
|
240
|
-
3. Extract types/queries/mutations for context
|
|
241
|
-
|
|
242
|
-
**For GraphQL (Reference option):**
|
|
243
|
-
1. Note the relative path for docs.json
|
|
244
|
-
2. Extract schema info for context
|
|
245
|
-
|
|
246
|
-
### Step 4: Update docs.json with API Reference
|
|
247
|
-
|
|
248
|
-
**Read existing `docs.json` or create new one.**
|
|
249
|
-
|
|
250
|
-
Add the `docType` field and API reference tab:
|
|
251
|
-
|
|
252
|
-
**For OpenAPI:**
|
|
253
|
-
```json
|
|
254
|
-
{
|
|
255
|
-
"name": "Project Name",
|
|
256
|
-
"docType": "api",
|
|
257
|
-
"navigation": {
|
|
258
|
-
"tabs": [
|
|
239
|
+
],
|
|
240
|
+
|
|
241
|
+
"api": {
|
|
242
|
+
"type": "REST",
|
|
243
|
+
"baseUrl": "/api/v1",
|
|
244
|
+
"specPath": "api-reference/openapi.json",
|
|
245
|
+
"authentication": {
|
|
246
|
+
"type": "bearer",
|
|
247
|
+
"headerName": "Authorization",
|
|
248
|
+
"description": "JWT token required"
|
|
249
|
+
},
|
|
250
|
+
"endpoints": [
|
|
259
251
|
{
|
|
260
|
-
"
|
|
261
|
-
"
|
|
252
|
+
"method": "POST",
|
|
253
|
+
"path": "/auth/login",
|
|
254
|
+
"handler": "src/routes/auth.ts:login",
|
|
255
|
+
"description": "User login",
|
|
256
|
+
"auth": "none"
|
|
262
257
|
},
|
|
263
258
|
{
|
|
264
|
-
"
|
|
265
|
-
"
|
|
266
|
-
"
|
|
259
|
+
"method": "GET",
|
|
260
|
+
"path": "/users/:id",
|
|
261
|
+
"handler": "src/routes/users.ts:getUser",
|
|
262
|
+
"auth": "required",
|
|
263
|
+
"responseType": "User"
|
|
267
264
|
}
|
|
268
265
|
]
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
{
|
|
285
|
-
"tab": "GraphQL API",
|
|
286
|
-
"type": "graphql",
|
|
287
|
-
"schema": "api-reference/schema.graphql",
|
|
288
|
-
"endpoint": "https://api.example.com/graphql"
|
|
289
|
-
}
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
"examples": [
|
|
269
|
+
{
|
|
270
|
+
"path": "examples/basic-auth.ts",
|
|
271
|
+
"description": "Basic authentication flow",
|
|
272
|
+
"tags": ["auth", "login"],
|
|
273
|
+
"runnable": true
|
|
274
|
+
}
|
|
275
|
+
],
|
|
276
|
+
|
|
277
|
+
"config": {
|
|
278
|
+
"envVars": [
|
|
279
|
+
{ "name": "JWT_SECRET", "description": "Secret for JWT signing", "required": true },
|
|
280
|
+
{ "name": "DATABASE_URL", "description": "Database connection string", "required": true }
|
|
290
281
|
]
|
|
282
|
+
},
|
|
283
|
+
|
|
284
|
+
"errors": [
|
|
285
|
+
{ "name": "AuthenticationError", "code": "AUTH_FAILED", "message": "Invalid credentials" },
|
|
286
|
+
{ "name": "NotFoundError", "code": "NOT_FOUND", "message": "Resource not found" }
|
|
287
|
+
],
|
|
288
|
+
|
|
289
|
+
"dependencies": {
|
|
290
|
+
"express": "^4.18.0",
|
|
291
|
+
"jsonwebtoken": "^9.0.0"
|
|
291
292
|
}
|
|
292
293
|
}
|
|
293
294
|
```
|
|
294
295
|
|
|
295
|
-
|
|
296
|
+
### Step 5: Create Context File
|
|
297
|
+
|
|
298
|
+
Save to `.devdoc/context.json`:
|
|
296
299
|
```json
|
|
297
300
|
{
|
|
298
|
-
"
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
301
|
+
"$schema": "https://devdoc.sh/schemas/context.json",
|
|
302
|
+
"version": "1.0",
|
|
303
|
+
"lastUpdated": "2026-01-24T10:00:00Z",
|
|
304
|
+
"git": {
|
|
305
|
+
"commitHash": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0",
|
|
306
|
+
"commitShort": "a1b2c3d",
|
|
307
|
+
"branch": "main"
|
|
308
|
+
},
|
|
309
|
+
"preferences": {
|
|
310
|
+
"docType": "api",
|
|
311
|
+
"apiType": "openapi",
|
|
312
|
+
"audience": "Backend developers",
|
|
313
|
+
"codeLanguage": "TypeScript"
|
|
314
|
+
},
|
|
315
|
+
"product": {
|
|
316
|
+
"name": "Product Name",
|
|
317
|
+
"description": "From README",
|
|
318
|
+
"type": "api"
|
|
319
|
+
},
|
|
320
|
+
"api": {
|
|
321
|
+
"style": "REST",
|
|
322
|
+
"specPath": "api-reference/openapi.json",
|
|
323
|
+
"baseUrl": "https://api.example.com"
|
|
324
|
+
},
|
|
325
|
+
"documentation": {
|
|
326
|
+
"voice": "professional",
|
|
327
|
+
"codeExamples": {
|
|
328
|
+
"primaryLanguage": "TypeScript"
|
|
329
|
+
}
|
|
304
330
|
}
|
|
305
331
|
}
|
|
306
332
|
```
|
|
307
333
|
|
|
308
|
-
Tell user
|
|
309
|
-
|
|
310
|
-
|
|
334
|
+
**Tell user:**
|
|
335
|
+
```
|
|
336
|
+
✅ Context saved!
|
|
311
337
|
|
|
312
|
-
|
|
338
|
+
- Doc Type: API Documentation
|
|
339
|
+
- API: REST (45 endpoints)
|
|
340
|
+
- Audience: Backend developers
|
|
341
|
+
- Code examples: TypeScript
|
|
313
342
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
- For quickstart: read `.devdoc/templates/quickstart.md`
|
|
318
|
-
- For tutorials: read `.devdoc/templates/tutorial.md`
|
|
343
|
+
Memory map created with 12 modules scanned.
|
|
344
|
+
Ready to generate documentation.
|
|
345
|
+
```
|
|
319
346
|
|
|
320
|
-
|
|
321
|
-
- Use correct product name from `product.name`
|
|
322
|
-
- Use terminology from `terminology.glossary`
|
|
323
|
-
- Avoid terms from `terminology.avoidTerms`
|
|
324
|
-
- Use code language from `documentation.codeExamples.primaryLanguage`
|
|
325
|
-
- Match voice from `documentation.voice`
|
|
326
|
-
- Reference API spec path from `api.specPath`
|
|
347
|
+
### Step 6: Plan Documentation Structure
|
|
327
348
|
|
|
328
|
-
|
|
349
|
+
Based on user preferences, plan the structure:
|
|
329
350
|
|
|
330
|
-
|
|
351
|
+
#### For API Docs:
|
|
352
|
+
```
|
|
353
|
+
docs/
|
|
354
|
+
├── index.mdx # Overview, value prop
|
|
355
|
+
├── quickstart.mdx # 5-min getting started
|
|
356
|
+
├── authentication.mdx # Auth setup
|
|
357
|
+
├── guides/
|
|
358
|
+
│ ├── overview.mdx # Core concepts
|
|
359
|
+
│ └── {use-cases}.mdx # Common use cases
|
|
360
|
+
├── api-reference/
|
|
361
|
+
│ ├── openapi.json # Imported spec
|
|
362
|
+
│ ├── introduction.mdx
|
|
363
|
+
│ └── errors.mdx
|
|
364
|
+
└── sdks/ # If SDKs exist
|
|
365
|
+
```
|
|
331
366
|
|
|
332
|
-
For
|
|
367
|
+
#### For Product Docs:
|
|
368
|
+
```
|
|
369
|
+
docs/
|
|
370
|
+
├── index.mdx
|
|
371
|
+
├── getting-started/
|
|
372
|
+
│ ├── quickstart.mdx
|
|
373
|
+
│ └── key-concepts.mdx
|
|
374
|
+
├── features/
|
|
375
|
+
│ └── {feature}.mdx
|
|
376
|
+
├── tutorials/
|
|
377
|
+
└── troubleshooting/
|
|
378
|
+
```
|
|
333
379
|
|
|
380
|
+
#### For Internal Docs:
|
|
334
381
|
```
|
|
335
382
|
docs/
|
|
336
|
-
├── .
|
|
337
|
-
│ ├── context.json
|
|
338
|
-
│ └── templates/
|
|
339
|
-
├── docs.json
|
|
340
|
-
├── index.mdx # Project overview
|
|
383
|
+
├── index.mdx
|
|
341
384
|
├── getting-started/
|
|
342
|
-
│ ├── setup.mdx
|
|
343
|
-
│
|
|
344
|
-
│ └── first-contribution.mdx
|
|
385
|
+
│ ├── setup.mdx
|
|
386
|
+
│ └── prerequisites.mdx
|
|
345
387
|
├── architecture/
|
|
346
|
-
│ ├── overview.mdx # System architecture
|
|
347
|
-
│ ├── folder-structure.mdx
|
|
348
|
-
│ └── decisions.mdx # ADRs, design decisions
|
|
349
388
|
├── development/
|
|
350
|
-
|
|
351
|
-
│ ├── testing.mdx # How to run/write tests
|
|
352
|
-
│ ├── debugging.mdx # Common issues, debugging tips
|
|
353
|
-
│ └── deployment.mdx # How to deploy
|
|
354
|
-
├── api/ # Internal API docs (if applicable)
|
|
355
|
-
│ └── ...
|
|
356
|
-
└── contributing.mdx # Contribution guidelines
|
|
389
|
+
└── contributing.mdx
|
|
357
390
|
```
|
|
358
391
|
|
|
359
|
-
|
|
360
|
-
- How to set up local development
|
|
361
|
-
- Codebase architecture and patterns
|
|
362
|
-
- Internal APIs and services
|
|
363
|
-
- Debugging and troubleshooting
|
|
364
|
-
- Team conventions and standards
|
|
365
|
-
|
|
366
|
-
**Voice:** Technical, direct, assumes familiarity with codebase
|
|
367
|
-
|
|
368
|
-
---
|
|
392
|
+
### Step 7: Generate Documentation
|
|
369
393
|
|
|
370
|
-
|
|
394
|
+
**Use the code graph to write accurate docs:**
|
|
371
395
|
|
|
372
|
-
|
|
396
|
+
1. **Read `.devdoc/code-graph.json`** before writing each page
|
|
397
|
+
2. **Reference exact function signatures** from the graph
|
|
398
|
+
3. **Extract real code examples** from the examples array
|
|
399
|
+
4. **Use correct types** from the types array
|
|
400
|
+
5. **Match voice to audience** (technical for API, friendly for product)
|
|
373
401
|
|
|
402
|
+
**For each page:**
|
|
374
403
|
```
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
├── quickstart.mdx # 5-minute getting started
|
|
382
|
-
├── authentication.mdx # Auth setup (API keys, OAuth)
|
|
383
|
-
├── guides/
|
|
384
|
-
│ ├── overview.mdx # Concepts overview
|
|
385
|
-
│ └── {use-case}.mdx # Common use case tutorials
|
|
386
|
-
├── api-reference/
|
|
387
|
-
│ ├── introduction.mdx # API overview, base URL, versioning
|
|
388
|
-
│ ├── authentication.mdx # Auth details
|
|
389
|
-
│ ├── errors.mdx # Error codes and handling
|
|
390
|
-
│ ├── openapi.json # Full API spec (if imported)
|
|
391
|
-
│ └── schema.graphql # GraphQL schema (if imported)
|
|
392
|
-
├── sdks/ # If SDKs exist
|
|
393
|
-
│ ├── javascript.mdx
|
|
394
|
-
│ ├── python.mdx
|
|
395
|
-
│ └── ...
|
|
396
|
-
├── webhooks.mdx # If webhooks exist
|
|
397
|
-
└── changelog.mdx # API changelog
|
|
398
|
-
```
|
|
399
|
-
|
|
400
|
-
**Content focus:**
|
|
401
|
-
- Quick time-to-first-API-call
|
|
402
|
-
- Authentication and authorization
|
|
403
|
-
- API reference with examples
|
|
404
|
-
- SDKs and client libraries
|
|
405
|
-
- Error handling and troubleshooting
|
|
406
|
-
- Rate limits and best practices
|
|
407
|
-
|
|
408
|
-
**Voice:** Professional, helpful, code-focused
|
|
409
|
-
|
|
410
|
-
---
|
|
411
|
-
|
|
412
|
-
## docType: "product"
|
|
413
|
-
|
|
414
|
-
For end users of your product, create:
|
|
415
|
-
|
|
404
|
+
1. Read code-graph.json to find relevant modules
|
|
405
|
+
2. Use exact signatures from exports array
|
|
406
|
+
3. Reference types from types array
|
|
407
|
+
4. Extract examples from examples array or source
|
|
408
|
+
5. Document errors from errors array
|
|
409
|
+
6. Add TODO markers for sections needing review
|
|
416
410
|
```
|
|
417
|
-
docs/
|
|
418
|
-
├── .devdoc/
|
|
419
|
-
│ ├── context.json
|
|
420
|
-
│ └── templates/
|
|
421
|
-
├── docs.json
|
|
422
|
-
├── index.mdx # Product overview
|
|
423
|
-
├── getting-started/
|
|
424
|
-
│ ├── quickstart.mdx # First steps
|
|
425
|
-
│ ├── account-setup.mdx # Account creation, onboarding
|
|
426
|
-
│ └── key-concepts.mdx # Core concepts explained
|
|
427
|
-
├── features/
|
|
428
|
-
│ ├── {feature-1}.mdx # Feature guides
|
|
429
|
-
│ ├── {feature-2}.mdx
|
|
430
|
-
│ └── ...
|
|
431
|
-
├── tutorials/
|
|
432
|
-
│ ├── {workflow-1}.mdx # Step-by-step tutorials
|
|
433
|
-
│ └── ...
|
|
434
|
-
├── integrations/ # If integrations exist
|
|
435
|
-
│ └── ...
|
|
436
|
-
├── troubleshooting/
|
|
437
|
-
│ ├── common-issues.mdx
|
|
438
|
-
│ └── faq.mdx
|
|
439
|
-
└── release-notes.mdx # What's new
|
|
440
|
-
```
|
|
441
|
-
|
|
442
|
-
**Content focus:**
|
|
443
|
-
- Non-technical language (minimal code)
|
|
444
|
-
- Screenshots and visual guides
|
|
445
|
-
- Step-by-step tutorials
|
|
446
|
-
- Use case focused
|
|
447
|
-
- FAQs and troubleshooting
|
|
448
|
-
- Feature explanations
|
|
449
|
-
|
|
450
|
-
**Voice:** Friendly, supportive, non-technical
|
|
451
411
|
|
|
452
|
-
|
|
412
|
+
**Example - Writing auth docs:**
|
|
413
|
+
```
|
|
414
|
+
1. Find "auth" module in code-graph.json
|
|
415
|
+
2. Get login() signature: "login(email: string, password: string): Promise<AuthToken>"
|
|
416
|
+
3. Get AuthToken type definition
|
|
417
|
+
4. Find auth example in examples array
|
|
418
|
+
5. Write docs with EXACT signatures and types
|
|
419
|
+
```
|
|
453
420
|
|
|
454
|
-
|
|
421
|
+
### Step 8: Update docs.json
|
|
455
422
|
|
|
456
|
-
|
|
457
|
-
```json
|
|
458
|
-
{
|
|
459
|
-
"name": "{Project Name}",
|
|
460
|
-
"docType": "internal",
|
|
461
|
-
"navigation": {
|
|
462
|
-
"tabs": [
|
|
463
|
-
{
|
|
464
|
-
"tab": "Documentation",
|
|
465
|
-
"groups": [
|
|
466
|
-
{ "group": "Getting Started", "pages": ["index", "getting-started/setup", "getting-started/prerequisites"] },
|
|
467
|
-
{ "group": "Architecture", "pages": ["architecture/overview", "architecture/folder-structure"] },
|
|
468
|
-
{ "group": "Development", "pages": ["development/workflow", "development/testing", "development/deployment"] },
|
|
469
|
-
{ "group": "Contributing", "pages": ["contributing"] }
|
|
470
|
-
]
|
|
471
|
-
}
|
|
472
|
-
]
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
```
|
|
423
|
+
Configure navigation based on doc type:
|
|
476
424
|
|
|
477
|
-
|
|
425
|
+
**API Docs with OpenAPI:**
|
|
478
426
|
```json
|
|
479
427
|
{
|
|
480
|
-
"name": "
|
|
428
|
+
"name": "Product Name",
|
|
481
429
|
"docType": "api",
|
|
482
430
|
"navigation": {
|
|
483
431
|
"tabs": [
|
|
484
432
|
{
|
|
485
433
|
"tab": "Guides",
|
|
486
|
-
"groups": [
|
|
487
|
-
{ "group": "Getting Started", "pages": ["index", "quickstart", "authentication"] },
|
|
488
|
-
{ "group": "Guides", "pages": ["guides/overview"] }
|
|
489
|
-
]
|
|
434
|
+
"groups": [...]
|
|
490
435
|
},
|
|
491
436
|
{
|
|
492
437
|
"tab": "API Reference",
|
|
@@ -498,20 +443,12 @@ docs/
|
|
|
498
443
|
}
|
|
499
444
|
```
|
|
500
445
|
|
|
501
|
-
|
|
446
|
+
**API Docs with GraphQL:**
|
|
502
447
|
```json
|
|
503
448
|
{
|
|
504
|
-
"name": "{Product Name}",
|
|
505
|
-
"docType": "api",
|
|
506
449
|
"navigation": {
|
|
507
450
|
"tabs": [
|
|
508
|
-
{
|
|
509
|
-
"tab": "Guides",
|
|
510
|
-
"groups": [
|
|
511
|
-
{ "group": "Getting Started", "pages": ["index", "quickstart", "authentication"] },
|
|
512
|
-
{ "group": "Guides", "pages": ["guides/overview"] }
|
|
513
|
-
]
|
|
514
|
-
},
|
|
451
|
+
{ "tab": "Guides", "groups": [...] },
|
|
515
452
|
{
|
|
516
453
|
"tab": "GraphQL API",
|
|
517
454
|
"type": "graphql",
|
|
@@ -523,35 +460,46 @@ docs/
|
|
|
523
460
|
}
|
|
524
461
|
```
|
|
525
462
|
|
|
526
|
-
###
|
|
527
|
-
|
|
528
|
-
{
|
|
529
|
-
"name": "{Product Name}",
|
|
530
|
-
"docType": "product",
|
|
531
|
-
"navigation": {
|
|
532
|
-
"tabs": [
|
|
533
|
-
{
|
|
534
|
-
"tab": "Documentation",
|
|
535
|
-
"groups": [
|
|
536
|
-
{ "group": "Getting Started", "pages": ["index", "getting-started/quickstart", "getting-started/key-concepts"] },
|
|
537
|
-
{ "group": "Features", "pages": ["features/..."] },
|
|
538
|
-
{ "group": "Tutorials", "pages": ["tutorials/..."] },
|
|
539
|
-
{ "group": "Help", "pages": ["troubleshooting/common-issues", "troubleshooting/faq"] }
|
|
540
|
-
]
|
|
541
|
-
}
|
|
542
|
-
]
|
|
543
|
-
}
|
|
544
|
-
}
|
|
463
|
+
### Step 9: Summary
|
|
464
|
+
|
|
545
465
|
```
|
|
466
|
+
✅ Documentation Generated!
|
|
467
|
+
|
|
468
|
+
Files created:
|
|
469
|
+
- docs.json (navigation configured)
|
|
470
|
+
- index.mdx
|
|
471
|
+
- quickstart.mdx
|
|
472
|
+
- authentication.mdx
|
|
473
|
+
- guides/overview.mdx
|
|
474
|
+
- api-reference/openapi.json (imported)
|
|
475
|
+
|
|
476
|
+
Code graph files:
|
|
477
|
+
- .devdoc/context.json (user preferences)
|
|
478
|
+
- .devdoc/code-graph.json (complete code analysis)
|
|
479
|
+
|
|
480
|
+
Next steps:
|
|
481
|
+
1. Run `devdoc dev` to preview
|
|
482
|
+
2. Review TODO markers in generated docs
|
|
483
|
+
3. Run `/whisk-theme` to match your branding
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
---
|
|
487
|
+
|
|
488
|
+
## Key Principles
|
|
489
|
+
|
|
490
|
+
| Principle | Description |
|
|
491
|
+
|-----------|-------------|
|
|
492
|
+
| Ask first | Get user preferences before scanning |
|
|
493
|
+
| Build code graph | Scan entire codebase, extract all signatures |
|
|
494
|
+
| Store the graph | Save to code-graph.json for updates |
|
|
495
|
+
| Use real code | Reference exact signatures, never fabricate |
|
|
496
|
+
| Mark unknowns | Add TODO for sections needing review |
|
|
546
497
|
|
|
547
|
-
##
|
|
498
|
+
## Code Graph Usage
|
|
548
499
|
|
|
549
|
-
|
|
550
|
-
-
|
|
551
|
-
-
|
|
552
|
-
-
|
|
553
|
-
-
|
|
554
|
-
-
|
|
555
|
-
- Update context.json if you learn new information
|
|
556
|
-
- **Import existing API specs** rather than creating manual docs
|
|
557
|
-
- **Validate specs** before importing
|
|
500
|
+
The code-graph.json enables:
|
|
501
|
+
- **Accurate docs** - Use exact function signatures
|
|
502
|
+
- **Complete coverage** - Know all exports to document
|
|
503
|
+
- **Easy updates** - Re-scan to refresh the graph
|
|
504
|
+
- **No hallucination** - Only document what exists
|
|
505
|
+
- **Type accuracy** - Reference real type definitions
|