create-claude-context 1.0.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/LICENSE +21 -0
- package/README.md +146 -0
- package/bin/create-claude-context.js +61 -0
- package/lib/detector.js +373 -0
- package/lib/index.js +170 -0
- package/lib/installer.js +362 -0
- package/lib/placeholder.js +208 -0
- package/lib/prompts.js +287 -0
- package/lib/spinner.js +60 -0
- package/lib/validate.js +147 -0
- package/package.json +59 -0
- package/templates/CLAUDE.md.template +235 -0
- package/templates/base/README.md +257 -0
- package/templates/base/RPI_WORKFLOW_PLAN.md +320 -0
- package/templates/base/agents/api-developer.md +76 -0
- package/templates/base/agents/context-engineer.md +525 -0
- package/templates/base/agents/core-architect.md +76 -0
- package/templates/base/agents/database-ops.md +76 -0
- package/templates/base/agents/deployment-ops.md +76 -0
- package/templates/base/agents/integration-hub.md +76 -0
- package/templates/base/analytics/README.md +114 -0
- package/templates/base/ci-templates/README.md +108 -0
- package/templates/base/ci-templates/github-actions/context-check.yml +144 -0
- package/templates/base/ci-templates/github-actions/validate-docs.yml +105 -0
- package/templates/base/commands/analytics.md +238 -0
- package/templates/base/commands/collab.md +194 -0
- package/templates/base/commands/help.md +450 -0
- package/templates/base/commands/rpi-implement.md +115 -0
- package/templates/base/commands/rpi-plan.md +93 -0
- package/templates/base/commands/rpi-research.md +88 -0
- package/templates/base/commands/validate-all.md +77 -0
- package/templates/base/commands/verify-docs-current.md +86 -0
- package/templates/base/config/base.json +57 -0
- package/templates/base/config/environments/development.json +13 -0
- package/templates/base/config/environments/production.json +17 -0
- package/templates/base/config/environments/staging.json +13 -0
- package/templates/base/config/local.json.example +21 -0
- package/templates/base/context/ARCHITECTURE_SNAPSHOT.md +156 -0
- package/templates/base/context/CODE_TO_WORKFLOW_MAP.md +94 -0
- package/templates/base/context/KNOWN_GOTCHAS.md +195 -0
- package/templates/base/context/WORKFLOW_INDEX.md +129 -0
- package/templates/base/context/workflows/WORKFLOW_TEMPLATE.md +294 -0
- package/templates/base/indexes/agents/CAPABILITY_MATRIX.md +255 -0
- package/templates/base/indexes/agents/CATEGORY_INDEX.md +44 -0
- package/templates/base/indexes/code/CATEGORY_INDEX.md +38 -0
- package/templates/base/indexes/routing/CATEGORY_INDEX.md +39 -0
- package/templates/base/indexes/search/CATEGORY_INDEX.md +39 -0
- package/templates/base/indexes/workflows/CATEGORY_INDEX.md +38 -0
- package/templates/base/knowledge/README.md +98 -0
- package/templates/base/knowledge/sessions/README.md +88 -0
- package/templates/base/knowledge/sessions/TEMPLATE.md +150 -0
- package/templates/base/knowledge/shared/decisions/0001-adopt-context-engineering.md +144 -0
- package/templates/base/knowledge/shared/decisions/README.md +49 -0
- package/templates/base/knowledge/shared/decisions/TEMPLATE.md +123 -0
- package/templates/base/knowledge/shared/patterns/README.md +62 -0
- package/templates/base/knowledge/shared/patterns/TEMPLATE.md +120 -0
- package/templates/base/plans/PLAN_TEMPLATE.md +250 -0
- package/templates/base/plans/active/.gitkeep +0 -0
- package/templates/base/plans/completed/.gitkeep +0 -0
- package/templates/base/research/RESEARCH_TEMPLATE.md +153 -0
- package/templates/base/research/active/.gitkeep +0 -0
- package/templates/base/research/completed/.gitkeep +0 -0
- package/templates/base/schemas/agent.schema.json +141 -0
- package/templates/base/schemas/command.schema.json +134 -0
- package/templates/base/schemas/manifest.schema.json +117 -0
- package/templates/base/schemas/plan.schema.json +136 -0
- package/templates/base/schemas/research.schema.json +115 -0
- package/templates/base/schemas/settings.schema.json +244 -0
- package/templates/base/schemas/workflow.schema.json +126 -0
- package/templates/base/settings.json +57 -0
- package/templates/base/standards/COMPATIBILITY.md +219 -0
- package/templates/base/standards/EXTENSION_GUIDELINES.md +280 -0
- package/templates/base/standards/QUALITY_CHECKLIST.md +211 -0
- package/templates/base/standards/README.md +66 -0
- package/templates/base/team/README.md +168 -0
- package/templates/base/team/config.json +79 -0
- package/templates/base/team/roles.json +145 -0
- package/templates/base/tools/bin/claude-context.js +151 -0
- package/templates/base/tools/lib/config-loader.js +363 -0
- package/templates/base/tools/lib/detector.js +350 -0
- package/templates/base/tools/lib/diagnose.js +206 -0
- package/templates/base/tools/lib/errors.js +199 -0
- package/templates/base/tools/lib/index.js +24 -0
- package/templates/base/tools/lib/init.js +192 -0
- package/templates/base/tools/lib/logger.js +230 -0
- package/templates/base/tools/lib/placeholder.js +201 -0
- package/templates/base/tools/lib/validate.js +521 -0
- package/templates/base/tools/package.json +49 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main orchestrator for create-claude-context
|
|
3
|
+
*
|
|
4
|
+
* Handles the full installation flow:
|
|
5
|
+
* 1. Interactive prompts (or defaults)
|
|
6
|
+
* 2. Directory structure creation
|
|
7
|
+
* 3. Template copying
|
|
8
|
+
* 4. Tech stack detection
|
|
9
|
+
* 5. Placeholder replacement
|
|
10
|
+
* 6. Validation
|
|
11
|
+
* 7. Plugin installation (optional)
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const path = require('path');
|
|
15
|
+
const fs = require('fs');
|
|
16
|
+
const chalk = require('chalk');
|
|
17
|
+
const { runPrompts, getDefaults } = require('./prompts');
|
|
18
|
+
const { createSpinner } = require('./spinner');
|
|
19
|
+
const {
|
|
20
|
+
createDirectoryStructure,
|
|
21
|
+
copyTemplates,
|
|
22
|
+
createClaudeMd
|
|
23
|
+
} = require('./installer');
|
|
24
|
+
const { detectTechStack } = require('./detector');
|
|
25
|
+
const { replacePlaceholders } = require('./placeholder');
|
|
26
|
+
const { validateInstallation } = require('./validate');
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Main entry point
|
|
30
|
+
*/
|
|
31
|
+
async function run(options = {}) {
|
|
32
|
+
const {
|
|
33
|
+
projectName,
|
|
34
|
+
skipPrompts = false,
|
|
35
|
+
installPlugin = true,
|
|
36
|
+
template,
|
|
37
|
+
initGit = true,
|
|
38
|
+
dryRun = false,
|
|
39
|
+
verbose = false
|
|
40
|
+
} = options;
|
|
41
|
+
|
|
42
|
+
// Determine target directory
|
|
43
|
+
const targetDir = projectName
|
|
44
|
+
? path.resolve(process.cwd(), projectName)
|
|
45
|
+
: process.cwd();
|
|
46
|
+
|
|
47
|
+
const projectNameResolved = projectName || path.basename(targetDir);
|
|
48
|
+
|
|
49
|
+
// Get configuration (prompts or defaults)
|
|
50
|
+
let config;
|
|
51
|
+
if (skipPrompts) {
|
|
52
|
+
config = await getDefaults(targetDir, template);
|
|
53
|
+
} else {
|
|
54
|
+
config = await runPrompts(targetDir, template);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
config.projectName = projectNameResolved;
|
|
58
|
+
config.targetDir = targetDir;
|
|
59
|
+
config.installPlugin = installPlugin && config.installPlugin;
|
|
60
|
+
config.initGit = initGit;
|
|
61
|
+
config.dryRun = dryRun;
|
|
62
|
+
config.verbose = verbose;
|
|
63
|
+
|
|
64
|
+
if (dryRun) {
|
|
65
|
+
console.log(chalk.yellow('\n--dry-run mode: No changes will be made\n'));
|
|
66
|
+
console.log('Configuration:', JSON.stringify(config, null, 2));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Phase 1: Create target directory if needed
|
|
71
|
+
const spinner = createSpinner();
|
|
72
|
+
|
|
73
|
+
if (projectName && !fs.existsSync(targetDir)) {
|
|
74
|
+
spinner.start('Creating project directory...');
|
|
75
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
76
|
+
spinner.succeed(`Created project directory: ${projectNameResolved}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Phase 2: Create .claude directory structure
|
|
80
|
+
spinner.start('Creating .claude directory structure...');
|
|
81
|
+
const dirsCreated = await createDirectoryStructure(targetDir, config);
|
|
82
|
+
spinner.succeed(`Created .claude directory structure (${dirsCreated} directories)`);
|
|
83
|
+
|
|
84
|
+
// Phase 3: Copy template files
|
|
85
|
+
spinner.start('Copying template files...');
|
|
86
|
+
const filesCopied = await copyTemplates(targetDir, config);
|
|
87
|
+
spinner.succeed(`Copied ${filesCopied} template files`);
|
|
88
|
+
|
|
89
|
+
// Phase 4: Detect technology stack
|
|
90
|
+
spinner.start('Detecting technology stack...');
|
|
91
|
+
const techStack = await detectTechStack(targetDir);
|
|
92
|
+
spinner.succeed(`Detected: ${techStack.summary || 'Generic project'}`);
|
|
93
|
+
|
|
94
|
+
// Phase 5: Replace placeholders
|
|
95
|
+
spinner.start('Populating templates with project info...');
|
|
96
|
+
const placeholdersReplaced = await replacePlaceholders(targetDir, {
|
|
97
|
+
...config,
|
|
98
|
+
techStack
|
|
99
|
+
});
|
|
100
|
+
spinner.succeed(`Replaced ${placeholdersReplaced} placeholders`);
|
|
101
|
+
|
|
102
|
+
// Phase 6: Create CLAUDE.md at root
|
|
103
|
+
spinner.start('Creating CLAUDE.md...');
|
|
104
|
+
await createClaudeMd(targetDir, config, techStack);
|
|
105
|
+
spinner.succeed('Created CLAUDE.md at project root');
|
|
106
|
+
|
|
107
|
+
// Phase 7: Validate installation
|
|
108
|
+
spinner.start('Validating installation...');
|
|
109
|
+
const validation = await validateInstallation(targetDir);
|
|
110
|
+
if (validation.passed) {
|
|
111
|
+
spinner.succeed('All validations passed');
|
|
112
|
+
} else {
|
|
113
|
+
spinner.warn(`Validation completed with ${validation.warnings} warnings`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Phase 8: Install Claude Code plugin (optional)
|
|
117
|
+
if (config.installPlugin) {
|
|
118
|
+
spinner.start('Installing Claude Code plugin...');
|
|
119
|
+
// Plugin installation would use: npx claude-plugins install claude-context-engineering
|
|
120
|
+
// For now, we'll note it as a next step
|
|
121
|
+
spinner.succeed('Plugin ready (install with: /plugin install claude-context-engineering)');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Phase 9: Initialize git (optional)
|
|
125
|
+
if (config.initGit && !fs.existsSync(path.join(targetDir, '.git'))) {
|
|
126
|
+
spinner.start('Initializing git repository...');
|
|
127
|
+
try {
|
|
128
|
+
const { execSync } = require('child_process');
|
|
129
|
+
execSync('git init', { cwd: targetDir, stdio: 'pipe' });
|
|
130
|
+
spinner.succeed('Initialized git repository');
|
|
131
|
+
} catch (e) {
|
|
132
|
+
spinner.warn('Could not initialize git (git may not be installed)');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Success message
|
|
137
|
+
showSuccess(config, techStack);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Display success message with next steps
|
|
142
|
+
*/
|
|
143
|
+
function showSuccess(config, techStack) {
|
|
144
|
+
const boxWidth = 59;
|
|
145
|
+
|
|
146
|
+
console.log(`
|
|
147
|
+
${chalk.green('╔' + '═'.repeat(boxWidth) + '╗')}
|
|
148
|
+
${chalk.green('║')} ${chalk.bold.white('✓ Context Engineering Initialized Successfully!')} ${chalk.green('║')}
|
|
149
|
+
${chalk.green('╚' + '═'.repeat(boxWidth) + '╝')}
|
|
150
|
+
|
|
151
|
+
${chalk.bold('Created:')}
|
|
152
|
+
${chalk.cyan('•')} .claude/ ${chalk.gray('(context engineering system)')}
|
|
153
|
+
${chalk.cyan('•')} CLAUDE.md ${chalk.gray('(AI navigation guide)')}
|
|
154
|
+
|
|
155
|
+
${chalk.bold('Available Commands:')}
|
|
156
|
+
${chalk.cyan('•')} /rpi-research ${chalk.gray('Research a feature')}
|
|
157
|
+
${chalk.cyan('•')} /rpi-plan ${chalk.gray('Create implementation plan')}
|
|
158
|
+
${chalk.cyan('•')} /rpi-implement ${chalk.gray('Execute with documentation')}
|
|
159
|
+
${chalk.cyan('•')} /validate-all ${chalk.gray('Run validation suite')}
|
|
160
|
+
|
|
161
|
+
${chalk.bold('Next Steps:')}
|
|
162
|
+
${chalk.white('1.')} Review ${chalk.cyan('CLAUDE.md')} and customize for your project
|
|
163
|
+
${chalk.white('2.')} Run: ${chalk.cyan('@context-engineer "Discover workflows for this codebase"')}
|
|
164
|
+
${chalk.white('3.')} Use ${chalk.cyan('/rpi-research')} for your first feature
|
|
165
|
+
|
|
166
|
+
${chalk.gray('Documentation: https://github.com/SireJeff/claude-context-engineering-template')}
|
|
167
|
+
`);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
module.exports = { run };
|
package/lib/installer.js
ADDED
|
@@ -0,0 +1,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
|
+
'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
|
+
};
|