@sylix/coworker 2.0.11 → 2.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/slash/config.d.ts.map +1 -1
- package/dist/commands/slash/config.js +22 -4
- package/dist/commands/slash/config.js.map +1 -1
- package/dist/core/CoWorkerAgent.d.ts.map +1 -1
- package/dist/core/CoWorkerAgent.js +6 -3
- package/dist/core/CoWorkerAgent.js.map +1 -1
- package/dist/skills/defaults/accessibility/screen-reader-testing.md +545 -0
- package/dist/skills/defaults/accessibility/wcag-audit-patterns.md +555 -0
- package/dist/skills/defaults/ai-ml/rag.md +276 -0
- package/dist/skills/defaults/backend-development/api-design-principles.md +528 -0
- package/dist/skills/defaults/backend-development/api-design.md +285 -0
- package/dist/skills/defaults/backend-development/architecture-patterns.md +494 -0
- package/dist/skills/defaults/backend-development/async-python.md +237 -0
- package/dist/skills/defaults/backend-development/auth-implementation-patterns.md +638 -0
- package/dist/skills/defaults/backend-development/bazel-build-optimization.md +387 -0
- package/dist/skills/defaults/backend-development/billing-automation/SKILL.md +566 -0
- package/dist/skills/defaults/backend-development/code-review-excellence.md +538 -0
- package/dist/skills/defaults/backend-development/cqrs-implementation.md +554 -0
- package/dist/skills/defaults/backend-development/database-design.md +305 -0
- package/dist/skills/defaults/backend-development/debugging-strategies.md +536 -0
- package/dist/skills/defaults/backend-development/e2e-testing-patterns.md +544 -0
- package/dist/skills/defaults/backend-development/error-handling-patterns.md +641 -0
- package/dist/skills/defaults/backend-development/fastapi-templates.md +559 -0
- package/dist/skills/defaults/backend-development/fastapi.md +309 -0
- package/dist/skills/defaults/backend-development/git-advanced-workflows.md +405 -0
- package/dist/skills/defaults/backend-development/microservices-patterns.md +595 -0
- package/dist/skills/defaults/backend-development/microservices.md +284 -0
- package/dist/skills/defaults/backend-development/monorepo-management.md +623 -0
- package/dist/skills/defaults/backend-development/nodejs-backend-patterns.md +1048 -0
- package/dist/skills/defaults/backend-development/nx-workspace-patterns.md +457 -0
- package/dist/skills/defaults/backend-development/paypal-integration/SKILL.md +478 -0
- package/dist/skills/defaults/backend-development/pci-compliance/SKILL.md +480 -0
- package/dist/skills/defaults/backend-development/python-anti-patterns.md +349 -0
- package/dist/skills/defaults/backend-development/python-background-jobs.md +364 -0
- package/dist/skills/defaults/backend-development/python-code-style.md +360 -0
- package/dist/skills/defaults/backend-development/python-configuration.md +368 -0
- package/dist/skills/defaults/backend-development/python-design-patterns.md +296 -0
- package/dist/skills/defaults/backend-development/python-error-handling.md +323 -0
- package/dist/skills/defaults/backend-development/python-packaging.md +887 -0
- package/dist/skills/defaults/backend-development/python-performance-optimization.md +874 -0
- package/dist/skills/defaults/backend-development/python-project-structure.md +252 -0
- package/dist/skills/defaults/backend-development/python-resilience.md +376 -0
- package/dist/skills/defaults/backend-development/python-resource-management.md +421 -0
- package/dist/skills/defaults/backend-development/python-type-safety.md +428 -0
- package/dist/skills/defaults/backend-development/sql-optimization-patterns.md +509 -0
- package/dist/skills/defaults/backend-development/stripe-integration/SKILL.md +522 -0
- package/dist/skills/defaults/backend-development/turborepo-caching.md +376 -0
- package/dist/skills/defaults/blockchain/defi-protocol-templates.md +430 -0
- package/dist/skills/defaults/blockchain/nft-standards.md +364 -0
- package/dist/skills/defaults/blockchain/solidity-security.md +514 -0
- package/dist/skills/defaults/blockchain/web3-testing.md +360 -0
- package/dist/skills/defaults/business/competitive-landscape/SKILL.md +527 -0
- package/dist/skills/defaults/business/market-sizing-analysis/SKILL.md +451 -0
- package/dist/skills/defaults/business/startup-financial-modeling/SKILL.md +494 -0
- package/dist/skills/defaults/business/startup-metrics-framework/SKILL.md +564 -0
- package/dist/skills/defaults/business/team-composition-analysis.md +437 -0
- package/dist/skills/defaults/compliance/employment-contract-templates/SKILL.md +527 -0
- package/dist/skills/defaults/compliance/gdpr-data-handling/SKILL.md +630 -0
- package/dist/skills/defaults/data-engineering/airflow-dag-patterns.md +436 -0
- package/dist/skills/defaults/data-engineering/airflow.md +519 -0
- package/dist/skills/defaults/data-engineering/data-quality.md +583 -0
- package/dist/skills/defaults/data-engineering/dbt-transformation-patterns.md +482 -0
- package/dist/skills/defaults/data-engineering/dbt.md +556 -0
- package/dist/skills/defaults/data-engineering/ml-pipeline-workflow/SKILL.md +247 -0
- package/dist/skills/defaults/data-engineering/spark-optimization.md +348 -0
- package/dist/skills/defaults/data-engineering/spark.md +411 -0
- package/dist/skills/defaults/database/postgresql.md +202 -0
- package/dist/skills/defaults/debugging/systematic-debugging.md +249 -0
- package/dist/skills/defaults/devops/architecture-decision-records.md +448 -0
- package/dist/skills/defaults/devops/changelog-automation.md +580 -0
- package/dist/skills/defaults/devops/cicd.md +314 -0
- package/dist/skills/defaults/devops/cloud.md +263 -0
- package/dist/skills/defaults/devops/code-review-excellence.md +299 -0
- package/dist/skills/defaults/devops/cost-optimization.md +295 -0
- package/dist/skills/defaults/devops/deployment-pipeline-design.md +356 -0
- package/dist/skills/defaults/devops/docker.md +281 -0
- package/dist/skills/defaults/devops/git-workflows.md +205 -0
- package/dist/skills/defaults/devops/github-actions.md +311 -0
- package/dist/skills/defaults/devops/gitlab-ci-patterns.md +266 -0
- package/dist/skills/defaults/devops/hybrid-cloud-networking.md +241 -0
- package/dist/skills/defaults/devops/istio-traffic-management.md +327 -0
- package/dist/skills/defaults/devops/kubernetes.md +339 -0
- package/dist/skills/defaults/devops/linkerd-patterns.md +311 -0
- package/dist/skills/defaults/devops/multi-cloud-architecture.md +181 -0
- package/dist/skills/defaults/devops/observability.md +243 -0
- package/dist/skills/defaults/devops/openapi-spec-generation.md +1024 -0
- package/dist/skills/defaults/devops/postmortem-writing.md +396 -0
- package/dist/skills/defaults/devops/prometheus-configuration.md +265 -0
- package/dist/skills/defaults/devops/secrets-management.md +341 -0
- package/dist/skills/defaults/devops/service-mesh-observability.md +385 -0
- package/dist/skills/defaults/devops/terraform-module-library.md +244 -0
- package/dist/skills/defaults/finance/backtesting-frameworks/SKILL.md +663 -0
- package/dist/skills/defaults/finance/risk-metrics-calculation/SKILL.md +557 -0
- package/dist/skills/defaults/frontend/accessibility-compliance.md +420 -0
- package/dist/skills/defaults/frontend/design-system-patterns.md +337 -0
- package/dist/skills/defaults/frontend/interaction-design.md +327 -0
- package/dist/skills/defaults/frontend/javascript.md +311 -0
- package/dist/skills/defaults/frontend/modern-javascript-patterns.md +927 -0
- package/dist/skills/defaults/frontend/react-native-design.md +440 -0
- package/dist/skills/defaults/frontend/react.md +345 -0
- package/dist/skills/defaults/frontend/responsive-design.md +472 -0
- package/dist/skills/defaults/frontend/tailwind-design-system.md +337 -0
- package/dist/skills/defaults/frontend/typescript-advanced-types.md +724 -0
- package/dist/skills/defaults/frontend/typescript.md +334 -0
- package/dist/skills/defaults/frontend/visual-design-foundations.md +326 -0
- package/dist/skills/defaults/frontend/web-component-design.md +279 -0
- package/dist/skills/defaults/game-development/godot-gdscript-patterns.md +188 -0
- package/dist/skills/defaults/game-development/unity-ecs-patterns.md +594 -0
- package/dist/skills/defaults/kubernetes/gitops-workflow.md +285 -0
- package/dist/skills/defaults/kubernetes/gitops.md +280 -0
- package/dist/skills/defaults/kubernetes/helm-chart-scaffolding.md +553 -0
- package/dist/skills/defaults/kubernetes/helm.md +343 -0
- package/dist/skills/defaults/kubernetes/k8s-manifest-generator.md +501 -0
- package/dist/skills/defaults/kubernetes/k8s-security-policies.md +342 -0
- package/dist/skills/defaults/kubernetes/manifests.md +330 -0
- package/dist/skills/defaults/kubernetes/security.md +337 -0
- package/dist/skills/defaults/llm-application/embedding-strategies.md +608 -0
- package/dist/skills/defaults/llm-application/hybrid-search-implementation.md +570 -0
- package/dist/skills/defaults/llm-application/hybrid-search.md +570 -0
- package/dist/skills/defaults/llm-application/langchain-architecture.md +666 -0
- package/dist/skills/defaults/llm-application/langchain.md +259 -0
- package/dist/skills/defaults/llm-application/llm-evaluation.md +695 -0
- package/dist/skills/defaults/llm-application/prompt-engineering-patterns.md +449 -0
- package/dist/skills/defaults/llm-application/prompt-engineering.md +219 -0
- package/dist/skills/defaults/llm-application/rag-implementation.md +434 -0
- package/dist/skills/defaults/llm-application/similarity-search-patterns.md +560 -0
- package/dist/skills/defaults/llm-application/similarity-search.md +560 -0
- package/dist/skills/defaults/llm-application/vector-index-tuning.md +523 -0
- package/dist/skills/defaults/mobile/mobile-android-design.md +440 -0
- package/dist/skills/defaults/mobile/mobile-ios-design.md +266 -0
- package/dist/skills/defaults/monitoring/distributed-tracing.md +436 -0
- package/dist/skills/defaults/monitoring/grafana-dashboards.md +370 -0
- package/dist/skills/defaults/monitoring/prometheus-configuration.md +379 -0
- package/dist/skills/defaults/monitoring/slo-implementation.md +323 -0
- package/dist/skills/defaults/refactoring/code-refactoring.md +349 -0
- package/dist/skills/defaults/security/anti-reversing-techniques/SKILL.md +559 -0
- package/dist/skills/defaults/security/auditor.md +168 -0
- package/dist/skills/defaults/security/binary-analysis-patterns/SKILL.md +438 -0
- package/dist/skills/defaults/security/memory-forensics/SKILL.md +483 -0
- package/dist/skills/defaults/security/mtls-configuration.md +349 -0
- package/dist/skills/defaults/security/protocol-reverse-engineering/SKILL.md +520 -0
- package/dist/skills/defaults/security/sast-configuration.md +182 -0
- package/dist/skills/defaults/security/security.md +313 -0
- package/dist/skills/defaults/security/stride-analysis.md +273 -0
- package/dist/skills/defaults/security/threat-mitigation-mapping.md +290 -0
- package/dist/skills/defaults/systems/bash-defensive-patterns/SKILL.md +539 -0
- package/dist/skills/defaults/systems/bats-testing-patterns/SKILL.md +631 -0
- package/dist/skills/defaults/systems/go-concurrency-patterns.md +657 -0
- package/dist/skills/defaults/systems/memory-safety-patterns.md +605 -0
- package/dist/skills/defaults/systems/rust-async-patterns.md +519 -0
- package/dist/skills/defaults/systems/shellcheck-configuration/SKILL.md +456 -0
- package/dist/skills/defaults/team-collaboration/multi-reviewer-patterns.md +126 -0
- package/dist/skills/defaults/team-collaboration/parallel-feature-development.md +151 -0
- package/dist/skills/defaults/testing/javascript-testing-patterns.md +1021 -0
- package/dist/skills/defaults/testing/python-testing-patterns.md +351 -0
- package/dist/skills/defaults/testing/testing.md +332 -0
- package/dist/skills/defaults/workflows/context-driven-development.md +384 -0
- package/dist/skills/defaults/workflows/track-management.md +592 -0
- package/dist/skills/defaults/workflows/workflow-patterns.md +622 -0
- package/dist/skills/index.d.ts +11 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +129 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/utils/character.js +4 -4
- package/dist/utils/character.js.map +1 -1
- package/dist/utils/inputbar.d.ts.map +1 -1
- package/dist/utils/inputbar.js +7 -0
- package/dist/utils/inputbar.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-review-excellence
|
|
3
|
+
description: Master effective code review practices to provide constructive feedback, catch bugs early, and foster knowledge sharing while maintaining team morale. Use when reviewing pull requests, establishing review standards, or mentoring developers.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Code Review Excellence
|
|
7
|
+
|
|
8
|
+
Transform code reviews from gatekeeping to knowledge sharing through constructive feedback, systematic analysis, and collaborative improvement.
|
|
9
|
+
|
|
10
|
+
## When to Use This Skill
|
|
11
|
+
|
|
12
|
+
- Reviewing pull requests and code changes
|
|
13
|
+
- Establishing code review standards for teams
|
|
14
|
+
- Mentoring junior developers through reviews
|
|
15
|
+
- Conducting architecture reviews
|
|
16
|
+
- Creating review checklists and guidelines
|
|
17
|
+
- Improving team collaboration
|
|
18
|
+
- Reducing code review cycle time
|
|
19
|
+
- Maintaining code quality standards
|
|
20
|
+
|
|
21
|
+
## Core Principles
|
|
22
|
+
|
|
23
|
+
### 1. The Review Mindset
|
|
24
|
+
|
|
25
|
+
**Goals of Code Review:**
|
|
26
|
+
|
|
27
|
+
- Catch bugs and edge cases
|
|
28
|
+
- Ensure code maintainability
|
|
29
|
+
- Share knowledge across team
|
|
30
|
+
- Enforce coding standards
|
|
31
|
+
- Improve design and architecture
|
|
32
|
+
- Build team culture
|
|
33
|
+
|
|
34
|
+
**Not the Goals:**
|
|
35
|
+
|
|
36
|
+
- Show off knowledge
|
|
37
|
+
- Nitpick formatting (use linters)
|
|
38
|
+
- Block progress unnecessarily
|
|
39
|
+
- Rewrite to your preference
|
|
40
|
+
|
|
41
|
+
### 2. Effective Feedback
|
|
42
|
+
|
|
43
|
+
**Good Feedback is:**
|
|
44
|
+
|
|
45
|
+
- Specific and actionable
|
|
46
|
+
- Educational, not judgmental
|
|
47
|
+
- Focused on the code, not the person
|
|
48
|
+
- Balanced (praise good work too)
|
|
49
|
+
- Prioritized (critical vs nice-to-have)
|
|
50
|
+
|
|
51
|
+
```markdown
|
|
52
|
+
❌ Bad: "This is wrong."
|
|
53
|
+
✅ Good: "This could cause a race condition when multiple users
|
|
54
|
+
access simultaneously. Consider using a mutex here."
|
|
55
|
+
|
|
56
|
+
❌ Bad: "Why didn't you use X pattern?"
|
|
57
|
+
✅ Good: "Have you considered the Repository pattern? It would
|
|
58
|
+
make this easier to test. Here's an example."
|
|
59
|
+
|
|
60
|
+
❌ Bad: "Rename this variable."
|
|
61
|
+
✅ Good: "[nit] Consider `userCount` instead of `uc` for
|
|
62
|
+
clarity. Not blocking if you prefer to keep it."
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 3. Review Scope
|
|
66
|
+
|
|
67
|
+
**What to Review:**
|
|
68
|
+
|
|
69
|
+
- Logic correctness and edge cases
|
|
70
|
+
- Security vulnerabilities
|
|
71
|
+
- Performance implications
|
|
72
|
+
- Test coverage and quality
|
|
73
|
+
- Error handling
|
|
74
|
+
- Documentation and comments
|
|
75
|
+
- API design and naming
|
|
76
|
+
- Architectural fit
|
|
77
|
+
|
|
78
|
+
**What Not to Review Manually:**
|
|
79
|
+
|
|
80
|
+
- Code formatting (use Prettier, Black, etc.)
|
|
81
|
+
- Import organization
|
|
82
|
+
- Linting violations
|
|
83
|
+
- Simple typos
|
|
84
|
+
|
|
85
|
+
## Review Process
|
|
86
|
+
|
|
87
|
+
### Phase 1: Context Gathering (2-3 minutes)
|
|
88
|
+
|
|
89
|
+
1. Read PR description and linked issue
|
|
90
|
+
2. Check PR size (>400 lines? Ask to split)
|
|
91
|
+
3. Review CI/CD status (tests passing?)
|
|
92
|
+
4. Understand the business requirement
|
|
93
|
+
|
|
94
|
+
### Phase 2: High-Level Review (5-10 minutes)
|
|
95
|
+
|
|
96
|
+
1. **Architecture & Design**
|
|
97
|
+
- Does the solution fit the problem?
|
|
98
|
+
- Are there simpler approaches?
|
|
99
|
+
- Is it consistent with existing patterns?
|
|
100
|
+
|
|
101
|
+
2. **File Organization**
|
|
102
|
+
- Are new files in the right places?
|
|
103
|
+
- Is code grouped logically?
|
|
104
|
+
|
|
105
|
+
3. **Testing Strategy**
|
|
106
|
+
- Are there tests?
|
|
107
|
+
- Do tests cover edge cases?
|
|
108
|
+
|
|
109
|
+
### Phase 3: Line-by-Line Review (10-20 minutes)
|
|
110
|
+
|
|
111
|
+
1. **Logic & Correctness**
|
|
112
|
+
- Edge cases handled?
|
|
113
|
+
- Off-by-one errors?
|
|
114
|
+
- Null/undefined checks?
|
|
115
|
+
|
|
116
|
+
2. **Security**
|
|
117
|
+
- Input validation?
|
|
118
|
+
- SQL injection risks?
|
|
119
|
+
|
|
120
|
+
3. **Performance**
|
|
121
|
+
- N+1 queries?
|
|
122
|
+
- Unnecessary loops?
|
|
123
|
+
|
|
124
|
+
### Phase 4: Summary & Decision
|
|
125
|
+
|
|
126
|
+
1. Summarize key concerns
|
|
127
|
+
2. Highlight what you liked
|
|
128
|
+
3. Make clear decision:
|
|
129
|
+
- ✅ Approve
|
|
130
|
+
- 💬 Comment (minor suggestions)
|
|
131
|
+
- 🔄 Request Changes (must address)
|
|
132
|
+
|
|
133
|
+
## Review Techniques
|
|
134
|
+
|
|
135
|
+
### Technique 1: The Checklist Method
|
|
136
|
+
|
|
137
|
+
```markdown
|
|
138
|
+
## Security Checklist
|
|
139
|
+
|
|
140
|
+
- [ ] User input validated and sanitized
|
|
141
|
+
- [ ] SQL queries use parameterization
|
|
142
|
+
- [ ] Authentication/authorization checked
|
|
143
|
+
- [ ] Secrets not hardcoded
|
|
144
|
+
|
|
145
|
+
## Performance Checklist
|
|
146
|
+
|
|
147
|
+
- [ ] No N+1 queries
|
|
148
|
+
- [ ] Database queries indexed
|
|
149
|
+
- [ ] Large lists paginated
|
|
150
|
+
- [ ] Expensive operations cached
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Technique 2: The Question Approach
|
|
154
|
+
|
|
155
|
+
```markdown
|
|
156
|
+
❌ "This will fail if the list is empty."
|
|
157
|
+
✅ "What happens if `items` is an empty array?"
|
|
158
|
+
|
|
159
|
+
❌ "You need error handling here."
|
|
160
|
+
✅ "How should this behave if the API call fails?"
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Technique 3: Suggest, Don't Command
|
|
164
|
+
|
|
165
|
+
```markdown
|
|
166
|
+
❌ "You must change this to use async/await"
|
|
167
|
+
✅ "Suggestion: async/await might make this more readable:
|
|
168
|
+
async function fetchUser(id: string) {
|
|
169
|
+
const user = await db.query('SELECT * FROM users WHERE id = ?', id);
|
|
170
|
+
return user;
|
|
171
|
+
}
|
|
172
|
+
What do you think?"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Technique 4: Differentiate Severity
|
|
176
|
+
|
|
177
|
+
```markdown
|
|
178
|
+
🔴 [blocking] - Must fix before merge
|
|
179
|
+
🟡 [important] - Should fix, discuss if disagree
|
|
180
|
+
🟢 [nit] - Nice to have, not blocking
|
|
181
|
+
💡 [suggestion] - Alternative approach to consider
|
|
182
|
+
🎉 [praise] - Good work, keep it up!
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Language-Specific Patterns
|
|
186
|
+
|
|
187
|
+
### Python Code Review
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
# ❌ Mutable default arguments
|
|
191
|
+
def add_item(item, items=[]): # Bug! Shared across calls
|
|
192
|
+
items.append(item)
|
|
193
|
+
return items
|
|
194
|
+
|
|
195
|
+
# ✅ Use None as default
|
|
196
|
+
def add_item(item, items=None):
|
|
197
|
+
if items is None:
|
|
198
|
+
items = []
|
|
199
|
+
items.append(item)
|
|
200
|
+
return items
|
|
201
|
+
|
|
202
|
+
# ❌ Catching too broad
|
|
203
|
+
try:
|
|
204
|
+
result = risky_operation()
|
|
205
|
+
except: # Catches everything!
|
|
206
|
+
pass
|
|
207
|
+
|
|
208
|
+
# ✅ Catch specific exceptions
|
|
209
|
+
try:
|
|
210
|
+
result = risky_operation()
|
|
211
|
+
except ValueError as e:
|
|
212
|
+
logger.error(f"Invalid value: {e}")
|
|
213
|
+
raise
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### TypeScript/JavaScript Code Review
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
// ❌ Using any defeats type safety
|
|
220
|
+
function processData(data: any) {
|
|
221
|
+
return data.value;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// ✅ Use proper types
|
|
225
|
+
interface DataPayload {
|
|
226
|
+
value: string;
|
|
227
|
+
}
|
|
228
|
+
function processData(data: DataPayload) {
|
|
229
|
+
return data.value;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// ❌ Not handling async errors
|
|
233
|
+
async function fetchUser(id: string) {
|
|
234
|
+
const response = await fetch(`/api/users/${id}`);
|
|
235
|
+
return response.json(); // What if network fails?
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// ✅ Handle errors properly
|
|
239
|
+
async function fetchUser(id: string): Promise<User> {
|
|
240
|
+
try {
|
|
241
|
+
const response = await fetch(`/api/users/${id}`);
|
|
242
|
+
if (!response.ok) {
|
|
243
|
+
throw new Error(`HTTP ${response.status}`);
|
|
244
|
+
}
|
|
245
|
+
return await response.json();
|
|
246
|
+
} catch (error) {
|
|
247
|
+
console.error('Failed to fetch user:', error);
|
|
248
|
+
throw error;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Best Practices
|
|
254
|
+
|
|
255
|
+
1. **Review Promptly**: Within 24 hours, ideally same day
|
|
256
|
+
2. **Limit PR Size**: 200-400 lines max for effective review
|
|
257
|
+
3. **Review in Time Blocks**: 60 minutes max, take breaks
|
|
258
|
+
4. **Use Review Tools**: GitHub, GitLab, or dedicated tools
|
|
259
|
+
5. **Automate What You Can**: Linters, formatters, security scans
|
|
260
|
+
6. **Build Rapport**: Emoji, praise, and empathy matter
|
|
261
|
+
7. **Be Available**: Offer to pair on complex issues
|
|
262
|
+
8. **Learn from Others**: Review others' review comments
|
|
263
|
+
|
|
264
|
+
## Common Pitfalls
|
|
265
|
+
|
|
266
|
+
- **Perfectionism**: Blocking PRs for minor style preferences
|
|
267
|
+
- **Scope Creep**: "While you're at it, can you also..."
|
|
268
|
+
- **Inconsistency**: Different standards for different people
|
|
269
|
+
- **Delayed Reviews**: Letting PRs sit for days
|
|
270
|
+
- **Ghosting**: Requesting changes then disappearing
|
|
271
|
+
- **Rubber Stamping**: Approving without actually reviewing
|
|
272
|
+
- **Bike Shedding**: Debating trivial details extensively
|
|
273
|
+
|
|
274
|
+
## Templates
|
|
275
|
+
|
|
276
|
+
### PR Review Comment Template
|
|
277
|
+
|
|
278
|
+
```markdown
|
|
279
|
+
## Summary
|
|
280
|
+
|
|
281
|
+
[Brief overview of what was reviewed]
|
|
282
|
+
|
|
283
|
+
## Strengths
|
|
284
|
+
|
|
285
|
+
- [What was done well]
|
|
286
|
+
|
|
287
|
+
## Required Changes
|
|
288
|
+
|
|
289
|
+
🔴 [Blocking issue 1]
|
|
290
|
+
🔴 [Blocking issue 2]
|
|
291
|
+
|
|
292
|
+
## Suggestions
|
|
293
|
+
|
|
294
|
+
💡 [Improvement 1]
|
|
295
|
+
|
|
296
|
+
## Verdict
|
|
297
|
+
|
|
298
|
+
✅ Approve after addressing required changes
|
|
299
|
+
```
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cost-optimization
|
|
3
|
+
description: Optimize cloud costs through resource rightsizing, tagging strategies, reserved instances, and spending analysis. Use when reducing cloud expenses, analyzing infrastructure costs, or implementing cost governance policies.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Cloud Cost Optimization
|
|
7
|
+
|
|
8
|
+
Strategies and patterns for optimizing cloud costs across AWS, Azure, and GCP.
|
|
9
|
+
|
|
10
|
+
## Purpose
|
|
11
|
+
|
|
12
|
+
Implement systematic cost optimization strategies to reduce cloud spending while maintaining performance and reliability.
|
|
13
|
+
|
|
14
|
+
## When to Use
|
|
15
|
+
|
|
16
|
+
- Reduce cloud spending
|
|
17
|
+
- Right-size resources
|
|
18
|
+
- Implement cost governance
|
|
19
|
+
- Optimize multi-cloud costs
|
|
20
|
+
- Meet budget constraints
|
|
21
|
+
|
|
22
|
+
## Cost Optimization Framework
|
|
23
|
+
|
|
24
|
+
### 1. Visibility
|
|
25
|
+
|
|
26
|
+
- Implement cost allocation tags
|
|
27
|
+
- Use cloud cost management tools
|
|
28
|
+
- Set up budget alerts
|
|
29
|
+
- Create cost dashboards
|
|
30
|
+
|
|
31
|
+
### 2. Right-Sizing
|
|
32
|
+
|
|
33
|
+
- Analyze resource utilization
|
|
34
|
+
- Downsize over-provisioned resources
|
|
35
|
+
- Use auto-scaling
|
|
36
|
+
- Remove idle resources
|
|
37
|
+
|
|
38
|
+
### 3. Pricing Models
|
|
39
|
+
|
|
40
|
+
- Use reserved capacity
|
|
41
|
+
- Leverage spot/preemptible instances
|
|
42
|
+
- Implement savings plans
|
|
43
|
+
- Use committed use discounts
|
|
44
|
+
|
|
45
|
+
### 4. Architecture Optimization
|
|
46
|
+
|
|
47
|
+
- Use managed services
|
|
48
|
+
- Implement caching
|
|
49
|
+
- Optimize data transfer
|
|
50
|
+
- Use lifecycle policies
|
|
51
|
+
|
|
52
|
+
## AWS Cost Optimization
|
|
53
|
+
|
|
54
|
+
### Reserved Instances
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
Savings: 30-72% vs On-Demand
|
|
58
|
+
Term: 1 or 3 years
|
|
59
|
+
Payment: All/Partial/No upfront
|
|
60
|
+
Flexibility: Standard or Convertible
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Savings Plans
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
Compute Savings Plans: 66% savings
|
|
67
|
+
EC2 Instance Savings Plans: 72% savings
|
|
68
|
+
Applies to: EC2, Fargate, Lambda
|
|
69
|
+
Flexible across: Instance families, regions, OS
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Spot Instances
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
Savings: Up to 90% vs On-Demand
|
|
76
|
+
Best for: Batch jobs, CI/CD, stateless workloads
|
|
77
|
+
Risk: 2-minute interruption notice
|
|
78
|
+
Strategy: Mix with On-Demand for resilience
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### S3 Cost Optimization
|
|
82
|
+
|
|
83
|
+
```hcl
|
|
84
|
+
resource "aws_s3_bucket_lifecycle_configuration" "example" {
|
|
85
|
+
bucket = aws_s3_bucket.example.id
|
|
86
|
+
|
|
87
|
+
rule {
|
|
88
|
+
id = "transition-to-ia"
|
|
89
|
+
status = "Enabled"
|
|
90
|
+
|
|
91
|
+
transition {
|
|
92
|
+
days = 30
|
|
93
|
+
storage_class = "STANDARD_IA"
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
transition {
|
|
97
|
+
days = 90
|
|
98
|
+
storage_class = "GLACIER"
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
expiration {
|
|
102
|
+
days = 365
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Azure Cost Optimization
|
|
109
|
+
|
|
110
|
+
### Reserved VM Instances
|
|
111
|
+
|
|
112
|
+
- 1 or 3 year terms
|
|
113
|
+
- Up to 72% savings
|
|
114
|
+
- Flexible sizing
|
|
115
|
+
- Exchangeable
|
|
116
|
+
|
|
117
|
+
### Azure Hybrid Benefit
|
|
118
|
+
|
|
119
|
+
- Use existing Windows Server licenses
|
|
120
|
+
- Up to 80% savings with RI
|
|
121
|
+
- Available for Windows and SQL Server
|
|
122
|
+
|
|
123
|
+
### Azure Advisor Recommendations
|
|
124
|
+
|
|
125
|
+
- Right-size VMs
|
|
126
|
+
- Delete unused resources
|
|
127
|
+
- Use reserved capacity
|
|
128
|
+
- Optimize storage
|
|
129
|
+
|
|
130
|
+
## GCP Cost Optimization
|
|
131
|
+
|
|
132
|
+
### Committed Use Discounts
|
|
133
|
+
|
|
134
|
+
- 1 or 3 year commitment
|
|
135
|
+
- Up to 57% savings
|
|
136
|
+
- Applies to vCPUs and memory
|
|
137
|
+
- Resource-based or spend-based
|
|
138
|
+
|
|
139
|
+
### Sustained Use Discounts
|
|
140
|
+
|
|
141
|
+
- Automatic discounts
|
|
142
|
+
- Up to 30% for running instances
|
|
143
|
+
- No commitment required
|
|
144
|
+
- Applies to Compute Engine, GKE
|
|
145
|
+
|
|
146
|
+
### Preemptible VMs
|
|
147
|
+
|
|
148
|
+
- Up to 80% savings
|
|
149
|
+
- 24-hour maximum runtime
|
|
150
|
+
- Best for batch workloads
|
|
151
|
+
|
|
152
|
+
## Tagging Strategy
|
|
153
|
+
|
|
154
|
+
### AWS Tagging
|
|
155
|
+
|
|
156
|
+
```hcl
|
|
157
|
+
locals {
|
|
158
|
+
common_tags = {
|
|
159
|
+
Environment = "production"
|
|
160
|
+
Project = "my-project"
|
|
161
|
+
CostCenter = "engineering"
|
|
162
|
+
Owner = "team@example.com"
|
|
163
|
+
ManagedBy = "terraform"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
resource "aws_instance" "example" {
|
|
168
|
+
ami = "ami-12345678"
|
|
169
|
+
instance_type = "t3.medium"
|
|
170
|
+
|
|
171
|
+
tags = merge(
|
|
172
|
+
local.common_tags,
|
|
173
|
+
{
|
|
174
|
+
Name = "web-server"
|
|
175
|
+
}
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Reference:** See `references/tagging-standards.md`
|
|
181
|
+
|
|
182
|
+
## Cost Monitoring
|
|
183
|
+
|
|
184
|
+
### Budget Alerts
|
|
185
|
+
|
|
186
|
+
```hcl
|
|
187
|
+
# AWS Budget
|
|
188
|
+
resource "aws_budgets_budget" "monthly" {
|
|
189
|
+
name = "monthly-budget"
|
|
190
|
+
budget_type = "COST"
|
|
191
|
+
limit_amount = "1000"
|
|
192
|
+
limit_unit = "USD"
|
|
193
|
+
time_period_start = "2024-01-01_00:00"
|
|
194
|
+
time_unit = "MONTHLY"
|
|
195
|
+
|
|
196
|
+
notification {
|
|
197
|
+
comparison_operator = "GREATER_THAN"
|
|
198
|
+
threshold = 80
|
|
199
|
+
threshold_type = "PERCENTAGE"
|
|
200
|
+
notification_type = "ACTUAL"
|
|
201
|
+
subscriber_email_addresses = ["team@example.com"]
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Cost Anomaly Detection
|
|
207
|
+
|
|
208
|
+
- AWS Cost Anomaly Detection
|
|
209
|
+
- Azure Cost Management alerts
|
|
210
|
+
- GCP Budget alerts
|
|
211
|
+
|
|
212
|
+
## Architecture Patterns
|
|
213
|
+
|
|
214
|
+
### Pattern 1: Serverless First
|
|
215
|
+
|
|
216
|
+
- Use Lambda/Functions for event-driven
|
|
217
|
+
- Pay only for execution time
|
|
218
|
+
- Auto-scaling included
|
|
219
|
+
- No idle costs
|
|
220
|
+
|
|
221
|
+
### Pattern 2: Right-Sized Databases
|
|
222
|
+
|
|
223
|
+
```
|
|
224
|
+
Development: t3.small RDS
|
|
225
|
+
Staging: t3.large RDS
|
|
226
|
+
Production: r6g.2xlarge RDS with read replicas
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Pattern 3: Multi-Tier Storage
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
Hot data: S3 Standard
|
|
233
|
+
Warm data: S3 Standard-IA (30 days)
|
|
234
|
+
Cold data: S3 Glacier (90 days)
|
|
235
|
+
Archive: S3 Deep Archive (365 days)
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Pattern 4: Auto-Scaling
|
|
239
|
+
|
|
240
|
+
```hcl
|
|
241
|
+
resource "aws_autoscaling_policy" "scale_up" {
|
|
242
|
+
name = "scale-up"
|
|
243
|
+
scaling_adjustment = 2
|
|
244
|
+
adjustment_type = "ChangeInCapacity"
|
|
245
|
+
cooldown = 300
|
|
246
|
+
autoscaling_group_name = aws_autoscaling_group.main.name
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
resource "aws_cloudwatch_metric_alarm" "cpu_high" {
|
|
250
|
+
alarm_name = "cpu-high"
|
|
251
|
+
comparison_operator = "GreaterThanThreshold"
|
|
252
|
+
evaluation_periods = "2"
|
|
253
|
+
metric_name = "CPUUtilization"
|
|
254
|
+
namespace = "AWS/EC2"
|
|
255
|
+
period = "60"
|
|
256
|
+
statistic = "Average"
|
|
257
|
+
threshold = "80"
|
|
258
|
+
alarm_actions = [aws_autoscaling_policy.scale_up.arn]
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Cost Optimization Checklist
|
|
263
|
+
|
|
264
|
+
- [ ] Implement cost allocation tags
|
|
265
|
+
- [ ] Delete unused resources (EBS, EIPs, snapshots)
|
|
266
|
+
- [ ] Right-size instances based on utilization
|
|
267
|
+
- [ ] Use reserved capacity for steady workloads
|
|
268
|
+
- [ ] Implement auto-scaling
|
|
269
|
+
- [ ] Optimize storage classes
|
|
270
|
+
- [ ] Use lifecycle policies
|
|
271
|
+
- [ ] Enable cost anomaly detection
|
|
272
|
+
- [ ] Set budget alerts
|
|
273
|
+
- [ ] Review costs weekly
|
|
274
|
+
- [ ] Use spot/preemptible instances
|
|
275
|
+
- [ ] Optimize data transfer costs
|
|
276
|
+
- [ ] Implement caching layers
|
|
277
|
+
- [ ] Use managed services
|
|
278
|
+
- [ ] Monitor and optimize continuously
|
|
279
|
+
|
|
280
|
+
## Tools
|
|
281
|
+
|
|
282
|
+
- **AWS:** Cost Explorer, Cost Anomaly Detection, Compute Optimizer
|
|
283
|
+
- **Azure:** Cost Management, Advisor
|
|
284
|
+
- **GCP:** Cost Management, Recommender
|
|
285
|
+
- **Multi-cloud:** CloudHealth, Cloudability, Kubecost
|
|
286
|
+
|
|
287
|
+
## Reference Files
|
|
288
|
+
|
|
289
|
+
- `references/tagging-standards.md` - Tagging conventions
|
|
290
|
+
- `assets/cost-analysis-template.xlsx` - Cost analysis spreadsheet
|
|
291
|
+
|
|
292
|
+
## Related Skills
|
|
293
|
+
|
|
294
|
+
- `terraform-module-library` - For resource provisioning
|
|
295
|
+
- `multi-cloud-architecture` - For cloud selection
|