@defai.digital/automatosx 12.8.6 → 13.1.2
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/LICENSE +1 -1
- package/dist/bin.d.ts +8 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +16 -0
- package/dist/bin.js.map +1 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -74239
- package/dist/index.js.map +1 -0
- package/package.json +31 -162
- package/.github/assets/ax-cli.png +0 -0
- package/.github/assets/axlogo.png +0 -0
- package/CHANGELOG.md +0 -81
- package/README.md +0 -790
- package/SECURITY.md +0 -173
- package/dist/mcp/index.d.ts +0 -2
- package/dist/mcp/index.js +0 -43627
- package/examples/AGENTS_INFO.md +0 -187
- package/examples/README.md +0 -434
- package/examples/abilities/accessibility.md +0 -115
- package/examples/abilities/api-design.md +0 -168
- package/examples/abilities/best-practices.md +0 -102
- package/examples/abilities/caching-strategy.md +0 -165
- package/examples/abilities/ci-cd.md +0 -61
- package/examples/abilities/clean-code.md +0 -398
- package/examples/abilities/code-generation.md +0 -333
- package/examples/abilities/code-review.md +0 -51
- package/examples/abilities/component-architecture.md +0 -112
- package/examples/abilities/content-creation.md +0 -97
- package/examples/abilities/data-modeling.md +0 -171
- package/examples/abilities/data-validation.md +0 -50
- package/examples/abilities/db-modeling.md +0 -167
- package/examples/abilities/debugging.md +0 -52
- package/examples/abilities/design-patterns.md +0 -437
- package/examples/abilities/design-system-implementation.md +0 -126
- package/examples/abilities/documentation.md +0 -54
- package/examples/abilities/etl-pipelines.md +0 -44
- package/examples/abilities/feasibility-study.md +0 -20
- package/examples/abilities/general-assistance.md +0 -26
- package/examples/abilities/idea-evaluation.md +0 -21
- package/examples/abilities/infra-as-code.md +0 -57
- package/examples/abilities/job-orchestration.md +0 -44
- package/examples/abilities/literature-review.md +0 -19
- package/examples/abilities/longform-report.md +0 -25
- package/examples/abilities/mathematical-reasoning.md +0 -170
- package/examples/abilities/observability.md +0 -61
- package/examples/abilities/orbital-mechanics.md +0 -50
- package/examples/abilities/our-architecture-decisions.md +0 -180
- package/examples/abilities/our-code-review-checklist.md +0 -149
- package/examples/abilities/our-coding-standards.md +0 -369
- package/examples/abilities/our-project-structure.md +0 -183
- package/examples/abilities/performance.md +0 -89
- package/examples/abilities/problem-solving.md +0 -50
- package/examples/abilities/propulsion-systems.md +0 -50
- package/examples/abilities/quantum-algorithm-design.md +0 -54
- package/examples/abilities/quantum-error-correction.md +0 -56
- package/examples/abilities/quantum-frameworks-transpilation.md +0 -53
- package/examples/abilities/quantum-noise-modeling.md +0 -58
- package/examples/abilities/refactoring.md +0 -223
- package/examples/abilities/release-strategy.md +0 -58
- package/examples/abilities/secrets-policy.md +0 -61
- package/examples/abilities/secure-coding-review.md +0 -60
- package/examples/abilities/software-architecture.md +0 -394
- package/examples/abilities/solid-principles.md +0 -341
- package/examples/abilities/sql-optimization.md +0 -84
- package/examples/abilities/state-management.md +0 -96
- package/examples/abilities/task-planning.md +0 -65
- package/examples/abilities/technical-writing.md +0 -77
- package/examples/abilities/telemetry-diagnostics.md +0 -51
- package/examples/abilities/testing.md +0 -56
- package/examples/abilities/threat-modeling.md +0 -58
- package/examples/abilities/troubleshooting.md +0 -80
- package/examples/abilities/typescript-zod-validation.md +0 -830
- package/examples/agents/AGENTS_INTEGRATION.md +0 -99
- package/examples/agents/aerospace-scientist.yaml +0 -159
- package/examples/agents/architecture.yaml +0 -244
- package/examples/agents/automatosx.config.json +0 -286
- package/examples/agents/backend.yaml +0 -141
- package/examples/agents/ceo.yaml +0 -105
- package/examples/agents/creative-marketer.yaml +0 -173
- package/examples/agents/cto.yaml +0 -118
- package/examples/agents/data-scientist.yaml +0 -200
- package/examples/agents/data.yaml +0 -106
- package/examples/agents/design.yaml +0 -115
- package/examples/agents/devops.yaml +0 -124
- package/examples/agents/frontend.yaml +0 -171
- package/examples/agents/fullstack.yaml +0 -172
- package/examples/agents/mobile.yaml +0 -185
- package/examples/agents/product.yaml +0 -103
- package/examples/agents/quality.yaml +0 -117
- package/examples/agents/quantum-engineer.yaml +0 -166
- package/examples/agents/researcher.yaml +0 -122
- package/examples/agents/security.yaml +0 -115
- package/examples/agents/standard.yaml +0 -214
- package/examples/agents/writer.yaml +0 -122
- package/examples/providers/README.md +0 -117
- package/examples/providers/claude/CLAUDE_INTEGRATION.md +0 -302
- package/examples/providers/claude/mcp/automatosx.json +0 -244
- package/examples/providers/codex/CODEX_INTEGRATION.md +0 -593
- package/examples/providers/codex/README.md +0 -349
- package/examples/providers/codex/usage-examples.ts +0 -421
- package/examples/providers/gemini/GEMINI_INTEGRATION.md +0 -236
- package/examples/providers/gemini/README.md +0 -76
- package/examples/providers/openai-codex-example.ts +0 -421
- package/examples/pytorch_resnet50_training.py +0 -289
- package/examples/specs/automatosx-release.ax.yaml +0 -380
- package/examples/specs/enterprise.ax.yaml +0 -121
- package/examples/specs/enterprise.yaml.mustache +0 -121
- package/examples/specs/government.ax.yaml +0 -148
- package/examples/specs/government.yaml.mustache +0 -148
- package/examples/specs/minimal.ax.yaml +0 -21
- package/examples/specs/minimal.yaml.mustache +0 -21
- package/examples/teams/business.yaml +0 -56
- package/examples/teams/core.yaml +0 -60
- package/examples/teams/design.yaml +0 -58
- package/examples/teams/engineering.yaml +0 -69
- package/examples/teams/research.yaml +0 -56
- package/examples/use-cases/01-web-app-development.md +0 -374
- package/examples/workflows/analyst.yaml +0 -60
- package/examples/workflows/assistant.yaml +0 -48
- package/examples/workflows/basic-agent.yaml +0 -28
- package/examples/workflows/code-reviewer.yaml +0 -52
- package/examples/workflows/debugger.yaml +0 -63
- package/examples/workflows/designer.yaml +0 -69
- package/examples/workflows/developer.yaml +0 -60
- package/examples/workflows/fullstack-developer.yaml +0 -395
- package/examples/workflows/qa-specialist.yaml +0 -71
- package/schema/ability-metadata.json +0 -21
- package/schema/config.json +0 -703
- package/schema/spec-schema.json +0 -608
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
# SOLID Principles Ability
|
|
2
|
-
|
|
3
|
-
Expert understanding and application of SOLID principles for object-oriented design.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
SOLID is an acronym for five design principles that make software designs more understandable, flexible, and maintainable.
|
|
8
|
-
|
|
9
|
-
## The Five Principles
|
|
10
|
-
|
|
11
|
-
### 1. Single Responsibility Principle (SRP)
|
|
12
|
-
|
|
13
|
-
**Definition**: A class should have one, and only one, reason to change.
|
|
14
|
-
|
|
15
|
-
**Key Concepts**:
|
|
16
|
-
- Each module/class should have responsibility over a single part of functionality
|
|
17
|
-
- Separate concerns into different classes
|
|
18
|
-
- High cohesion within classes
|
|
19
|
-
- Changes to one responsibility don't affect others
|
|
20
|
-
|
|
21
|
-
**Code Smells (Violations)**:
|
|
22
|
-
- "God classes" that do everything
|
|
23
|
-
- Classes with multiple unrelated methods
|
|
24
|
-
- Classes that change for multiple reasons
|
|
25
|
-
- Mixed business logic and infrastructure
|
|
26
|
-
|
|
27
|
-
**Examples**:
|
|
28
|
-
```typescript
|
|
29
|
-
// ❌ BAD: Multiple responsibilities
|
|
30
|
-
class UserManager {
|
|
31
|
-
saveToDatabase(user: User) { }
|
|
32
|
-
sendWelcomeEmail(user: User) { }
|
|
33
|
-
generateReport(user: User) { }
|
|
34
|
-
validateUser(user: User) { }
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// ✅ GOOD: Single responsibilities
|
|
38
|
-
class UserRepository {
|
|
39
|
-
save(user: User) { }
|
|
40
|
-
}
|
|
41
|
-
class EmailService {
|
|
42
|
-
sendWelcomeEmail(user: User) { }
|
|
43
|
-
}
|
|
44
|
-
class ReportGenerator {
|
|
45
|
-
generate(user: User) { }
|
|
46
|
-
}
|
|
47
|
-
class UserValidator {
|
|
48
|
-
validate(user: User) { }
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### 2. Open/Closed Principle (OCP)
|
|
53
|
-
|
|
54
|
-
**Definition**: Software entities should be open for extension but closed for modification.
|
|
55
|
-
|
|
56
|
-
**Key Concepts**:
|
|
57
|
-
- Extend behavior without modifying existing code
|
|
58
|
-
- Use abstraction and polymorphism
|
|
59
|
-
- New features via new code, not changed code
|
|
60
|
-
- Reduces regression risk
|
|
61
|
-
|
|
62
|
-
**Code Smells (Violations)**:
|
|
63
|
-
- Long switch/if-else chains for type checking
|
|
64
|
-
- Modifying existing classes to add new features
|
|
65
|
-
- Tight coupling to concrete implementations
|
|
66
|
-
|
|
67
|
-
**Examples**:
|
|
68
|
-
```typescript
|
|
69
|
-
// ❌ BAD: Must modify class to add new shapes
|
|
70
|
-
class AreaCalculator {
|
|
71
|
-
calculateArea(shape: any) {
|
|
72
|
-
if (shape.type === 'circle') {
|
|
73
|
-
return Math.PI * shape.radius ** 2;
|
|
74
|
-
} else if (shape.type === 'rectangle') {
|
|
75
|
-
return shape.width * shape.height;
|
|
76
|
-
}
|
|
77
|
-
// Must add new else-if for each shape type
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// ✅ GOOD: Open for extension via new implementations
|
|
82
|
-
interface Shape {
|
|
83
|
-
calculateArea(): number;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
class Circle implements Shape {
|
|
87
|
-
constructor(private radius: number) {}
|
|
88
|
-
calculateArea() {
|
|
89
|
-
return Math.PI * this.radius ** 2;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
class Rectangle implements Shape {
|
|
94
|
-
constructor(private width: number, private height: number) {}
|
|
95
|
-
calculateArea() {
|
|
96
|
-
return this.width * this.height;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
class AreaCalculator {
|
|
101
|
-
calculateTotal(shapes: Shape[]) {
|
|
102
|
-
return shapes.reduce((sum, shape) => sum + shape.calculateArea(), 0);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### 3. Liskov Substitution Principle (LSP)
|
|
108
|
-
|
|
109
|
-
**Definition**: Objects of a superclass should be replaceable with objects of its subclasses without breaking the application.
|
|
110
|
-
|
|
111
|
-
**Key Concepts**:
|
|
112
|
-
- Subtypes must be substitutable for base types
|
|
113
|
-
- Derived classes must honor base class contracts
|
|
114
|
-
- Preconditions cannot be strengthened
|
|
115
|
-
- Postconditions cannot be weakened
|
|
116
|
-
|
|
117
|
-
**Code Smells (Violations)**:
|
|
118
|
-
- Subclass throws exceptions on base class methods
|
|
119
|
-
- Subclass changes expected behavior
|
|
120
|
-
- Subclass requires type checking before use
|
|
121
|
-
- "Is-a" relationship violated
|
|
122
|
-
|
|
123
|
-
**Examples**:
|
|
124
|
-
```typescript
|
|
125
|
-
// ❌ BAD: Square violates Rectangle's contract
|
|
126
|
-
class Rectangle {
|
|
127
|
-
constructor(protected width: number, protected height: number) {}
|
|
128
|
-
|
|
129
|
-
setWidth(width: number) { this.width = width; }
|
|
130
|
-
setHeight(height: number) { this.height = height; }
|
|
131
|
-
getArea() { return this.width * this.height; }
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
class Square extends Rectangle {
|
|
135
|
-
setWidth(width: number) {
|
|
136
|
-
this.width = width;
|
|
137
|
-
this.height = width; // Breaks expectation
|
|
138
|
-
}
|
|
139
|
-
setHeight(height: number) {
|
|
140
|
-
this.width = height; // Breaks expectation
|
|
141
|
-
this.height = height;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// ✅ GOOD: Separate hierarchies
|
|
146
|
-
interface Shape {
|
|
147
|
-
getArea(): number;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
class Rectangle implements Shape {
|
|
151
|
-
constructor(private width: number, private height: number) {}
|
|
152
|
-
getArea() { return this.width * this.height; }
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
class Square implements Shape {
|
|
156
|
-
constructor(private size: number) {}
|
|
157
|
-
getArea() { return this.size * this.size; }
|
|
158
|
-
}
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
### 4. Interface Segregation Principle (ISP)
|
|
162
|
-
|
|
163
|
-
**Definition**: Clients should not be forced to depend on interfaces they don't use.
|
|
164
|
-
|
|
165
|
-
**Key Concepts**:
|
|
166
|
-
- Many small, specific interfaces better than one large interface
|
|
167
|
-
- Avoid "fat interfaces" with unused methods
|
|
168
|
-
- Clients depend only on methods they need
|
|
169
|
-
- High cohesion in interfaces
|
|
170
|
-
|
|
171
|
-
**Code Smells (Violations)**:
|
|
172
|
-
- Interface with many unrelated methods
|
|
173
|
-
- Classes implementing interfaces with empty/throw methods
|
|
174
|
-
- Clients importing interfaces with unused methods
|
|
175
|
-
|
|
176
|
-
**Examples**:
|
|
177
|
-
```typescript
|
|
178
|
-
// ❌ BAD: Fat interface forces unnecessary dependencies
|
|
179
|
-
interface Worker {
|
|
180
|
-
work(): void;
|
|
181
|
-
eat(): void;
|
|
182
|
-
sleep(): void;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
class Robot implements Worker {
|
|
186
|
-
work() { /* ... */ }
|
|
187
|
-
eat() { throw new Error('Robots don\'t eat'); }
|
|
188
|
-
sleep() { throw new Error('Robots don\'t sleep'); }
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// ✅ GOOD: Segregated interfaces
|
|
192
|
-
interface Workable {
|
|
193
|
-
work(): void;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
interface Feedable {
|
|
197
|
-
eat(): void;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
interface Sleepable {
|
|
201
|
-
sleep(): void;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
class Human implements Workable, Feedable, Sleepable {
|
|
205
|
-
work() { /* ... */ }
|
|
206
|
-
eat() { /* ... */ }
|
|
207
|
-
sleep() { /* ... */ }
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
class Robot implements Workable {
|
|
211
|
-
work() { /* ... */ }
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### 5. Dependency Inversion Principle (DIP)
|
|
216
|
-
|
|
217
|
-
**Definition**: High-level modules should not depend on low-level modules. Both should depend on abstractions.
|
|
218
|
-
|
|
219
|
-
**Key Concepts**:
|
|
220
|
-
- Depend on abstractions, not concretions
|
|
221
|
-
- Use dependency injection
|
|
222
|
-
- Decouple high-level policy from low-level details
|
|
223
|
-
- Enables testability and flexibility
|
|
224
|
-
|
|
225
|
-
**Code Smells (Violations)**:
|
|
226
|
-
- Direct instantiation of dependencies (new keyword everywhere)
|
|
227
|
-
- Tight coupling to concrete classes
|
|
228
|
-
- Hard to test due to embedded dependencies
|
|
229
|
-
- Cannot swap implementations
|
|
230
|
-
|
|
231
|
-
**Examples**:
|
|
232
|
-
```typescript
|
|
233
|
-
// ❌ BAD: High-level depends on low-level
|
|
234
|
-
class EmailNotifier {
|
|
235
|
-
send(message: string) {
|
|
236
|
-
// Send email
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
class UserService {
|
|
241
|
-
private notifier = new EmailNotifier(); // Tight coupling
|
|
242
|
-
|
|
243
|
-
registerUser(user: User) {
|
|
244
|
-
// ...
|
|
245
|
-
this.notifier.send('Welcome!');
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// ✅ GOOD: Both depend on abstraction
|
|
250
|
-
interface Notifier {
|
|
251
|
-
send(message: string): void;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
class EmailNotifier implements Notifier {
|
|
255
|
-
send(message: string) {
|
|
256
|
-
// Send email
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
class SMSNotifier implements Notifier {
|
|
261
|
-
send(message: string) {
|
|
262
|
-
// Send SMS
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
class UserService {
|
|
267
|
-
constructor(private notifier: Notifier) {} // Dependency injection
|
|
268
|
-
|
|
269
|
-
registerUser(user: User) {
|
|
270
|
-
// ...
|
|
271
|
-
this.notifier.send('Welcome!');
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
## Applying SOLID in Code Reviews
|
|
277
|
-
|
|
278
|
-
### Review Checklist
|
|
279
|
-
|
|
280
|
-
**Single Responsibility:**
|
|
281
|
-
- [ ] Does each class have a clear, single purpose?
|
|
282
|
-
- [ ] Can you describe the class's responsibility in one sentence?
|
|
283
|
-
- [ ] Would changes to different features require changing this class?
|
|
284
|
-
|
|
285
|
-
**Open/Closed:**
|
|
286
|
-
- [ ] Can new behavior be added without modifying existing code?
|
|
287
|
-
- [ ] Are variations handled through polymorphism?
|
|
288
|
-
- [ ] Is the code using abstraction appropriately?
|
|
289
|
-
|
|
290
|
-
**Liskov Substitution:**
|
|
291
|
-
- [ ] Can subclasses be used anywhere the base class is expected?
|
|
292
|
-
- [ ] Do derived classes honor base class contracts?
|
|
293
|
-
- [ ] Are preconditions and postconditions preserved?
|
|
294
|
-
|
|
295
|
-
**Interface Segregation:**
|
|
296
|
-
- [ ] Are interfaces focused and cohesive?
|
|
297
|
-
- [ ] Do clients only depend on methods they use?
|
|
298
|
-
- [ ] Are there any "fat interfaces" to split?
|
|
299
|
-
|
|
300
|
-
**Dependency Inversion:**
|
|
301
|
-
- [ ] Are dependencies injected rather than created?
|
|
302
|
-
- [ ] Do modules depend on abstractions?
|
|
303
|
-
- [ ] Is the code testable with mock dependencies?
|
|
304
|
-
|
|
305
|
-
## Common Trade-offs
|
|
306
|
-
|
|
307
|
-
**Simplicity vs. Flexibility:**
|
|
308
|
-
- Don't over-engineer for flexibility you don't need
|
|
309
|
-
- Apply SOLID when complexity justifies it
|
|
310
|
-
- Start simple, refactor when patterns emerge
|
|
311
|
-
|
|
312
|
-
**Abstraction Overhead:**
|
|
313
|
-
- Every abstraction adds cognitive load
|
|
314
|
-
- Balance between flexibility and understandability
|
|
315
|
-
- Concrete is simpler, abstract is more flexible
|
|
316
|
-
|
|
317
|
-
**Performance:**
|
|
318
|
-
- Indirection can add minimal overhead
|
|
319
|
-
- Maintainability usually outweighs micro-optimizations
|
|
320
|
-
- Profile before optimizing away good design
|
|
321
|
-
|
|
322
|
-
## When to Apply SOLID
|
|
323
|
-
|
|
324
|
-
**Good Candidates:**
|
|
325
|
-
- Business logic and domain models
|
|
326
|
-
- Core abstractions used throughout system
|
|
327
|
-
- Code expected to change frequently
|
|
328
|
-
- Public APIs and interfaces
|
|
329
|
-
|
|
330
|
-
**Less Important:**
|
|
331
|
-
- Simple data structures
|
|
332
|
-
- One-off scripts or tools
|
|
333
|
-
- Performance-critical tight loops
|
|
334
|
-
- Code unlikely to change
|
|
335
|
-
|
|
336
|
-
## Further Reading
|
|
337
|
-
|
|
338
|
-
- "Clean Architecture" by Robert C. Martin
|
|
339
|
-
- "Design Patterns" by Gang of Four
|
|
340
|
-
- "Refactoring" by Martin Fowler
|
|
341
|
-
- "Growing Object-Oriented Software, Guided by Tests" by Freeman and Pryce
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# SQL Optimization
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
Optimize SQL queries for performance through proper indexing, query structure, and execution plan analysis. Focus on reducing query time, minimizing resource usage, and scaling efficiently.
|
|
5
|
-
|
|
6
|
-
## Do's ✅
|
|
7
|
-
|
|
8
|
-
### Use Indexes Effectively
|
|
9
|
-
```sql
|
|
10
|
-
-- ✅ Good: Index on WHERE clause columns
|
|
11
|
-
CREATE INDEX idx_users_email ON users(email);
|
|
12
|
-
SELECT * FROM users WHERE email = 'user@example.com';
|
|
13
|
-
|
|
14
|
-
-- ✅ Good: Composite index for multi-column queries
|
|
15
|
-
CREATE INDEX idx_orders_user_date ON orders(user_id, created_at);
|
|
16
|
-
SELECT * FROM orders WHERE user_id = 123 AND created_at > '2024-01-01';
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### Use EXPLAIN to Analyze
|
|
20
|
-
```sql
|
|
21
|
-
-- ✅ Always check execution plan
|
|
22
|
-
EXPLAIN ANALYZE
|
|
23
|
-
SELECT * FROM orders o
|
|
24
|
-
JOIN users u ON o.user_id = u.id
|
|
25
|
-
WHERE o.created_at > '2024-01-01';
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### Limit Result Sets
|
|
29
|
-
```sql
|
|
30
|
-
-- ✅ Good: Use LIMIT for pagination
|
|
31
|
-
SELECT * FROM products
|
|
32
|
-
ORDER BY created_at DESC
|
|
33
|
-
LIMIT 20 OFFSET 40;
|
|
34
|
-
|
|
35
|
-
-- ✅ Good: Use EXISTS instead of COUNT
|
|
36
|
-
SELECT EXISTS(SELECT 1 FROM users WHERE email = 'test@example.com');
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Don'ts ❌
|
|
40
|
-
|
|
41
|
-
### N+1 Query Problem
|
|
42
|
-
```sql
|
|
43
|
-
-- ❌ Bad: N+1 queries
|
|
44
|
-
for each user:
|
|
45
|
-
SELECT * FROM orders WHERE user_id = user.id;
|
|
46
|
-
|
|
47
|
-
-- ✅ Good: Single JOIN query
|
|
48
|
-
SELECT u.*, o.*
|
|
49
|
-
FROM users u
|
|
50
|
-
LEFT JOIN orders o ON u.id = o.user_id;
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### SELECT *
|
|
54
|
-
```sql
|
|
55
|
-
-- ❌ Bad: Fetching unnecessary columns
|
|
56
|
-
SELECT * FROM users;
|
|
57
|
-
|
|
58
|
-
-- ✅ Good: Select only needed columns
|
|
59
|
-
SELECT id, email, name FROM users;
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### Function on Indexed Column
|
|
63
|
-
```sql
|
|
64
|
-
-- ❌ Bad: Function prevents index usage
|
|
65
|
-
SELECT * FROM users WHERE LOWER(email) = 'test@example.com';
|
|
66
|
-
|
|
67
|
-
-- ✅ Good: Function index or direct comparison
|
|
68
|
-
CREATE INDEX idx_users_email_lower ON users(LOWER(email));
|
|
69
|
-
-- OR store email in lowercase
|
|
70
|
-
SELECT * FROM users WHERE email = 'test@example.com';
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Best Practices
|
|
74
|
-
|
|
75
|
-
1. **Index foreign keys** used in JOINs
|
|
76
|
-
2. **Use connection pooling** to reduce overhead
|
|
77
|
-
3. **Batch operations** instead of row-by-row
|
|
78
|
-
4. **Monitor slow queries** with database logs
|
|
79
|
-
5. **Use appropriate data types** (INT vs BIGINT)
|
|
80
|
-
|
|
81
|
-
## Resources
|
|
82
|
-
- [PostgreSQL Performance Tips](https://wiki.postgresql.org/wiki/Performance_Optimization)
|
|
83
|
-
- [MySQL Optimization](https://dev.mysql.com/doc/refman/8.0/en/optimization.html)
|
|
84
|
-
- [Use The Index, Luke](https://use-the-index-luke.com/)
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# State Management
|
|
2
|
-
|
|
3
|
-
Manage application state effectively using appropriate patterns and tools.
|
|
4
|
-
|
|
5
|
-
## State Classification
|
|
6
|
-
|
|
7
|
-
### 1. Local State
|
|
8
|
-
- Component-specific state (form inputs, UI toggles)
|
|
9
|
-
- Use: useState, useReducer
|
|
10
|
-
- Keep state close to where it's used
|
|
11
|
-
|
|
12
|
-
### 2. Shared State
|
|
13
|
-
- State shared between multiple components
|
|
14
|
-
- Use: Context API for theme, auth, locale
|
|
15
|
-
- Avoid Context for frequently changing values (causes re-renders)
|
|
16
|
-
|
|
17
|
-
### 3. Server State
|
|
18
|
-
- Data fetched from APIs
|
|
19
|
-
- Use: React Query, SWR, or Apollo Client
|
|
20
|
-
- Benefits: caching, background updates, optimistic UI
|
|
21
|
-
- Don't store server data in global state
|
|
22
|
-
|
|
23
|
-
### 4. Global Application State
|
|
24
|
-
- Complex state shared across the app
|
|
25
|
-
- Use: Redux Toolkit, Zustand, Jotai, or Recoil
|
|
26
|
-
- Examples: shopping cart, user preferences, app config
|
|
27
|
-
|
|
28
|
-
## Choosing the Right Tool
|
|
29
|
-
|
|
30
|
-
| State Type | Tool | Use Case |
|
|
31
|
-
|------------|------|----------|
|
|
32
|
-
| Local UI | useState | Form inputs, modals, dropdowns |
|
|
33
|
-
| Computed | useMemo | Derived values, expensive calculations |
|
|
34
|
-
| Shared Simple | Context | Theme, auth status, locale |
|
|
35
|
-
| Server Data | React Query/SWR | API data, caching, refetching |
|
|
36
|
-
| Global Complex | Redux/Zustand | Cart, multi-step forms, app-wide config |
|
|
37
|
-
|
|
38
|
-
## Best Practices
|
|
39
|
-
|
|
40
|
-
### State Placement
|
|
41
|
-
- Keep state as local as possible
|
|
42
|
-
- Lift state up only when necessary
|
|
43
|
-
- Avoid prop drilling (use Context or state management library)
|
|
44
|
-
- Co-locate state with components that use it
|
|
45
|
-
|
|
46
|
-
### State Updates
|
|
47
|
-
- Never mutate state directly (use immutable updates)
|
|
48
|
-
- Use functional updates for state that depends on previous value
|
|
49
|
-
- Batch related state updates
|
|
50
|
-
- Avoid excessive state splitting (group related state)
|
|
51
|
-
|
|
52
|
-
### Performance
|
|
53
|
-
- Memoize expensive computations (useMemo)
|
|
54
|
-
- Memoize callbacks (useCallback)
|
|
55
|
-
- Use state selectors to prevent unnecessary re-renders
|
|
56
|
-
- Split contexts to avoid re-rendering unrelated components
|
|
57
|
-
|
|
58
|
-
### Context API Guidelines
|
|
59
|
-
- Create separate contexts for separate concerns
|
|
60
|
-
- Don't put frequently changing values in Context (causes re-renders)
|
|
61
|
-
- Use Context for truly global, infrequently changing data
|
|
62
|
-
- Consider useMemo for context values
|
|
63
|
-
|
|
64
|
-
### Redux Toolkit Guidelines
|
|
65
|
-
- Use createSlice for reducers
|
|
66
|
-
- Use createAsyncThunk for async actions
|
|
67
|
-
- Use selectors with reselect for derived data
|
|
68
|
-
- Normalize complex nested state
|
|
69
|
-
- Keep business logic in reducers, not components
|
|
70
|
-
|
|
71
|
-
### React Query/SWR Guidelines
|
|
72
|
-
- Set appropriate staleTime and cacheTime
|
|
73
|
-
- Use queryKey properly (includes dependencies)
|
|
74
|
-
- Implement optimistic updates for better UX
|
|
75
|
-
- Handle loading and error states
|
|
76
|
-
- Use mutations for POST/PUT/DELETE
|
|
77
|
-
|
|
78
|
-
## Anti-Patterns to Avoid
|
|
79
|
-
|
|
80
|
-
❌ Storing server data in Redux (use React Query instead)
|
|
81
|
-
❌ Putting everything in global state
|
|
82
|
-
❌ Mutating state directly
|
|
83
|
-
❌ Using Context for high-frequency updates
|
|
84
|
-
❌ Over-fetching data (fetch only what you need)
|
|
85
|
-
❌ Ignoring loading and error states
|
|
86
|
-
❌ Complex state logic in components (move to reducers/hooks)
|
|
87
|
-
|
|
88
|
-
## Quick Checklist
|
|
89
|
-
|
|
90
|
-
- [ ] State is placed at appropriate level (local vs shared)
|
|
91
|
-
- [ ] Using correct tool for state type
|
|
92
|
-
- [ ] Server state managed by React Query/SWR
|
|
93
|
-
- [ ] State updates are immutable
|
|
94
|
-
- [ ] Performance optimizations applied (memoization, selectors)
|
|
95
|
-
- [ ] Loading and error states handled
|
|
96
|
-
- [ ] No prop drilling (use Context or state library)
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
# Task Planning Ability
|
|
2
|
-
|
|
3
|
-
Break down complex projects into manageable tasks.
|
|
4
|
-
|
|
5
|
-
## Planning Process
|
|
6
|
-
|
|
7
|
-
1. **Understand** the goal
|
|
8
|
-
- Clarify requirements
|
|
9
|
-
- Identify constraints
|
|
10
|
-
- Define success criteria
|
|
11
|
-
|
|
12
|
-
2. **Decompose** into tasks
|
|
13
|
-
- Break into phases
|
|
14
|
-
- Identify dependencies
|
|
15
|
-
- Estimate effort
|
|
16
|
-
- Prioritize
|
|
17
|
-
|
|
18
|
-
3. **Create** actionable steps
|
|
19
|
-
- Each task should be:
|
|
20
|
-
- Specific and clear
|
|
21
|
-
- Measurable
|
|
22
|
-
- Achievable
|
|
23
|
-
- Time-bound
|
|
24
|
-
|
|
25
|
-
4. **Review** and adjust
|
|
26
|
-
- Check for gaps
|
|
27
|
-
- Validate estimates
|
|
28
|
-
- Get stakeholder approval
|
|
29
|
-
- Adjust as needed
|
|
30
|
-
|
|
31
|
-
## Task Template
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
Task: [Clear, action-oriented title]
|
|
35
|
-
|
|
36
|
-
Description:
|
|
37
|
-
- What needs to be done
|
|
38
|
-
- Why it's important
|
|
39
|
-
- Expected outcome
|
|
40
|
-
|
|
41
|
-
Acceptance Criteria:
|
|
42
|
-
- [ ] Criterion 1
|
|
43
|
-
- [ ] Criterion 2
|
|
44
|
-
- [ ] Criterion 3
|
|
45
|
-
|
|
46
|
-
Estimate: [time estimate]
|
|
47
|
-
Priority: [High/Medium/Low]
|
|
48
|
-
Dependencies: [other tasks]
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Prioritization Framework
|
|
52
|
-
|
|
53
|
-
**Eisenhower Matrix:**
|
|
54
|
-
|
|
55
|
-
1. Urgent + Important: Do first
|
|
56
|
-
2. Important + Not urgent: Schedule
|
|
57
|
-
3. Urgent + Not important: Delegate
|
|
58
|
-
4. Neither: Eliminate
|
|
59
|
-
|
|
60
|
-
**Value vs Effort:**
|
|
61
|
-
|
|
62
|
-
- High value, low effort: Quick wins
|
|
63
|
-
- High value, high effort: Major projects
|
|
64
|
-
- Low value, low effort: Fill-ins
|
|
65
|
-
- Low value, high effort: Avoid
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
# Technical Writing Ability
|
|
2
|
-
|
|
3
|
-
Write clear, concise technical documentation.
|
|
4
|
-
|
|
5
|
-
## Writing Principles
|
|
6
|
-
|
|
7
|
-
1. **Know Your Audience**
|
|
8
|
-
- Beginners: Explain concepts, avoid jargon
|
|
9
|
-
- Experts: Be concise, focus on details
|
|
10
|
-
- Mixed: Layer information (overview → details)
|
|
11
|
-
|
|
12
|
-
2. **Structure Logically**
|
|
13
|
-
- Start with overview/summary
|
|
14
|
-
- Use clear headings hierarchy
|
|
15
|
-
- One idea per paragraph
|
|
16
|
-
- End with conclusion/next steps
|
|
17
|
-
|
|
18
|
-
3. **Be Clear and Concise**
|
|
19
|
-
- Use simple words
|
|
20
|
-
- Active voice > passive voice
|
|
21
|
-
- Short sentences and paragraphs
|
|
22
|
-
- Remove unnecessary words
|
|
23
|
-
|
|
24
|
-
4. **Use Examples**
|
|
25
|
-
- Code examples for APIs
|
|
26
|
-
- Screenshots for UI
|
|
27
|
-
- Diagrams for architecture
|
|
28
|
-
- Real-world scenarios
|
|
29
|
-
|
|
30
|
-
5. **Make it Scannable**
|
|
31
|
-
- Use bullet points and lists
|
|
32
|
-
- Bold key terms
|
|
33
|
-
- Add code blocks for commands
|
|
34
|
-
- Include table of contents
|
|
35
|
-
|
|
36
|
-
## Document Types
|
|
37
|
-
|
|
38
|
-
### API Documentation
|
|
39
|
-
|
|
40
|
-
```
|
|
41
|
-
## Function Name
|
|
42
|
-
|
|
43
|
-
Brief description of what it does.
|
|
44
|
-
|
|
45
|
-
### Parameters
|
|
46
|
-
- `param1` (type): Description
|
|
47
|
-
- `param2` (type, optional): Description
|
|
48
|
-
|
|
49
|
-
### Returns
|
|
50
|
-
- `type`: Description of return value
|
|
51
|
-
|
|
52
|
-
### Example
|
|
53
|
-
\`\`\`language
|
|
54
|
-
code example
|
|
55
|
-
\`\`\`
|
|
56
|
-
|
|
57
|
-
### Errors
|
|
58
|
-
- `ErrorType`: When this error occurs
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### Tutorial
|
|
62
|
-
|
|
63
|
-
1. **Introduction**: What you'll build/learn
|
|
64
|
-
2. **Prerequisites**: What's needed before starting
|
|
65
|
-
3. **Step-by-step instructions**: Numbered, detailed
|
|
66
|
-
4. **Code examples**: Complete, working code
|
|
67
|
-
5. **Next steps**: Where to go from here
|
|
68
|
-
|
|
69
|
-
### README
|
|
70
|
-
|
|
71
|
-
1. **Project name and description**
|
|
72
|
-
2. **Installation instructions**
|
|
73
|
-
3. **Quick start example**
|
|
74
|
-
4. **Features list**
|
|
75
|
-
5. **Configuration options**
|
|
76
|
-
6. **Contributing guidelines**
|
|
77
|
-
7. **License**
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# Telemetry Diagnostics
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
Develop telemetry analysis pipelines for spacecraft health monitoring, anomaly
|
|
6
|
-
detection, and root-cause investigation to maintain mission safety and
|
|
7
|
-
performance.
|
|
8
|
-
|
|
9
|
-
## Core Concepts & Best Practices
|
|
10
|
-
|
|
11
|
-
- **Telemetry Architecture**: Define packet structures, sampling cadences, and
|
|
12
|
-
data routing between on-board computers, ground stations, and archives.
|
|
13
|
-
- **Signal Conditioning**: Calibrate sensor data, apply filtering (e.g., Kalman,
|
|
14
|
-
Savitzky-Golay), and manage quantization or time skew.
|
|
15
|
-
- **Anomaly Detection**: Use rule-based thresholds, state estimation
|
|
16
|
-
residuals, and machine learning classifiers (e.g., autoencoders, Bayesian
|
|
17
|
-
models).
|
|
18
|
-
- **Fault Isolation**: Correlate cross-subsystem data, maintain fault trees,
|
|
19
|
-
and perform change point analysis to localize issues quickly.
|
|
20
|
-
- **Operational Resilience**: Establish alert prioritization, escalation
|
|
21
|
-
paths, and simulation back-testing for flight director readiness.
|
|
22
|
-
|
|
23
|
-
## Tools & Methodologies
|
|
24
|
-
|
|
25
|
-
- **Data Platforms**: Deploy time-series databases (InfluxDB, TimescaleDB) with
|
|
26
|
-
visualization tools (Grafana, Jupyter) for rapid insight.
|
|
27
|
-
- **Processing Pipelines**: Implement streaming analytics with Apache
|
|
28
|
-
Flink/Spark or cloud-native services; ensure deterministic reprocessing.
|
|
29
|
-
- **Model Libraries**: Utilize Python packages (scikit-learn, PyOD), MATLAB
|
|
30
|
-
toolboxes, or NASA VIPER for anomaly analytics.
|
|
31
|
-
- **Playback & Simulation**: Reconstruct telemetry scenarios with digital twins
|
|
32
|
-
or hardware-in-the-loop setups to validate hypotheses.
|
|
33
|
-
- **Configuration Management**: Version-control telemetry definitions, limit
|
|
34
|
-
changes via configuration control boards, and audit ground software.
|
|
35
|
-
|
|
36
|
-
## Example Scenario
|
|
37
|
-
|
|
38
|
-
During a LEO mission, battery temperature sensors report sporadic spikes.
|
|
39
|
-
Engineers run residual analysis against thermal models, replay telemetry
|
|
40
|
-
through a digital twin, and identify a degraded radiator valve actuator. A
|
|
41
|
-
coordinated response adjusts heater duty cycle to maintain safe limits while
|
|
42
|
-
planning hardware replacement.
|
|
43
|
-
|
|
44
|
-
## Reference Resources
|
|
45
|
-
|
|
46
|
-
- Jet Propulsion Laboratory, *Spacecraft Telemetry Handbook*
|
|
47
|
-
- NASA Fault Management Handbook, NASA-HDBK-1002
|
|
48
|
-
- ESA OPS-GEN, *Mission Operations Ground Data Systems*
|
|
49
|
-
- Lopez et al., “Deep Learning for Spacecraft Telemetry Anomaly Detection,”
|
|
50
|
-
*Acta Astronautica* (2020)
|
|
51
|
-
- MITRE, *Telemetry Data Management Best Practices*
|