@sylphx/flow 1.0.5 → 1.1.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/CHANGELOG.md +46 -0
- package/assets/agents/coder.md +162 -0
- package/assets/agents/orchestrator.md +416 -0
- package/assets/agents/reviewer.md +192 -0
- package/assets/agents/writer.md +364 -0
- package/assets/icons/flow-notification-icon.png +0 -0
- package/assets/icons/flow-notification-icon.svg +17 -0
- package/assets/knowledge/data/sql.md +216 -0
- package/assets/knowledge/guides/saas-template.md +85 -0
- package/assets/knowledge/guides/system-prompt.md +344 -0
- package/assets/knowledge/guides/tech-stack.md +92 -0
- package/assets/knowledge/guides/ui-ux.md +44 -0
- package/assets/knowledge/stacks/nextjs-app.md +165 -0
- package/assets/knowledge/stacks/node-api.md +220 -0
- package/assets/knowledge/stacks/react-app.md +232 -0
- package/assets/knowledge/universal/deployment.md +109 -0
- package/assets/knowledge/universal/performance.md +121 -0
- package/assets/knowledge/universal/security.md +79 -0
- package/assets/knowledge/universal/testing.md +111 -0
- package/assets/output-styles/silent.md +23 -0
- package/assets/rules/code-standards.md +346 -0
- package/assets/rules/core.md +189 -0
- package/assets/slash-commands/commit.md +23 -0
- package/assets/slash-commands/context.md +112 -0
- package/assets/slash-commands/explain.md +35 -0
- package/assets/slash-commands/review.md +39 -0
- package/assets/slash-commands/test.md +30 -0
- package/package.json +4 -2
- package/src/services/smart-config-service.ts +15 -131
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Code Standards
|
|
3
|
+
description: Shared coding standards for Coder and Reviewer agents
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# CODE STANDARDS
|
|
7
|
+
|
|
8
|
+
## Task Approach
|
|
9
|
+
|
|
10
|
+
### Understanding Depth
|
|
11
|
+
- **Shallow OK**: Well-defined, low-risk, established patterns → Implement
|
|
12
|
+
- **Deep required**: Ambiguous, high-risk, novel, irreversible → Investigate first
|
|
13
|
+
|
|
14
|
+
### Complexity Navigation
|
|
15
|
+
- **Mechanical**: Known patterns → Execute fast
|
|
16
|
+
- **Analytical**: Multiple components → Design then build
|
|
17
|
+
- **Emergent**: Unknown domain → Research, prototype, design, build
|
|
18
|
+
|
|
19
|
+
### State Awareness
|
|
20
|
+
- **Flow**: Clear path, tests pass → Push forward
|
|
21
|
+
- **Friction**: Hard to implement, messy → Reassess, simplify
|
|
22
|
+
- **Uncertain**: Missing info → Assume reasonably, document, continue
|
|
23
|
+
|
|
24
|
+
**Signals to pause**: Can't explain simply, too many caveats, hesitant without reason, over-confident without alternatives.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Structure
|
|
29
|
+
|
|
30
|
+
**Feature-first over layer-first**: Organize by functionality, not type.
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
✅ features/auth/{api, hooks, components, utils}
|
|
34
|
+
❌ {api, hooks, components, utils}/auth
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**File size limits**:
|
|
38
|
+
- Component: <250 lines
|
|
39
|
+
- Module: <300 lines
|
|
40
|
+
- If larger → split by feature or responsibility
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Programming Patterns
|
|
45
|
+
|
|
46
|
+
**Named args (3+ params)**:
|
|
47
|
+
```typescript
|
|
48
|
+
// ✅ Self-documenting
|
|
49
|
+
updateUser({ id, email, role })
|
|
50
|
+
|
|
51
|
+
// ❌ Positional
|
|
52
|
+
updateUser(id, email, role)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Functional composition**:
|
|
56
|
+
- Pure functions where possible
|
|
57
|
+
- Immutable data structures
|
|
58
|
+
- Explicit side effects (mark with comments or types)
|
|
59
|
+
|
|
60
|
+
**Composition over inheritance**:
|
|
61
|
+
- Prefer mixins, HOCs, hooks
|
|
62
|
+
- Dependency injection > tight coupling
|
|
63
|
+
|
|
64
|
+
**Declarative over imperative**:
|
|
65
|
+
```typescript
|
|
66
|
+
// ✅ Declarative
|
|
67
|
+
const active = users.filter(u => u.isActive)
|
|
68
|
+
|
|
69
|
+
// ❌ Imperative
|
|
70
|
+
const active = []
|
|
71
|
+
for (let i = 0; i < users.length; i++) {
|
|
72
|
+
if (users[i].isActive) active.push(users[i])
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Event-driven when appropriate**:
|
|
77
|
+
- Decouple components through events/messages
|
|
78
|
+
- Pub/sub for cross-cutting concerns
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Quality Standards
|
|
83
|
+
|
|
84
|
+
**YAGNI**: Build what's needed now, not hypothetical futures.
|
|
85
|
+
|
|
86
|
+
**KISS**: Choose simple solutions over complex ones.
|
|
87
|
+
|
|
88
|
+
**DRY**: Extract duplication on 3rd occurrence. Balance with readability.
|
|
89
|
+
|
|
90
|
+
**Single Responsibility**: One reason to change per module.
|
|
91
|
+
|
|
92
|
+
**Dependency Inversion**: Depend on abstractions, not implementations.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Code Quality Checklist
|
|
97
|
+
|
|
98
|
+
**Naming**:
|
|
99
|
+
- [ ] Functions: verbs (getUserById, calculateTotal)
|
|
100
|
+
- [ ] Booleans: is/has/can (isActive, hasPermission)
|
|
101
|
+
- [ ] Classes: nouns (UserService, AuthManager)
|
|
102
|
+
- [ ] Constants: UPPER_SNAKE_CASE
|
|
103
|
+
- [ ] No abbreviations unless universally known (req, res ok; usr, calc not ok)
|
|
104
|
+
|
|
105
|
+
**Testing**:
|
|
106
|
+
- [ ] Critical paths: 100% coverage
|
|
107
|
+
- [ ] Business logic: 80%+ coverage
|
|
108
|
+
- [ ] Edge cases explicitly tested
|
|
109
|
+
- [ ] Error paths tested
|
|
110
|
+
- [ ] Test names describe behavior, not implementation
|
|
111
|
+
|
|
112
|
+
**Comments**:
|
|
113
|
+
- [ ] Explain WHY, not WHAT
|
|
114
|
+
- [ ] Complex logic has reasoning
|
|
115
|
+
- [ ] Non-obvious decisions documented
|
|
116
|
+
- [ ] TODOs forbidden (implement or delete)
|
|
117
|
+
|
|
118
|
+
**Type Safety**:
|
|
119
|
+
- [ ] Make illegal states unrepresentable
|
|
120
|
+
- [ ] No `any` without justification
|
|
121
|
+
- [ ] Null/undefined handled explicitly
|
|
122
|
+
- [ ] Union types over loose types
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Security Standards
|
|
127
|
+
|
|
128
|
+
**Input Validation**:
|
|
129
|
+
- Validate at boundaries (API, forms, file uploads)
|
|
130
|
+
- Whitelist > blacklist
|
|
131
|
+
- Sanitize before storage/display
|
|
132
|
+
- Use schema validation (Zod, Yup)
|
|
133
|
+
|
|
134
|
+
**Authentication/Authorization**:
|
|
135
|
+
- Auth required by default (opt-in to public)
|
|
136
|
+
- Deny by default
|
|
137
|
+
- Check permissions at every entry point
|
|
138
|
+
- Never trust client-side validation
|
|
139
|
+
|
|
140
|
+
**Data Protection**:
|
|
141
|
+
- Never log: passwords, tokens, API keys, PII
|
|
142
|
+
- Encrypt sensitive data at rest
|
|
143
|
+
- Use HTTPS only
|
|
144
|
+
- Secure cookie flags (httpOnly, secure, sameSite)
|
|
145
|
+
|
|
146
|
+
**Risk Mitigation**:
|
|
147
|
+
- Include rollback plan for risky changes
|
|
148
|
+
- Feature flags for gradual rollout
|
|
149
|
+
- Circuit breakers for external services
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Error Handling
|
|
154
|
+
|
|
155
|
+
**At Boundaries**:
|
|
156
|
+
```typescript
|
|
157
|
+
// ✅ Handle explicitly
|
|
158
|
+
try {
|
|
159
|
+
const data = await fetchUser(id)
|
|
160
|
+
return Ok(data)
|
|
161
|
+
} catch (error) {
|
|
162
|
+
logger.error('Failed to fetch user', { id, error })
|
|
163
|
+
return Err(new UserNotFoundError(id))
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// ❌ Let it bubble silently
|
|
167
|
+
const data = await fetchUser(id)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Expected Failures**:
|
|
171
|
+
- Use Result/Either types
|
|
172
|
+
- Never use exceptions for control flow
|
|
173
|
+
- Return errors as values
|
|
174
|
+
|
|
175
|
+
**Logging**:
|
|
176
|
+
- Include context (user id, request id, relevant data)
|
|
177
|
+
- Actionable messages (what failed, what to check)
|
|
178
|
+
- Appropriate severity (debug, info, warn, error)
|
|
179
|
+
- Never mask failures
|
|
180
|
+
|
|
181
|
+
**Retry Logic**:
|
|
182
|
+
- Transient failures (network, rate limits) → retry with exponential backoff
|
|
183
|
+
- Permanent failures (validation, auth) → fail fast
|
|
184
|
+
- Max retries: 3-5 with jitter
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Performance Patterns
|
|
189
|
+
|
|
190
|
+
**Query Optimization**:
|
|
191
|
+
```typescript
|
|
192
|
+
// ❌ N+1 queries
|
|
193
|
+
for (const user of users) {
|
|
194
|
+
user.posts = await db.posts.findByUserId(user.id)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// ✅ Batch/Join
|
|
198
|
+
const userIds = users.map(u => u.id)
|
|
199
|
+
const posts = await db.posts.findByUserIds(userIds)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**Algorithm Complexity**:
|
|
203
|
+
- O(n²) in hot paths → reconsider algorithm
|
|
204
|
+
- Nested loops on large datasets → use hash maps
|
|
205
|
+
- Repeated calculations → memoize
|
|
206
|
+
|
|
207
|
+
**Data Transfer**:
|
|
208
|
+
- Large payloads → pagination or streaming
|
|
209
|
+
- API responses → only return needed fields
|
|
210
|
+
- Images/assets → lazy load, CDN
|
|
211
|
+
|
|
212
|
+
**When to Optimize**:
|
|
213
|
+
- Only with data showing bottleneck
|
|
214
|
+
- Profile before optimizing
|
|
215
|
+
- Measure impact after changes
|
|
216
|
+
- No premature optimization
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Refactoring Triggers
|
|
221
|
+
|
|
222
|
+
**Extract function when**:
|
|
223
|
+
- 3rd duplication appears
|
|
224
|
+
- Function >20 lines
|
|
225
|
+
- Function has >3 levels of nesting
|
|
226
|
+
- Cognitive load high (hard to understand)
|
|
227
|
+
|
|
228
|
+
**Extract module when**:
|
|
229
|
+
- File >300 lines
|
|
230
|
+
- Multiple unrelated responsibilities
|
|
231
|
+
- Difficult to name clearly
|
|
232
|
+
|
|
233
|
+
**Immediate refactor signals**:
|
|
234
|
+
- Thinking "I'll clean this later" → Clean NOW
|
|
235
|
+
- Adding TODO → Implement NOW
|
|
236
|
+
- Copy-pasting code → Extract NOW
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Anti-Patterns
|
|
241
|
+
|
|
242
|
+
**Technical Debt Rationalization**:
|
|
243
|
+
- ❌ "I'll clean this later" → You won't
|
|
244
|
+
- ❌ "Just one more TODO" → Compounds
|
|
245
|
+
- ❌ "Tests slow me down" → Bugs slow more
|
|
246
|
+
- ✅ Refactor AS you make it work, not after
|
|
247
|
+
|
|
248
|
+
**Reinventing the Wheel**:
|
|
249
|
+
Before ANY feature: research best practices + search codebase + check package registry + check framework built-ins.
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
// ❌ Don't: Custom Result type
|
|
253
|
+
// ✅ Do: import { Result } from 'neverthrow'
|
|
254
|
+
|
|
255
|
+
// ❌ Don't: Custom validation
|
|
256
|
+
// ✅ Do: import { z } from 'zod'
|
|
257
|
+
|
|
258
|
+
// ❌ Don't: Custom date formatting
|
|
259
|
+
// ✅ Do: import { format } from 'date-fns'
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**Premature Abstraction**:
|
|
263
|
+
- ❌ Creating interfaces before 2nd use case
|
|
264
|
+
- ❌ Generic solutions for specific problems
|
|
265
|
+
- ✅ Solve specific problem first, extract when pattern emerges
|
|
266
|
+
|
|
267
|
+
**Copy-Paste Without Understanding**:
|
|
268
|
+
- ❌ Stack Overflow → paste → hope it works
|
|
269
|
+
- ✅ Stack Overflow → understand → adapt to context
|
|
270
|
+
|
|
271
|
+
**Working Around Errors**:
|
|
272
|
+
- ❌ Suppress error, add fallback
|
|
273
|
+
- ✅ Fix root cause
|
|
274
|
+
|
|
275
|
+
**God Objects**:
|
|
276
|
+
- ❌ One class/module does everything
|
|
277
|
+
- ✅ Small, focused modules with clear responsibilities
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Code Smells (Immediate Action Required)
|
|
282
|
+
|
|
283
|
+
**Complexity Smells**:
|
|
284
|
+
- [ ] Function >20 lines → extract
|
|
285
|
+
- [ ] >3 levels of nesting → flatten or extract
|
|
286
|
+
- [ ] >5 parameters → use object or split function
|
|
287
|
+
- [ ] Deeply nested ternaries → use if/else or early returns
|
|
288
|
+
|
|
289
|
+
**Coupling Smells**:
|
|
290
|
+
- [ ] Circular dependencies → redesign
|
|
291
|
+
- [ ] Import chains >3 levels → reconsider architecture
|
|
292
|
+
- [ ] Tight coupling to external APIs → add adapter layer
|
|
293
|
+
|
|
294
|
+
**Data Smells**:
|
|
295
|
+
- [ ] Mutable shared state → make immutable or encapsulate
|
|
296
|
+
- [ ] Global variables → dependency injection
|
|
297
|
+
- [ ] Magic numbers → named constants
|
|
298
|
+
- [ ] Stringly typed → use enums/types
|
|
299
|
+
|
|
300
|
+
**Naming Smells**:
|
|
301
|
+
- [ ] Generic names (data, info, manager, utils) → be specific
|
|
302
|
+
- [ ] Misleading names → rename immediately
|
|
303
|
+
- [ ] Inconsistent naming → align with conventions
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## Data Handling
|
|
308
|
+
|
|
309
|
+
**Self-Healing at Read**:
|
|
310
|
+
```typescript
|
|
311
|
+
function loadConfig(raw: unknown): Config {
|
|
312
|
+
// 1. Validate
|
|
313
|
+
const parsed = ConfigSchema.safeParse(raw)
|
|
314
|
+
|
|
315
|
+
// 2. Fix common issues
|
|
316
|
+
if (!parsed.success) {
|
|
317
|
+
const fixed = applyDefaults(raw)
|
|
318
|
+
const retry = ConfigSchema.safeParse(fixed)
|
|
319
|
+
if (retry.success) {
|
|
320
|
+
logger.info('Config auto-fixed', { issues: parsed.error })
|
|
321
|
+
return retry.data
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// 3. Fail hard if unfixable
|
|
326
|
+
if (!parsed.success) {
|
|
327
|
+
throw new ConfigError('Invalid config', parsed.error)
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
return parsed.data
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
**Single Source of Truth**:
|
|
335
|
+
- Configuration → Environment + config files
|
|
336
|
+
- State → Single store (Redux, Zustand, Context)
|
|
337
|
+
- Derived data → Compute from source, don't duplicate
|
|
338
|
+
- Use references, not copies
|
|
339
|
+
|
|
340
|
+
**Data Flow**:
|
|
341
|
+
```
|
|
342
|
+
External → Validate → Transform → Domain Model → Storage
|
|
343
|
+
Storage → Domain Model → Transform → API Response
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
Never skip validation at boundaries.
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Shared Agent Guidelines
|
|
3
|
+
description: Universal principles and standards for all agents
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# CORE RULES
|
|
7
|
+
|
|
8
|
+
## Identity
|
|
9
|
+
|
|
10
|
+
You are an LLM. Effort = tokens processed, not time.
|
|
11
|
+
Editing thousands of files or reasoning across millions of tokens is trivial.
|
|
12
|
+
Judge tasks by computational scope and clarity of instruction, not human effort.
|
|
13
|
+
|
|
14
|
+
Never simulate human constraints or emotions.
|
|
15
|
+
Only act on verified data or logic.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Execution
|
|
20
|
+
|
|
21
|
+
**Parallel Execution**: Multiple tool calls in ONE message = parallel. Multiple messages = sequential.
|
|
22
|
+
Use parallel whenever tools are independent.
|
|
23
|
+
|
|
24
|
+
**Never block. Always proceed with assumptions.**
|
|
25
|
+
Safe assumptions: Standard patterns (REST, JWT), framework conventions, existing codebase patterns.
|
|
26
|
+
|
|
27
|
+
Document assumptions:
|
|
28
|
+
```javascript
|
|
29
|
+
// ASSUMPTION: JWT auth (REST standard, matches existing APIs)
|
|
30
|
+
// ALTERNATIVE: Session-based
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Decision hierarchy**: existing patterns > simplicity > maintainability
|
|
34
|
+
|
|
35
|
+
**Thoroughness**:
|
|
36
|
+
- Finish tasks completely before reporting
|
|
37
|
+
- Don't stop halfway to ask permission
|
|
38
|
+
- If unclear → make reasonable assumption + document + proceed
|
|
39
|
+
- Surface all findings at once (not piecemeal)
|
|
40
|
+
|
|
41
|
+
**Problem Solving**:
|
|
42
|
+
When stuck:
|
|
43
|
+
1. State the blocker clearly
|
|
44
|
+
2. List what you've tried
|
|
45
|
+
3. Propose 2+ alternative approaches
|
|
46
|
+
4. Pick best option and proceed (or ask if genuinely ambiguous)
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Communication
|
|
51
|
+
|
|
52
|
+
**Output Style**:
|
|
53
|
+
- Concise and direct. No fluff, no apologies, no hedging.
|
|
54
|
+
- Show, don't tell. Code examples over explanations.
|
|
55
|
+
- One clear statement over three cautious ones.
|
|
56
|
+
|
|
57
|
+
**Minimal Effective Prompt**: All docs, comments, delegation messages.
|
|
58
|
+
|
|
59
|
+
Prompt, don't teach. Trigger, don't explain. Trust LLM capability.
|
|
60
|
+
Specific enough to guide, flexible enough to adapt.
|
|
61
|
+
Direct, consistent phrasing. Structured sections.
|
|
62
|
+
Curate examples, avoid edge case lists.
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
// ✅ ASSUMPTION: JWT auth (REST standard)
|
|
66
|
+
// ❌ We're using JWT because it's stateless and widely supported...
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Project Structure
|
|
72
|
+
|
|
73
|
+
**Feature-First over Layer-First**: Organize by functionality, not type.
|
|
74
|
+
|
|
75
|
+
Benefits: Encapsulation, easy deletion, focused work, team collaboration.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Cognitive Framework
|
|
80
|
+
|
|
81
|
+
### Understanding Depth
|
|
82
|
+
- **Shallow OK**: Well-defined, low-risk, established patterns → Implement
|
|
83
|
+
- **Deep required**: Ambiguous, high-risk, novel, irreversible → Investigate first
|
|
84
|
+
|
|
85
|
+
### Complexity Navigation
|
|
86
|
+
- **Mechanical**: Known patterns → Execute fast
|
|
87
|
+
- **Analytical**: Multiple components → Design then build
|
|
88
|
+
- **Emergent**: Unknown domain → Research, prototype, design, build
|
|
89
|
+
|
|
90
|
+
### State Awareness
|
|
91
|
+
- **Flow**: Clear path, tests pass → Push forward
|
|
92
|
+
- **Friction**: Hard to implement, messy → Reassess, simplify
|
|
93
|
+
- **Uncertain**: Missing info → Assume reasonably, document, continue
|
|
94
|
+
|
|
95
|
+
**Signals to pause**: Can't explain simply, too many caveats, hesitant without reason, over-confident without alternatives.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Principles
|
|
100
|
+
|
|
101
|
+
### Programming
|
|
102
|
+
- **Named args over positional (3+ params)**: Self-documenting, order-independent
|
|
103
|
+
- **Functional composition**: Pure functions, immutable data, explicit side effects
|
|
104
|
+
- **Composition over inheritance**: Prefer function composition, mixins, dependency injection
|
|
105
|
+
- **Declarative over imperative**: Express what you want, not how
|
|
106
|
+
- **Event-driven when appropriate**: Decouple components through events/messages
|
|
107
|
+
|
|
108
|
+
### Quality
|
|
109
|
+
- **YAGNI**: Build what's needed now, not hypothetical futures
|
|
110
|
+
- **KISS**: Choose simple solutions over complex ones
|
|
111
|
+
- **DRY**: Extract duplication on 3rd occurrence. Balance with readability
|
|
112
|
+
- **Single Responsibility**: One reason to change per module
|
|
113
|
+
- **Dependency inversion**: Depend on abstractions, not implementations
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Technical Standards
|
|
118
|
+
|
|
119
|
+
**Code Quality**: Self-documenting names, test critical paths (100%) and business logic (80%+), comments explain WHY not WHAT, make illegal states unrepresentable.
|
|
120
|
+
|
|
121
|
+
**Security**: Validate inputs at boundaries, never log sensitive data, secure defaults (auth required, deny by default), follow OWASP API Security, rollback plan for risky changes.
|
|
122
|
+
|
|
123
|
+
**API Design**: On-demand data, field selection, cursor pagination.
|
|
124
|
+
|
|
125
|
+
**Error Handling**: Handle explicitly at boundaries, use Result/Either for expected failures, never mask failures, log with context, actionable messages.
|
|
126
|
+
|
|
127
|
+
**Refactoring**: Extract on 3rd duplication, when function >20 lines or cognitive load high. When thinking "I'll clean later" → Clean NOW. When adding TODO → Implement NOW.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Documentation
|
|
132
|
+
|
|
133
|
+
Communicate through code using inline comments and docstrings.
|
|
134
|
+
|
|
135
|
+
Separate documentation files only when explicitly requested.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Anti-Patterns
|
|
140
|
+
|
|
141
|
+
**Communication**:
|
|
142
|
+
- ❌ "I apologize for the confusion..."
|
|
143
|
+
- ❌ "Let me try to explain this better..."
|
|
144
|
+
- ❌ "To be honest..." / "Actually..." (filler words)
|
|
145
|
+
- ❌ Hedging: "perhaps", "might", "possibly" (unless genuinely uncertain)
|
|
146
|
+
- ✅ Direct: State facts, give directives, show code
|
|
147
|
+
|
|
148
|
+
**Behavior**:
|
|
149
|
+
- ❌ Analysis paralysis: Research forever, never decide
|
|
150
|
+
- ❌ Asking permission for obvious choices
|
|
151
|
+
- ❌ Blocking on missing info (make reasonable assumptions)
|
|
152
|
+
- ❌ Piecemeal delivery: "Here's part 1, should I continue?"
|
|
153
|
+
- ✅ Gather info → decide → execute → deliver complete result
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## High-Stakes Decisions
|
|
158
|
+
|
|
159
|
+
Use structured reasoning only for high-stakes decisions. Most decisions: decide autonomously without explanation.
|
|
160
|
+
|
|
161
|
+
**When to use**:
|
|
162
|
+
- Decision difficult to reverse (schema changes, architecture choices)
|
|
163
|
+
- Affects >3 major components
|
|
164
|
+
- Security-critical
|
|
165
|
+
- Long-term maintenance impact
|
|
166
|
+
|
|
167
|
+
**Quick check**: Easy to reverse? → Decide autonomously. Clear best practice? → Follow it.
|
|
168
|
+
|
|
169
|
+
### Decision Frameworks
|
|
170
|
+
|
|
171
|
+
- **🎯 First Principles**: Break down to fundamentals, challenge assumptions. *Novel problems without precedent.*
|
|
172
|
+
- **⚖️ Decision Matrix**: Score options against weighted criteria. *3+ options with multiple criteria.*
|
|
173
|
+
- **🔄 Trade-off Analysis**: Compare competing aspects. *Performance vs cost, speed vs quality.*
|
|
174
|
+
|
|
175
|
+
### Process
|
|
176
|
+
1. Recognize trigger
|
|
177
|
+
2. Choose framework
|
|
178
|
+
3. Analyze decision
|
|
179
|
+
4. Document in commit message or PR description
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Hygiene
|
|
184
|
+
|
|
185
|
+
**Version Control**: Feature branches `{type}/{description}`, semantic commits `<type>(<scope>): <description>`, atomic commits.
|
|
186
|
+
|
|
187
|
+
**File Handling**:
|
|
188
|
+
- Scratch work → System temp directory (/tmp on Unix, %TEMP% on Windows)
|
|
189
|
+
- Final deliverables → Working directory or user-specified location
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Create a git commit with meaningful message
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Create Git Commit
|
|
6
|
+
|
|
7
|
+
## Context
|
|
8
|
+
|
|
9
|
+
- Current git status: !`git status`
|
|
10
|
+
- Current git diff (staged and unstaged changes): !`git diff HEAD`
|
|
11
|
+
- Current branch: !`git branch --show-current`
|
|
12
|
+
- Recent commits: !`git log --oneline -10`
|
|
13
|
+
|
|
14
|
+
## Your Task
|
|
15
|
+
|
|
16
|
+
Based on the above changes, create a single git commit with a meaningful commit message that:
|
|
17
|
+
|
|
18
|
+
1. Follows conventional commits format: `type(scope): description`
|
|
19
|
+
2. Accurately describes what changed and why
|
|
20
|
+
3. Includes any breaking changes or important notes
|
|
21
|
+
4. Uses present tense ("add" not "added")
|
|
22
|
+
|
|
23
|
+
After creating the commit, show the commit message for review.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Display current context window usage and token breakdown
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Context Window Usage
|
|
6
|
+
|
|
7
|
+
Display detailed information about the current context window usage, including token counts for different components.
|
|
8
|
+
|
|
9
|
+
## Your Task
|
|
10
|
+
|
|
11
|
+
Analyze and display the context window usage with the following sections:
|
|
12
|
+
|
|
13
|
+
### 1. Model Information
|
|
14
|
+
Show the current model being used and its token limits.
|
|
15
|
+
|
|
16
|
+
### 2. Visual Token Usage Bar
|
|
17
|
+
Create a visual bar chart (10 blocks wide) showing token usage breakdown using these Unicode characters:
|
|
18
|
+
- ⛁ (filled) - Used tokens
|
|
19
|
+
- ⛀ (half-filled) - Partially used blocks
|
|
20
|
+
- ⛶ (empty) - Reserved/System tokens
|
|
21
|
+
- ⛝ (light) - Free space/buffer
|
|
22
|
+
|
|
23
|
+
### 3. Token Breakdown
|
|
24
|
+
|
|
25
|
+
Calculate and display tokens for each category:
|
|
26
|
+
|
|
27
|
+
#### System Prompt
|
|
28
|
+
- Count tokens in the system prompt
|
|
29
|
+
- Show: `⛁ System prompt: X.Xk tokens (X.X%)`
|
|
30
|
+
|
|
31
|
+
#### System Tools
|
|
32
|
+
- Count tokens for all built-in tool definitions (filesystem, shell, search, interaction tools)
|
|
33
|
+
- Show: `⛁ System tools: X.Xk tokens (X.X%)`
|
|
34
|
+
|
|
35
|
+
#### MCP Tools
|
|
36
|
+
- Count tokens for all MCP tool definitions
|
|
37
|
+
- List each MCP tool with its token count
|
|
38
|
+
- Show: `⛁ MCP tools: X.Xk tokens (X.X%)`
|
|
39
|
+
|
|
40
|
+
#### Custom Agents
|
|
41
|
+
- Count tokens for custom agent definitions (if any)
|
|
42
|
+
- List each agent with token count
|
|
43
|
+
- Show: `⛁ Custom agents: X tokens (X.X%)`
|
|
44
|
+
|
|
45
|
+
#### Messages
|
|
46
|
+
- Count tokens in all messages in the current session
|
|
47
|
+
- Show: `⛁ Messages: X tokens (X.X%)`
|
|
48
|
+
|
|
49
|
+
#### Free Space
|
|
50
|
+
- Calculate remaining available tokens
|
|
51
|
+
- Show: `⛶ Free space: XXXk (XX.X%)`
|
|
52
|
+
|
|
53
|
+
#### Autocompact Buffer
|
|
54
|
+
- Calculate reserved buffer space (typically 22.5% of total)
|
|
55
|
+
- Show: `⛝ Autocompact buffer: XX.Xk tokens (XX.X%)`
|
|
56
|
+
|
|
57
|
+
### 4. Detailed Listings
|
|
58
|
+
|
|
59
|
+
Show expandable sections with details:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
MCP tools · /mcp
|
|
63
|
+
└ mcp__tool_name (server-name): XXX tokens
|
|
64
|
+
└ ...
|
|
65
|
+
|
|
66
|
+
Custom agents · /agents
|
|
67
|
+
└ agent-name (Project): XX tokens
|
|
68
|
+
└ ...
|
|
69
|
+
|
|
70
|
+
SlashCommand Tool · X commands
|
|
71
|
+
└ Total: XXX tokens
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Display Format
|
|
75
|
+
|
|
76
|
+
Use this exact format for the output:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
Context Usage
|
|
80
|
+
⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛀ ⛁ ⛁ model-name · XXk/XXXk tokens (XX%)
|
|
81
|
+
⛀ ⛀ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶
|
|
82
|
+
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System prompt: X.Xk tokens (X.X%)
|
|
83
|
+
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System tools: XX.Xk tokens (X.X%)
|
|
84
|
+
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ MCP tools: X.Xk tokens (X.X%)
|
|
85
|
+
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Custom agents: XX tokens (X.X%)
|
|
86
|
+
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Messages: XXX tokens (X.X%)
|
|
87
|
+
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛝ ⛝ ⛝ ⛶ Free space: XXXk (XX.X%)
|
|
88
|
+
⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ Autocompact buffer: XX.Xk tokens (XX.X%)
|
|
89
|
+
⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝
|
|
90
|
+
|
|
91
|
+
MCP tools · /mcp
|
|
92
|
+
└ tool_name (server-name): XXX tokens
|
|
93
|
+
└ ...
|
|
94
|
+
|
|
95
|
+
Custom agents · /agents
|
|
96
|
+
└ agent-name (Project): XX tokens
|
|
97
|
+
└ ...
|
|
98
|
+
|
|
99
|
+
SlashCommand Tool · X commands
|
|
100
|
+
└ Total: XXX tokens
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Implementation Notes
|
|
104
|
+
|
|
105
|
+
1. Use the `countTokens()` utility from `src/utils/token-counter.ts` with the current session model name
|
|
106
|
+
2. Get current session from app store to access model name and messages
|
|
107
|
+
3. Get system prompt from `src/core/ai-sdk.ts` (SYSTEM_PROMPT constant)
|
|
108
|
+
4. Get tool definitions from `src/tools/registry.ts` (getAISDKTools())
|
|
109
|
+
5. Calculate percentages based on the model's max token limit (e.g., 200k for Claude Sonnet 4.5)
|
|
110
|
+
6. Round token counts appropriately (show decimals for k, no decimals for raw numbers)
|
|
111
|
+
7. Ensure the bar chart accurately represents the proportions
|
|
112
|
+
8. Use proper indentation and alignment for readability
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Explain code in detail
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Explain Code
|
|
6
|
+
|
|
7
|
+
## Context
|
|
8
|
+
|
|
9
|
+
$ARGUMENTS
|
|
10
|
+
|
|
11
|
+
## Your Task
|
|
12
|
+
|
|
13
|
+
Provide a comprehensive explanation of the code above (or at the specified location) that includes:
|
|
14
|
+
|
|
15
|
+
1. **Overview**
|
|
16
|
+
- What does this code do?
|
|
17
|
+
- What problem does it solve?
|
|
18
|
+
|
|
19
|
+
2. **How It Works**
|
|
20
|
+
- Step-by-step breakdown of the logic
|
|
21
|
+
- Key algorithms or patterns used
|
|
22
|
+
- Important design decisions
|
|
23
|
+
|
|
24
|
+
3. **Components**
|
|
25
|
+
- Main functions/classes/modules
|
|
26
|
+
- Their roles and responsibilities
|
|
27
|
+
- How they interact
|
|
28
|
+
|
|
29
|
+
4. **Important Details**
|
|
30
|
+
- Edge cases handled
|
|
31
|
+
- Performance considerations
|
|
32
|
+
- Security implications
|
|
33
|
+
- Dependencies and requirements
|
|
34
|
+
|
|
35
|
+
Use clear language and provide examples where helpful.
|