claude-code-autoconfig 1.0.8 → 1.0.10
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/.claude/commands/autoconfig.md +83 -58
- package/bin/cli.js +49 -155
- package/package.json +1 -1
|
@@ -65,7 +65,86 @@ If CLAUDE.md mentions MCP servers or tool integrations:
|
|
|
65
65
|
2. Add to `.claude/.mcp.json` in the mcpServers object
|
|
66
66
|
3. Notify: "Migrated MCP config to .claude/.mcp.json"
|
|
67
67
|
|
|
68
|
-
## Step 1:
|
|
68
|
+
## Step 1: Create Scaffold Files
|
|
69
|
+
|
|
70
|
+
Create these files if they don't already exist:
|
|
71
|
+
|
|
72
|
+
### .claude/settings.json
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"permissions": {
|
|
76
|
+
"allow": [
|
|
77
|
+
"Read(./**)",
|
|
78
|
+
"Edit(./**)",
|
|
79
|
+
"Write(./**)",
|
|
80
|
+
"WebSearch",
|
|
81
|
+
"WebFetch",
|
|
82
|
+
"Bash(npm run dev)",
|
|
83
|
+
"Bash(npm run build)",
|
|
84
|
+
"Bash(npm run lint)",
|
|
85
|
+
"Bash(npm run lint:fix)",
|
|
86
|
+
"Bash(npm run typecheck)",
|
|
87
|
+
"Bash(npm run test)",
|
|
88
|
+
"Bash(npm run test:*)",
|
|
89
|
+
"Bash(npm run validate)",
|
|
90
|
+
"Bash(git status)",
|
|
91
|
+
"Bash(git diff:*)",
|
|
92
|
+
"Bash(git add:*)",
|
|
93
|
+
"Bash(git commit:*)",
|
|
94
|
+
"Bash(git push:*)",
|
|
95
|
+
"Bash(git pull)",
|
|
96
|
+
"Bash(git checkout:*)",
|
|
97
|
+
"Bash(git branch:*)"
|
|
98
|
+
],
|
|
99
|
+
"deny": [
|
|
100
|
+
"Read(./.env)",
|
|
101
|
+
"Read(./.env.*)",
|
|
102
|
+
"Read(./secrets/**)",
|
|
103
|
+
"Read(./**/credentials.*)",
|
|
104
|
+
"Read(./**/*.pem)",
|
|
105
|
+
"Read(./**/*.key)",
|
|
106
|
+
"Bash(rm -rf:*)",
|
|
107
|
+
"Bash(curl:*)",
|
|
108
|
+
"Bash(wget:*)"
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### .claude/.mcp.json
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"mcpServers": {}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### .claude/feedback/FEEDBACK.md
|
|
122
|
+
```markdown
|
|
123
|
+
<!-- @description Team-maintained corrections and guidance for Claude. Add notes here when Claude does something wrong — it learns for next time. This directory persists across /autoconfig runs. -->
|
|
124
|
+
|
|
125
|
+
# Team Feedback
|
|
126
|
+
|
|
127
|
+
Add corrections and guidance here when Claude does something wrong.
|
|
128
|
+
Claude reads this directory and learns for next time.
|
|
129
|
+
|
|
130
|
+
## YYYY-MM-DD: Brief title
|
|
131
|
+
|
|
132
|
+
Describe what Claude did wrong and what to do instead.
|
|
133
|
+
Keep entries brief and actionable.
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### .claude/rules/ (empty directory)
|
|
137
|
+
Create the directory if it doesn't exist.
|
|
138
|
+
|
|
139
|
+
### CLAUDE.md (template)
|
|
140
|
+
If no CLAUDE.md exists, create it with this template:
|
|
141
|
+
```markdown
|
|
142
|
+
# Project Name
|
|
143
|
+
|
|
144
|
+
> Run `/autoconfig` to populate this based on your project.
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Step 2: Detect Environment
|
|
69
148
|
|
|
70
149
|
**Operating System:**
|
|
71
150
|
Check the platform and note it for command syntax:
|
|
@@ -74,7 +153,7 @@ Check the platform and note it for command syntax:
|
|
|
74
153
|
|
|
75
154
|
Include this in CLAUDE.md so all commands use the correct syntax.
|
|
76
155
|
|
|
77
|
-
## Step
|
|
156
|
+
## Step 3: Scan the Project
|
|
78
157
|
|
|
79
158
|
Look for these indicators to understand the project:
|
|
80
159
|
|
|
@@ -117,7 +196,7 @@ Look for these indicators to understand the project:
|
|
|
117
196
|
- `.github/workflows/` → GitHub Actions
|
|
118
197
|
- `serverless.yml` → Serverless Framework
|
|
119
198
|
|
|
120
|
-
## Step
|
|
199
|
+
## Step 4: Populate CLAUDE.md
|
|
121
200
|
|
|
122
201
|
Focus on what Claude Code actually needs to work effectively. Claude can explore the codebase itself — don't document what it can discover.
|
|
123
202
|
|
|
@@ -158,60 +237,6 @@ See `.claude/feedback/` for corrections and guidance from the team.
|
|
|
158
237
|
|
|
159
238
|
This pointer persists across autoconfig runs and directs Claude to team-maintained content.
|
|
160
239
|
|
|
161
|
-
## Step 4: Create Rules Directory
|
|
162
|
-
|
|
163
|
-
Create an empty `.claude/rules/` directory. Do not create any subdirectories or rule files.
|
|
164
|
-
|
|
165
|
-
Rules are path-scoped context files that load automatically when Claude works on matching files. Effective rules require deep understanding of your codebase patterns, team conventions, and quality goals — they should be crafted intentionally, not auto-generated.
|
|
166
|
-
|
|
167
|
-
## Step 5: Configure Settings
|
|
168
|
-
|
|
169
|
-
Update `.claude/settings.json` using the official schema.
|
|
170
|
-
|
|
171
|
-
### Deny Patterns (files Claude shouldn't read/write)
|
|
172
|
-
|
|
173
|
-
Use `Read()` for blocking reads, `Edit()` for blocking writes:
|
|
174
|
-
|
|
175
|
-
**Always deny (security):**
|
|
176
|
-
```
|
|
177
|
-
Read(./.env)
|
|
178
|
-
Read(./.env.*)
|
|
179
|
-
Read(./secrets/**)
|
|
180
|
-
Edit(./.env)
|
|
181
|
-
Edit(./.env.*)
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
**Often deny (generated/vendor):**
|
|
185
|
-
```
|
|
186
|
-
Edit(./node_modules/**)
|
|
187
|
-
Edit(./dist/**)
|
|
188
|
-
Edit(./.git/**)
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### Allow Patterns (auto-approve without prompting)
|
|
192
|
-
|
|
193
|
-
Use `Bash()` patterns with prefix matching:
|
|
194
|
-
|
|
195
|
-
```
|
|
196
|
-
Bash(npm run test:*)
|
|
197
|
-
Bash(npm run lint:*)
|
|
198
|
-
Bash(npm run build)
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
### Environment Variables
|
|
202
|
-
|
|
203
|
-
Set session-level env vars:
|
|
204
|
-
|
|
205
|
-
```json
|
|
206
|
-
{
|
|
207
|
-
"env": {
|
|
208
|
-
"NODE_ENV": "development"
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
**Keep it minimal** — only include patterns that actually exist in this project.
|
|
214
|
-
|
|
215
240
|
## Guidelines
|
|
216
241
|
|
|
217
242
|
- Replace ALL placeholder content with real values from THIS project
|
|
@@ -219,7 +244,7 @@ Set session-level env vars:
|
|
|
219
244
|
- Optimize for Claude's efficiency, not human documentation
|
|
220
245
|
- When uncertain, leave it out — Claude can ask or explore
|
|
221
246
|
|
|
222
|
-
## Step
|
|
247
|
+
## Step 5: Update the Guide
|
|
223
248
|
|
|
224
249
|
After populating CLAUDE.md, update the guide's file preview to show the actual content:
|
|
225
250
|
|
package/bin/cli.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
|
+
const readline = require('readline');
|
|
5
6
|
const { execSync, spawn } = require('child_process');
|
|
6
7
|
|
|
7
8
|
const cwd = process.cwd();
|
|
@@ -17,33 +18,9 @@ function isReservedName(name) {
|
|
|
17
18
|
return WINDOWS_RESERVED.includes(baseName);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
// Clean up any accidentally created reserved files
|
|
21
|
-
function cleanupReservedFiles(dir) {
|
|
22
|
-
if (!fs.existsSync(dir)) return;
|
|
23
|
-
try {
|
|
24
|
-
const entries = fs.readdirSync(dir);
|
|
25
|
-
for (const entry of entries) {
|
|
26
|
-
if (isReservedName(entry)) {
|
|
27
|
-
const filePath = path.join(dir, entry);
|
|
28
|
-
try {
|
|
29
|
-
fs.unlinkSync(filePath);
|
|
30
|
-
console.log('\x1b[33m%s\x1b[0m', `⚠️ Removed invalid file: ${entry}`);
|
|
31
|
-
} catch (e) {
|
|
32
|
-
// May fail on Windows - that's ok
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
} catch (e) {
|
|
37
|
-
// Ignore errors
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
21
|
console.log('\x1b[36m%s\x1b[0m', '🚀 Claude Code Autoconfig');
|
|
42
22
|
console.log();
|
|
43
23
|
|
|
44
|
-
// Clean up any reserved files from previous installs
|
|
45
|
-
cleanupReservedFiles(cwd);
|
|
46
|
-
|
|
47
24
|
// Step 1: Check if Claude Code is installed
|
|
48
25
|
function isClaudeInstalled() {
|
|
49
26
|
try {
|
|
@@ -77,116 +54,17 @@ if (!isClaudeInstalled()) {
|
|
|
77
54
|
|
|
78
55
|
console.log('\x1b[32m%s\x1b[0m', '✅ Claude Code detected');
|
|
79
56
|
|
|
80
|
-
// Step 2:
|
|
57
|
+
// Step 2: Copy minimal bootstrap (commands/ and guide/ only)
|
|
81
58
|
const claudeDest = path.join(cwd, '.claude');
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
function copyDirForBackup(src, dest) {
|
|
86
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
87
|
-
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
88
|
-
|
|
89
|
-
for (const entry of entries) {
|
|
90
|
-
if (SKIP_FILES.includes(entry.name)) continue;
|
|
91
|
-
if (isReservedName(entry.name)) continue;
|
|
92
|
-
|
|
93
|
-
const srcPath = path.join(src, entry.name);
|
|
94
|
-
const destPath = path.join(dest, entry.name);
|
|
95
|
-
|
|
96
|
-
if (entry.isDirectory()) {
|
|
97
|
-
copyDirForBackup(srcPath, destPath);
|
|
98
|
-
} else {
|
|
99
|
-
fs.copyFileSync(srcPath, destPath);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (fs.existsSync(claudeDest)) {
|
|
105
|
-
// Create timestamped backup
|
|
106
|
-
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
107
|
-
const migrationDir = path.join(claudeDest, 'migration');
|
|
108
|
-
migrationPath = path.join(migrationDir, timestamp);
|
|
109
|
-
|
|
110
|
-
fs.mkdirSync(migrationPath, { recursive: true });
|
|
111
|
-
|
|
112
|
-
// Copy existing files to backup (excluding migration folder itself)
|
|
113
|
-
const entries = fs.readdirSync(claudeDest, { withFileTypes: true });
|
|
114
|
-
for (const entry of entries) {
|
|
115
|
-
if (entry.name === 'migration') continue;
|
|
116
|
-
|
|
117
|
-
const srcPath = path.join(claudeDest, entry.name);
|
|
118
|
-
const destPath = path.join(migrationPath, entry.name);
|
|
119
|
-
|
|
120
|
-
if (entry.isDirectory()) {
|
|
121
|
-
copyDirForBackup(srcPath, destPath);
|
|
122
|
-
} else {
|
|
123
|
-
fs.copyFileSync(srcPath, destPath);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// Write migration metadata for the guide to read
|
|
128
|
-
const latestPath = path.join(migrationDir, 'latest.json');
|
|
129
|
-
const backedUpFiles = [];
|
|
130
|
-
|
|
131
|
-
function collectFiles(dir, prefix = '') {
|
|
132
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
133
|
-
for (const entry of entries) {
|
|
134
|
-
const relPath = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
135
|
-
if (entry.isDirectory()) {
|
|
136
|
-
collectFiles(path.join(dir, entry.name), relPath);
|
|
137
|
-
} else {
|
|
138
|
-
backedUpFiles.push(relPath);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
collectFiles(migrationPath);
|
|
143
|
-
|
|
144
|
-
fs.writeFileSync(latestPath, JSON.stringify({
|
|
145
|
-
timestamp: timestamp,
|
|
146
|
-
backedUpFiles: backedUpFiles
|
|
147
|
-
}, null, 2));
|
|
148
|
-
|
|
149
|
-
// Create/update migration README
|
|
150
|
-
const readmePath = path.join(migrationDir, 'README.md');
|
|
151
|
-
const readmeContent = `# Migration Backups
|
|
152
|
-
|
|
153
|
-
This folder contains backups of previous .claude/ configurations created during autoconfig upgrades.
|
|
154
|
-
|
|
155
|
-
Each timestamped folder contains the files that existed before that migration.
|
|
156
|
-
|
|
157
|
-
## Backups
|
|
158
|
-
|
|
159
|
-
- \`${timestamp}/\` - Backup created during autoconfig install
|
|
160
|
-
|
|
161
|
-
## Restoring
|
|
162
|
-
|
|
163
|
-
To restore a previous configuration, copy files from the backup folder back to \`.claude/\`.
|
|
164
|
-
`;
|
|
165
|
-
|
|
166
|
-
// Append to existing README or create new
|
|
167
|
-
if (fs.existsSync(readmePath)) {
|
|
168
|
-
const existing = fs.readFileSync(readmePath, 'utf8');
|
|
169
|
-
const newEntry = `- \`${timestamp}/\` - Backup created during autoconfig install\n`;
|
|
170
|
-
if (!existing.includes(timestamp)) {
|
|
171
|
-
const updated = existing.replace('## Backups\n\n', `## Backups\n\n${newEntry}`);
|
|
172
|
-
fs.writeFileSync(readmePath, updated);
|
|
173
|
-
}
|
|
174
|
-
} else {
|
|
175
|
-
fs.writeFileSync(readmePath, readmeContent);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
console.log('\x1b[33m%s\x1b[0m', `⚠️ Existing .claude/ backed up to migration/${timestamp}/`);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// Step 3: Copy new files
|
|
182
|
-
const claudeSrc = path.join(packageDir, '.claude');
|
|
59
|
+
const commandsSrc = path.join(packageDir, '.claude', 'commands');
|
|
60
|
+
const guideSrc = path.join(packageDir, '.claude', 'guide');
|
|
61
|
+
const agentsSrc = path.join(packageDir, '.claude', 'agents');
|
|
183
62
|
|
|
184
63
|
function copyDir(src, dest) {
|
|
185
64
|
fs.mkdirSync(dest, { recursive: true });
|
|
186
65
|
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
187
66
|
|
|
188
67
|
for (const entry of entries) {
|
|
189
|
-
if (SKIP_FILES.includes(entry.name)) continue;
|
|
190
68
|
if (isReservedName(entry.name)) continue;
|
|
191
69
|
|
|
192
70
|
const srcPath = path.join(src, entry.name);
|
|
@@ -200,44 +78,60 @@ function copyDir(src, dest) {
|
|
|
200
78
|
}
|
|
201
79
|
}
|
|
202
80
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
81
|
+
// Copy commands (required for /autoconfig to work)
|
|
82
|
+
if (fs.existsSync(commandsSrc)) {
|
|
83
|
+
copyDir(commandsSrc, path.join(claudeDest, 'commands'));
|
|
206
84
|
} else {
|
|
207
|
-
console.log('\x1b[31m%s\x1b[0m', '❌ Error:
|
|
85
|
+
console.log('\x1b[31m%s\x1b[0m', '❌ Error: commands directory not found');
|
|
208
86
|
process.exit(1);
|
|
209
87
|
}
|
|
210
88
|
|
|
211
|
-
// Copy
|
|
212
|
-
|
|
213
|
-
|
|
89
|
+
// Copy guide (too large to generate)
|
|
90
|
+
if (fs.existsSync(guideSrc)) {
|
|
91
|
+
copyDir(guideSrc, path.join(claudeDest, 'guide'));
|
|
92
|
+
}
|
|
214
93
|
|
|
215
|
-
if
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
fs.copyFileSync(claudeMdDest, path.join(migrationPath, 'CLAUDE.md'));
|
|
219
|
-
}
|
|
220
|
-
console.log('\x1b[33m%s\x1b[0m', '⚠️ CLAUDE.md exists, saved template as CLAUDE.md.template');
|
|
221
|
-
fs.copyFileSync(claudeMdSrc, path.join(cwd, 'CLAUDE.md.template'));
|
|
222
|
-
} else if (fs.existsSync(claudeMdSrc)) {
|
|
223
|
-
fs.copyFileSync(claudeMdSrc, claudeMdDest);
|
|
224
|
-
console.log('\x1b[32m%s\x1b[0m', '✅ Created CLAUDE.md');
|
|
94
|
+
// Copy agents if exists
|
|
95
|
+
if (fs.existsSync(agentsSrc)) {
|
|
96
|
+
copyDir(agentsSrc, path.join(claudeDest, 'agents'));
|
|
225
97
|
}
|
|
226
98
|
|
|
227
|
-
|
|
99
|
+
console.log('\x1b[32m%s\x1b[0m', '✅ Prepared /autoconfig command');
|
|
100
|
+
|
|
101
|
+
// Step 3: Show "ONE MORE STEP" message
|
|
228
102
|
console.log();
|
|
229
|
-
console.log('\x1b[
|
|
230
|
-
console.log('\x1b[33m
|
|
103
|
+
console.log('\x1b[33m╔══════════════════════════════════════════╗\x1b[0m');
|
|
104
|
+
console.log('\x1b[33m║ ║\x1b[0m');
|
|
105
|
+
console.log('\x1b[33m║\x1b[0m \x1b[1;33mONE MORE STEP\x1b[0m \x1b[33m║\x1b[0m');
|
|
106
|
+
console.log('\x1b[33m║ ║\x1b[0m');
|
|
107
|
+
console.log('\x1b[33m║\x1b[0m Run \x1b[36m/autoconfig\x1b[0m in Claude Code \x1b[33m║\x1b[0m');
|
|
108
|
+
console.log('\x1b[33m║\x1b[0m to complete setup \x1b[33m║\x1b[0m');
|
|
109
|
+
console.log('\x1b[33m║ ║\x1b[0m');
|
|
110
|
+
console.log('\x1b[33m╚══════════════════════════════════════════╝\x1b[0m');
|
|
231
111
|
console.log();
|
|
232
112
|
|
|
233
|
-
//
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
shell: true
|
|
113
|
+
// Step 4: Wait for Enter, then launch Claude Code
|
|
114
|
+
const rl = readline.createInterface({
|
|
115
|
+
input: process.stdin,
|
|
116
|
+
output: process.stdout
|
|
238
117
|
});
|
|
239
118
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
119
|
+
rl.question('\x1b[90mPress ENTER to open Claude Code...\x1b[0m', () => {
|
|
120
|
+
rl.close();
|
|
121
|
+
|
|
122
|
+
console.log();
|
|
123
|
+
console.log('\x1b[36m%s\x1b[0m', '🚀 Launching Claude Code...');
|
|
124
|
+
console.log();
|
|
125
|
+
|
|
126
|
+
// Spawn claude in the current directory
|
|
127
|
+
const claude = spawn('claude', [], {
|
|
128
|
+
cwd: cwd,
|
|
129
|
+
stdio: 'inherit',
|
|
130
|
+
shell: true
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
claude.on('error', (err) => {
|
|
134
|
+
console.log('\x1b[31m%s\x1b[0m', '❌ Failed to launch Claude Code');
|
|
135
|
+
console.log(' Run "claude" manually, then run /autoconfig');
|
|
136
|
+
});
|
|
243
137
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-code-autoconfig",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "Intelligent, self-configuring setup for Claude Code. One command analyzes your project, configures Claude, and shows you what it did.",
|
|
5
5
|
"author": "ADAC 1001 <info@adac1001.com>",
|
|
6
6
|
"license": "MIT",
|