create-claude-context 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +146 -146
  3. package/bin/create-claude-context.js +61 -61
  4. package/lib/detector.js +373 -373
  5. package/lib/index.js +170 -170
  6. package/lib/installer.js +371 -362
  7. package/lib/placeholder.js +208 -208
  8. package/lib/prompts.js +287 -287
  9. package/lib/spinner.js +60 -60
  10. package/lib/validate.js +147 -147
  11. package/package.json +59 -59
  12. package/templates/CLAUDE.md.template +235 -235
  13. package/templates/base/README.md +257 -257
  14. package/templates/base/RPI_WORKFLOW_PLAN.md +320 -320
  15. package/templates/base/agents/api-developer.md +76 -76
  16. package/templates/base/agents/context-engineer.md +525 -525
  17. package/templates/base/agents/core-architect.md +76 -76
  18. package/templates/base/agents/database-ops.md +76 -76
  19. package/templates/base/agents/deployment-ops.md +76 -76
  20. package/templates/base/agents/integration-hub.md +76 -76
  21. package/templates/base/analytics/README.md +114 -114
  22. package/templates/base/automation/config.json +58 -0
  23. package/templates/base/automation/generators/code-mapper.js +308 -0
  24. package/templates/base/automation/generators/index-builder.js +321 -0
  25. package/templates/base/automation/hooks/post-commit.sh +83 -0
  26. package/templates/base/automation/hooks/pre-commit.sh +103 -0
  27. package/templates/base/ci-templates/README.md +108 -108
  28. package/templates/base/ci-templates/github-actions/context-check.yml +144 -144
  29. package/templates/base/ci-templates/github-actions/validate-docs.yml +105 -105
  30. package/templates/base/commands/analytics.md +238 -238
  31. package/templates/base/commands/auto-sync.md +172 -0
  32. package/templates/base/commands/collab.md +194 -194
  33. package/templates/base/commands/help.md +450 -450
  34. package/templates/base/commands/rpi-implement.md +115 -115
  35. package/templates/base/commands/rpi-plan.md +93 -93
  36. package/templates/base/commands/rpi-research.md +88 -88
  37. package/templates/base/commands/session-resume.md +144 -0
  38. package/templates/base/commands/session-save.md +112 -0
  39. package/templates/base/commands/validate-all.md +77 -77
  40. package/templates/base/commands/verify-docs-current.md +86 -86
  41. package/templates/base/config/base.json +57 -57
  42. package/templates/base/config/environments/development.json +13 -13
  43. package/templates/base/config/environments/production.json +17 -17
  44. package/templates/base/config/environments/staging.json +13 -13
  45. package/templates/base/config/local.json.example +21 -21
  46. package/templates/base/context/.meta/generated-at.json +18 -0
  47. package/templates/base/context/ARCHITECTURE_SNAPSHOT.md +156 -156
  48. package/templates/base/context/CODE_TO_WORKFLOW_MAP.md +94 -94
  49. package/templates/base/context/FILE_OWNERSHIP.md +57 -0
  50. package/templates/base/context/INTEGRATION_POINTS.md +92 -0
  51. package/templates/base/context/KNOWN_GOTCHAS.md +195 -195
  52. package/templates/base/context/TESTING_MAP.md +95 -0
  53. package/templates/base/context/WORKFLOW_INDEX.md +129 -129
  54. package/templates/base/context/workflows/WORKFLOW_TEMPLATE.md +294 -294
  55. package/templates/base/indexes/agents/CAPABILITY_MATRIX.md +255 -255
  56. package/templates/base/indexes/agents/CATEGORY_INDEX.md +44 -44
  57. package/templates/base/indexes/code/CATEGORY_INDEX.md +38 -38
  58. package/templates/base/indexes/routing/CATEGORY_INDEX.md +39 -39
  59. package/templates/base/indexes/search/CATEGORY_INDEX.md +39 -39
  60. package/templates/base/indexes/workflows/CATEGORY_INDEX.md +38 -38
  61. package/templates/base/knowledge/README.md +98 -98
  62. package/templates/base/knowledge/sessions/README.md +88 -88
  63. package/templates/base/knowledge/sessions/TEMPLATE.md +150 -150
  64. package/templates/base/knowledge/shared/decisions/0001-adopt-context-engineering.md +144 -144
  65. package/templates/base/knowledge/shared/decisions/README.md +49 -49
  66. package/templates/base/knowledge/shared/decisions/TEMPLATE.md +123 -123
  67. package/templates/base/knowledge/shared/patterns/README.md +62 -62
  68. package/templates/base/knowledge/shared/patterns/TEMPLATE.md +120 -120
  69. package/templates/base/plans/PLAN_TEMPLATE.md +250 -250
  70. package/templates/base/research/RESEARCH_TEMPLATE.md +153 -153
  71. package/templates/base/schemas/agent.schema.json +141 -141
  72. package/templates/base/schemas/anchors.schema.json +54 -0
  73. package/templates/base/schemas/automation.schema.json +93 -0
  74. package/templates/base/schemas/command.schema.json +134 -134
  75. package/templates/base/schemas/hashes.schema.json +40 -0
  76. package/templates/base/schemas/manifest.schema.json +117 -117
  77. package/templates/base/schemas/plan.schema.json +136 -136
  78. package/templates/base/schemas/research.schema.json +115 -115
  79. package/templates/base/schemas/roles.schema.json +34 -0
  80. package/templates/base/schemas/session.schema.json +77 -0
  81. package/templates/base/schemas/settings.schema.json +244 -244
  82. package/templates/base/schemas/staleness.schema.json +53 -0
  83. package/templates/base/schemas/team-config.schema.json +42 -0
  84. package/templates/base/schemas/workflow.schema.json +126 -126
  85. package/templates/base/session/checkpoints/.gitkeep +2 -0
  86. package/templates/base/session/current/state.json +20 -0
  87. package/templates/base/session/history/.gitkeep +2 -0
  88. package/templates/base/settings.json +79 -57
  89. package/templates/base/standards/COMPATIBILITY.md +219 -219
  90. package/templates/base/standards/EXTENSION_GUIDELINES.md +280 -280
  91. package/templates/base/standards/QUALITY_CHECKLIST.md +211 -211
  92. package/templates/base/standards/README.md +66 -66
  93. package/templates/base/sync/anchors.json +6 -0
  94. package/templates/base/sync/hashes.json +6 -0
  95. package/templates/base/sync/staleness.json +10 -0
  96. package/templates/base/team/README.md +168 -168
  97. package/templates/base/team/config.json +79 -79
  98. package/templates/base/team/roles.json +145 -145
  99. package/templates/base/tools/bin/claude-context.js +151 -151
  100. package/templates/base/tools/lib/anchor-resolver.js +276 -0
  101. package/templates/base/tools/lib/config-loader.js +363 -363
  102. package/templates/base/tools/lib/detector.js +350 -350
  103. package/templates/base/tools/lib/diagnose.js +206 -206
  104. package/templates/base/tools/lib/drift-detector.js +373 -0
  105. package/templates/base/tools/lib/errors.js +199 -199
  106. package/templates/base/tools/lib/index.js +36 -24
  107. package/templates/base/tools/lib/init.js +192 -192
  108. package/templates/base/tools/lib/logger.js +230 -230
  109. package/templates/base/tools/lib/placeholder.js +201 -201
  110. package/templates/base/tools/lib/session-manager.js +354 -0
  111. package/templates/base/tools/lib/validate.js +521 -521
  112. package/templates/base/tools/package.json +49 -49
package/lib/installer.js CHANGED
@@ -1,362 +1,371 @@
1
- /**
2
- * Claude Context Engineering - File Installer
3
- *
4
- * Handles copying template files and creating directory structure.
5
- */
6
-
7
- const fs = require('fs');
8
- const path = require('path');
9
-
10
- /**
11
- * Directory structure for .claude/
12
- */
13
- const DIRECTORY_STRUCTURE = [
14
- 'agents',
15
- 'commands',
16
- 'config',
17
- 'config/environments',
18
- 'context',
19
- 'context/workflows',
20
- 'indexes',
21
- 'indexes/agents',
22
- 'indexes/code',
23
- 'indexes/routing',
24
- 'indexes/search',
25
- 'indexes/workflows',
26
- 'knowledge',
27
- 'knowledge/sessions',
28
- 'knowledge/shared',
29
- 'knowledge/shared/decisions',
30
- 'knowledge/shared/patterns',
31
- 'plans',
32
- 'plans/active',
33
- 'plans/completed',
34
- 'research',
35
- 'research/active',
36
- 'research/completed',
37
- 'schemas',
38
- 'standards',
39
- 'team',
40
- 'ci-templates',
41
- 'ci-templates/github-actions',
42
- 'tools',
43
- 'tools/bin',
44
- 'tools/lib',
45
- ];
46
-
47
- /**
48
- * Create the .claude directory structure
49
- */
50
- async function createDirectoryStructure(targetDir, config = {}) {
51
- const claudeDir = path.join(targetDir, '.claude');
52
-
53
- // Create main .claude directory
54
- if (!fs.existsSync(claudeDir)) {
55
- fs.mkdirSync(claudeDir, { recursive: true });
56
- }
57
-
58
- let dirsCreated = 0;
59
-
60
- // Filter directories based on features
61
- let dirsToCreate = [...DIRECTORY_STRUCTURE];
62
-
63
- if (!config.features?.ci) {
64
- dirsToCreate = dirsToCreate.filter(d => !d.startsWith('ci-templates'));
65
- }
66
- if (!config.features?.team) {
67
- dirsToCreate = dirsToCreate.filter(d => !d.startsWith('team') && !d.includes('knowledge'));
68
- }
69
- if (!config.features?.analytics) {
70
- dirsToCreate = dirsToCreate.filter(d => !d.startsWith('analytics'));
71
- }
72
-
73
- // Create each directory
74
- for (const dir of dirsToCreate) {
75
- const fullPath = path.join(claudeDir, dir);
76
- if (!fs.existsSync(fullPath)) {
77
- fs.mkdirSync(fullPath, { recursive: true });
78
- dirsCreated++;
79
- }
80
- }
81
-
82
- return dirsCreated;
83
- }
84
-
85
- /**
86
- * Copy template files from the bundled templates
87
- */
88
- async function copyTemplates(targetDir, config = {}) {
89
- const claudeDir = path.join(targetDir, '.claude');
90
- const templatesDir = path.join(__dirname, '..', 'templates', 'base');
91
-
92
- let filesCopied = 0;
93
-
94
- // Check if templates exist
95
- if (!fs.existsSync(templatesDir)) {
96
- // If no bundled templates, create minimal files
97
- filesCopied = await createMinimalFiles(claudeDir, config);
98
- return filesCopied;
99
- }
100
-
101
- // Copy all files from templates
102
- filesCopied = await copyDirectory(templatesDir, claudeDir);
103
-
104
- return filesCopied;
105
- }
106
-
107
- /**
108
- * Recursively copy a directory
109
- */
110
- async function copyDirectory(src, dest) {
111
- let count = 0;
112
-
113
- if (!fs.existsSync(src)) {
114
- return count;
115
- }
116
-
117
- const entries = fs.readdirSync(src, { withFileTypes: true });
118
-
119
- for (const entry of entries) {
120
- const srcPath = path.join(src, entry.name);
121
- const destPath = path.join(dest, entry.name);
122
-
123
- if (entry.isDirectory()) {
124
- if (!fs.existsSync(destPath)) {
125
- fs.mkdirSync(destPath, { recursive: true });
126
- }
127
- count += await copyDirectory(srcPath, destPath);
128
- } else {
129
- // Copy file
130
- fs.copyFileSync(srcPath, destPath);
131
- count++;
132
- }
133
- }
134
-
135
- return count;
136
- }
137
-
138
- /**
139
- * Create minimal files when no templates are bundled
140
- */
141
- async function createMinimalFiles(claudeDir, config = {}) {
142
- let count = 0;
143
-
144
- // README.md
145
- const readmeContent = `# .claude Configuration - ${config.projectName || 'Project'}
146
-
147
- This directory contains the Claude Context Engineering system.
148
-
149
- ## Quick Start
150
-
151
- 1. Load workflow index: Read \`.claude/context/WORKFLOW_INDEX.md\`
152
- 2. Use RPI workflow: /rpi-research → /rpi-plan → /rpi-implement
153
- 3. Validate changes: /verify-docs-current
154
-
155
- ## Configuration
156
-
157
- - **Agents**: ${config.features?.agents ? '6 specialized agents' : 'disabled'}
158
- - **Commands**: ${config.features?.rpi ? 'RPI workflow + validation' : 'basic'}
159
- - **Context Budget**: 200k tokens max, target <40%
160
-
161
- *Generated by create-claude-context*
162
- `;
163
- fs.writeFileSync(path.join(claudeDir, 'README.md'), readmeContent);
164
- count++;
165
-
166
- // settings.json
167
- const settingsContent = {
168
- '$schema': './schemas/settings.schema.json',
169
- version: '1.0.0',
170
- project: {
171
- name: config.projectName || 'my-project',
172
- status: 'development'
173
- },
174
- context: {
175
- maxTokens: 200000,
176
- targetUtilization: 0.4
177
- },
178
- validation: {
179
- lineAccuracyThreshold: 60,
180
- onCommit: true
181
- }
182
- };
183
- fs.writeFileSync(
184
- path.join(claudeDir, 'settings.json'),
185
- JSON.stringify(settingsContent, null, 2)
186
- );
187
- count++;
188
-
189
- // WORKFLOW_INDEX.md
190
- const workflowIndexContent = `# Workflow Index
191
-
192
- ## Primary Workflows
193
-
194
- | Workflow | Entry Point | Description |
195
- |----------|-------------|-------------|
196
- | *To be discovered* | - | Run @context-engineer to populate |
197
-
198
- ## Quick Reference
199
-
200
- - Use \`/rpi-research\` to discover workflows
201
- - Use \`@context-engineer\` for initial setup
202
-
203
- *Run @context-engineer "Discover workflows for this codebase" to populate this index.*
204
- `;
205
- fs.writeFileSync(
206
- path.join(claudeDir, 'context', 'WORKFLOW_INDEX.md'),
207
- workflowIndexContent
208
- );
209
- count++;
210
-
211
- // RPI_WORKFLOW_PLAN.md
212
- const rpiContent = `# RPI (Research, Plan, Implement) Workflow
213
-
214
- ## Phase 1: RESEARCH (/rpi-research)
215
- - Explore codebase using parallel agents
216
- - Output: Research document in \`.claude/research/active/\`
217
-
218
- ## Phase 2: PLAN (/rpi-plan)
219
- - Create implementation blueprint with file:line precision
220
- - Output: Plan document in \`.claude/plans/active/\`
221
-
222
- ## Phase 3: IMPLEMENT (/rpi-implement)
223
- - Execute with atomic changes
224
- - ONE CHANGE ONE TEST → ONE COMMIT
225
-
226
- ## Context Budget
227
- - Research: 25-30%
228
- - Plan: 20-25%
229
- - Implement: 30-40%
230
- `;
231
- fs.writeFileSync(path.join(claudeDir, 'RPI_WORKFLOW_PLAN.md'), rpiContent);
232
- count++;
233
-
234
- // Create placeholder files for research and plans
235
- const researchTemplate = `# Research Template
236
-
237
- Use this template for RPI Research phase.
238
-
239
- ## Objective
240
- [What you're researching]
241
-
242
- ## Files Explored
243
- | File | Lines | Findings |
244
- |------|-------|----------|
245
-
246
- ## Summary
247
- [150 words max]
248
- `;
249
- fs.writeFileSync(
250
- path.join(claudeDir, 'research', 'RESEARCH_TEMPLATE.md'),
251
- researchTemplate
252
- );
253
- count++;
254
-
255
- const planTemplate = `# Plan Template
256
-
257
- Use this template for RPI Plan phase.
258
-
259
- ## Research Summary
260
- [From Phase 1]
261
-
262
- ## Files to Modify
263
- | File | Lines | Change | Risk |
264
- |------|-------|--------|------|
265
-
266
- ## Steps
267
- 1. Step 1
268
- 2. Step 2
269
-
270
- ## Rollback Plan
271
- - Revert: \`git revert HEAD\`
272
- `;
273
- fs.writeFileSync(
274
- path.join(claudeDir, 'plans', 'PLAN_TEMPLATE.md'),
275
- planTemplate
276
- );
277
- count++;
278
-
279
- return count;
280
- }
281
-
282
- /**
283
- * Create CLAUDE.md at project root
284
- */
285
- async function createClaudeMd(targetDir, config = {}, techStack = {}) {
286
- const claudeMdPath = path.join(targetDir, 'CLAUDE.md');
287
-
288
- // Check for template
289
- const templatePath = path.join(__dirname, '..', 'templates', 'CLAUDE.md.template');
290
-
291
- let content;
292
-
293
- if (fs.existsSync(templatePath)) {
294
- content = fs.readFileSync(templatePath, 'utf8');
295
- } else {
296
- // Create minimal CLAUDE.md
297
- content = `# CLAUDE.md - ${config.projectName || 'Project'}
298
-
299
- This file provides guidance to Claude Code when working with this repository.
300
-
301
- ---
302
-
303
- ## Project Identity
304
-
305
- **Platform:** ${config.projectName || 'Project'} application
306
- **Tech Stack:** ${techStack.summary || techStack.stack || 'Not detected'}
307
- **Status:** Development
308
-
309
- ---
310
-
311
- ## Essential Commands
312
-
313
- ### Development
314
- \`\`\`bash
315
- ${techStack.commands?.install || 'npm install'}
316
- ${techStack.commands?.dev || 'npm run dev'}
317
- \`\`\`
318
-
319
- ### Testing
320
- \`\`\`bash
321
- ${techStack.commands?.test || 'npm test'}
322
- \`\`\`
323
-
324
- ---
325
-
326
- ## Navigation Rules
327
-
328
- ### High-Level Task
329
- 1. Start: [.claude/context/WORKFLOW_INDEX.md](./.claude/context/WORKFLOW_INDEX.md)
330
- 2. Load relevant workflow
331
- 3. Implement with context
332
-
333
- ### Feature Development
334
- 1. /rpi-research - Explore codebase
335
- 2. /rpi-plan - Create blueprint
336
- 3. /rpi-implement - Execute with tests
337
-
338
- ---
339
-
340
- ## Documentation System
341
-
342
- **Navigation:** 3-level chain (CLAUDE.md → Category → Domain → Detail)
343
- **Validation:** Run /verify-docs-current after modifications
344
- **RPI Workflow:** /rpi-research → /rpi-plan /rpi-implement
345
-
346
- See: [.claude/RPI_WORKFLOW_PLAN.md](./.claude/RPI_WORKFLOW_PLAN.md)
347
-
348
- ---
349
-
350
- *Generated by create-claude-context*
351
- `;
352
- }
353
-
354
- fs.writeFileSync(claudeMdPath, content);
355
- }
356
-
357
- module.exports = {
358
- createDirectoryStructure,
359
- copyTemplates,
360
- createClaudeMd,
361
- DIRECTORY_STRUCTURE,
362
- };
1
+ /**
2
+ * Claude Context Engineering - File Installer
3
+ *
4
+ * Handles copying template files and creating directory structure.
5
+ */
6
+
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+
10
+ /**
11
+ * Directory structure for .claude/
12
+ */
13
+ const DIRECTORY_STRUCTURE = [
14
+ 'agents',
15
+ 'automation',
16
+ 'automation/generators',
17
+ 'automation/hooks',
18
+ 'commands',
19
+ 'config',
20
+ 'config/environments',
21
+ 'context',
22
+ 'context/workflows',
23
+ 'context/.meta',
24
+ 'indexes',
25
+ 'indexes/agents',
26
+ 'indexes/code',
27
+ 'indexes/routing',
28
+ 'indexes/search',
29
+ 'indexes/workflows',
30
+ 'knowledge',
31
+ 'knowledge/sessions',
32
+ 'knowledge/shared',
33
+ 'knowledge/shared/decisions',
34
+ 'knowledge/shared/patterns',
35
+ 'plans',
36
+ 'plans/active',
37
+ 'plans/completed',
38
+ 'research',
39
+ 'research/active',
40
+ 'research/completed',
41
+ 'schemas',
42
+ 'session',
43
+ 'session/current',
44
+ 'session/history',
45
+ 'session/checkpoints',
46
+ 'standards',
47
+ 'sync',
48
+ 'team',
49
+ 'ci-templates',
50
+ 'ci-templates/github-actions',
51
+ 'tools',
52
+ 'tools/bin',
53
+ 'tools/lib',
54
+ ];
55
+
56
+ /**
57
+ * Create the .claude directory structure
58
+ */
59
+ async function createDirectoryStructure(targetDir, config = {}) {
60
+ const claudeDir = path.join(targetDir, '.claude');
61
+
62
+ // Create main .claude directory
63
+ if (!fs.existsSync(claudeDir)) {
64
+ fs.mkdirSync(claudeDir, { recursive: true });
65
+ }
66
+
67
+ let dirsCreated = 0;
68
+
69
+ // Filter directories based on features
70
+ let dirsToCreate = [...DIRECTORY_STRUCTURE];
71
+
72
+ if (!config.features?.ci) {
73
+ dirsToCreate = dirsToCreate.filter(d => !d.startsWith('ci-templates'));
74
+ }
75
+ if (!config.features?.team) {
76
+ dirsToCreate = dirsToCreate.filter(d => !d.startsWith('team') && !d.includes('knowledge'));
77
+ }
78
+ if (!config.features?.analytics) {
79
+ dirsToCreate = dirsToCreate.filter(d => !d.startsWith('analytics'));
80
+ }
81
+
82
+ // Create each directory
83
+ for (const dir of dirsToCreate) {
84
+ const fullPath = path.join(claudeDir, dir);
85
+ if (!fs.existsSync(fullPath)) {
86
+ fs.mkdirSync(fullPath, { recursive: true });
87
+ dirsCreated++;
88
+ }
89
+ }
90
+
91
+ return dirsCreated;
92
+ }
93
+
94
+ /**
95
+ * Copy template files from the bundled templates
96
+ */
97
+ async function copyTemplates(targetDir, config = {}) {
98
+ const claudeDir = path.join(targetDir, '.claude');
99
+ const templatesDir = path.join(__dirname, '..', 'templates', 'base');
100
+
101
+ let filesCopied = 0;
102
+
103
+ // Check if templates exist
104
+ if (!fs.existsSync(templatesDir)) {
105
+ // If no bundled templates, create minimal files
106
+ filesCopied = await createMinimalFiles(claudeDir, config);
107
+ return filesCopied;
108
+ }
109
+
110
+ // Copy all files from templates
111
+ filesCopied = await copyDirectory(templatesDir, claudeDir);
112
+
113
+ return filesCopied;
114
+ }
115
+
116
+ /**
117
+ * Recursively copy a directory
118
+ */
119
+ async function copyDirectory(src, dest) {
120
+ let count = 0;
121
+
122
+ if (!fs.existsSync(src)) {
123
+ return count;
124
+ }
125
+
126
+ const entries = fs.readdirSync(src, { withFileTypes: true });
127
+
128
+ for (const entry of entries) {
129
+ const srcPath = path.join(src, entry.name);
130
+ const destPath = path.join(dest, entry.name);
131
+
132
+ if (entry.isDirectory()) {
133
+ if (!fs.existsSync(destPath)) {
134
+ fs.mkdirSync(destPath, { recursive: true });
135
+ }
136
+ count += await copyDirectory(srcPath, destPath);
137
+ } else {
138
+ // Copy file
139
+ fs.copyFileSync(srcPath, destPath);
140
+ count++;
141
+ }
142
+ }
143
+
144
+ return count;
145
+ }
146
+
147
+ /**
148
+ * Create minimal files when no templates are bundled
149
+ */
150
+ async function createMinimalFiles(claudeDir, config = {}) {
151
+ let count = 0;
152
+
153
+ // README.md
154
+ const readmeContent = `# .claude Configuration - ${config.projectName || 'Project'}
155
+
156
+ This directory contains the Claude Context Engineering system.
157
+
158
+ ## Quick Start
159
+
160
+ 1. Load workflow index: Read \`.claude/context/WORKFLOW_INDEX.md\`
161
+ 2. Use RPI workflow: /rpi-research → /rpi-plan → /rpi-implement
162
+ 3. Validate changes: /verify-docs-current
163
+
164
+ ## Configuration
165
+
166
+ - **Agents**: ${config.features?.agents ? '6 specialized agents' : 'disabled'}
167
+ - **Commands**: ${config.features?.rpi ? 'RPI workflow + validation' : 'basic'}
168
+ - **Context Budget**: 200k tokens max, target <40%
169
+
170
+ *Generated by create-claude-context*
171
+ `;
172
+ fs.writeFileSync(path.join(claudeDir, 'README.md'), readmeContent);
173
+ count++;
174
+
175
+ // settings.json
176
+ const settingsContent = {
177
+ '$schema': './schemas/settings.schema.json',
178
+ version: '1.0.0',
179
+ project: {
180
+ name: config.projectName || 'my-project',
181
+ status: 'development'
182
+ },
183
+ context: {
184
+ maxTokens: 200000,
185
+ targetUtilization: 0.4
186
+ },
187
+ validation: {
188
+ lineAccuracyThreshold: 60,
189
+ onCommit: true
190
+ }
191
+ };
192
+ fs.writeFileSync(
193
+ path.join(claudeDir, 'settings.json'),
194
+ JSON.stringify(settingsContent, null, 2)
195
+ );
196
+ count++;
197
+
198
+ // WORKFLOW_INDEX.md
199
+ const workflowIndexContent = `# Workflow Index
200
+
201
+ ## Primary Workflows
202
+
203
+ | Workflow | Entry Point | Description |
204
+ |----------|-------------|-------------|
205
+ | *To be discovered* | - | Run @context-engineer to populate |
206
+
207
+ ## Quick Reference
208
+
209
+ - Use \`/rpi-research\` to discover workflows
210
+ - Use \`@context-engineer\` for initial setup
211
+
212
+ *Run @context-engineer "Discover workflows for this codebase" to populate this index.*
213
+ `;
214
+ fs.writeFileSync(
215
+ path.join(claudeDir, 'context', 'WORKFLOW_INDEX.md'),
216
+ workflowIndexContent
217
+ );
218
+ count++;
219
+
220
+ // RPI_WORKFLOW_PLAN.md
221
+ const rpiContent = `# RPI (Research, Plan, Implement) Workflow
222
+
223
+ ## Phase 1: RESEARCH (/rpi-research)
224
+ - Explore codebase using parallel agents
225
+ - Output: Research document in \`.claude/research/active/\`
226
+
227
+ ## Phase 2: PLAN (/rpi-plan)
228
+ - Create implementation blueprint with file:line precision
229
+ - Output: Plan document in \`.claude/plans/active/\`
230
+
231
+ ## Phase 3: IMPLEMENT (/rpi-implement)
232
+ - Execute with atomic changes
233
+ - ONE CHANGE → ONE TEST → ONE COMMIT
234
+
235
+ ## Context Budget
236
+ - Research: 25-30%
237
+ - Plan: 20-25%
238
+ - Implement: 30-40%
239
+ `;
240
+ fs.writeFileSync(path.join(claudeDir, 'RPI_WORKFLOW_PLAN.md'), rpiContent);
241
+ count++;
242
+
243
+ // Create placeholder files for research and plans
244
+ const researchTemplate = `# Research Template
245
+
246
+ Use this template for RPI Research phase.
247
+
248
+ ## Objective
249
+ [What you're researching]
250
+
251
+ ## Files Explored
252
+ | File | Lines | Findings |
253
+ |------|-------|----------|
254
+
255
+ ## Summary
256
+ [150 words max]
257
+ `;
258
+ fs.writeFileSync(
259
+ path.join(claudeDir, 'research', 'RESEARCH_TEMPLATE.md'),
260
+ researchTemplate
261
+ );
262
+ count++;
263
+
264
+ const planTemplate = `# Plan Template
265
+
266
+ Use this template for RPI Plan phase.
267
+
268
+ ## Research Summary
269
+ [From Phase 1]
270
+
271
+ ## Files to Modify
272
+ | File | Lines | Change | Risk |
273
+ |------|-------|--------|------|
274
+
275
+ ## Steps
276
+ 1. Step 1
277
+ 2. Step 2
278
+
279
+ ## Rollback Plan
280
+ - Revert: \`git revert HEAD\`
281
+ `;
282
+ fs.writeFileSync(
283
+ path.join(claudeDir, 'plans', 'PLAN_TEMPLATE.md'),
284
+ planTemplate
285
+ );
286
+ count++;
287
+
288
+ return count;
289
+ }
290
+
291
+ /**
292
+ * Create CLAUDE.md at project root
293
+ */
294
+ async function createClaudeMd(targetDir, config = {}, techStack = {}) {
295
+ const claudeMdPath = path.join(targetDir, 'CLAUDE.md');
296
+
297
+ // Check for template
298
+ const templatePath = path.join(__dirname, '..', 'templates', 'CLAUDE.md.template');
299
+
300
+ let content;
301
+
302
+ if (fs.existsSync(templatePath)) {
303
+ content = fs.readFileSync(templatePath, 'utf8');
304
+ } else {
305
+ // Create minimal CLAUDE.md
306
+ content = `# CLAUDE.md - ${config.projectName || 'Project'}
307
+
308
+ This file provides guidance to Claude Code when working with this repository.
309
+
310
+ ---
311
+
312
+ ## Project Identity
313
+
314
+ **Platform:** ${config.projectName || 'Project'} application
315
+ **Tech Stack:** ${techStack.summary || techStack.stack || 'Not detected'}
316
+ **Status:** Development
317
+
318
+ ---
319
+
320
+ ## Essential Commands
321
+
322
+ ### Development
323
+ \`\`\`bash
324
+ ${techStack.commands?.install || 'npm install'}
325
+ ${techStack.commands?.dev || 'npm run dev'}
326
+ \`\`\`
327
+
328
+ ### Testing
329
+ \`\`\`bash
330
+ ${techStack.commands?.test || 'npm test'}
331
+ \`\`\`
332
+
333
+ ---
334
+
335
+ ## Navigation Rules
336
+
337
+ ### High-Level Task
338
+ 1. Start: [.claude/context/WORKFLOW_INDEX.md](./.claude/context/WORKFLOW_INDEX.md)
339
+ 2. Load relevant workflow
340
+ 3. Implement with context
341
+
342
+ ### Feature Development
343
+ 1. /rpi-research - Explore codebase
344
+ 2. /rpi-plan - Create blueprint
345
+ 3. /rpi-implement - Execute with tests
346
+
347
+ ---
348
+
349
+ ## Documentation System
350
+
351
+ **Navigation:** 3-level chain (CLAUDE.md → Category → Domain → Detail)
352
+ **Validation:** Run /verify-docs-current after modifications
353
+ **RPI Workflow:** /rpi-research → /rpi-plan → /rpi-implement
354
+
355
+ See: [.claude/RPI_WORKFLOW_PLAN.md](./.claude/RPI_WORKFLOW_PLAN.md)
356
+
357
+ ---
358
+
359
+ *Generated by create-claude-context*
360
+ `;
361
+ }
362
+
363
+ fs.writeFileSync(claudeMdPath, content);
364
+ }
365
+
366
+ module.exports = {
367
+ createDirectoryStructure,
368
+ copyTemplates,
369
+ createClaudeMd,
370
+ DIRECTORY_STRUCTURE,
371
+ };