claude-code-autoconfig 1.0.113 → 1.0.115

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,366 +1,367 @@
1
- <!-- @description The command you just ran. Analyzes your project and populates CLAUDE.md with real context. Re-run anytime your stack changes. -->
2
-
3
- # Autoconfig
4
-
5
- Analyze this project and configure Claude Code with real context.
6
-
7
- **Setup Note**: During autoconfig, prefer Glob/Read/Write tools over Bash commands. This ensures smooth setup without permission prompts. Only use Bash for opening the guide at the end.
8
-
9
- ## Step 1: Detect Environment
10
-
11
- **Operating System:**
12
- Check the platform and note it for command syntax:
13
- - Windows use `del`, `rmdir`, backslashes, `.cmd`/`.ps1` scripts
14
- - macOS/Linux → use `rm`, `mkdir -p`, forward slashes, `.sh` scripts
15
-
16
- Include this in CLAUDE.md so all commands use the correct syntax.
17
-
18
- ## Step 2: Scan the Project
19
-
20
- Look for these indicators to understand the project:
21
-
22
- **Package/Config Files:**
23
- - `package.json` → Node.js, npm scripts, dependencies
24
- - `requirements.txt` / `pyproject.toml` / `setup.py` → Python
25
- - `Cargo.toml` → Rust
26
- - `go.mod` → Go
27
- - `Gemfile` → Ruby
28
- - `pom.xml` / `build.gradle` Java
29
- - `*.csproj` / `*.sln` → .NET
30
- - `composer.json` → PHP
31
-
32
- **Framework Indicators:**
33
- - `next.config.*` / `app/` directory → Next.js
34
- - `vite.config.*` → Vite
35
- - `angular.json`Angular
36
- - `svelte.config.*`Svelte
37
- - `remix.config.*` → Remix
38
- - `nuxt.config.*` → Nuxt
39
- - `django` in imports Django
40
- - `flask` in imports → Flask
41
- - `fastapi` in imports → FastAPI
42
- - `express` in dependenciesExpress
43
- - `rails` / `Gemfile` with rails Rails
44
- - `laravel` → Laravel
45
-
46
- **Testing Frameworks:**
47
- - `jest.config.*` / `@jest` in deps → Jest
48
- - `vitest.config.*` → Vitest
49
- - `pytest.ini` / `conftest.py` Pytest
50
- - `*_test.go` filesGo testing
51
- - `*_spec.rb` files → RSpec
52
- - `cypress/` or `playwright/` E2E testing
53
-
54
- **Infrastructure:**
55
- - `Dockerfile` / `docker-compose.*` → Docker
56
- - `*.tf` filesTerraform
57
- - `k8s/` or `kubernetes/` Kubernetes
58
- - `.github/workflows/` → GitHub Actions
59
- - `serverless.yml`Serverless Framework
60
-
61
- ## Step 2b: Detect Version Divergence
62
-
63
- Scan for version declarations across the project. Multiple version sources that disagree can cause release failures (e.g., package.json says 1.0.74 but a hardcoded constant says 1.0.72).
64
-
65
- **Version Sources to Check:**
66
-
67
- | Source | Detection Method |
68
- |--------|------------------|
69
- | `package.json` | Parse JSON, read `version` field |
70
- | `**/*.{ts,js,mjs}` | Regex: `/(?:export\s+)?(?:const\|let\|var)\s+((?:BASE_\|APP_\|LIB_)?VERSION)\s*=\s*['"](\d+\.\d+\.\d+)['"]/i` |
71
- | `**/manifest.json` | Parse JSON, read `version` field |
72
- | `**/manifest.config.{ts,js}` | Regex: `/version:\s*['"](\d+\.\d+\.\d+)['"]/` |
73
- | `**/Info.plist` | Regex: `/<key>CFBundleShortVersionString<\/key>\s*<string>(\d+\.\d+\.\d+)<\/string>/` |
74
- | `**/build.gradle` | Regex: `/versionName\s+['"](\d+\.\d+\.\d+)['"]/` |
75
- | `pyproject.toml` | Parse TOML, read `project.version` or `tool.poetry.version` |
76
- | `Cargo.toml` | Parse TOML, read `package.version` |
77
-
78
- **Algorithm:**
79
-
80
- 1. Glob for each file pattern
81
- 2. Extract version using the appropriate method (JSON parse, regex, TOML parse)
82
- 3. Collect results as `{ file, identifier, version }`
83
- 4. Compare all collected versions
84
- 5. **If all versions match** → no action needed
85
- 6. **If versions diverge** → flag for CLAUDE.md
86
-
87
- **Skip these locations** (generated/vendored):
88
- - `node_modules/**`
89
- - `dist/**`
90
- - `build/**`
91
- - `.git/**`
92
-
93
- **Edge Cases:**
94
- - If version field references a function or variable (not a literal), note it as "dynamic"
95
- - For monorepos, compare root package.json against workspace packages
96
- - If only one version source exists, no comparison needed skip silently
97
-
98
- ## Step 3: Populate CLAUDE.md
99
-
100
- Focus on what Claude Code actually needs to work effectively. Claude can explore the codebase itself — don't document what it can discover.
101
-
102
- **Wrap content in markers** so `/sync-claude-md` knows what's auto-generated:
103
-
104
- ```markdown
105
- <!-- AUTO-GENERATED BY /autoconfig at {TIMESTAMP} UTC — Do not edit. Use .claude/feedback/ for corrections. -->
106
-
107
- # Project Name
108
- ...content...
109
-
110
- <!-- END AUTO-GENERATED at {TIMESTAMP} UTC — Use .claude/feedback/ for corrections. -->
111
- ```
112
-
113
- Replace `{TIMESTAMP}` with the current UTC time in format `YYYY-MM-DD HH:MM:SS` (e.g., `2026-01-14 16:30:45`). Use the same timestamp in both markers.
114
-
115
- **Always include:**
116
- - **Project name + one-liner**: What is this thing?
117
- - **Tech stack**: One to two lines max. Only mention choices Claude wouldn't guess from config files alone (e.g., "Firebase Auth via WEB_OAUTH" is worth including; "React 18 with TypeScript" is not — Claude sees that in `package.json`). Do NOT list individual dependencies, testing libraries, or build tools that appear in `package.json`/`requirements.txt` — Claude reads those files directly.
118
- - **Commands**: How to run, test, build, deploy — Claude needs these to execute tasks
119
- - **Non-obvious conventions**: Multi-schema databases, monorepo structure, unusual patterns Claude wouldn't infer
120
-
121
- **Include if divergence detected (from Step 2b):**
122
- - **Version Management**: Only add this section if version divergence was found
123
-
124
- ```markdown
125
- ## Version Management
126
-
127
- ⚠️ Multiple version sources detected with different values:
128
- - `package.json:version` "X.Y.Z"
129
- - `{file}:{identifier}` → "A.B.C"
130
-
131
- Verify which source is authoritative before releases.
132
- ```
133
-
134
- Place this section near the top (after Tech Stack, before Commands) since version issues block releases.
135
-
136
- **Include if relevant:**
137
- - **Deployment flow**: If non-standard or involves multiple steps
138
- - **Key architectural decisions**: Only when the project has non-standard module boundaries (e.g., Chrome extension background/content split, microservice routing, multi-entrypoint builds). For standard single-entrypoint apps (Next.js, Express, Django), skip it — Claude can infer the architecture from the file structure.
139
-
140
- **Skip these — Claude can discover them:**
141
- - Detailed project structure trees (Claude can run `ls` or `tree`)
142
- - Exhaustive route/endpoint lists (Claude can grep)
143
- - File-by-file descriptions (Claude can read files)
144
- - Database model lists (Claude can read schema files)
145
- - Individual dependency names or versions (Claude reads `package.json`/`requirements.txt` directly)
146
- - Standard framework patterns (e.g., "uses app router" for Next.js — Claude sees `app/` directory)
147
-
148
- **Keep it tight.** A 30-line CLAUDE.md that hits the essentials beats a 200-line doc Claude has to parse every session.
149
-
150
- **Always end with:**
151
- ```markdown
152
- ## Team Feedback
153
- See `.claude/feedback/` for corrections and guidance from the team.
154
- ```
155
-
156
- This pointer persists across autoconfig runs and directs Claude to team-maintained content.
157
-
158
- ## Step 4: Create Rules Directory
159
-
160
- Create `.claude/rules/` directory if it doesn't exist by writing a `.gitkeep` file to it:
161
-
162
- ```
163
- Write .claude/rules/.gitkeep with empty content
164
- ```
165
-
166
- **Important**: Use Write tool to create the directory (by creating a placeholder file), not `mkdir` Bash commands. This avoids permission prompts during setup.
167
-
168
- 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.
169
-
170
- ## Step 5: Configure Formatter (JS/Node Projects)
171
-
172
- **Only for projects with `package.json`:**
173
-
174
- 1. Check if `scripts.format` already exists in `package.json`
175
-
176
- 2. **If `scripts.format` exists:**
177
- - Skip to adding the hook (Step 5b)
178
-
179
- 3. **If `scripts.format` does NOT exist:**
180
- - Ask the user:
181
- ```
182
- No formatter detected. Adding one ensures Claude's output
183
- matches your project's style.
184
-
185
- Should I add Prettier to this project? (y/n)
186
- ```
187
-
188
- 4. **If user says yes:**
189
- - Run: `npm install -D prettier`
190
- - Add to `package.json` scripts:
191
- ```json
192
- "format": "[ -f .prettierrc ] && prettier --write . || echo 'Create .prettierrc to enable formatting'"
193
- ```
194
- - Create `.prettierrc.example` in project root:
195
- ```json
196
- {
197
- "semi": true,
198
- "singleQuote": false,
199
- "tabWidth": 2
200
- }
201
- ```
202
- - Inform user: "Formatting is ready but inactive. Rename `.prettierrc.example` to `.prettierrc` when your team decides on style preferences."
203
-
204
- 5. **If user says no:**
205
- - Skip formatter setup, continue to Step 6
206
-
207
- **Step 5b: Add PostToolUse Format Hook**
208
-
209
- If the project has `scripts.format` (either existing or just added), add the format hook to `.claude/settings.json`:
210
-
211
- ```json
212
- {
213
- "hooks": {
214
- "PostToolUse": [
215
- {
216
- "matcher": "Write|Edit",
217
- "hooks": [
218
- { "type": "command", "command": "node .claude/hooks/format.js" }
219
- ]
220
- }
221
- ]
222
- }
223
- }
224
- ```
225
-
226
- The format hook script (`.claude/hooks/format.js`) runs `npm run format` after Write/Edit operations on source files. Users can customize this script to add file filtering or different formatting logic.
227
-
228
- **Important:** Merge this with any existing hooks. Don't overwrite existing hooks.
229
-
230
- ## Step 6: Configure Settings
231
-
232
- Update `.claude/settings.json` using the official schema.
233
-
234
- ### Deny Patterns (files Claude shouldn't read/write)
235
-
236
- Use `Read()` for blocking reads, `Edit()` for blocking writes:
237
-
238
- **Always deny (security):**
239
- ```
240
- Read(./.env)
241
- Read(./.env.*)
242
- Read(./secrets/**)
243
- Edit(./.env)
244
- Edit(./.env.*)
245
- ```
246
-
247
- **Always deny (Windows artifacts):**
248
- ```
249
- Write(./nul)
250
- Edit(./nul)
251
- ```
252
- These prevent accidental `nul` file creation from bash/Windows command translation issues.
253
-
254
- **Often deny (generated/vendor):**
255
- ```
256
- Edit(./node_modules/**)
257
- Edit(./dist/**)
258
- Edit(./.git/**)
259
- ```
260
-
261
- ### Allow Patterns (auto-approve without prompting)
262
-
263
- Use `Bash()` patterns with prefix matching:
264
-
265
- ```
266
- Bash(npm run test:*)
267
- Bash(npm run lint:*)
268
- Bash(npm run build)
269
- ```
270
-
271
- ### Environment Variables
272
-
273
- Set session-level env vars:
274
-
275
- ```json
276
- {
277
- "env": {
278
- "NODE_ENV": "development"
279
- }
280
- }
281
- ```
282
-
283
- **Keep it minimal** — only include patterns that actually exist in this project.
284
-
285
- ## Guidelines
286
-
287
- - Replace ALL placeholder content with real values from THIS project
288
- - Delete sections that don't apply no empty stubs
289
- - Optimize for Claude's efficiency, not human documentation
290
- - When uncertain, leave it out — Claude can ask or explore
291
-
292
- ## Step 7: Configure MEMORY.md
293
-
294
- Claude Code has a persistent auto memory file (`MEMORY.md`) that loads into the system prompt at the start of every session. Write the debugging methodology to this file so Claude always follows evidence-based troubleshooting.
295
-
296
- **Locate the MEMORY.md file:**
297
-
298
- The file lives at `~/.claude/projects/{encoded-project-path}/memory/MEMORY.md` where the project path is encoded by replacing path separators with dashes and removing colons (e.g., `C:\CODE\my-project` becomes `C--CODE-my-project`).
299
-
300
- **Before writing, read MEMORY.md first.** If a `## Debugging` section (or similar heading like `## Debugging — Evidence Before Solutions`) already exists, **skip this step entirely** — never duplicate or overwrite user-curated memory content.
301
-
302
- **Only if no debugging section exists**, write this content (append if file already exists, create if it doesn't):
303
-
304
- ```markdown
305
- ## Debugging — Evidence Before Solutions
306
- NEVER guess the root cause and jump to coding a fix. Ask yourself: is the cause deterministic and verifiable from the error alone (e.g., stack trace, compile error)? If yes, fix it directly. If not:
307
- 1. Add logging / check actual data first
308
- 2. Confirm root cause with evidence
309
- 3. Only then propose and implement a fix
310
- ```
311
-
312
- **Important**: Use the Write tool (or Edit to append). Do not skip this step on first-time setup — it ensures Claude investigates root causes before making changes in every future session. But never overwrite existing user content in MEMORY.md.
313
-
314
- ## Step 8: Update the Docs
315
-
316
- After populating CLAUDE.md, update the docs file previews to show actual project content:
317
-
318
- 1. Open `.claude/docs/autoconfig.docs.html`
319
- 2. Find the `fileContents` JavaScript object
320
- 3. Update these entries with the real content just generated:
321
- - `'claude-md'` the CLAUDE.md content from Step 3
322
- - `'memory-md'` → the MEMORY.md content from Step 7
323
- - `'settings'` → the settings.json content from Step 6
324
- 4. Use template literal syntax and escape any backticks in the content
325
-
326
- This ensures double-clicking these files in the docs shows real project content, not stale placeholders.
327
-
328
- ## After Completion
329
-
330
- ### Open Docs & Finale
331
-
332
- **Only if `.claude/docs/autoconfig.docs.html` exists**, open it in the user's browser:
333
-
334
- - macOS: `open .claude/docs/autoconfig.docs.html`
335
- - Linux: `xdg-open .claude/docs/autoconfig.docs.html`
336
- - Windows: `powershell -NoProfile -Command "Start-Process '.claude/docs/autoconfig.docs.html'"`
337
-
338
- If the docs file exists, output:
339
-
340
- ---
341
-
342
- ✅ Setup complete! The interactive docs are now open in your browser.
343
-
344
- ---
345
-
346
- If the docs file does NOT exist (e.g., user ran `/autoconfig` without the full npx install), output:
347
-
348
- ---
349
-
350
- ✅ Setup complete!
351
-
352
- Run `/show-docs` to view the interactive documentation (requires full install via `npx claude-code-autoconfig`).
353
-
354
- ---
355
-
356
- **IMPORTANT**: Do not add any additional text, summaries, or details after this message. The finale should be clean and punchy - end here.
357
-
358
- ### Windows Cleanup
359
-
360
- On Windows, if a `nul` file was accidentally created in the project root (a common artifact from bash/Unix command translation), delete it silently using the Bash tool:
361
-
362
- ```bash
363
- del nul 2>NUL
364
- ```
365
-
1
+ <!-- @description The command you just ran. Analyzes your project and populates CLAUDE.md with real context. Re-run anytime your stack changes. -->
2
+ <!-- @version 1 -->
3
+
4
+ # Autoconfig
5
+
6
+ Analyze this project and configure Claude Code with real context.
7
+
8
+ **Setup Note**: During autoconfig, prefer Glob/Read/Write tools over Bash commands. This ensures smooth setup without permission prompts. Only use Bash for opening the guide at the end.
9
+
10
+ ## Step 1: Detect Environment
11
+
12
+ **Operating System:**
13
+ Check the platform and note it for command syntax:
14
+ - Windows → use `del`, `rmdir`, backslashes, `.cmd`/`.ps1` scripts
15
+ - macOS/Linux → use `rm`, `mkdir -p`, forward slashes, `.sh` scripts
16
+
17
+ Include this in CLAUDE.md so all commands use the correct syntax.
18
+
19
+ ## Step 2: Scan the Project
20
+
21
+ Look for these indicators to understand the project:
22
+
23
+ **Package/Config Files:**
24
+ - `package.json` Node.js, npm scripts, dependencies
25
+ - `requirements.txt` / `pyproject.toml` / `setup.py` Python
26
+ - `Cargo.toml` → Rust
27
+ - `go.mod` → Go
28
+ - `Gemfile` → Ruby
29
+ - `pom.xml` / `build.gradle`Java
30
+ - `*.csproj` / `*.sln` → .NET
31
+ - `composer.json` → PHP
32
+
33
+ **Framework Indicators:**
34
+ - `next.config.*` / `app/` directory Next.js
35
+ - `vite.config.*`Vite
36
+ - `angular.json`Angular
37
+ - `svelte.config.*` → Svelte
38
+ - `remix.config.*` → Remix
39
+ - `nuxt.config.*`Nuxt
40
+ - `django` in imports → Django
41
+ - `flask` in imports → Flask
42
+ - `fastapi` in importsFastAPI
43
+ - `express` in dependenciesExpress
44
+ - `rails` / `Gemfile` with rails Rails
45
+ - `laravel` → Laravel
46
+
47
+ **Testing Frameworks:**
48
+ - `jest.config.*` / `@jest` in deps Jest
49
+ - `vitest.config.*`Vitest
50
+ - `pytest.ini` / `conftest.py` Pytest
51
+ - `*_test.go` files → Go testing
52
+ - `*_spec.rb` filesRSpec
53
+ - `cypress/` or `playwright/` → E2E testing
54
+
55
+ **Infrastructure:**
56
+ - `Dockerfile` / `docker-compose.*` Docker
57
+ - `*.tf` filesTerraform
58
+ - `k8s/` or `kubernetes/` Kubernetes
59
+ - `.github/workflows/`GitHub Actions
60
+ - `serverless.yml` → Serverless Framework
61
+
62
+ ## Step 2b: Detect Version Divergence
63
+
64
+ Scan for version declarations across the project. Multiple version sources that disagree can cause release failures (e.g., package.json says 1.0.74 but a hardcoded constant says 1.0.72).
65
+
66
+ **Version Sources to Check:**
67
+
68
+ | Source | Detection Method |
69
+ |--------|------------------|
70
+ | `package.json` | Parse JSON, read `version` field |
71
+ | `**/*.{ts,js,mjs}` | Regex: `/(?:export\s+)?(?:const\|let\|var)\s+((?:BASE_\|APP_\|LIB_)?VERSION)\s*=\s*['"](\d+\.\d+\.\d+)['"]/i` |
72
+ | `**/manifest.json` | Parse JSON, read `version` field |
73
+ | `**/manifest.config.{ts,js}` | Regex: `/version:\s*['"](\d+\.\d+\.\d+)['"]/` |
74
+ | `**/Info.plist` | Regex: `/<key>CFBundleShortVersionString<\/key>\s*<string>(\d+\.\d+\.\d+)<\/string>/` |
75
+ | `**/build.gradle` | Regex: `/versionName\s+['"](\d+\.\d+\.\d+)['"]/` |
76
+ | `pyproject.toml` | Parse TOML, read `project.version` or `tool.poetry.version` |
77
+ | `Cargo.toml` | Parse TOML, read `package.version` |
78
+
79
+ **Algorithm:**
80
+
81
+ 1. Glob for each file pattern
82
+ 2. Extract version using the appropriate method (JSON parse, regex, TOML parse)
83
+ 3. Collect results as `{ file, identifier, version }`
84
+ 4. Compare all collected versions
85
+ 5. **If all versions match** → no action needed
86
+ 6. **If versions diverge** → flag for CLAUDE.md
87
+
88
+ **Skip these locations** (generated/vendored):
89
+ - `node_modules/**`
90
+ - `dist/**`
91
+ - `build/**`
92
+ - `.git/**`
93
+
94
+ **Edge Cases:**
95
+ - If version field references a function or variable (not a literal), note it as "dynamic"
96
+ - For monorepos, compare root package.json against workspace packages
97
+ - If only one version source exists, no comparison needed — skip silently
98
+
99
+ ## Step 3: Populate CLAUDE.md
100
+
101
+ Focus on what Claude Code actually needs to work effectively. Claude can explore the codebase itself — don't document what it can discover.
102
+
103
+ **Wrap content in markers** so `/sync-claude-md` knows what's auto-generated:
104
+
105
+ ```markdown
106
+ <!-- AUTO-GENERATED BY /autoconfig at {TIMESTAMP} UTC — Do not edit. Use .claude/feedback/ for corrections. -->
107
+
108
+ # Project Name
109
+ ...content...
110
+
111
+ <!-- END AUTO-GENERATED at {TIMESTAMP} UTC — Use .claude/feedback/ for corrections. -->
112
+ ```
113
+
114
+ Replace `{TIMESTAMP}` with the current UTC time in format `YYYY-MM-DD HH:MM:SS` (e.g., `2026-01-14 16:30:45`). Use the same timestamp in both markers.
115
+
116
+ **Always include:**
117
+ - **Project name + one-liner**: What is this thing?
118
+ - **Tech stack**: One to two lines max. Only mention choices Claude wouldn't guess from config files alone (e.g., "Firebase Auth via WEB_OAUTH" is worth including; "React 18 with TypeScript" is not — Claude sees that in `package.json`). Do NOT list individual dependencies, testing libraries, or build tools that appear in `package.json`/`requirements.txt` — Claude reads those files directly.
119
+ - **Commands**: How to run, test, build, deploy Claude needs these to execute tasks
120
+ - **Non-obvious conventions**: Multi-schema databases, monorepo structure, unusual patterns Claude wouldn't infer
121
+
122
+ **Include if divergence detected (from Step 2b):**
123
+ - **Version Management**: Only add this section if version divergence was found
124
+
125
+ ```markdown
126
+ ## Version Management
127
+
128
+ ⚠️ Multiple version sources detected with different values:
129
+ - `package.json:version` → "X.Y.Z"
130
+ - `{file}:{identifier}` → "A.B.C"
131
+
132
+ Verify which source is authoritative before releases.
133
+ ```
134
+
135
+ Place this section near the top (after Tech Stack, before Commands) since version issues block releases.
136
+
137
+ **Include if relevant:**
138
+ - **Deployment flow**: If non-standard or involves multiple steps
139
+ - **Key architectural decisions**: Only when the project has non-standard module boundaries (e.g., Chrome extension background/content split, microservice routing, multi-entrypoint builds). For standard single-entrypoint apps (Next.js, Express, Django), skip it — Claude can infer the architecture from the file structure.
140
+
141
+ **Skip these Claude can discover them:**
142
+ - Detailed project structure trees (Claude can run `ls` or `tree`)
143
+ - Exhaustive route/endpoint lists (Claude can grep)
144
+ - File-by-file descriptions (Claude can read files)
145
+ - Database model lists (Claude can read schema files)
146
+ - Individual dependency names or versions (Claude reads `package.json`/`requirements.txt` directly)
147
+ - Standard framework patterns (e.g., "uses app router" for Next.js — Claude sees `app/` directory)
148
+
149
+ **Keep it tight.** A 30-line CLAUDE.md that hits the essentials beats a 200-line doc Claude has to parse every session.
150
+
151
+ **Always end with:**
152
+ ```markdown
153
+ ## Team Feedback
154
+ See `.claude/feedback/` for corrections and guidance from the team.
155
+ ```
156
+
157
+ This pointer persists across autoconfig runs and directs Claude to team-maintained content.
158
+
159
+ ## Step 4: Create Rules Directory
160
+
161
+ Create `.claude/rules/` directory if it doesn't exist by writing a `.gitkeep` file to it:
162
+
163
+ ```
164
+ Write .claude/rules/.gitkeep with empty content
165
+ ```
166
+
167
+ **Important**: Use Write tool to create the directory (by creating a placeholder file), not `mkdir` Bash commands. This avoids permission prompts during setup.
168
+
169
+ 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.
170
+
171
+ ## Step 5: Configure Formatter (JS/Node Projects)
172
+
173
+ **Only for projects with `package.json`:**
174
+
175
+ 1. Check if `scripts.format` already exists in `package.json`
176
+
177
+ 2. **If `scripts.format` exists:**
178
+ - Skip to adding the hook (Step 5b)
179
+
180
+ 3. **If `scripts.format` does NOT exist:**
181
+ - Ask the user:
182
+ ```
183
+ No formatter detected. Adding one ensures Claude's output
184
+ matches your project's style.
185
+
186
+ Should I add Prettier to this project? (y/n)
187
+ ```
188
+
189
+ 4. **If user says yes:**
190
+ - Run: `npm install -D prettier`
191
+ - Add to `package.json` scripts:
192
+ ```json
193
+ "format": "[ -f .prettierrc ] && prettier --write . || echo 'Create .prettierrc to enable formatting'"
194
+ ```
195
+ - Create `.prettierrc.example` in project root:
196
+ ```json
197
+ {
198
+ "semi": true,
199
+ "singleQuote": false,
200
+ "tabWidth": 2
201
+ }
202
+ ```
203
+ - Inform user: "Formatting is ready but inactive. Rename `.prettierrc.example` to `.prettierrc` when your team decides on style preferences."
204
+
205
+ 5. **If user says no:**
206
+ - Skip formatter setup, continue to Step 6
207
+
208
+ **Step 5b: Add PostToolUse Format Hook**
209
+
210
+ If the project has `scripts.format` (either existing or just added), add the format hook to `.claude/settings.json`:
211
+
212
+ ```json
213
+ {
214
+ "hooks": {
215
+ "PostToolUse": [
216
+ {
217
+ "matcher": "Write|Edit",
218
+ "hooks": [
219
+ { "type": "command", "command": "node .claude/hooks/format.js" }
220
+ ]
221
+ }
222
+ ]
223
+ }
224
+ }
225
+ ```
226
+
227
+ The format hook script (`.claude/hooks/format.js`) runs `npm run format` after Write/Edit operations on source files. Users can customize this script to add file filtering or different formatting logic.
228
+
229
+ **Important:** Merge this with any existing hooks. Don't overwrite existing hooks.
230
+
231
+ ## Step 6: Configure Settings
232
+
233
+ Update `.claude/settings.json` using the official schema.
234
+
235
+ ### Deny Patterns (files Claude shouldn't read/write)
236
+
237
+ Use `Read()` for blocking reads, `Edit()` for blocking writes:
238
+
239
+ **Always deny (security):**
240
+ ```
241
+ Read(./.env)
242
+ Read(./.env.*)
243
+ Read(./secrets/**)
244
+ Edit(./.env)
245
+ Edit(./.env.*)
246
+ ```
247
+
248
+ **Always deny (Windows artifacts):**
249
+ ```
250
+ Write(./nul)
251
+ Edit(./nul)
252
+ ```
253
+ These prevent accidental `nul` file creation from bash/Windows command translation issues.
254
+
255
+ **Often deny (generated/vendor):**
256
+ ```
257
+ Edit(./node_modules/**)
258
+ Edit(./dist/**)
259
+ Edit(./.git/**)
260
+ ```
261
+
262
+ ### Allow Patterns (auto-approve without prompting)
263
+
264
+ Use `Bash()` patterns with prefix matching:
265
+
266
+ ```
267
+ Bash(npm run test:*)
268
+ Bash(npm run lint:*)
269
+ Bash(npm run build)
270
+ ```
271
+
272
+ ### Environment Variables
273
+
274
+ Set session-level env vars:
275
+
276
+ ```json
277
+ {
278
+ "env": {
279
+ "NODE_ENV": "development"
280
+ }
281
+ }
282
+ ```
283
+
284
+ **Keep it minimal** — only include patterns that actually exist in this project.
285
+
286
+ ## Guidelines
287
+
288
+ - Replace ALL placeholder content with real values from THIS project
289
+ - Delete sections that don't apply no empty stubs
290
+ - Optimize for Claude's efficiency, not human documentation
291
+ - When uncertain, leave it out — Claude can ask or explore
292
+
293
+ ## Step 7: Configure MEMORY.md
294
+
295
+ Claude Code has a persistent auto memory file (`MEMORY.md`) that loads into the system prompt at the start of every session. Write the debugging methodology to this file so Claude always follows evidence-based troubleshooting.
296
+
297
+ **Locate the MEMORY.md file:**
298
+
299
+ The file lives at `~/.claude/projects/{encoded-project-path}/memory/MEMORY.md` where the project path is encoded by replacing path separators with dashes and removing colons (e.g., `C:\CODE\my-project` becomes `C--CODE-my-project`).
300
+
301
+ **Before writing, read MEMORY.md first.** If a `## Debugging` section (or similar heading like `## Debugging — Evidence Before Solutions`) already exists, **skip this step entirely** — never duplicate or overwrite user-curated memory content.
302
+
303
+ **Only if no debugging section exists**, write this content (append if file already exists, create if it doesn't):
304
+
305
+ ```markdown
306
+ ## Debugging Evidence Before Solutions
307
+ NEVER guess the root cause and jump to coding a fix. Ask yourself: is the cause deterministic and verifiable from the error alone (e.g., stack trace, compile error)? If yes, fix it directly. If not:
308
+ 1. Add logging / check actual data first
309
+ 2. Confirm root cause with evidence
310
+ 3. Only then propose and implement a fix
311
+ ```
312
+
313
+ **Important**: Use the Write tool (or Edit to append). Do not skip this step on first-time setup — it ensures Claude investigates root causes before making changes in every future session. But never overwrite existing user content in MEMORY.md.
314
+
315
+ ## Step 8: Update the Docs
316
+
317
+ After populating CLAUDE.md, update the docs file previews to show actual project content:
318
+
319
+ 1. Open `.claude/docs/autoconfig.docs.html`
320
+ 2. Find the `fileContents` JavaScript object
321
+ 3. Update these entries with the real content just generated:
322
+ - `'claude-md'` → the CLAUDE.md content from Step 3
323
+ - `'memory-md'` → the MEMORY.md content from Step 7
324
+ - `'settings'` the settings.json content from Step 6
325
+ 4. Use template literal syntax and escape any backticks in the content
326
+
327
+ This ensures double-clicking these files in the docs shows real project content, not stale placeholders.
328
+
329
+ ## After Completion
330
+
331
+ ### Open Docs & Finale
332
+
333
+ **Only if `.claude/docs/autoconfig.docs.html` exists**, open it in the user's browser:
334
+
335
+ - macOS: `open .claude/docs/autoconfig.docs.html`
336
+ - Linux: `xdg-open .claude/docs/autoconfig.docs.html`
337
+ - Windows: `powershell -NoProfile -Command "Start-Process '.claude/docs/autoconfig.docs.html'"`
338
+
339
+ If the docs file exists, output:
340
+
341
+ ---
342
+
343
+ ✅ Setup complete! The interactive docs are now open in your browser.
344
+
345
+ ---
346
+
347
+ If the docs file does NOT exist (e.g., user ran `/autoconfig` without the full npx install), output:
348
+
349
+ ---
350
+
351
+ ✅ Setup complete!
352
+
353
+ Run `/show-docs` to view the interactive documentation (requires full install via `npx claude-code-autoconfig`).
354
+
355
+ ---
356
+
357
+ **IMPORTANT**: Do not add any additional text, summaries, or details after this message. The finale should be clean and punchy - end here.
358
+
359
+ ### Windows Cleanup
360
+
361
+ On Windows, if a `nul` file was accidentally created in the project root (a common artifact from bash/Unix command translation), delete it silently using the Bash tool:
362
+
363
+ ```bash
364
+ del nul 2>NUL
365
+ ```
366
+
366
367
  Do this cleanup silently without any output to the user.