claude-code-autoconfig 1.0.171 → 1.0.173
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/extract-rules.md +260 -0
- package/CHANGELOG.md +6 -6
- package/package.json +1 -2
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
<!-- @description Scan Claude artifacts and extract structured rules into .claude/rules/ -->
|
|
2
|
+
<!-- @version 3 -->
|
|
3
|
+
<!-- @param select | string | optional | Write only specific rules by number: "1,3,5". Default: all. -->
|
|
4
|
+
<!-- @param keep-sources | boolean | optional | Write rules but skip source cleanup (Step 8) -->
|
|
5
|
+
<!-- @response success | Rules extracted, written, and sources cleaned up. -->
|
|
6
|
+
<!-- @response no-rules | No extractable rules found in scanned sources. -->
|
|
7
|
+
<!-- @sideeffect Creates .claude/rules/ files and removes extracted content from source files -->
|
|
8
|
+
<!-- @example /extract-rules | Scan, propose, prompt for approval, write, and clean up -->
|
|
9
|
+
<!-- @example /extract-rules --keep-sources | Write rules without modifying source files -->
|
|
10
|
+
<!-- @example /extract-rules --select 1,3 | Write only rules #1 and #3 -->
|
|
11
|
+
|
|
12
|
+
# Extract Rules
|
|
13
|
+
|
|
14
|
+
Scan all Claude configuration artifacts and propose structured rules for `.claude/rules/`.
|
|
15
|
+
|
|
16
|
+
## Step 0: Git safety check
|
|
17
|
+
|
|
18
|
+
Before doing anything else, check for uncommitted changes:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
git status --porcelain
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
If there are uncommitted changes, show this warning and wait for confirmation:
|
|
25
|
+
|
|
26
|
+
> **Warning:** This command will modify files (extract rules from sources and optionally clean up originals). You have uncommitted changes.
|
|
27
|
+
>
|
|
28
|
+
> Commit your work before proceeding, or type "continue" to proceed anyway.
|
|
29
|
+
|
|
30
|
+
If the working tree is clean, proceed silently.
|
|
31
|
+
|
|
32
|
+
## Step 1: Discover sources
|
|
33
|
+
|
|
34
|
+
Scan these locations for `.md` files containing potential rules. **Skip any that don't exist** — not all projects have all of these:
|
|
35
|
+
|
|
36
|
+
1. `CLAUDE.md` (project root)
|
|
37
|
+
2. `CLAUDE.local.md` (project root, if present)
|
|
38
|
+
3. All `.md` files in `.claude/` recursively (feedback, commands, etc.) — **excluding** `.claude/rules/` and `.claude/commands/extract-rules.md`
|
|
39
|
+
4. Any nested `CLAUDE.md` files in subdirectories (e.g., `src/CLAUDE.md`)
|
|
40
|
+
5. Auto memory files — memory often contains misplaced imperatives that should be promoted to rules. To find the memory directory, list `~/.claude/projects/` and fuzzy-match against the current project path. The directory name encodes the path with dashes replacing separators, but encoding varies by platform and may not be consistent for paths with spaces, special characters, or deep nesting. **Discovery strategy**: list all directories under `~/.claude/projects/`, then find the one whose name best matches the current working directory (check if the directory name contains key path segments like the project folder name). Read `MEMORY.md` in that directory, then each `.md` file it links to. If no match is found or the memory directory can't be read, skip this source silently.
|
|
41
|
+
|
|
42
|
+
Also read all existing `.claude/rules/` files to avoid proposing duplicates.
|
|
43
|
+
|
|
44
|
+
## Step 2: Extract candidate rules
|
|
45
|
+
|
|
46
|
+
A rule is a **deterministic behavioral instruction** that Claude should follow when working on specific files or file patterns. Good rules are:
|
|
47
|
+
|
|
48
|
+
- **Actionable**: "Do X" or "Never do Y" — not background context
|
|
49
|
+
- **Scoped**: Applies to specific files, directories, or file patterns
|
|
50
|
+
- **Not already enforced**: Skip anything already handled by hooks, settings, or linting
|
|
51
|
+
- **Not ephemeral**: Skip project status, session notes, debugging histories
|
|
52
|
+
|
|
53
|
+
**Skip these** (they belong in other artifacts):
|
|
54
|
+
- Domain knowledge / business logic explanations → stay in their source doc
|
|
55
|
+
- Slash command definitions → stay in `commands/`
|
|
56
|
+
- Session-specific debugging notes → stay in memory
|
|
57
|
+
- Deployment / operational procedures → stay in their source doc
|
|
58
|
+
- **Unscoped behavioral imperatives** (e.g., "always use conventional commits", "ask before deleting files") → stay in CLAUDE.md. The value of `.claude/rules/` is path-scoped loading — a rule without a meaningful file scope loads identically to CLAUDE.md, so extracting it is just moving it sideways. Only extract if you can identify a real file pattern.
|
|
59
|
+
|
|
60
|
+
## Step 3: Deduplicate
|
|
61
|
+
|
|
62
|
+
- If a candidate rule already exists in `.claude/rules/` (same intent, even if worded differently), skip it
|
|
63
|
+
- If the same guidance appears in multiple sources, note all sources but propose one rule
|
|
64
|
+
- Group related rules into single files when they share the same `paths` scope. If two imperatives apply to the same files, they belong in one rule file. If they target different files, keep them separate — even if topically related.
|
|
65
|
+
- **Rules spanning multiple scopes**: If a rule applies to multiple file patterns (e.g., "never use `any` in tests or production code"), use multiple entries in the `paths` array — this is valid and preferred over splitting into separate rule files:
|
|
66
|
+
```yaml
|
|
67
|
+
paths:
|
|
68
|
+
- "**/*.test.*"
|
|
69
|
+
- "src/**/*"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Step 4: Detect conflicts
|
|
73
|
+
|
|
74
|
+
Check for contradictory guidance across sources. Two rules conflict when they give opposite instructions for the same scope (e.g., "always mock the DB in tests" vs "never mock the DB in tests").
|
|
75
|
+
|
|
76
|
+
For each conflict found:
|
|
77
|
+
- Flag it with `⚠️ CONFLICT` in the output
|
|
78
|
+
- Show both sources and the contradictory statements
|
|
79
|
+
- Do **not** propose either rule — ask the user which one wins
|
|
80
|
+
|
|
81
|
+
Conflicts block extraction for the affected rules only. Non-conflicting rules proceed normally.
|
|
82
|
+
|
|
83
|
+
## Step 5: Rate confidence
|
|
84
|
+
|
|
85
|
+
For each proposed rule, assign a confidence level:
|
|
86
|
+
|
|
87
|
+
- **HIGH** — Explicit imperative instruction ("never do X", "always do Y", "must use Z", "prefer X over Y"). The source text literally contains an imperative. Extract these.
|
|
88
|
+
- **SKIP** — Everything else: inferred conventions, contextual guidance, implementation details derivable from the code. Do not propose these.
|
|
89
|
+
|
|
90
|
+
## Step 6: Output proposals
|
|
91
|
+
|
|
92
|
+
For each HIGH-confidence rule, output:
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
### Rule: <short name>
|
|
96
|
+
**Source**: <file(s) it was extracted from>
|
|
97
|
+
**Paths**: <e.g., `src/background.ts`, `src/**/*.ts`, `*.ts`>
|
|
98
|
+
**File name**: <proposed .claude/rules/ filename, e.g., `linkedin-selectors.md`>
|
|
99
|
+
|
|
100
|
+
--- file content ---
|
|
101
|
+
---
|
|
102
|
+
paths:
|
|
103
|
+
- "src/background.ts"
|
|
104
|
+
- "src/**/*.ts"
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
<rule content here>
|
|
108
|
+
--- end file content ---
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The file content block must include proper YAML frontmatter with `paths` as an array. This is the exact format Claude Code expects.
|
|
112
|
+
|
|
113
|
+
**Validate paths**: Before proposing a rule, use Glob to verify that at least one `paths` pattern matches existing files in the project. If no files match, flag it with `⚠️ no matching files` and exclude it from the proposal. Dead rules erode trust.
|
|
114
|
+
|
|
115
|
+
**Output format**: Always show the summary table first, followed by a stats line. If there are 5 or fewer proposals, show the full file-content blocks after the table. If there are more than 5, ask the user if they want to see the full content for all rules or specific ones (e.g., "show 1,3" or "show all").
|
|
116
|
+
|
|
117
|
+
Summary table format:
|
|
118
|
+
|
|
119
|
+
| # | Rule file | Paths | Source(s) | Status |
|
|
120
|
+
|---|-----------|-------|-----------|--------|
|
|
121
|
+
|
|
122
|
+
Status column: `NEW` if no prior rule exists, `UPDATE` if it would merge with/extend an existing rule, `SKIP` if already covered.
|
|
123
|
+
|
|
124
|
+
After the table, show a stats line:
|
|
125
|
+
|
|
126
|
+
> Scanned **N** sources · Extracted **X** rules · Skipped **Y** candidates
|
|
127
|
+
|
|
128
|
+
### Examples
|
|
129
|
+
|
|
130
|
+
**Example 1: Clear imperative → single rule**
|
|
131
|
+
|
|
132
|
+
Source (`.claude/feedback/FEEDBACK.md`):
|
|
133
|
+
```markdown
|
|
134
|
+
## Dev Build vs Prod Build — CRITICAL
|
|
135
|
+
**ALWAYS use `npm run build`** (dev build) for local development and testing.
|
|
136
|
+
**NEVER use `build:prod`** unless the user explicitly asks to package for distribution.
|
|
137
|
+
Dev build includes a stable ID in the config. Prod build = random ID = broken auth.
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Extracted rule (`.claude/rules/build-rules.md`):
|
|
141
|
+
```markdown
|
|
142
|
+
---
|
|
143
|
+
paths:
|
|
144
|
+
- "build.config.ts"
|
|
145
|
+
- "package.json"
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
ALWAYS use `npm run build` (dev build) for local development and testing. NEVER use `build:prod` unless the user explicitly asks to package for distribution.
|
|
149
|
+
|
|
150
|
+
Dev build includes a stable ID in the config. Prod build = random ID = broken auth.
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Note: the imperative ("ALWAYS", "NEVER") transfers directly. The explanation is condensed but kept — it justifies the rule. Paths target the files a developer would touch when building.
|
|
154
|
+
|
|
155
|
+
**Example 2: Mixed content → split into two rules**
|
|
156
|
+
|
|
157
|
+
Source (`.claude/feedback/FEEDBACK.md`):
|
|
158
|
+
```markdown
|
|
159
|
+
## Related Projects
|
|
160
|
+
The business logic lives in the adjacent `../backend-api` project. This project is mostly UI — it sends raw data to the API which does the actual processing.
|
|
161
|
+
Treat these as a single unit. When the user mentions a feature, check backend-api automatically. Don't ask — just go find it.
|
|
162
|
+
|
|
163
|
+
## Fix Scoping
|
|
164
|
+
Scope fixes narrowly. Each data source has unique structure.
|
|
165
|
+
1. Check the `match()` function before modifying handlers
|
|
166
|
+
2. Don't apply fixes broadly across sources without asking
|
|
167
|
+
3. Test on the specific input that had the problem
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Extracted as TWO rules because they have different path scopes:
|
|
171
|
+
|
|
172
|
+
`.claude/rules/related-projects.md`:
|
|
173
|
+
```markdown
|
|
174
|
+
---
|
|
175
|
+
paths:
|
|
176
|
+
- "src/scrapers/*.ts"
|
|
177
|
+
- "src/services/*.ts"
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
The business logic lives in `../backend-api`. When the user mentions a feature, check backend-api automatically. Don't ask — just go find it.
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
`.claude/rules/fix-scoping.md`:
|
|
184
|
+
```markdown
|
|
185
|
+
---
|
|
186
|
+
paths:
|
|
187
|
+
- "src/scrapers/*.ts"
|
|
188
|
+
- "src/adapters/*.ts"
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
Scope fixes narrowly. Each data source has unique structure.
|
|
192
|
+
1. Check the `match()` function before modifying handlers
|
|
193
|
+
2. Don't apply fixes broadly across sources without asking
|
|
194
|
+
3. Test on the specific input that had the problem
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Note: same source section, but the "related projects" rule applies broadly to services while "fix scoping" targets handler files specifically. Different paths → separate rules.
|
|
198
|
+
|
|
199
|
+
## Step 7: Write rules
|
|
200
|
+
|
|
201
|
+
Write all proposed rules directly. No prompt needed — the user committed their work in Step 0 and can revert if needed.
|
|
202
|
+
|
|
203
|
+
- **If `--select N,N,...` is passed**: Write only the specified rules by number from the summary table. Skip all others.
|
|
204
|
+
- **If `--keep-sources` is passed**: Skip Step 8 (source cleanup) entirely. Rules are written but original source files are left untouched. Useful for validating extracted rules before committing to the full migration.
|
|
205
|
+
|
|
206
|
+
## Step 8: Source cleanup
|
|
207
|
+
|
|
208
|
+
**Skip this step if `--keep-sources` was passed.**
|
|
209
|
+
|
|
210
|
+
After writing rules, remove the extracted content from the original source files:
|
|
211
|
+
|
|
212
|
+
1. For each written rule, locate the original text in the source file(s)
|
|
213
|
+
2. Remove the extracted lines from the source — do not leave comments or placeholders
|
|
214
|
+
3. If removing content leaves an empty section (e.g., a `## Discoveries` section with no remaining entries), remove the section heading too
|
|
215
|
+
4. Preserve all non-extracted content in the source file
|
|
216
|
+
5. **Memory files**: Do NOT edit memory files (`~/.claude/projects/.../memory/`). These are outside the project directory and managed by Claude's auto-memory system. Extracted imperatives from memory will naturally be pruned by autodream once the rule takes over.
|
|
217
|
+
|
|
218
|
+
Show what was cleaned:
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
Cleaned sources:
|
|
222
|
+
CLAUDE.md — removed 3 lines (2 rules extracted)
|
|
223
|
+
.claude/feedback/FEEDBACK.md — removed 1 line (1 rule extracted)
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Step 9: Changelog summary
|
|
227
|
+
|
|
228
|
+
After applying rules (and optional cleanup), show a final changelog summarizing all changes. This is the last output the user sees, so it must be self-contained and scannable.
|
|
229
|
+
|
|
230
|
+
Format each rule as a block with a blank line between blocks:
|
|
231
|
+
|
|
232
|
+
```
|
|
233
|
+
NEW .claude/rules/build-rules.md
|
|
234
|
+
[manifest.config.ts, package.json]
|
|
235
|
+
1. "ALWAYS use dev build, NEVER use prod for local testing"
|
|
236
|
+
2. "Bump BASE_VERSION before CWS builds"
|
|
237
|
+
from FEEDBACK.md
|
|
238
|
+
|
|
239
|
+
NEW .claude/rules/content-logging.md
|
|
240
|
+
[src/content.tsx, src/components/**/*.tsx]
|
|
241
|
+
"Never import fileLogger in content scripts"
|
|
242
|
+
from MEMORY.md → feedback_check_logs_yourself.md
|
|
243
|
+
|
|
244
|
+
UPD .claude/rules/debugging.md
|
|
245
|
+
[src/**/*.ts, src/**/*.tsx]
|
|
246
|
+
added "check logs yourself, never ask user"
|
|
247
|
+
from MEMORY.md → feedback_check_logs_yourself.md
|
|
248
|
+
|
|
249
|
+
--- 4 rules unchanged
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Each block has four lines:
|
|
253
|
+
1. Status prefix + full rule file path (`.claude/rules/filename.md`)
|
|
254
|
+
2. `[paths]` — the file patterns that trigger this rule, in square brackets
|
|
255
|
+
3. Rule description(s) — numbered list if multiple imperatives, no number if single
|
|
256
|
+
4. `from` — source file. For memory files discovered via MEMORY.md index, use arrow notation: `from MEMORY.md → specific_file.md`
|
|
257
|
+
|
|
258
|
+
Other rules:
|
|
259
|
+
- Status prefixes: `NEW` (created), `UPD` (merged new content into existing rule), `---` (unchanged count)
|
|
260
|
+
- On re-runs with no changes, show: `No new rules found. N existing rules unchanged.`
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v1.0.173
|
|
4
|
+
- feat: ship /extract-rules to users
|
|
5
|
+
|
|
6
|
+
## v1.0.172
|
|
7
|
+
- feat: /extract-rules v3 — auto-apply, --keep-sources, changelog with paths
|
|
8
|
+
|
|
3
9
|
## v1.0.171
|
|
4
10
|
- feat: /extract-rules v3 — automatic flow, --keep-sources, changelog summary
|
|
5
11
|
|
|
@@ -141,9 +147,3 @@
|
|
|
141
147
|
## v1.0.124
|
|
142
148
|
- fix: remove Step 0 from /autoconfig, clarify terminal requirement
|
|
143
149
|
|
|
144
|
-
## v1.0.123
|
|
145
|
-
- fix: use npm exec instead of npx in Step 0
|
|
146
|
-
|
|
147
|
-
## v1.0.122
|
|
148
|
-
- feat: /autoconfig pulls latest package before configuring
|
|
149
|
-
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-code-autoconfig",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.173",
|
|
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",
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
"!.claude/cca.config.json",
|
|
39
39
|
"!.claude/.autoconfig-version",
|
|
40
40
|
"!.claude/commands/publish.md",
|
|
41
|
-
"!.claude/commands/extract-rules.md",
|
|
42
41
|
"!.claude/plans",
|
|
43
42
|
"CLAUDE.md",
|
|
44
43
|
"CHANGELOG.md"
|