@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.
@@ -1,492 +1,437 @@
1
1
  ---
2
2
  name: bootstrap-docs
3
- description: Analyze repository and generate documentation. Creates context memory for consistent AI assistance.
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 Memory
10
+ ### Step 1: Check Existing Context & Codebase
11
11
 
12
- **First, check if `.devdoc/context.json` exists:**
13
-
14
- **If context.json exists and is populated:**
15
- - Read the context file
16
- - Tell user: "Found existing product context. Using saved configuration."
17
- - Skip to Step 5 (Generate Documentation)
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
- ### Step 2: Discovery Flow (Context Creation)
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
- #### 2a. Detect Project Structure
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 `docs.json` exists in current directory:**
27
- - You're in a DevDoc docs folder
28
- - Source code is likely in `../` (parent directory)
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 `package.json` and `src/` exist:**
31
- - You're at repo root
32
- - Create docs in `./docs/` subfolder
47
+ **If neither exists:**
48
+ - Proceed to Step 2 (Ask User Preferences)
33
49
 
34
- **If neither matches:**
35
- - Ask user for the source code path
50
+ ### Step 2: Ask User Preferences First
36
51
 
37
- #### 2b. Scan for Existing API Specs
52
+ **Don't scan yet - ask the user what they want:**
38
53
 
39
- **Search for OpenAPI specs:**
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
- **Search for GraphQL schemas:**
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
- schema.graphql, schema.gql
50
- *.graphql, *.gql
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
- **If found, store the paths for later use.**
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
- #### 2c. Auto-Discover Information
71
+ #### Question 3: API Type (if API Docs selected)
72
+ ```
73
+ What type of API do you have?
57
74
 
58
- Scan the repository and extract:
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
- From package.json / pyproject.toml / Cargo.toml:
67
- - Primary language
68
- - Framework (from dependencies)
69
- - Project type (library, cli, api, etc.)
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
- From OpenAPI spec (if exists):
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
- From GraphQL schema (if exists):
79
- - API style: GraphQL
80
- - Types count
81
- - Queries/Mutations
95
+ **Only if user selected OpenAPI or GraphQL:**
82
96
 
83
- From source code structure:
84
- - Key directories
85
- - Naming conventions
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
- #### 2d. Ask Key Questions
89
-
90
- After auto-discovery, ask the user to confirm/provide:
91
-
92
- **Question 1: Documentation Type**
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
- **Question 2: Import Existing API Spec (if detected)**
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
- **Question 3: Target Audience**
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
- **Question 4: Terminology (optional)**
142
- "Any specific terminology I should know? For example:
143
- - Brand names with specific capitalization
144
- - Terms to avoid or prefer
145
- - Domain-specific vocabulary
146
-
147
- (Press Enter to skip)"
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
- **Question 5: Code Examples**
150
- "What language should I use for code examples?
151
- (e.g., TypeScript, Python, curl)"
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
- #### 2e. Create Context Memory
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
- Create `.devdoc/` folder and `context.json` with discovered + user info:
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/context.json",
162
+ "$schema": "https://devdoc.sh/schemas/code-graph.json",
160
163
  "version": "1.0",
161
- "lastUpdated": "2026-01-24T10:30:00Z",
162
- "product": {
163
- "name": "[from README/package.json]",
164
- "description": "[from README]",
165
- "type": "[api/sdk/platform/cli/library]",
166
- "domain": "[inferred or asked]",
167
- "targetAudience": "[from Question 3]",
168
- "keyFeatures": ["[from README]"]
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
- "terminology": {
171
- "glossary": {},
172
- "avoidTerms": [],
173
- "brandNames": {}
174
+
175
+ "project": {
176
+ "name": "Project Name",
177
+ "description": "From README",
178
+ "language": "TypeScript",
179
+ "framework": "Express",
180
+ "rootDir": "src/"
174
181
  },
175
- "api": {
176
- "style": "[REST/GraphQL/etc if detected]",
177
- "specPath": "[path to imported/referenced spec]",
178
- "baseUrl": "[from OpenAPI if found]",
179
- "authentication": {
180
- "type": "[from OpenAPI if found]",
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
- "documentation": {
193
- "voice": "[based on docType]",
194
- "perspective": "second_person",
195
- "codeExamples": {
196
- "primaryLanguage": "[from Question 5]",
197
- "additionalLanguages": []
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
- "templates": {
200
- "guide": ".devdoc/templates/guide.md",
201
- "apiReference": ".devdoc/templates/api-reference.md",
202
- "tutorial": ".devdoc/templates/tutorial.md",
203
- "quickstart": ".devdoc/templates/quickstart.md",
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
- "learned": {
208
- "insights": [],
209
- "corrections": []
210
- }
211
- }
212
- ```
213
-
214
- Also copy template files to `.devdoc/templates/` if they don't exist.
215
-
216
- Tell user:
217
- "Created product context in `.devdoc/context.json`
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
- "tab": "Guides",
261
- "groups": [...]
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
- "tab": "API Reference",
265
- "type": "openapi",
266
- "spec": "api-reference/openapi.json"
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
- **For GraphQL:**
274
- ```json
275
- {
276
- "name": "Project Name",
277
- "docType": "api",
278
- "navigation": {
279
- "tabs": [
280
- {
281
- "tab": "Guides",
282
- "groups": [...]
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
- **For Both:**
296
+ ### Step 5: Create Context File
297
+
298
+ Save to `.devdoc/context.json`:
296
299
  ```json
297
300
  {
298
- "navigation": {
299
- "tabs": [
300
- { "tab": "Guides", "groups": [...] },
301
- { "tab": "REST API", "type": "openapi", "spec": "api-reference/openapi.json" },
302
- { "tab": "GraphQL API", "type": "graphql", "schema": "api-reference/schema.graphql" }
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: "Configured API Reference with {spec_type} from {path}"
309
-
310
- ### Step 5: Generate Documentation
334
+ **Tell user:**
335
+ ```
336
+ Context saved!
311
337
 
312
- **Read context from `.devdoc/context.json` before generating.**
338
+ - Doc Type: API Documentation
339
+ - API: REST (45 endpoints)
340
+ - Audience: Backend developers
341
+ - Code examples: TypeScript
313
342
 
314
- **Read the appropriate template** from `.devdoc/templates/` for each page type:
315
- - For guides: read `.devdoc/templates/guide.md`
316
- - For API reference: read `.devdoc/templates/api-reference.md`
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
- **Apply context throughout:**
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
- ## docType: "internal"
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 internal team documentation, create:
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
- ├── .devdoc/
337
- │ ├── context.json
338
- │ └── templates/
339
- ├── docs.json
340
- ├── index.mdx # Project overview
383
+ ├── index.mdx
341
384
  ├── getting-started/
342
- │ ├── setup.mdx # Dev environment setup
343
- ├── prerequisites.mdx # Required tools/versions
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
- │ ├── workflow.mdx # Git workflow, PR process
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
- **Content focus:**
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
- ## docType: "api"
394
+ **Use the code graph to write accurate docs:**
371
395
 
372
- For external developers using your API/SDK, create:
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
- docs/
376
- ├── .devdoc/
377
- │ ├── context.json
378
- │ └── templates/
379
- ├── docs.json
380
- ├── index.mdx # Product intro, value prop
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
- ## docs.json Templates (with docType)
421
+ ### Step 8: Update docs.json
455
422
 
456
- ### Internal Docs
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
- ### Customer API Docs (with OpenAPI)
425
+ **API Docs with OpenAPI:**
478
426
  ```json
479
427
  {
480
- "name": "{Product 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
- ### Customer API Docs (with GraphQL)
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
- ### Product Docs
527
- ```json
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
- ## Quality Guidelines
498
+ ## Code Graph Usage
548
499
 
549
- - Extract real code examples from source, don't fabricate
550
- - Match tone to audience based on docType
551
- - Add TODO markers for sections needing human review
552
- - Include relevant screenshots for product docs
553
- - Test all code examples work
554
- - Always use terminology from context.json
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