cmp-standards 2.0.1 → 2.4.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.
Files changed (110) hide show
  1. package/README.md +171 -101
  2. package/dist/cli/index.js +239 -7
  3. package/dist/cli/index.js.map +1 -1
  4. package/dist/dashboard/server.d.ts.map +1 -1
  5. package/dist/dashboard/server.js +203 -39
  6. package/dist/dashboard/server.js.map +1 -1
  7. package/dist/db/cloud.d.ts +174 -0
  8. package/dist/db/cloud.d.ts.map +1 -0
  9. package/dist/db/cloud.js +241 -0
  10. package/dist/db/cloud.js.map +1 -0
  11. package/dist/db/errors.d.ts +76 -0
  12. package/dist/db/errors.d.ts.map +1 -0
  13. package/dist/db/errors.js +135 -0
  14. package/dist/db/errors.js.map +1 -0
  15. package/dist/db/turso-client.d.ts +178 -0
  16. package/dist/db/turso-client.d.ts.map +1 -0
  17. package/dist/db/turso-client.js +455 -0
  18. package/dist/db/turso-client.js.map +1 -0
  19. package/dist/db/upstash-client.d.ts +161 -0
  20. package/dist/db/upstash-client.d.ts.map +1 -0
  21. package/dist/db/upstash-client.js +325 -0
  22. package/dist/db/upstash-client.js.map +1 -0
  23. package/dist/hooks/cloud-post-tool-use.d.ts +30 -0
  24. package/dist/hooks/cloud-post-tool-use.d.ts.map +1 -0
  25. package/dist/hooks/cloud-post-tool-use.js +116 -0
  26. package/dist/hooks/cloud-post-tool-use.js.map +1 -0
  27. package/dist/hooks/cloud-pre-tool-use.d.ts +19 -0
  28. package/dist/hooks/cloud-pre-tool-use.d.ts.map +1 -0
  29. package/dist/hooks/cloud-pre-tool-use.js +149 -0
  30. package/dist/hooks/cloud-pre-tool-use.js.map +1 -0
  31. package/dist/hooks/cloud-session-start.d.ts +20 -0
  32. package/dist/hooks/cloud-session-start.d.ts.map +1 -0
  33. package/dist/hooks/cloud-session-start.js +130 -0
  34. package/dist/hooks/cloud-session-start.js.map +1 -0
  35. package/dist/hooks/index.d.ts +3 -0
  36. package/dist/hooks/index.d.ts.map +1 -1
  37. package/dist/hooks/index.js +5 -0
  38. package/dist/hooks/index.js.map +1 -1
  39. package/dist/hooks/memory-checkpoint.d.ts.map +1 -1
  40. package/dist/hooks/memory-checkpoint.js +12 -20
  41. package/dist/hooks/memory-checkpoint.js.map +1 -1
  42. package/dist/hooks/pre-tool-use.d.ts +2 -8
  43. package/dist/hooks/pre-tool-use.d.ts.map +1 -1
  44. package/dist/hooks/pre-tool-use.js +7 -106
  45. package/dist/hooks/pre-tool-use.js.map +1 -1
  46. package/dist/hooks/session-start.d.ts.map +1 -1
  47. package/dist/hooks/session-start.js +15 -6
  48. package/dist/hooks/session-start.js.map +1 -1
  49. package/dist/index.d.ts +10 -0
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +14 -1
  52. package/dist/index.js.map +1 -1
  53. package/dist/mcp/server.d.ts.map +1 -1
  54. package/dist/mcp/server.js +223 -0
  55. package/dist/mcp/server.js.map +1 -1
  56. package/dist/schema/tracking.d.ts +644 -0
  57. package/dist/schema/tracking.d.ts.map +1 -0
  58. package/dist/schema/tracking.js +204 -0
  59. package/dist/schema/tracking.js.map +1 -0
  60. package/dist/services/ProjectScaffold.d.ts.map +1 -1
  61. package/dist/services/ProjectScaffold.js +33 -5
  62. package/dist/services/ProjectScaffold.js.map +1 -1
  63. package/dist/services/TaskTracker.d.ts +1 -1
  64. package/dist/services/TaskTracker.d.ts.map +1 -1
  65. package/dist/services/TaskTracker.js +4 -8
  66. package/dist/services/TaskTracker.js.map +1 -1
  67. package/dist/services/WorkPlanManager.d.ts +1 -1
  68. package/dist/services/WorkPlanManager.d.ts.map +1 -1
  69. package/dist/services/WorkPlanManager.js +8 -14
  70. package/dist/services/WorkPlanManager.js.map +1 -1
  71. package/dist/services/auto-inject.d.ts +1 -0
  72. package/dist/services/auto-inject.d.ts.map +1 -1
  73. package/dist/services/auto-inject.js +12 -17
  74. package/dist/services/auto-inject.js.map +1 -1
  75. package/dist/services/cross-project-sync.d.ts +2 -0
  76. package/dist/services/cross-project-sync.d.ts.map +1 -1
  77. package/dist/services/cross-project-sync.js +26 -21
  78. package/dist/services/cross-project-sync.js.map +1 -1
  79. package/dist/services/memory-consolidation.d.ts.map +1 -1
  80. package/dist/services/memory-consolidation.js +30 -27
  81. package/dist/services/memory-consolidation.js.map +1 -1
  82. package/dist/utils/env-loader.d.ts +41 -0
  83. package/dist/utils/env-loader.d.ts.map +1 -0
  84. package/dist/utils/env-loader.js +78 -0
  85. package/dist/utils/env-loader.js.map +1 -0
  86. package/dist/utils/git.d.ts +52 -0
  87. package/dist/utils/git.d.ts.map +1 -0
  88. package/dist/utils/git.js +267 -0
  89. package/dist/utils/git.js.map +1 -0
  90. package/dist/utils/paths.d.ts +39 -5
  91. package/dist/utils/paths.d.ts.map +1 -1
  92. package/dist/utils/paths.js +88 -7
  93. package/dist/utils/paths.js.map +1 -1
  94. package/package.json +8 -2
  95. package/standards/README.md +50 -0
  96. package/standards/experts/expert-routing.md +215 -0
  97. package/standards/general/code-quality.md +86 -0
  98. package/standards/general/memory-usage.md +205 -0
  99. package/standards/general/sync-workflow.md +235 -0
  100. package/standards/general/workflow.md +82 -0
  101. package/standards/hooks/mandatory-tracking.md +446 -0
  102. package/standards/infrastructure/cloud-database.md +287 -0
  103. package/standards/mcp/server-design.md +243 -0
  104. package/standards/mcp/tool-patterns.md +354 -0
  105. package/standards/skills/skill-structure.md +286 -0
  106. package/standards/skills/workflow-design.md +323 -0
  107. package/standards/tools/tool-design.md +297 -0
  108. package/templates/claude-settings.json +72 -0
  109. package/templates/memory-config.json +2 -28
  110. package/templates/skills/continue.md +205 -0
@@ -0,0 +1,354 @@
1
+ # Patrones de Diseño para MCP Tools
2
+
3
+ ## Patrón: CRUD Básico
4
+
5
+ Para entidades que necesitan operaciones estándar:
6
+
7
+ ```typescript
8
+ // tools/entity.ts
9
+ export const entityTools = [
10
+ {
11
+ name: 'entity_create',
12
+ description: 'Create a new entity',
13
+ inputSchema: {
14
+ type: 'object',
15
+ properties: {
16
+ title: { type: 'string' },
17
+ data: { type: 'object' }
18
+ },
19
+ required: ['title']
20
+ }
21
+ },
22
+ {
23
+ name: 'entity_get',
24
+ description: 'Get entity by ID',
25
+ inputSchema: {
26
+ type: 'object',
27
+ properties: {
28
+ id: { type: 'string' }
29
+ },
30
+ required: ['id']
31
+ }
32
+ },
33
+ {
34
+ name: 'entity_list',
35
+ description: 'List entities with optional filters',
36
+ inputSchema: {
37
+ type: 'object',
38
+ properties: {
39
+ limit: { type: 'number', default: 10 },
40
+ filter: { type: 'object' }
41
+ }
42
+ }
43
+ },
44
+ {
45
+ name: 'entity_update',
46
+ description: 'Update entity by ID',
47
+ inputSchema: {
48
+ type: 'object',
49
+ properties: {
50
+ id: { type: 'string' },
51
+ updates: { type: 'object' }
52
+ },
53
+ required: ['id', 'updates']
54
+ }
55
+ },
56
+ {
57
+ name: 'entity_delete',
58
+ description: 'Delete entity by ID',
59
+ inputSchema: {
60
+ type: 'object',
61
+ properties: {
62
+ id: { type: 'string' }
63
+ },
64
+ required: ['id']
65
+ }
66
+ }
67
+ ]
68
+ ```
69
+
70
+ ## Patrón: Search Tool
71
+
72
+ Para búsquedas con múltiples criterios:
73
+
74
+ ```typescript
75
+ {
76
+ name: 'memory_search',
77
+ description: 'Search memories by content, domain, tags, or date range',
78
+ inputSchema: {
79
+ type: 'object',
80
+ properties: {
81
+ query: {
82
+ type: 'string',
83
+ description: 'Text to search in title and body'
84
+ },
85
+ domain: {
86
+ type: 'string',
87
+ description: 'Filter by domain (e.g., "architecture", "performance")'
88
+ },
89
+ tags: {
90
+ type: 'array',
91
+ items: { type: 'string' },
92
+ description: 'Filter by tags (AND logic)'
93
+ },
94
+ dateFrom: {
95
+ type: 'string',
96
+ description: 'ISO date string for start range'
97
+ },
98
+ dateTo: {
99
+ type: 'string',
100
+ description: 'ISO date string for end range'
101
+ },
102
+ limit: {
103
+ type: 'number',
104
+ default: 10,
105
+ description: 'Max results to return'
106
+ }
107
+ }
108
+ }
109
+ }
110
+ ```
111
+
112
+ **Handler Pattern:**
113
+
114
+ ```typescript
115
+ async function handleSearch(args: SearchArgs) {
116
+ const conditions: SQL[] = []
117
+
118
+ if (args.query) {
119
+ conditions.push(
120
+ or(
121
+ like(memories.title, `%${args.query}%`),
122
+ like(memories.body, `%${args.query}%`)
123
+ )
124
+ )
125
+ }
126
+
127
+ if (args.domain) {
128
+ conditions.push(eq(memories.domain, args.domain))
129
+ }
130
+
131
+ // Build query with all conditions
132
+ const results = await db.query.memories.findMany({
133
+ where: and(...conditions),
134
+ limit: args.limit ?? 10,
135
+ orderBy: desc(memories.createdAt)
136
+ })
137
+
138
+ return results
139
+ }
140
+ ```
141
+
142
+ ## Patrón: Batch Operations
143
+
144
+ Para operaciones sobre múltiples items:
145
+
146
+ ```typescript
147
+ {
148
+ name: 'tasks_batch_update',
149
+ description: 'Update status of multiple tasks at once',
150
+ inputSchema: {
151
+ type: 'object',
152
+ properties: {
153
+ ids: {
154
+ type: 'array',
155
+ items: { type: 'string' },
156
+ description: 'Task IDs to update'
157
+ },
158
+ status: {
159
+ type: 'string',
160
+ enum: ['pending', 'in_progress', 'completed']
161
+ }
162
+ },
163
+ required: ['ids', 'status']
164
+ }
165
+ }
166
+ ```
167
+
168
+ **Handler con Promise.all:**
169
+
170
+ ```typescript
171
+ async function handleBatchUpdate(args: BatchUpdateArgs) {
172
+ const results = await Promise.allSettled(
173
+ args.ids.map(id =>
174
+ db.update(tasks)
175
+ .set({ status: args.status, updatedAt: new Date() })
176
+ .where(eq(tasks.id, id))
177
+ )
178
+ )
179
+
180
+ const succeeded = results.filter(r => r.status === 'fulfilled').length
181
+ const failed = results.filter(r => r.status === 'rejected').length
182
+
183
+ return {
184
+ total: args.ids.length,
185
+ succeeded,
186
+ failed
187
+ }
188
+ }
189
+ ```
190
+
191
+ ## Patrón: Aggregation Tool
192
+
193
+ Para datos agregados/estadísticas:
194
+
195
+ ```typescript
196
+ {
197
+ name: 'analytics_summary',
198
+ description: 'Get aggregated analytics for a time period',
199
+ inputSchema: {
200
+ type: 'object',
201
+ properties: {
202
+ period: {
203
+ type: 'string',
204
+ enum: ['day', 'week', 'month'],
205
+ default: 'week'
206
+ },
207
+ metrics: {
208
+ type: 'array',
209
+ items: {
210
+ type: 'string',
211
+ enum: ['memories_created', 'patterns_detected', 'tasks_completed']
212
+ }
213
+ }
214
+ }
215
+ }
216
+ }
217
+ ```
218
+
219
+ ## Patrón: Composite Tool
220
+
221
+ Cuando una operación necesita múltiples pasos:
222
+
223
+ ```typescript
224
+ {
225
+ name: 'session_init',
226
+ description: 'Initialize a new work session with context loading',
227
+ inputSchema: {
228
+ type: 'object',
229
+ properties: {
230
+ projectPath: { type: 'string' },
231
+ loadMemories: { type: 'boolean', default: true },
232
+ checkPatterns: { type: 'boolean', default: true }
233
+ },
234
+ required: ['projectPath']
235
+ }
236
+ }
237
+ ```
238
+
239
+ **Handler:**
240
+
241
+ ```typescript
242
+ async function handleSessionInit(args: SessionInitArgs) {
243
+ const results: Record<string, unknown> = {}
244
+
245
+ // Step 1: Load project config
246
+ results.config = await loadProjectConfig(args.projectPath)
247
+
248
+ // Step 2: Parallel operations
249
+ const [memories, patterns] = await Promise.all([
250
+ args.loadMemories ? loadRecentMemories() : [],
251
+ args.checkPatterns ? detectPatterns() : []
252
+ ])
253
+
254
+ results.memories = memories
255
+ results.patterns = patterns
256
+
257
+ // Step 3: Generate context summary
258
+ results.summary = generateContextSummary(results)
259
+
260
+ return results
261
+ }
262
+ ```
263
+
264
+ ## Patrón: Validation Tool
265
+
266
+ Para validar datos antes de operaciones costosas:
267
+
268
+ ```typescript
269
+ {
270
+ name: 'schema_validate',
271
+ description: 'Validate data against a schema before processing',
272
+ inputSchema: {
273
+ type: 'object',
274
+ properties: {
275
+ schemaName: { type: 'string' },
276
+ data: { type: 'object' }
277
+ },
278
+ required: ['schemaName', 'data']
279
+ }
280
+ }
281
+ ```
282
+
283
+ ## Anti-Patterns
284
+
285
+ ### NO: Tools Demasiado Genéricas
286
+
287
+ ```typescript
288
+ // MAL - demasiado genérica
289
+ {
290
+ name: 'do_database_operation',
291
+ inputSchema: {
292
+ properties: {
293
+ operation: { type: 'string' }, // "insert", "update", "delete"
294
+ table: { type: 'string' },
295
+ data: { type: 'object' }
296
+ }
297
+ }
298
+ }
299
+
300
+ // BIEN - específica y clara
301
+ {
302
+ name: 'memory_create',
303
+ // ...
304
+ }
305
+ ```
306
+
307
+ ### NO: Tools con Demasiados Parámetros
308
+
309
+ ```typescript
310
+ // MAL - 15 parámetros
311
+ {
312
+ name: 'complex_search',
313
+ inputSchema: {
314
+ properties: {
315
+ // ... 15 propiedades
316
+ }
317
+ }
318
+ }
319
+
320
+ // BIEN - dividir en tools más simples
321
+ {
322
+ name: 'search_by_content',
323
+ // 2-3 parámetros
324
+ }
325
+ {
326
+ name: 'search_by_metadata',
327
+ // 2-3 parámetros
328
+ }
329
+ ```
330
+
331
+ ### NO: Efectos Secundarios Ocultos
332
+
333
+ ```typescript
334
+ // MAL - hace más de lo que dice
335
+ async function handleGetMemory(id: string) {
336
+ const memory = await getMemory(id)
337
+ await updateAccessCount(id) // Efecto secundario oculto
338
+ await logAccess(id) // Otro efecto secundario
339
+ return memory
340
+ }
341
+
342
+ // BIEN - solo hace lo que dice
343
+ async function handleGetMemory(id: string) {
344
+ return await getMemory(id)
345
+ }
346
+ ```
347
+
348
+ ## Tips de Rendimiento
349
+
350
+ 1. **Paginación obligatoria** para list operations
351
+ 2. **Índices** en campos de búsqueda
352
+ 3. **Caché** para datos que no cambian frecuentemente
353
+ 4. **Parallel queries** con Promise.all cuando son independientes
354
+ 5. **Streaming** para respuestas grandes (futuro de MCP)
@@ -0,0 +1,286 @@
1
+ # Estructura de Skills
2
+
3
+ ## Qué es una Skill
4
+
5
+ Una **Skill** es un conjunto de instrucciones que Claude Code puede ejecutar. Se invocan con `/skill-name` y expanden a un prompt completo.
6
+
7
+ ## Ubicaciones
8
+
9
+ ```
10
+ .claude/
11
+ ├── skills/ # Project skills
12
+ │ ├── commit.md
13
+ │ ├── review-pr.md
14
+ │ └── create-component.md
15
+ └── settings.json # Skill registration
16
+
17
+ ~/.claude/
18
+ └── skills/ # Global skills
19
+ └── my-global-skill.md
20
+ ```
21
+
22
+ ## Anatomía de una Skill
23
+
24
+ ```markdown
25
+ ---
26
+ name: create-component
27
+ description: Create a new React component with tests
28
+ arguments:
29
+ - name: componentName
30
+ description: Name of the component
31
+ required: true
32
+ - name: type
33
+ description: Component type
34
+ enum: [page, feature, ui]
35
+ default: feature
36
+ ---
37
+
38
+ # Create Component: {{componentName}}
39
+
40
+ ## Instructions
41
+
42
+ 1. Create the component file at `src/components/{{type}}/{{componentName}}.tsx`
43
+ 2. Create the test file at `src/components/{{type}}/{{componentName}}.test.tsx`
44
+ 3. Export from barrel file
45
+
46
+ ## Component Template
47
+
48
+ ```tsx
49
+ export function {{componentName}}() {
50
+ return <div>{{componentName}}</div>
51
+ }
52
+ ```
53
+
54
+ ## Test Template
55
+
56
+ ```tsx
57
+ import { render, screen } from '@testing-library/react'
58
+ import { {{componentName}} } from './{{componentName}}'
59
+
60
+ describe('{{componentName}}', () => {
61
+ it('renders', () => {
62
+ render(<{{componentName}} />)
63
+ expect(screen.getByText('{{componentName}}')).toBeInTheDocument()
64
+ })
65
+ })
66
+ ```
67
+ ```
68
+
69
+ ## Frontmatter
70
+
71
+ ```yaml
72
+ ---
73
+ name: skill-name # Required: kebab-case
74
+ description: Brief desc # Required: <100 chars
75
+ arguments: # Optional: arguments
76
+ - name: argName
77
+ description: What it is
78
+ required: true/false
79
+ default: value
80
+ enum: [opt1, opt2]
81
+ ---
82
+ ```
83
+
84
+ ## Variables
85
+
86
+ Usar `{{variable}}` para interpolación:
87
+
88
+ ```markdown
89
+ # Task: {{taskName}}
90
+
91
+ Working on component {{componentName}} in {{directory}}.
92
+ ```
93
+
94
+ ## Categorías de Skills
95
+
96
+ ### 1. Workflow Skills
97
+
98
+ Automatizan flujos de trabajo comunes:
99
+
100
+ ```markdown
101
+ ---
102
+ name: commit
103
+ description: Create a git commit with conventional format
104
+ ---
105
+
106
+ # Commit Changes
107
+
108
+ 1. Run `git status` to see changes
109
+ 2. Run `git diff` to review changes
110
+ 3. Create commit message following conventional commits
111
+ 4. Execute `git commit -m "message"`
112
+ ```
113
+
114
+ ### 2. Generator Skills
115
+
116
+ Crean código/archivos:
117
+
118
+ ```markdown
119
+ ---
120
+ name: create-router
121
+ description: Create a new TRPC router
122
+ arguments:
123
+ - name: routerName
124
+ required: true
125
+ ---
126
+
127
+ # Create Router: {{routerName}}
128
+
129
+ Create file at `src/server/api/routers/{{routerName}}.ts`
130
+ ```
131
+
132
+ ### 3. Analysis Skills
133
+
134
+ Analizan código/proyecto:
135
+
136
+ ```markdown
137
+ ---
138
+ name: review-pr
139
+ description: Review pull request changes
140
+ arguments:
141
+ - name: prNumber
142
+ required: true
143
+ ---
144
+
145
+ # Review PR #{{prNumber}}
146
+
147
+ 1. Fetch PR changes
148
+ 2. Analyze for security issues
149
+ 3. Check code quality
150
+ 4. Provide feedback
151
+ ```
152
+
153
+ ### 4. Documentation Skills
154
+
155
+ Generan documentación:
156
+
157
+ ```markdown
158
+ ---
159
+ name: document-api
160
+ description: Generate API documentation
161
+ ---
162
+
163
+ # Document API
164
+
165
+ 1. Scan all TRPC routers
166
+ 2. Extract procedure signatures
167
+ 3. Generate markdown docs
168
+ ```
169
+
170
+ ## Registrar Skills
171
+
172
+ En `.claude/settings.json`:
173
+
174
+ ```json
175
+ {
176
+ "skills": [
177
+ {
178
+ "name": "create-component",
179
+ "file": ".claude/skills/create-component.md"
180
+ },
181
+ {
182
+ "name": "commit",
183
+ "file": ".claude/skills/commit.md"
184
+ }
185
+ ]
186
+ }
187
+ ```
188
+
189
+ ## Best Practices
190
+
191
+ ### 1. Instrucciones Claras
192
+
193
+ ```markdown
194
+ # BIEN
195
+ 1. First, read the existing component at `src/components/Button.tsx`
196
+ 2. Create new variant following the same pattern
197
+ 3. Add to exports in `src/components/index.ts`
198
+
199
+ # MAL
200
+ Create a component somehow and put it somewhere.
201
+ ```
202
+
203
+ ### 2. Contexto Necesario
204
+
205
+ ```markdown
206
+ # BIEN
207
+ ## Context
208
+ This project uses:
209
+ - React 19 with Server Components
210
+ - Tailwind CSS for styling
211
+ - Shadcn UI components
212
+
213
+ ## Task
214
+ Create component following these conventions.
215
+
216
+ # MAL
217
+ Create a component.
218
+ ```
219
+
220
+ ### 3. Ejemplos Concretos
221
+
222
+ ```markdown
223
+ ## Example
224
+
225
+ Input: `/create-component UserProfile page`
226
+
227
+ Creates:
228
+ - `src/components/page/UserProfile.tsx`
229
+ - `src/components/page/UserProfile.test.tsx`
230
+ - Updates `src/components/page/index.ts`
231
+ ```
232
+
233
+ ### 4. Manejo de Errores
234
+
235
+ ```markdown
236
+ ## If errors occur
237
+
238
+ 1. If component already exists: ask user to confirm overwrite
239
+ 2. If directory missing: create it
240
+ 3. If imports fail: check barrel exports exist
241
+ ```
242
+
243
+ ## Anti-Patterns
244
+
245
+ ### NO: Skills demasiado genéricas
246
+
247
+ ```markdown
248
+ # MAL
249
+ ---
250
+ name: do-stuff
251
+ description: Does things
252
+ ---
253
+
254
+ Do whatever the user wants.
255
+ ```
256
+
257
+ ### NO: Sin estructura clara
258
+
259
+ ```markdown
260
+ # MAL
261
+ Create component and test and export and also maybe some types.
262
+ ```
263
+
264
+ ### NO: Hardcoded values
265
+
266
+ ```markdown
267
+ # MAL
268
+ Create file at `/Users/carlos/project/src/Component.tsx`
269
+
270
+ # BIEN
271
+ Create file at `src/components/{{componentName}}.tsx`
272
+ ```
273
+
274
+ ## Testing Skills
275
+
276
+ Antes de registrar una skill:
277
+
278
+ 1. Probar con diferentes argumentos
279
+ 2. Verificar que maneja edge cases
280
+ 3. Confirmar que sigue los estándares del proyecto
281
+
282
+ ```bash
283
+ # Test skill manually
284
+ /create-component TestComponent feature
285
+ # Verify output matches expectations
286
+ ```