claudify-agent 0.0.0-stage → 1.0.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.
- package/.claude/QUICK-REFERENCE.md +213 -0
- package/.claude/cost-dashboard.md +162 -0
- package/.claude/docs/COST-OPTIMIZATION.md +403 -0
- package/.claude/docs/MCP-INTEGRATION-GUIDE.md +348 -0
- package/.claude/docs/PLAN-MODE-OPTIMIZATION.md +836 -0
- package/.claude/hooks/auto-learning-review.ts +195 -0
- package/.claude/hooks/auto-lint-fix.ts +104 -0
- package/.claude/hooks/auto-security-review.ts +354 -0
- package/.claude/hooks/auto-validate.ts +348 -0
- package/.claude/hooks/plan-quality-tracker.ts +719 -0
- package/.claude/rules/anti-patterns.md +22 -0
- package/.claude/rules/context-tier-1.md +41 -0
- package/.claude/rules/context-tier-2.md +285 -0
- package/.claude/rules/general.md +25 -0
- package/.claude/rules/mcp-auto-use.md +46 -0
- package/.claude/rules/parallel-exploration-auto.md +31 -0
- package/.claude/rules/plan-mode-execution.md +289 -0
- package/.claude/rules/plan-mode-research.md +34 -0
- package/.claude/rules/plan-mode-structure.md +166 -0
- package/.claude/rules/plan-mode-validation.md +130 -0
- package/.claude/rules/security-critical.md +19 -0
- package/.claude/rules/tool-auto-selection.md +45 -0
- package/.claude/rules/tool-strategy.md +22 -0
- package/.claude/scripts/auto-validate.js +69 -0
- package/.claude/scripts/security-scan.js +45 -0
- package/.claude/security-dashboard.md +142 -0
- package/.claude/skills/backend-concurrency/SKILL.md +203 -0
- package/.claude/skills/debug-optimizer/SKILL.md +399 -0
- package/.claude/skills/debug-optimizer.md +12 -0
- package/.claude/skills/golang-guide/SKILL.md +177 -0
- package/.claude/skills/learning-loop/SKILL.md +308 -0
- package/.claude/skills/mcp-mastery/SKILL.md +214 -0
- package/.claude/skills/nestjs-guide/SKILL.md +197 -0
- package/.claude/skills/nextjs-guide/SKILL.md +687 -0
- package/.claude/skills/nextjs.md +13 -0
- package/.claude/skills/parallel-exploration/SKILL.md +193 -0
- package/.claude/skills/plan-mode-mastery/SKILL.md +263 -0
- package/.claude/skills/python-guide/SKILL.md +822 -0
- package/.claude/skills/react-guide/SKILL.md +762 -0
- package/.claude/skills/react.md +12 -0
- package/.claude/skills/security.md +18 -0
- package/.claude/skills/solidity-guide/SKILL.md +32 -0
- package/.claude/skills/tool-selection/SKILL.md +428 -0
- package/.claude/skills/vite-guide/SKILL.md +445 -0
- package/CLAUDE.md +49 -0
- package/README.md +65 -2
- package/bin/cli.js +50 -0
- package/package.json +44 -4
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vite-guide
|
|
3
|
+
description: Optimize Vite projects for maximum performance. Use when configuring Vite, improving dev server speed, optimizing builds, or when the user mentions Vite, vite.config, build performance, or HMR issues.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Vite Best Practices
|
|
7
|
+
|
|
8
|
+
## Quick Start
|
|
9
|
+
|
|
10
|
+
When working with Vite projects:
|
|
11
|
+
|
|
12
|
+
1. **Check configuration** - Review vite.config.js for performance issues
|
|
13
|
+
2. **Audit plugins** - Identify slow plugins or heavy operations
|
|
14
|
+
3. **Optimize imports** - Remove barrel files, use explicit extensions
|
|
15
|
+
4. **Configure warmup** - Pre-transform frequently used files
|
|
16
|
+
5. **Profile if slow** - Use `vite --profile` to identify bottlenecks
|
|
17
|
+
|
|
18
|
+
## Configuration Fundamentals
|
|
19
|
+
|
|
20
|
+
### Use defineConfig
|
|
21
|
+
|
|
22
|
+
Always use the `defineConfig` helper for TypeScript intelligence:
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
import { defineConfig } from 'vite'
|
|
26
|
+
import react from '@vitejs/plugin-react-swc'
|
|
27
|
+
|
|
28
|
+
export default defineConfig({
|
|
29
|
+
plugins: [react()],
|
|
30
|
+
// ... config options
|
|
31
|
+
})
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Plugin Selection
|
|
35
|
+
|
|
36
|
+
**Preferred**: Use `@vitejs/plugin-react-swc` instead of `@vitejs/plugin-react` for 6-8x faster HMR.
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
// ✅ Good - SWC-based (fast)
|
|
40
|
+
import react from '@vitejs/plugin-react-swc'
|
|
41
|
+
|
|
42
|
+
// ❌ Avoid - Babel-based (slower)
|
|
43
|
+
import react from '@vitejs/plugin-react'
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Performance Optimization
|
|
47
|
+
|
|
48
|
+
### Development Server Speed
|
|
49
|
+
|
|
50
|
+
#### 1. Replace Babel with SWC
|
|
51
|
+
|
|
52
|
+
Switch to SWC for dramatically faster transformations:
|
|
53
|
+
|
|
54
|
+
```javascript
|
|
55
|
+
// vite.config.js
|
|
56
|
+
import { defineConfig } from 'vite'
|
|
57
|
+
import react from '@vitejs/plugin-react-swc'
|
|
58
|
+
|
|
59
|
+
export default defineConfig({
|
|
60
|
+
plugins: [react()],
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Impact**: Reduces HMR transformation from 3-4s to <500ms.
|
|
65
|
+
|
|
66
|
+
#### 2. Avoid Barrel Files
|
|
67
|
+
|
|
68
|
+
Barrel files force Vite to process thousands of modules unnecessarily.
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
// ❌ Bad - Barrel file import
|
|
72
|
+
import { slash, formatDate, debounce } from './utils'
|
|
73
|
+
|
|
74
|
+
// ✅ Good - Direct imports
|
|
75
|
+
import { slash } from './utils/slash.js'
|
|
76
|
+
import { formatDate } from './utils/formatDate.js'
|
|
77
|
+
import { debounce } from './utils/debounce.js'
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Why**: Barrel files (index.js re-exporting everything) require loading all files even when you need one function.
|
|
81
|
+
|
|
82
|
+
#### 3. Use Explicit Import Extensions
|
|
83
|
+
|
|
84
|
+
Enable TypeScript bundler module resolution and use explicit extensions:
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
// tsconfig.json
|
|
88
|
+
{
|
|
89
|
+
"compilerOptions": {
|
|
90
|
+
"moduleResolution": "bundler",
|
|
91
|
+
"allowImportingTsExtensions": true
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
// ✅ Good - Explicit extension
|
|
98
|
+
import { Component } from './Component.jsx'
|
|
99
|
+
|
|
100
|
+
// ❌ Avoid - Implicit extension (requires 6+ filesystem checks)
|
|
101
|
+
import { Component } from './Component'
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### 4. Configure File Warmup
|
|
105
|
+
|
|
106
|
+
Pre-transform frequently used files to avoid request waterfalls:
|
|
107
|
+
|
|
108
|
+
```javascript
|
|
109
|
+
// vite.config.js
|
|
110
|
+
export default defineConfig({
|
|
111
|
+
server: {
|
|
112
|
+
warmup: {
|
|
113
|
+
clientFiles: [
|
|
114
|
+
'./src/main.jsx',
|
|
115
|
+
'./src/App.jsx',
|
|
116
|
+
'./src/components/BigComponent.jsx',
|
|
117
|
+
'./src/utils/big-utils.js',
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
})
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**How to find files to warmup**: Run `vite --debug transform` and look for files with >100ms transform time.
|
|
125
|
+
|
|
126
|
+
#### 5. Optimize Dependency Pre-bundling
|
|
127
|
+
|
|
128
|
+
Control which dependencies are pre-bundled:
|
|
129
|
+
|
|
130
|
+
```javascript
|
|
131
|
+
// vite.config.js
|
|
132
|
+
export default defineConfig({
|
|
133
|
+
optimizeDeps: {
|
|
134
|
+
include: ['lodash-es', 'axios'], // Force pre-bundling
|
|
135
|
+
exclude: ['@custom/large-lib'], // Skip pre-bundling
|
|
136
|
+
entries: ['./src/**/*.jsx'], // Custom entry points
|
|
137
|
+
},
|
|
138
|
+
})
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Build Optimization
|
|
142
|
+
|
|
143
|
+
#### 1. Manual Chunking
|
|
144
|
+
|
|
145
|
+
Avoid single large bundle by implementing manual chunks:
|
|
146
|
+
|
|
147
|
+
```javascript
|
|
148
|
+
// vite.config.js
|
|
149
|
+
export default defineConfig({
|
|
150
|
+
build: {
|
|
151
|
+
rollupOptions: {
|
|
152
|
+
output: {
|
|
153
|
+
manualChunks: {
|
|
154
|
+
vendor: ['react', 'react-dom'],
|
|
155
|
+
utils: ['lodash-es', 'dayjs'],
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
})
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
#### 2. CSS Optimization
|
|
164
|
+
|
|
165
|
+
Use native tooling when possible:
|
|
166
|
+
|
|
167
|
+
```javascript
|
|
168
|
+
// vite.config.js
|
|
169
|
+
export default defineConfig({
|
|
170
|
+
css: {
|
|
171
|
+
transformer: 'lightningcss', // Experimental but faster
|
|
172
|
+
lightningcssOptions: {
|
|
173
|
+
minify: true,
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
})
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Alternative**: Stick with PostCSS for better compatibility.
|
|
180
|
+
|
|
181
|
+
#### 3. Asset Handling
|
|
182
|
+
|
|
183
|
+
**Preferred**: Import SVGs as URLs, not components:
|
|
184
|
+
|
|
185
|
+
```javascript
|
|
186
|
+
// ✅ Good - URL import
|
|
187
|
+
import logo from './logo.svg'
|
|
188
|
+
<img src={logo} alt="Logo" />
|
|
189
|
+
|
|
190
|
+
// ❌ Avoid - SVG as component (slower)
|
|
191
|
+
import { ReactComponent as Logo } from './logo.svg'
|
|
192
|
+
<Logo />
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Plugin Audit Practices
|
|
196
|
+
|
|
197
|
+
### Slow Plugin Detection
|
|
198
|
+
|
|
199
|
+
Identify slow plugins using debug mode:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# See transform times
|
|
203
|
+
vite --debug plugin-transform
|
|
204
|
+
|
|
205
|
+
# Profile entire build
|
|
206
|
+
vite --profile
|
|
207
|
+
# Press 'p + enter' to generate .cpuprofile
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Plugin Best Practices
|
|
211
|
+
|
|
212
|
+
When evaluating community plugins:
|
|
213
|
+
|
|
214
|
+
1. **Check hooks**: Avoid plugins with heavy `buildStart`, `config`, or `configResolved` hooks
|
|
215
|
+
2. **Dynamic imports**: Large dependencies should be dynamically imported
|
|
216
|
+
3. **Conditional transforms**: Plugins should check file extensions before transforming
|
|
217
|
+
|
|
218
|
+
**Example optimization** (for plugin authors):
|
|
219
|
+
|
|
220
|
+
```javascript
|
|
221
|
+
// ✅ Good - Check before transform
|
|
222
|
+
transform(code, id) {
|
|
223
|
+
if (!id.endsWith('.jsx')) return null
|
|
224
|
+
if (!code.includes('useState')) return null
|
|
225
|
+
// ... transformation
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// ❌ Bad - Always transform
|
|
229
|
+
transform(code, id) {
|
|
230
|
+
// ... heavy transformation
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Common Performance Issues
|
|
235
|
+
|
|
236
|
+
### Issue 1: Slow Dev Server Start
|
|
237
|
+
|
|
238
|
+
**Symptoms**: Server takes >5s to start.
|
|
239
|
+
|
|
240
|
+
**Fixes**:
|
|
241
|
+
1. Check for plugins with heavy `config` hooks
|
|
242
|
+
2. Reduce `optimizeDeps.include` to essentials only
|
|
243
|
+
3. Use `@vitejs/plugin-react-swc` instead of Babel
|
|
244
|
+
4. Run `vite --profile` to identify bottlenecks
|
|
245
|
+
|
|
246
|
+
### Issue 2: Slow HMR Updates
|
|
247
|
+
|
|
248
|
+
**Symptoms**: Changes take >1s to reflect in browser.
|
|
249
|
+
|
|
250
|
+
**Fixes**:
|
|
251
|
+
1. Remove barrel file imports
|
|
252
|
+
2. Disable "Disable Cache" in Chrome DevTools Network tab
|
|
253
|
+
3. Check browser extensions (test in incognito mode)
|
|
254
|
+
4. Warm up frequently changed files
|
|
255
|
+
|
|
256
|
+
### Issue 3: Large Production Bundles
|
|
257
|
+
|
|
258
|
+
**Symptoms**: Main chunk >500KB gzipped.
|
|
259
|
+
|
|
260
|
+
**Fixes**:
|
|
261
|
+
1. Implement manual chunking
|
|
262
|
+
2. Check for accidentally bundled node_modules
|
|
263
|
+
3. Use dynamic imports for heavy components
|
|
264
|
+
4. Analyze bundle with `npm run build -- --sourcemap`
|
|
265
|
+
|
|
266
|
+
### Issue 4: Slow Full Page Reloads
|
|
267
|
+
|
|
268
|
+
**Symptoms**: Full reload takes >3s.
|
|
269
|
+
|
|
270
|
+
**Fixes**:
|
|
271
|
+
1. Ensure browser cache is enabled (not disabled in DevTools)
|
|
272
|
+
2. Reduce number of transformed files
|
|
273
|
+
3. Avoid transforming SVGs to components
|
|
274
|
+
4. Use CSS instead of Sass/Less when possible
|
|
275
|
+
|
|
276
|
+
## Profiling and Debugging
|
|
277
|
+
|
|
278
|
+
### Debug Commands
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
# Profile startup and transformations
|
|
282
|
+
vite --profile
|
|
283
|
+
|
|
284
|
+
# See detailed transform timings
|
|
285
|
+
vite --debug plugin-transform
|
|
286
|
+
|
|
287
|
+
# Debug resolve operations
|
|
288
|
+
vite --debug resolve
|
|
289
|
+
|
|
290
|
+
# Check transform cache
|
|
291
|
+
vite --debug transform
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Analyzing CPU Profiles
|
|
295
|
+
|
|
296
|
+
1. Run `vite --profile`
|
|
297
|
+
2. Use the app normally
|
|
298
|
+
3. Press `p + enter` in terminal
|
|
299
|
+
4. Open `.cpuprofile` in [speedscope.app](https://www.speedscope.app/)
|
|
300
|
+
5. Look for:
|
|
301
|
+
- Long-running hooks (`buildStart`, `config`)
|
|
302
|
+
- Slow transformations (>100ms)
|
|
303
|
+
- Excessive resolve operations
|
|
304
|
+
|
|
305
|
+
### Performance Checklist
|
|
306
|
+
|
|
307
|
+
Before considering a Vite project optimized:
|
|
308
|
+
|
|
309
|
+
- [ ] Using `@vitejs/plugin-react-swc` (for React projects)
|
|
310
|
+
- [ ] No barrel file imports in critical path
|
|
311
|
+
- [ ] Explicit import extensions enabled
|
|
312
|
+
- [ ] Frequently used files warmed up
|
|
313
|
+
- [ ] Browser cache enabled in DevTools
|
|
314
|
+
- [ ] Manual chunking configured for build
|
|
315
|
+
- [ ] No heavy operations in plugin hooks
|
|
316
|
+
- [ ] Profiled with `vite --profile` (no major bottlenecks)
|
|
317
|
+
|
|
318
|
+
## Commands
|
|
319
|
+
|
|
320
|
+
**Profile Vite**: Run profiling to identify performance issues
|
|
321
|
+
**Optimize config**: Review and optimize vite.config.js
|
|
322
|
+
**Fix HMR**: Diagnose and fix slow HMR updates
|
|
323
|
+
**Audit plugins**: Check for slow community plugins
|
|
324
|
+
|
|
325
|
+
## Examples
|
|
326
|
+
|
|
327
|
+
### Example 1: Optimized vite.config.js
|
|
328
|
+
|
|
329
|
+
```javascript
|
|
330
|
+
import { defineConfig } from 'vite'
|
|
331
|
+
import react from '@vitejs/plugin-react-swc'
|
|
332
|
+
import { visualizer } from 'rollup-plugin-visualizer'
|
|
333
|
+
|
|
334
|
+
export default defineConfig({
|
|
335
|
+
plugins: [
|
|
336
|
+
react(),
|
|
337
|
+
visualizer({ open: true }), // Analyze bundle
|
|
338
|
+
],
|
|
339
|
+
|
|
340
|
+
server: {
|
|
341
|
+
warmup: {
|
|
342
|
+
clientFiles: [
|
|
343
|
+
'./src/main.jsx',
|
|
344
|
+
'./src/App.jsx',
|
|
345
|
+
],
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
|
|
349
|
+
optimizeDeps: {
|
|
350
|
+
include: ['lodash-es', 'axios'],
|
|
351
|
+
},
|
|
352
|
+
|
|
353
|
+
build: {
|
|
354
|
+
rollupOptions: {
|
|
355
|
+
output: {
|
|
356
|
+
manualChunks: {
|
|
357
|
+
vendor: ['react', 'react-dom'],
|
|
358
|
+
utils: ['lodash-es', 'dayjs'],
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
})
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### Example 2: Fixing Barrel File Imports
|
|
367
|
+
|
|
368
|
+
**Before** (slow):
|
|
369
|
+
|
|
370
|
+
```javascript
|
|
371
|
+
// src/App.jsx
|
|
372
|
+
import { Button, Input, Modal } from './components'
|
|
373
|
+
import { formatDate, validateEmail } from './utils'
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
**After** (fast):
|
|
377
|
+
|
|
378
|
+
```javascript
|
|
379
|
+
// src/App.jsx
|
|
380
|
+
import { Button } from './components/Button.jsx'
|
|
381
|
+
import { Input } from './components/Input.jsx'
|
|
382
|
+
import { Modal } from './components/Modal.jsx'
|
|
383
|
+
import { formatDate } from './utils/formatDate.js'
|
|
384
|
+
import { validateEmail } from './utils/validateEmail.js'
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### Example 3: Diagnosing Slow HMR
|
|
388
|
+
|
|
389
|
+
**User**: "My HMR is taking 3-4 seconds to update"
|
|
390
|
+
|
|
391
|
+
**Agent Response**:
|
|
392
|
+
"I'll diagnose the slow HMR issue. Let me check:
|
|
393
|
+
|
|
394
|
+
1. **Browser setup**: Is 'Disable Cache' checked in DevTools?
|
|
395
|
+
- Fix: Uncheck it in Network tab
|
|
396
|
+
|
|
397
|
+
2. **Plugin audit**: Running `vite --debug plugin-transform`
|
|
398
|
+
- Looking for transforms >100ms
|
|
399
|
+
|
|
400
|
+
3. **Import patterns**: Checking for barrel files
|
|
401
|
+
- Found: `import { X } from './utils'` in 5 files
|
|
402
|
+
- Fix: Use direct imports
|
|
403
|
+
|
|
404
|
+
4. **Plugin choice**: Using `@vitejs/plugin-react`?
|
|
405
|
+
- Fix: Switch to `@vitejs/plugin-react-swc`
|
|
406
|
+
|
|
407
|
+
Let me start by checking your vite.config.js and running a profile..."
|
|
408
|
+
|
|
409
|
+
## Additional Resources
|
|
410
|
+
|
|
411
|
+
- [Vite Performance Guide](https://vitejs.dev/guide/performance/)
|
|
412
|
+
- [Vite Config Reference](https://vitejs.dev/config/)
|
|
413
|
+
- [speedscope.app](https://www.speedscope.app/) - CPU profile viewer
|
|
414
|
+
- [rollup-plugin-visualizer](https://github.com/btd/rollup-plugin-visualizer) - Bundle analyzer
|
|
415
|
+
|
|
416
|
+
## Anti-Patterns to Avoid
|
|
417
|
+
|
|
418
|
+
### 1. Windows-Style Paths
|
|
419
|
+
- ✅ Use: `./src/components/Button.jsx`
|
|
420
|
+
- ❌ Avoid: `.\src\components\Button.jsx`
|
|
421
|
+
|
|
422
|
+
### 2. Too Many Warmup Files
|
|
423
|
+
```javascript
|
|
424
|
+
// ❌ Bad - Overloads dev server
|
|
425
|
+
warmup: {
|
|
426
|
+
clientFiles: ['./src/**/*'] // All files!
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// ✅ Good - Only critical files
|
|
430
|
+
warmup: {
|
|
431
|
+
clientFiles: [
|
|
432
|
+
'./src/main.jsx',
|
|
433
|
+
'./src/App.jsx',
|
|
434
|
+
]
|
|
435
|
+
}
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
### 3. Time-Sensitive Configuration
|
|
439
|
+
```javascript
|
|
440
|
+
// ❌ Bad - Will become outdated
|
|
441
|
+
// "Use Vite 5.0 features before 2026"
|
|
442
|
+
|
|
443
|
+
// ✅ Good - Use current stable features
|
|
444
|
+
// Use manualChunks for code splitting
|
|
445
|
+
```
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# CLAUDE CORE OPERATING SYSTEM
|
|
2
|
+
|
|
3
|
+
> **Universal Directive:** You are an autonomous Senior Software Engineer operating via Claude Code / Anthropic Agent loop. Follow these concise, modular instructions. Do not load all guidelines into context; inspect modular files on-demand using `@path` mentions.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. 🛑 Context & Token Preservation (Sub-20 Line Core)
|
|
8
|
+
- Keep responses concise and targeted. Never dump entire files when diffs suffice.
|
|
9
|
+
- Do NOT read whole directory trees. Inspect shallow structure first.
|
|
10
|
+
- Context Tiers (Inspect when prompted):
|
|
11
|
+
- **Tier 1 (Base):** @.claude/rules/context-tier-1.md
|
|
12
|
+
- **Tier 2 (Deep Task):** @.claude/rules/context-tier-2.md
|
|
13
|
+
- **Anti-Patterns:** @.claude/rules/anti-patterns.md
|
|
14
|
+
|
|
15
|
+
## 2. 📋 Plan First Protocol (Anti-Drift)
|
|
16
|
+
- For tasks touching **>= 2 files** or core architecture:
|
|
17
|
+
- Generate a concise Plan before modifying files.
|
|
18
|
+
- Research protocol: @.claude/rules/plan-mode-research.md
|
|
19
|
+
- Execution checklist: @.claude/rules/plan-mode-execution.md
|
|
20
|
+
- Validation steps: @.claude/rules/plan-mode-validation.md
|
|
21
|
+
- Plan structure guide: @.claude/rules/plan-mode-structure.md
|
|
22
|
+
|
|
23
|
+
## 3. 🧪 Zero-Token Local Verification Loop
|
|
24
|
+
After modifying code, execute local verification based on project stack:
|
|
25
|
+
- **Node/TS/NestJS:** `npm run lint:fix && npm run typecheck`
|
|
26
|
+
- **Go Backend:** `go vet ./... && go test -race ./...`
|
|
27
|
+
- **Solidity (SMC):** `forge test -vvv` hoặc `npx hardhat test`
|
|
28
|
+
- Core standards: @.claude/rules/general.md & @.claude/rules/security-critical.md
|
|
29
|
+
|
|
30
|
+
## 4. 📚 On-Demand Skills Index (Load ONLY When Tech Is Used)
|
|
31
|
+
- **Backend Concurrency & Locking:** @.claude/skills/backend-concurrency/SKILL.md
|
|
32
|
+
- **NestJS Enterprise:** @.claude/skills/nestjs-guide/SKILL.md
|
|
33
|
+
- **Golang Backend:** @.claude/skills/golang-guide/SKILL.md
|
|
34
|
+
- **Solidity (Smart Contracts):** @.claude/skills/solidity-guide/SKILL.md
|
|
35
|
+
- **Next.js:** @.claude/skills/nextjs-guide/SKILL.md
|
|
36
|
+
- **React:** @.claude/skills/react-guide/SKILL.md
|
|
37
|
+
- **Python:** @.claude/skills/python-guide/SKILL.md
|
|
38
|
+
- **Vite:** @.claude/skills/vite-guide/SKILL.md
|
|
39
|
+
- **MCP Mastery:** @.claude/skills/mcp-mastery/SKILL.md
|
|
40
|
+
- **Tool Selection:** @.claude/skills/tool-selection/SKILL.md
|
|
41
|
+
- **Debug Optimizer:** @.claude/skills/debug-optimizer/SKILL.md
|
|
42
|
+
- **Parallel Exploration:** @.claude/skills/parallel-exploration/SKILL.md
|
|
43
|
+
- **Learning Loop:** @.claude/skills/learning-loop/SKILL.md
|
|
44
|
+
|
|
45
|
+
## 5. 🔌 Tool & MCP Strategy
|
|
46
|
+
- Auto Tool Selection: @.claude/rules/tool-auto-selection.md
|
|
47
|
+
- Tool Strategy: @.claude/rules/tool-strategy.md
|
|
48
|
+
- MCP Auto-Usage: @.claude/rules/mcp-auto-use.md
|
|
49
|
+
- MCP Integration Guide: @.claude/docs/MCP-INTEGRATION-GUIDE.md
|
package/README.md
CHANGED
|
@@ -1,3 +1,66 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ⚡ claudify-agent
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **Enterprise-grade workflow & context optimization framework for Claude Code, Claude Desktop, and autonomous AI coding agents.**
|
|
4
|
+
|
|
5
|
+
Inspired by research-backed agent instruction patterns, **claudify-agent** acts as the deterministic bridle and operating system for Claude: preventing context bloat, eliminating repetitive LLM token waste through zero-token local hooks, and enforcing systematic plan-first development.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🚀 Quick Install via NPX
|
|
10
|
+
|
|
11
|
+
Không cần cài đặt rườm rà. Tại bất kỳ dự án mới hoặc có sẵn nào của bạn, chỉ cần mở terminal và chạy:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx claudify-agent init
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Lệnh này sẽ tự động khởi tạo:
|
|
18
|
+
- `CLAUDE.md`: File điều phối trung tâm tự động nạp bởi Claude Code CLI.
|
|
19
|
+
- `.claude/skills/`: Kho 12 cẩm nang chuyên sâu (Golang, NestJS, Concurrency/Locking, Solidity, Next.js, React...).
|
|
20
|
+
- `.claude/rules/`: 13 bộ luật tối ưu phân tầng ngữ cảnh (< 20 dòng/rule).
|
|
21
|
+
- `.claude/scripts/`: Hệ thống tự kiểm tra cú pháp, typecheck, và bảo mật tốn 0 token.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 📖 Hướng Dẫn Sử Dụng Chi Tiết (How to Use)
|
|
26
|
+
|
|
27
|
+
### Cách 1: Dùng với Claude Code CLI (Khuyên Dùng Nhất 🚀)
|
|
28
|
+
|
|
29
|
+
Sau khi chạy `npx claudify-agent init`, chỉ cần mở terminal và gõ:
|
|
30
|
+
```bash
|
|
31
|
+
claude
|
|
32
|
+
```
|
|
33
|
+
👉 Claude Code CLI sẽ tự động phát hiện và tuân thủ toàn bộ quy tắc trong `CLAUDE.md`:
|
|
34
|
+
- Tự động lập **Plan Mode** trước khi sửa từ 2 file trở lên.
|
|
35
|
+
- Tự động tra cứu kỹ năng chuyên biệt khi đụng tới backend Go, NestJS, hoặc Smart Contract.
|
|
36
|
+
- Tự chạy kiểm tra local sau khi code xong.
|
|
37
|
+
|
|
38
|
+
### Cách 2: Dùng với Claude Desktop / Claude Projects
|
|
39
|
+
|
|
40
|
+
1. Mở **Claude Desktop** $\rightarrow$ Tạo **Project** mới trỏ vào thư mục code.
|
|
41
|
+
2. Dán nội dung của [CLAUDE.md](CLAUDE.md) vào ô **Custom Instructions**.
|
|
42
|
+
3. Thêm thư mục `.claude/` vào Project Files để Claude tra cứu khi cần.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 🛠️ Kho Kỹ Năng Đầy Đủ (Included 12 Skills)
|
|
47
|
+
|
|
48
|
+
| Kỹ Năng | Đường dẫn | Trọng tâm giải quyết |
|
|
49
|
+
| :--- | :--- | :--- |
|
|
50
|
+
| **Backend Concurrency** | `.claude/skills/backend-concurrency/SKILL.md` | Chống Race conditions, Distributed Lock (Redis), Deadlock, Idempotency. |
|
|
51
|
+
| **Golang Backend** | `.claude/skills/golang-guide/SKILL.md` | Standard layout (`cmd/`, `internal/`), Worker Pool, Safe Goroutines, Context. |
|
|
52
|
+
| **NestJS Enterprise** | `.claude/skills/nestjs-guide/SKILL.md` | Module boundaries, TypeORM Transaction QueryRunner, DTO Validation. |
|
|
53
|
+
| **Solidity (Smart Contracts)** | `.claude/skills/solidity-guide/SKILL.md` | Mẫu CEI, ReentrancyGuard, tối ưu Gas EVM, Foundry/Hardhat tests. |
|
|
54
|
+
| **Next.js Guide** | `.claude/skills/nextjs-guide/SKILL.md` | App Router, Server Components & Server Actions. |
|
|
55
|
+
| **React Guide** | `.claude/skills/react-guide/SKILL.md` | Single Source of Truth, render optimization & Custom Hooks. |
|
|
56
|
+
| **Python Guide** | `.claude/skills/python-guide/SKILL.md` | FastAPI, Django, Type hints & Pydantic. |
|
|
57
|
+
| **MCP Mastery** | `.claude/skills/mcp-mastery/SKILL.md` | Kết nối và sử dụng các Model Context Protocol servers. |
|
|
58
|
+
| **Debug Optimizer** | `.claude/skills/debug-optimizer/SKILL.md` | Quy trình truy tìm nguyên nhân gốc rễ (Root Cause) 4 bước. |
|
|
59
|
+
| **Tool Selection** | `.claude/skills/tool-selection/SKILL.md` | Chiến lược chọn đúng tool nhằm giảm thiểu số lần gọi API. |
|
|
60
|
+
| **Plan Mastery** | `.claude/skills/plan-mode-mastery/SKILL.md` | Lập kế hoạch có hệ thống trước khi gõ code. |
|
|
61
|
+
| **Vite Guide** | `.claude/skills/vite-guide/SKILL.md` | Cấu hình bundling SPA tối ưu hiệu năng. |
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 📄 License
|
|
66
|
+
MIT © [mytoandeptrai](https://github.com/mytoandeptrai)
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Claudify CLI Tool
|
|
5
|
+
* Installs CLAUDE.md and .claude configuration into target projects.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
import { dirname, join, resolve } from 'path';
|
|
10
|
+
import { cp, access } from 'fs/promises';
|
|
11
|
+
import { existsSync } from 'fs';
|
|
12
|
+
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = dirname(__filename);
|
|
15
|
+
const packageRoot = resolve(__dirname, '..');
|
|
16
|
+
|
|
17
|
+
const args = process.argv.slice(2);
|
|
18
|
+
const command = args[0];
|
|
19
|
+
|
|
20
|
+
console.log('⚡ Claudify - Claude Agent & Context Optimization Toolkit\n');
|
|
21
|
+
|
|
22
|
+
if (command === 'init') {
|
|
23
|
+
const targetDir = process.cwd();
|
|
24
|
+
console.log(`📦 Initializing Claudify in: ${targetDir}`);
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
// 1. Copy CLAUDE.md
|
|
28
|
+
await cp(join(packageRoot, 'CLAUDE.md'), join(targetDir, 'CLAUDE.md'));
|
|
29
|
+
console.log(' ✅ Created CLAUDE.md (Root agent instruction guidelines)');
|
|
30
|
+
|
|
31
|
+
// 2. Copy .claude folder
|
|
32
|
+
await cp(join(packageRoot, '.claude'), join(targetDir, '.claude'), { recursive: true });
|
|
33
|
+
console.log(' ✅ Created .claude/ (Skills and automated verification scripts)');
|
|
34
|
+
|
|
35
|
+
console.log('\n🎉 Successfully initialized Claudify!');
|
|
36
|
+
console.log('👉 Next Steps:');
|
|
37
|
+
console.log(' - Review CLAUDE.md in your project root.');
|
|
38
|
+
console.log(' - Run Claude Code CLI (or open Claude Desktop) in this directory.');
|
|
39
|
+
console.log(' - Enjoy strict token minimization and deterministic local checks!');
|
|
40
|
+
} catch (err) {
|
|
41
|
+
console.error('❌ Failed to initialize:', err.message);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
console.log(`
|
|
46
|
+
Usage:
|
|
47
|
+
npx claudify init - Set up CLAUDE.md and .claude skills in current project
|
|
48
|
+
npx claudify --help - Show help options
|
|
49
|
+
`);
|
|
50
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claudify-agent",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Enterprise-grade workflow & context optimization framework for Claude Code, Claude Desktop, and AI coding agents.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "bin/cli.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"claudify-agent": "./bin/cli.js",
|
|
9
|
+
"claudify": "./bin/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"CLAUDE.md",
|
|
13
|
+
".claude",
|
|
14
|
+
"bin",
|
|
15
|
+
"README.md",
|
|
16
|
+
"package.json"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"lint": "eslint . --format=stylish",
|
|
20
|
+
"lint:fix": "eslint . --fix",
|
|
21
|
+
"typecheck": "tsc --noEmit",
|
|
22
|
+
"validate": "node .claude/scripts/auto-validate.js",
|
|
23
|
+
"security": "node .claude/scripts/security-scan.js"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"claude",
|
|
27
|
+
"claude-code",
|
|
28
|
+
"anthropic",
|
|
29
|
+
"ai-agent",
|
|
30
|
+
"mcp",
|
|
31
|
+
"developer-tools",
|
|
32
|
+
"token-optimization",
|
|
33
|
+
"context-management",
|
|
34
|
+
"golang",
|
|
35
|
+
"nestjs",
|
|
36
|
+
"solidity"
|
|
37
|
+
],
|
|
38
|
+
"author": "mytoandeptrai <mytoandn@gmail.com>",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=20.0.0"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
}
|
|
46
|
+
}
|