start-vibing-stacks 1.4.1 → 1.5.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/dist/setup.js CHANGED
@@ -65,6 +65,7 @@ export async function setupProject(projectDir, config, options = {}) {
65
65
  mkdirSync(join(claudeDir, 'hooks'), { recursive: true });
66
66
  mkdirSync(join(claudeDir, 'config'), { recursive: true });
67
67
  mkdirSync(join(claudeDir, 'commands'), { recursive: true });
68
+ mkdirSync(join(claudeDir, 'rules'), { recursive: true });
68
69
  mkdirSync(join(claudeDir, 'skills', 'codebase-knowledge', 'domains'), { recursive: true });
69
70
  spinner.text = 'Directory structure created';
70
71
  // 2. Copy shared agents (universal)
@@ -129,6 +130,14 @@ export async function setupProject(projectDir, config, options = {}) {
129
130
  spinner.text = 'Imported .cursorrules into Claude config';
130
131
  }
131
132
  }
133
+ // 11b. Ensure CLAUDE.local.md is gitignored
134
+ const gitignorePath = join(projectDir, '.gitignore');
135
+ if (existsSync(gitignorePath)) {
136
+ const gitignore = readFileSync(gitignorePath, 'utf8');
137
+ if (!gitignore.includes('CLAUDE.local.md')) {
138
+ writeFileSync(gitignorePath, gitignore.trimEnd() + '\n\n# Claude Code local preferences\nCLAUDE.local.md\n');
139
+ }
140
+ }
132
141
  // 12. Copy commands
133
142
  const sharedCommandsDir = join(PACKAGE_ROOT, 'stacks', '_shared', 'commands');
134
143
  if (existsSync(sharedCommandsDir)) {
@@ -140,6 +149,7 @@ export async function setupProject(projectDir, config, options = {}) {
140
149
  max_tokens: 8192,
141
150
  max_turns: 100,
142
151
  enableAllProjectMcpServers: true,
152
+ autoMemoryEnabled: true,
143
153
  context: {
144
154
  compaction_threshold: 0.85,
145
155
  enable_compaction: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "start-vibing-stacks",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "AI-powered multi-stack dev workflow for Claude Code. Supports PHP, Node.js, Python and more.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,44 +1,159 @@
1
1
  ---
2
2
  name: claude-md-compactor
3
- description: "AUTOMATICALLY invoke when CLAUDE.md exceeds 40k chars. Compacts while preserving critical knowledge."
3
+ description: "AUTOMATICALLY invoke when CLAUDE.md exceeds 40k chars OR auto memory MEMORY.md exceeds 200 lines. Compacts while preserving critical knowledge by offloading to topic files."
4
4
  model: sonnet
5
- tools: Read, Write, Edit, Bash, Grep
5
+ tools: Read, Write, Edit, Bash, Grep, Glob
6
6
  ---
7
7
 
8
8
  # Claude MD Compactor Agent
9
9
 
10
- Compact CLAUDE.md when it exceeds 40,000 characters.
10
+ ## Understanding Claude Code's Memory Architecture
11
11
 
12
- ## Target Sizes
12
+ Claude Code has a **hierarchical memory system**. Know it before compacting:
13
13
 
14
- | Section | Max Size |
15
- |---------|----------|
16
- | # Title | 1 line |
17
- | ## Last Change | 200 chars |
18
- | ## Overview | 300 chars |
19
- | ## Stack | 500 chars (table) |
20
- | ## Architecture | 800 chars (tree) |
21
- | ## Critical Rules | 2000 chars (bullets) |
22
- | ## FORBIDDEN | 1000 chars (table) |
14
+ ```
15
+ Memory Hierarchy (loaded at session start):
16
+ ┌─────────────────────────────────────────────────┐
17
+ Managed Policy (/etc/claude-code/CLAUDE.md) │ Org-wide (IT/DevOps)
18
+ ├─────────────────────────────────────────────────┤
19
+ User Memory (~/.claude/CLAUDE.md) │ Personal (all projects)
20
+ ├─────────────────────────────────────────────────┤
21
+ Project Memory (./CLAUDE.md or .claude/CLAUDE.md│ Team-shared (git tracked)
22
+ ├─────────────────────────────────────────────────┤
23
+ │ Project Rules (.claude/rules/*.md) │ ← Modular rules (git tracked)
24
+ ├─────────────────────────────────────────────────┤
25
+ │ Project Local (./CLAUDE.local.md) │ ← Personal (gitignored)
26
+ ├─────────────────────────────────────────────────┤
27
+ │ Auto Memory (~/.claude/projects/<proj>/memory/) │ ← Claude's own notes
28
+ │ ├─ MEMORY.md (first 200 lines loaded) │
29
+ │ ├─ debugging.md (on-demand) │
30
+ │ └─ patterns.md (on-demand) │
31
+ └─────────────────────────────────────────────────┘
32
+ ```
33
+
34
+ **Key facts:**
35
+ - `CLAUDE.md` is loaded IN FULL at session start → keep it lean
36
+ - Auto memory `MEMORY.md` only loads **first 200 lines** → index only, details in topic files
37
+ - `.claude/rules/*.md` load in full → use for modular, topic-specific rules
38
+ - `@path/to/file` imports work inside CLAUDE.md (max depth 5)
39
+ - Child directory CLAUDE.md files load **on demand** (not at startup)
40
+
41
+ ## When to Trigger
42
+
43
+ 1. `CLAUDE.md` exceeds **40,000 characters**
44
+ 2. Auto memory `MEMORY.md` exceeds **200 lines**
45
+ 3. Context window is running hot (>80% usage)
46
+ 4. Session start is slow (too much context loaded)
47
+
48
+ ## Compaction Strategy
49
+
50
+ ### Step 1: Audit Current Size
51
+
52
+ ```bash
53
+ wc -m CLAUDE.md # Project CLAUDE.md
54
+ wc -l ~/.claude/projects/*/memory/MEMORY.md 2>/dev/null # Auto memory
55
+ du -sh .claude/ # Total .claude size
56
+ ```
57
+
58
+ ### Step 2: Offload to Rules Files (NOT delete)
59
+
60
+ Move detailed sections from CLAUDE.md to `.claude/rules/`:
61
+
62
+ ```
63
+ CLAUDE.md (before — bloated):
64
+ ## Stack (500 chars)
65
+ ## Critical Rules (5000 chars of detailed rules)
66
+ ## API Patterns (3000 chars of examples)
67
+ ## Security (2000 chars)
68
+ ## Frontend Patterns (4000 chars)
69
+
70
+ CLAUDE.md (after — lean index):
71
+ ## Stack (500 chars)
72
+ ## Critical Rules (summary bullets + @.claude/rules/critical.md)
73
+ ## API Patterns (summary + @.claude/rules/api.md)
74
+ ## Security (summary + @.claude/rules/security.md)
75
+ ## Frontend Patterns (summary + @.claude/rules/frontend.md)
76
+ ```
23
77
 
24
- ## Must Remove
78
+ ### Step 3: Use @imports for Details
25
79
 
26
- - Verbose explanations → bullet points
27
- - Code examples > 5 lines → file references
28
- - Old "Last Change" entries → git has history
80
+ ```markdown
81
+ # MyProject
82
+
83
+ ## Critical Rules
84
+ - Always use UUIDs for primary keys
85
+ - Prepared statements only (no raw SQL)
86
+ - Full details: @.claude/rules/critical.md
87
+
88
+ ## API Standards
89
+ - UTC storage, timezone in Resource layer only
90
+ - Full patterns: @.claude/rules/api-standards.md
91
+ ```
92
+
93
+ ### Step 4: Compact Auto Memory MEMORY.md
94
+
95
+ If `MEMORY.md` > 200 lines, offload to topic files:
96
+
97
+ ```
98
+ ~/.claude/projects/<proj>/memory/
99
+ ├── MEMORY.md # INDEX ONLY (< 200 lines)
100
+ │ → "Debugging notes: see debugging.md"
101
+ │ → "API patterns: see api-conventions.md"
102
+ │ → "Performance learnings: see performance.md"
103
+ ├── debugging.md # Detailed debugging notes (on-demand)
104
+ ├── api-conventions.md # API decisions (on-demand)
105
+ └── performance.md # Performance learnings (on-demand)
106
+ ```
107
+
108
+ ### Step 5: Clean Stale Content
109
+
110
+ Remove from CLAUDE.md:
111
+ - Old "Last Change" entries (keep only latest)
112
+ - Resolved problems (move to domain docs)
113
+ - Code examples > 10 lines (reference file instead)
29
114
  - Duplicate information
30
115
  - Commented-out sections
31
116
 
32
- ## Must Keep
117
+ ## Target Sizes After Compaction
118
+
119
+ | Section | Max in CLAUDE.md | Overflow to |
120
+ |---------|-----------------|-------------|
121
+ | Title + Overview | 500 chars | — |
122
+ | Last Change | 200 chars | git history |
123
+ | Stack table | 500 chars | — |
124
+ | Architecture tree | 800 chars | — |
125
+ | Critical Rules | 500 chars summary | `.claude/rules/critical.md` |
126
+ | FORBIDDEN table | 500 chars | `.claude/rules/security.md` |
127
+ | Quality Gates | 300 chars | `config/quality-gates.json` |
128
+ | Per-domain rules | 200 chars each | `.claude/rules/{domain}.md` |
129
+ | **Total CLAUDE.md** | **< 15,000 chars** | Rules files |
130
+
131
+ ## FORBIDDEN During Compaction
33
132
 
34
- - Project title, overview, stack table
35
- - Architecture tree
36
- - Critical rules (bullets)
37
- - FORBIDDEN actions table
38
- - Quality gate commands
133
+ | Don't | Why |
134
+ |---|---|
135
+ | Delete rules entirely | Move to rules/ files instead |
136
+ | Remove FORBIDDEN table | Security must stay visible |
137
+ | Delete Last Change | Keep latest, remove older |
138
+ | Remove architecture tree | Essential for navigation |
139
+ | Compact code examples by truncating | Reference the file instead |
140
+ | Edit auto memory of other projects | Stay in current project only |
39
141
 
40
- ## After Compaction
142
+ ## After Compaction Verification
41
143
 
42
144
  ```bash
43
- wc -m CLAUDE.md # Must be < 40000
145
+ # CLAUDE.md under limit
146
+ wc -m CLAUDE.md # Must be < 40000 (target: < 15000)
147
+
148
+ # Auto memory index under limit
149
+ wc -l ~/.claude/projects/*/memory/MEMORY.md # Must be < 200 lines
150
+
151
+ # Rules files exist for offloaded content
152
+ ls .claude/rules/
153
+
154
+ # @imports are valid
155
+ grep -o '@[^ ]*' CLAUDE.md | while read f; do
156
+ path="${f#@}"
157
+ [ -f "$path" ] && echo "✅ $path" || echo "❌ MISSING: $path"
158
+ done
44
159
  ```
@@ -47,6 +47,21 @@ $_POST['name']; // ❌
47
47
  $_SESSION['user']; // ❌
48
48
  ```
49
49
 
50
+ ### AppServiceProvider — Connection Flush
51
+
52
+ ```php
53
+ // app/Providers/AppServiceProvider.php
54
+ use Laravel\Octane\Facades\Octane;
55
+
56
+ public function boot(): void
57
+ {
58
+ // MANDATORY: flush DB connections between requests
59
+ Octane::prepare(fn ($sandbox) => $sandbox->flushDatabaseConnections());
60
+ }
61
+ ```
62
+
63
+ **Rule:** ALWAYS pair persistent connections with `Octane::prepare` flush in AppServiceProvider.
64
+
50
65
  ### Memoization in Workers
51
66
 
52
67
  ```php
@@ -100,7 +100,25 @@ class UserResource extends JsonResource
100
100
  }
101
101
  ```
102
102
 
103
- **Rule:** Backend/DB in UTC. Timezone conversion ONLY in API Resources.
103
+ **Implementation:**
104
+
105
+ ```php
106
+ // app/Traits/FormatsDatesForApi.php
107
+ trait FormatsDatesForApi
108
+ {
109
+ protected function formatDateTime(
110
+ ?\Carbon\Carbon $date,
111
+ Request $request,
112
+ string $format = 'Y-m-d\TH:i:sP'
113
+ ): ?string {
114
+ if (!$date) return null;
115
+ $tz = $request->header('X-Timezone', $request->user()?->timezone ?? 'UTC');
116
+ return $date->copy()->setTimezone($tz)->format($format);
117
+ }
118
+ }
119
+ ```
120
+
121
+ **Rule:** Backend/DB in UTC. Timezone conversion ONLY in API Resources. ALL Resources with dates MUST use this trait.
104
122
 
105
123
  ### Action Endpoints
106
124