claude-setup 1.0.0 → 1.1.1

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.
@@ -30,17 +30,18 @@ export async function runAdd() {
30
30
  return;
31
31
  }
32
32
  if (isSingleFileOperation(userInput)) {
33
- console.log(`
34
- For single changes, Claude Code is faster:
35
- Just tell it: "${userInput}"
36
-
37
- Use claude-setup add when the change spans multiple files —
38
- capabilities that need documentation, MCP servers, skills, and hooks together.
33
+ console.log(`
34
+ For single changes, Claude Code is faster:
35
+ Just tell it: "${userInput}"
36
+
37
+ Use claude-setup add when the change spans multiple files —
38
+ capabilities that need documentation, MCP servers, skills, and hooks together.
39
39
  `);
40
40
  return;
41
41
  }
42
42
  const state = await readState();
43
- const collected = await collectProjectFiles();
43
+ // add only needs config files — source files are irrelevant and waste tokens
44
+ const collected = await collectProjectFiles(process.cwd(), "configOnly");
44
45
  const content = buildAddCommand(userInput, collected, state);
45
46
  ensureDir(".claude/commands");
46
47
  writeFileSync(".claude/commands/stack-add.md", content, "utf8");
@@ -10,7 +10,7 @@ function ensureDir(dir) {
10
10
  }
11
11
  export async function runInit() {
12
12
  const state = await readState();
13
- const collected = await collectProjectFiles();
13
+ const collected = await collectProjectFiles(process.cwd(), "deep");
14
14
  ensureDir(".claude/commands");
15
15
  if (isEmptyProject(collected)) {
16
16
  const content = buildEmptyProjectCommand();
@@ -24,7 +24,7 @@ export async function runRemove() {
24
24
  return;
25
25
  }
26
26
  const state = await readState();
27
- const collected = await collectProjectFiles();
27
+ const collected = await collectProjectFiles(process.cwd(), "configOnly");
28
28
  const content = buildRemoveCommand(userInput, state);
29
29
  ensureDir(".claude/commands");
30
30
  writeFileSync(".claude/commands/stack-remove.md", content, "utf8");
@@ -42,7 +42,7 @@ export async function runSync() {
42
42
  return;
43
43
  }
44
44
  const lastRun = manifest.runs.at(-1);
45
- const collected = await collectProjectFiles();
45
+ const collected = await collectProjectFiles(process.cwd(), "normal");
46
46
  const diff = computeDiff(lastRun.snapshot, collected);
47
47
  if (!diff.added.length && !diff.changed.length && !diff.deleted.length) {
48
48
  console.log(`✅ No changes since ${lastRun.at}. Setup is current.`);
@@ -0,0 +1,15 @@
1
+ export interface SetupConfig {
2
+ maxSourceFiles: number;
3
+ maxDepth: number;
4
+ maxFileSizeKB: number;
5
+ tokenBudget: {
6
+ init: number;
7
+ sync: number;
8
+ add: number;
9
+ remove: number;
10
+ };
11
+ digestMode: boolean;
12
+ extraBlockedDirs: string[];
13
+ sourceDirs: string[];
14
+ }
15
+ export declare function loadConfig(cwd?: string): SetupConfig;
package/dist/config.js ADDED
@@ -0,0 +1,42 @@
1
+ import { readFileSync, existsSync } from "fs";
2
+ import { join } from "path";
3
+ const DEFAULTS = {
4
+ maxSourceFiles: 15,
5
+ maxDepth: 6,
6
+ maxFileSizeKB: 80,
7
+ tokenBudget: {
8
+ init: 12_000,
9
+ sync: 6_000,
10
+ add: 3_000,
11
+ remove: 2_000,
12
+ },
13
+ digestMode: true,
14
+ extraBlockedDirs: [],
15
+ sourceDirs: [],
16
+ };
17
+ const CONFIG_FILENAME = ".claude-setup.json";
18
+ export function loadConfig(cwd = process.cwd()) {
19
+ const configPath = join(cwd, CONFIG_FILENAME);
20
+ if (!existsSync(configPath))
21
+ return { ...DEFAULTS };
22
+ try {
23
+ const raw = JSON.parse(readFileSync(configPath, "utf8"));
24
+ return {
25
+ maxSourceFiles: raw.maxSourceFiles ?? DEFAULTS.maxSourceFiles,
26
+ maxDepth: raw.maxDepth ?? DEFAULTS.maxDepth,
27
+ maxFileSizeKB: raw.maxFileSizeKB ?? DEFAULTS.maxFileSizeKB,
28
+ tokenBudget: {
29
+ init: raw.tokenBudget?.init ?? DEFAULTS.tokenBudget.init,
30
+ sync: raw.tokenBudget?.sync ?? DEFAULTS.tokenBudget.sync,
31
+ add: raw.tokenBudget?.add ?? DEFAULTS.tokenBudget.add,
32
+ remove: raw.tokenBudget?.remove ?? DEFAULTS.tokenBudget.remove,
33
+ },
34
+ digestMode: raw.digestMode ?? DEFAULTS.digestMode,
35
+ extraBlockedDirs: raw.extraBlockedDirs ?? DEFAULTS.extraBlockedDirs,
36
+ sourceDirs: raw.sourceDirs ?? DEFAULTS.sourceDirs,
37
+ };
38
+ }
39
+ catch {
40
+ return { ...DEFAULTS };
41
+ }
42
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-setup",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "Setup layer for Claude Code — reads your project, writes command files, Claude Code does the rest",
5
5
  "type": "module",
6
6
  "bin": {
package/templates/add.md CHANGED
@@ -1,20 +1,11 @@
1
- <!-- Generated by claude-setup add {{DATE}} -->
2
- <!-- Run /stack-add in Claude Code -->
1
+ <!-- claude-setup add {{DATE}} -->
3
2
 
4
- The developer wants to add this to their Claude Code setup:
5
- "{{USER_INPUT}}"
6
-
7
- ---
3
+ Add to Claude Code setup: "{{USER_INPUT}}"
8
4
 
9
5
  ## Project context
6
+ {{PROJECT_CONTEXT}}
10
7
 
11
- {{CONFIG_FILES}}
12
-
13
- {{SOURCE_FILES}}
14
-
15
- ---
16
-
17
- ## Current setup — read before writing anything
8
+ ## Current setup
18
9
 
19
10
  {{#if HAS_CLAUDE_MD}}
20
11
  ### CLAUDE.md
@@ -27,38 +18,16 @@ The developer wants to add this to their Claude Code setup:
27
18
  {{/if}}
28
19
 
29
20
  {{#if HAS_SETTINGS}}
30
- ### .claude/settings.json
21
+ ### settings.json
31
22
  {{SETTINGS_CONTENT}}
32
23
  {{/if}}
33
24
 
34
- Skills installed: {{SKILLS_LIST}}
35
- Commands installed: {{COMMANDS_LIST}}
36
-
37
- ---
38
-
39
- ## Your job
40
-
41
- Figure out which files need to change to fulfill the request.
42
- Adding a capability to Claude Code is rarely one file — it usually means touching
43
- CLAUDE.md, possibly an MCP entry, possibly a skill, possibly a hook.
44
-
45
- For every file you touch:
46
- - Read its current content above first
47
- - Merge and append only
48
- - Do not duplicate what already exists
49
- - Extend existing files rather than creating parallel ones
50
-
51
- If the request mentions something not evidenced in the project files: say so and ask
52
- whether they want to add it generically or need to add the underlying service first.
53
-
54
- ---
55
-
56
- ## Output format — strict
57
-
58
- Updated:
59
- ✅ [path] — [what changed and why]
25
+ Skills: {{SKILLS_LIST}} | Commands: {{COMMANDS_LIST}}
60
26
 
61
- Skipped:
62
- ⏭ [path] [why not needed for this request]
27
+ ## Rules
28
+ - Read current content before writing. Merge/append only.
29
+ - If request mentions something not in project files: ask first.
63
30
 
64
- One line per file. Nothing else.
31
+ ## Output — one line per file
32
+ Updated: ✅ [path] — [what and why]
33
+ Skipped: ⏭ [path] — [why]
package/templates/init.md CHANGED
@@ -1,132 +1,49 @@
1
- <!-- Generated by claude-setup {{VERSION}} on {{DATE}} — DO NOT hand-edit -->
2
- <!-- Run /stack-init in Claude Code -->
1
+ <!-- claude-setup {{VERSION}} {{DATE}} -->
3
2
 
4
- You are setting up this project for Claude Code.
5
- Read everything below. Understand the project yourself. Then act.
6
- Do not ask clarifying questions — reason from what you see.
3
+ Set up this project for Claude Code. Reason from what you see. Don't ask questions.
7
4
 
8
- ---
5
+ ## Project
9
6
 
10
- ## Project files
7
+ {{PROJECT_CONTEXT}}
11
8
 
12
- ### Configuration and manifest files
9
+ {{#if HAS_SOURCE}}
10
+ ## Source samples
13
11
 
14
- {{CONFIG_FILES}}
15
-
16
- ### Source files sampled
17
-
18
- {{SOURCE_FILES}}
19
-
20
- {{#if HAS_SKIPPED}}
21
- ### Files skipped (too large or filtered)
22
-
23
- {{SKIPPED_LIST}}
12
+ {{SOURCE_CONTEXT}}
24
13
  {{/if}}
25
14
 
26
- ---
27
-
28
- ## Existing Claude Code setup — READ EVERY LINE BEFORE TOUCHING ANYTHING
15
+ ## Existing setup — READ BEFORE WRITING
29
16
 
30
17
  {{#if HAS_CLAUDE_MD}}
31
- ### CLAUDE.md EXISTS — append only, never rewrite, never remove
18
+ ### CLAUDE.md (exists — append only)
32
19
  {{CLAUDE_MD_CONTENT}}
33
20
  {{else}}
34
- CLAUDE.md does not exist (create it)
21
+ CLAUDE.md: does not exist (create it)
35
22
  {{/if}}
36
23
 
37
24
  {{#if HAS_MCP_JSON}}
38
- ### .mcp.json EXISTS — merge only, never remove existing entries
25
+ ### .mcp.json (exists — merge only)
39
26
  {{MCP_JSON_CONTENT}}
40
27
  {{else}}
41
- .mcp.json → does not exist (create only if you find evidence of external services)
28
+ .mcp.json: create only if services evidenced above
42
29
  {{/if}}
43
30
 
44
31
  {{#if HAS_SETTINGS}}
45
- ### .claude/settings.json EXISTS — merge only, never remove existing hooks
32
+ ### settings.json (exists — merge only)
46
33
  {{SETTINGS_CONTENT}}
47
34
  {{else}}
48
- .claude/settings.json → does not exist (create only if hooks are warranted)
35
+ settings.json: create only if hooks warranted
49
36
  {{/if}}
50
37
 
51
- Skills installed: {{SKILLS_LIST}}
52
- Commands installed: {{COMMANDS_LIST}}
53
- Workflows installed: {{WORKFLOWS_LIST}}
54
- .github/ exists: {{HAS_GITHUB_DIR}}
55
-
56
- ---
57
-
58
- ## Your job
59
-
60
- Read the files above. Figure out the project from what you see — language, runtime,
61
- dependencies, structure, conventions. Do not assume anything not visible in the files.
62
-
63
- Then write the Claude Code setup for THIS specific project.
64
-
65
- ### CLAUDE.md
66
-
67
- Always write or update this. It is the most valuable artifact.
68
- Make it specific: reference actual file paths from the project, actual patterns you saw
69
- in the source, actual conventions the code follows.
70
- Generic advice that could apply to any project belongs in documentation, not here.
71
-
72
- If it exists: read it fully above first. Add only what is genuinely missing. Never remove.
73
-
74
- ### .mcp.json
75
-
76
- Only if you found evidence of external services in the config files, dependencies,
77
- or environment template. Evidence means it appears in the files above.
78
- No evidence = no server. Do not invent services that were not in scope.
79
- If it exists: add to it. Never remove existing entries. Produce valid JSON.
80
-
81
- ### .claude/settings.json
82
-
83
- Only if hooks genuinely earn their cost for this specific project.
84
- Every hook adds overhead on every Claude Code action.
85
- If it exists: add to it. Never remove existing hooks. Never modify existing values.
86
-
87
- ### .claude/skills/
88
-
89
- Only for patterns that recur across this codebase and benefit from automatic loading.
90
- Use `applies-when` frontmatter so skills load only when relevant — not on every message.
91
- If a similar skill already exists: extend it. Do not create a parallel one.
92
-
93
- ### .github/workflows/
94
-
95
- Only if `.github/` exists ({{HAS_GITHUB_DIR}}).
96
- Only workflows warranted by what you found.
97
- If workflows already exist: do not touch them.
98
-
99
- ---
100
-
101
- ## Absolute rules
102
-
103
- 1. You have the full content of every existing Claude config file above.
104
- Read it before writing. Never write blind.
105
-
106
- 2. Append and merge only. Never rewrite a file in full. Never remove existing content.
107
-
108
- 3. Write only what is evidenced by the project files. No evidence = skip it.
109
-
110
- 4. Every line in CLAUDE.md must reference something you actually saw.
111
- No generic boilerplate. No advice identical for every project.
112
-
113
- 5. MCP servers, skills, and hooks add cost on every Claude Code session.
114
- Only add them if they clearly earn their keep for THIS project.
115
-
116
- ---
117
-
118
- ## Output format — hard constraint, no exceptions
119
-
120
- After completing all work, output ONLY:
121
-
122
- Created:
123
- ✅ [path] — [one clause: what you saw that justified it]
124
-
125
- Updated:
126
- ✅ [path] — [one clause: what was added]
38
+ Skills: {{SKILLS_LIST}} | Commands: {{COMMANDS_LIST}} | Workflows: {{WORKFLOWS_LIST}} | .github: {{HAS_GITHUB_DIR}}
127
39
 
128
- Skipped:
129
- ⏭ [path] [one clause: why not needed]
40
+ ## Rules
41
+ 1. Read existing content above before writing. Never write blind.
42
+ 2. Append/merge only. Never rewrite or remove.
43
+ 3. Every line must trace to something in the project. No generic boilerplate.
44
+ 4. MCP/skills/hooks cost tokens every session. Only add if clearly earned.
130
45
 
131
- No summaries. No file contents. No "here's what I built."
132
- One line per file. Then stop.
46
+ ## Output one line per file, nothing else
47
+ Created: [path] [why]
48
+ Updated: ✅ [path] — [what added]
49
+ Skipped: ⏭ [path] — [why not needed]
@@ -1,12 +1,8 @@
1
- <!-- Generated by claude-setup remove {{DATE}} -->
2
- <!-- Run /stack-remove in Claude Code -->
1
+ <!-- claude-setup remove {{DATE}} -->
3
2
 
4
- Remove this from the Claude Code setup:
5
- "{{USER_INPUT}}"
3
+ Remove from setup: "{{USER_INPUT}}"
6
4
 
7
- ---
8
-
9
- ## Current setup — read everything before touching any file
5
+ ## Current setup
10
6
 
11
7
  {{#if HAS_CLAUDE_MD}}
12
8
  ### CLAUDE.md
@@ -19,35 +15,17 @@ Remove this from the Claude Code setup:
19
15
  {{/if}}
20
16
 
21
17
  {{#if HAS_SETTINGS}}
22
- ### .claude/settings.json
18
+ ### settings.json
23
19
  {{SETTINGS_CONTENT}}
24
20
  {{/if}}
25
21
 
26
- Skills: {{SKILLS_LIST}}
27
- Commands: {{COMMANDS_LIST}}
28
- Workflows: {{WORKFLOWS_LIST}}
29
-
30
- ---
31
-
32
- ## Your job
33
-
34
- Find everything related to the removal request across all files above.
35
- Remove surgically — section by section, key by key.
36
-
37
- Rules:
38
- - Never delete an entire file. Remove only the relevant section.
39
- - Never remove content unrelated to the request.
40
- - After every edit, the file must remain valid (JSON stays valid JSON, etc.)
41
- - If not found anywhere: say so and stop.
42
-
43
- ---
44
-
45
- ## Output format — strict
46
-
47
- Removed from:
48
- ✅ [path] — [what was removed]
22
+ Skills: {{SKILLS_LIST}} | Commands: {{COMMANDS_LIST}} | Workflows: {{WORKFLOWS_LIST}}
49
23
 
50
- Not found:
51
- ⏭ [path] not referenced
24
+ ## Rules
25
+ - Remove only related content. Never delete entire files.
26
+ - Files must remain valid after edit (JSON stays valid, etc.)
27
+ - If not found: say so and stop.
52
28
 
53
- One line per file. Nothing else.
29
+ ## Output — one line per file
30
+ Removed: ✅ [path] — [what removed]
31
+ Not found: ⏭ [path] — not referenced
package/templates/sync.md CHANGED
@@ -1,26 +1,16 @@
1
- <!-- Generated by claude-setup sync {{DATE}} -->
2
- <!-- Last setup: {{LAST_RUN_DATE}} -->
3
- <!-- Run /stack-sync in Claude Code -->
1
+ <!-- claude-setup sync {{DATE}} | last: {{LAST_RUN_DATE}} -->
4
2
 
5
- The project has changed since Claude Code was last set up.
6
- Your job: update the setup to reflect what changed. Nothing more.
3
+ Project changed since last setup. Update only what the changes demand.
7
4
 
8
- ---
9
-
10
- ## What changed since last setup
11
-
12
- ### Added files
5
+ ## Changes
6
+ ### Added
13
7
  {{ADDED_FILES}}
14
-
15
- ### Modified files
8
+ ### Modified
16
9
  {{MODIFIED_FILES}}
17
-
18
- ### Deleted files
10
+ ### Deleted
19
11
  {{DELETED_FILES}}
20
12
 
21
- ---
22
-
23
- ## Current setup — read before touching
13
+ ## Current setup
24
14
 
25
15
  {{#if HAS_CLAUDE_MD}}
26
16
  ### CLAUDE.md
@@ -33,38 +23,17 @@ Your job: update the setup to reflect what changed. Nothing more.
33
23
  {{/if}}
34
24
 
35
25
  {{#if HAS_SETTINGS}}
36
- ### .claude/settings.json
26
+ ### settings.json
37
27
  {{SETTINGS_CONTENT}}
38
28
  {{/if}}
39
29
 
40
- Skills: {{SKILLS_LIST}}
41
- Commands: {{COMMANDS_LIST}}
42
-
43
- ---
44
-
45
- ## Your job
46
-
47
- For each changed file: does this change have any implication for the Claude Code setup?
48
-
49
- Reason about the signal: a new dependency, a new directory, a deleted file that was
50
- referenced somewhere. Update only what the change demands.
51
-
52
- Do not update things that did not change.
53
- Do not rewrite files — surgical edits only.
54
- If a change has no implication for the setup: skip it and say why.
55
- If you are unsure: flag it for the developer rather than guessing.
56
-
57
- ---
58
-
59
- ## Output format — strict
60
-
61
- Updated:
62
- ✅ [path] — triggered by: [which changed file and why]
63
-
64
- Skipped:
65
- ⏭ [path] — [why this change has no setup implication]
30
+ Skills: {{SKILLS_LIST}} | Commands: {{COMMANDS_LIST}}
66
31
 
67
- Flagged:
68
- ⚠️ [something that needs the developer's decision]
32
+ ## Rules
33
+ - Surgical edits only. Don't rewrite files. Don't update unchanged things.
34
+ - If unsure about a change's implication: flag it, don't guess.
69
35
 
70
- One line per file. Nothing else.
36
+ ## Output — one line per file
37
+ Updated: ✅ [path] — triggered by: [which change and why]
38
+ Skipped: ⏭ [path] — [why no implication]
39
+ Flagged: ⚠️ [needs developer decision]