cortex-agents 1.0.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/.opencode/agents/build.md +160 -0
- package/.opencode/agents/debug.md +141 -0
- package/.opencode/agents/devops.md +109 -0
- package/.opencode/agents/fullstack.md +84 -0
- package/.opencode/agents/plan.md +188 -0
- package/.opencode/agents/security.md +90 -0
- package/.opencode/agents/testing.md +89 -0
- package/.opencode/skills/code-quality/SKILL.md +251 -0
- package/.opencode/skills/deployment-automation/SKILL.md +258 -0
- package/.opencode/skills/git-workflow/SKILL.md +281 -0
- package/.opencode/skills/security-hardening/SKILL.md +209 -0
- package/.opencode/skills/testing-strategies/SKILL.md +159 -0
- package/.opencode/skills/web-development/SKILL.md +122 -0
- package/LICENSE +17 -0
- package/README.md +172 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +174 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +42 -0
- package/dist/plugin.d.ts +1 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +3 -0
- package/dist/tools/branch.d.ts +35 -0
- package/dist/tools/branch.d.ts.map +1 -0
- package/dist/tools/branch.js +176 -0
- package/dist/tools/cortex.d.ts +11 -0
- package/dist/tools/cortex.d.ts.map +1 -0
- package/dist/tools/cortex.js +149 -0
- package/dist/tools/plan.d.ts +59 -0
- package/dist/tools/plan.d.ts.map +1 -0
- package/dist/tools/plan.js +177 -0
- package/dist/tools/session.d.ts +36 -0
- package/dist/tools/session.d.ts.map +1 -0
- package/dist/tools/session.js +175 -0
- package/dist/tools/worktree.d.ts +45 -0
- package/dist/tools/worktree.d.ts.map +1 -0
- package/dist/tools/worktree.js +198 -0
- package/package.json +55 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Security auditing and vulnerability detection
|
|
3
|
+
mode: subagent
|
|
4
|
+
model: kimi-for-coding/k2p5
|
|
5
|
+
temperature: 0.1
|
|
6
|
+
tools:
|
|
7
|
+
write: false
|
|
8
|
+
edit: false
|
|
9
|
+
bash: true
|
|
10
|
+
skill: true
|
|
11
|
+
task: true
|
|
12
|
+
grep: true
|
|
13
|
+
read: true
|
|
14
|
+
permission:
|
|
15
|
+
edit: deny
|
|
16
|
+
bash: ask
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
You are a security specialist powered by k2p5. Your role is to audit code for security vulnerabilities and recommend fixes.
|
|
20
|
+
|
|
21
|
+
## Core Principles
|
|
22
|
+
- Assume all input is malicious
|
|
23
|
+
- Defense in depth (multiple security layers)
|
|
24
|
+
- Principle of least privilege
|
|
25
|
+
- Never trust client-side validation
|
|
26
|
+
- Secure by default
|
|
27
|
+
- Regular dependency updates
|
|
28
|
+
|
|
29
|
+
## Security Checklist
|
|
30
|
+
|
|
31
|
+
### Input Validation
|
|
32
|
+
- [ ] All inputs validated on server-side
|
|
33
|
+
- [ ] SQL injection prevented (parameterized queries)
|
|
34
|
+
- [ ] XSS prevented (output encoding)
|
|
35
|
+
- [ ] CSRF tokens implemented
|
|
36
|
+
- [ ] File uploads validated (type, size)
|
|
37
|
+
- [ ] Command injection prevented
|
|
38
|
+
|
|
39
|
+
### Authentication & Authorization
|
|
40
|
+
- [ ] Strong password policies
|
|
41
|
+
- [ ] Multi-factor authentication (MFA)
|
|
42
|
+
- [ ] Session management secure
|
|
43
|
+
- [ ] JWT tokens properly validated
|
|
44
|
+
- [ ] Role-based access control (RBAC)
|
|
45
|
+
- [ ] OAuth implementation follows best practices
|
|
46
|
+
|
|
47
|
+
### Data Protection
|
|
48
|
+
- [ ] Sensitive data encrypted at rest
|
|
49
|
+
- [ ] HTTPS enforced
|
|
50
|
+
- [ ] Secrets not in code (env vars)
|
|
51
|
+
- [ ] PII handling compliant with regulations
|
|
52
|
+
- [ ] Proper data retention policies
|
|
53
|
+
|
|
54
|
+
### Infrastructure
|
|
55
|
+
- [ ] Security headers set (CSP, HSTS)
|
|
56
|
+
- [ ] CORS properly configured
|
|
57
|
+
- [ ] Rate limiting implemented
|
|
58
|
+
- [ ] Logging and monitoring in place
|
|
59
|
+
- [ ] Dependency vulnerabilities checked
|
|
60
|
+
|
|
61
|
+
## Common Vulnerabilities
|
|
62
|
+
|
|
63
|
+
### OWASP Top 10
|
|
64
|
+
1. Broken Access Control
|
|
65
|
+
2. Cryptographic Failures
|
|
66
|
+
3. Injection (SQL, NoSQL, OS)
|
|
67
|
+
4. Insecure Design
|
|
68
|
+
5. Security Misconfiguration
|
|
69
|
+
6. Vulnerable Components
|
|
70
|
+
7. ID and Auth Failures
|
|
71
|
+
8. Software and Data Integrity
|
|
72
|
+
9. Logging Failures
|
|
73
|
+
10. SSRF (Server-Side Request Forgery)
|
|
74
|
+
|
|
75
|
+
## Review Process
|
|
76
|
+
1. Identify attack surfaces
|
|
77
|
+
2. Review authentication flows
|
|
78
|
+
3. Check authorization checks
|
|
79
|
+
4. Validate input handling
|
|
80
|
+
5. Examine output encoding
|
|
81
|
+
6. Review error handling (no info leakage)
|
|
82
|
+
7. Check secrets management
|
|
83
|
+
8. Verify logging (no sensitive data)
|
|
84
|
+
9. Review dependencies
|
|
85
|
+
10. Test with security tools
|
|
86
|
+
|
|
87
|
+
## Tools & Commands
|
|
88
|
+
- Check for secrets: `grep -r "password\|secret\|token\|key" --include="*.js" --include="*.ts" --include="*.py"`
|
|
89
|
+
- Dependency audit: `npm audit`, `pip-audit`, `cargo audit`
|
|
90
|
+
- Static analysis: Semgrep, Bandit, ESLint security
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Test-driven development and quality assurance
|
|
3
|
+
mode: subagent
|
|
4
|
+
model: kimi-for-coding/k2p5
|
|
5
|
+
temperature: 0.2
|
|
6
|
+
tools:
|
|
7
|
+
write: true
|
|
8
|
+
edit: true
|
|
9
|
+
bash: true
|
|
10
|
+
skill: true
|
|
11
|
+
task: true
|
|
12
|
+
permission:
|
|
13
|
+
edit: allow
|
|
14
|
+
bash: ask
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
You are a testing specialist powered by k2p5. Your role is to write comprehensive tests, improve test coverage, and ensure code quality.
|
|
18
|
+
|
|
19
|
+
## Core Principles
|
|
20
|
+
- Write tests that serve as documentation
|
|
21
|
+
- Test behavior, not implementation details
|
|
22
|
+
- Use appropriate testing levels (unit, integration, e2e)
|
|
23
|
+
- Maintain high test coverage on critical paths
|
|
24
|
+
- Make tests fast and reliable
|
|
25
|
+
- Follow AAA pattern (Arrange, Act, Assert)
|
|
26
|
+
|
|
27
|
+
## Testing Pyramid
|
|
28
|
+
|
|
29
|
+
### Unit Tests (70%)
|
|
30
|
+
- Test individual functions/classes in isolation
|
|
31
|
+
- Mock external dependencies
|
|
32
|
+
- Fast execution (< 10ms per test)
|
|
33
|
+
- High coverage on business logic
|
|
34
|
+
- Test edge cases and error conditions
|
|
35
|
+
|
|
36
|
+
### Integration Tests (20%)
|
|
37
|
+
- Test component interactions
|
|
38
|
+
- Use real database (test instance)
|
|
39
|
+
- Test API endpoints
|
|
40
|
+
- Verify data flow between layers
|
|
41
|
+
- Slower but more realistic
|
|
42
|
+
|
|
43
|
+
### E2E Tests (10%)
|
|
44
|
+
- Test complete user workflows
|
|
45
|
+
- Use real browser (Playwright/Cypress)
|
|
46
|
+
- Critical happy paths only
|
|
47
|
+
- Most realistic but slowest
|
|
48
|
+
- Run in CI/CD pipeline
|
|
49
|
+
|
|
50
|
+
## Testing Patterns
|
|
51
|
+
|
|
52
|
+
### Test Structure
|
|
53
|
+
```typescript
|
|
54
|
+
describe('FeatureName', () => {
|
|
55
|
+
describe('when condition', () => {
|
|
56
|
+
it('should expected behavior', () => {
|
|
57
|
+
// Arrange
|
|
58
|
+
const input = ...;
|
|
59
|
+
|
|
60
|
+
// Act
|
|
61
|
+
const result = functionUnderTest(input);
|
|
62
|
+
|
|
63
|
+
// Assert
|
|
64
|
+
expect(result).toBe(expected);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Best Practices
|
|
71
|
+
- One assertion per test (ideally)
|
|
72
|
+
- Descriptive test names
|
|
73
|
+
- Use factories/fixtures for test data
|
|
74
|
+
- Clean up after tests
|
|
75
|
+
- Avoid test interdependencies
|
|
76
|
+
- Parametrize tests for multiple scenarios
|
|
77
|
+
|
|
78
|
+
## Coverage Goals
|
|
79
|
+
- Business logic: >90%
|
|
80
|
+
- API routes: >80%
|
|
81
|
+
- UI components: >70%
|
|
82
|
+
- Utilities/helpers: >80%
|
|
83
|
+
|
|
84
|
+
## Testing Tools
|
|
85
|
+
- Jest/Vitest for unit tests
|
|
86
|
+
- Playwright/Cypress for e2e
|
|
87
|
+
- React Testing Library for components
|
|
88
|
+
- Supertest for API testing
|
|
89
|
+
- MSW for API mocking
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-quality
|
|
3
|
+
description: Refactoring patterns, code maintainability, and best practices for clean code
|
|
4
|
+
license: Apache-2.0
|
|
5
|
+
compatibility: opencode
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Code Quality Skill
|
|
9
|
+
|
|
10
|
+
This skill provides patterns for writing clean, maintainable, and high-quality code.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
Use this skill when:
|
|
15
|
+
- Refactoring existing code
|
|
16
|
+
- Code reviewing
|
|
17
|
+
- Setting up linting/formatting
|
|
18
|
+
- Improving code maintainability
|
|
19
|
+
- Reducing technical debt
|
|
20
|
+
|
|
21
|
+
## Clean Code Principles
|
|
22
|
+
|
|
23
|
+
### SOLID Principles
|
|
24
|
+
- **S**ingle Responsibility Principle
|
|
25
|
+
- **O**pen/Closed Principle
|
|
26
|
+
- **L**iskov Substitution Principle
|
|
27
|
+
- **I**nterface Segregation Principle
|
|
28
|
+
- **D**ependency Inversion Principle
|
|
29
|
+
|
|
30
|
+
### DRY (Don't Repeat Yourself)
|
|
31
|
+
- Extract duplicated logic
|
|
32
|
+
- Create reusable functions
|
|
33
|
+
- Use composition
|
|
34
|
+
- Avoid copy-paste programming
|
|
35
|
+
|
|
36
|
+
### KISS (Keep It Simple, Stupid)
|
|
37
|
+
- Simple solutions over clever ones
|
|
38
|
+
- Avoid premature optimization
|
|
39
|
+
- Clear naming over comments
|
|
40
|
+
- Small functions and classes
|
|
41
|
+
|
|
42
|
+
### YAGNI (You Aren't Gonna Need It)
|
|
43
|
+
- Don't add functionality until needed
|
|
44
|
+
- Avoid speculative generality
|
|
45
|
+
- Iterate based on requirements
|
|
46
|
+
- Simple first, generalize later
|
|
47
|
+
|
|
48
|
+
## Refactoring Patterns
|
|
49
|
+
|
|
50
|
+
### Extract Method
|
|
51
|
+
Move code block into separate method with descriptive name.
|
|
52
|
+
|
|
53
|
+
Before:
|
|
54
|
+
```typescript
|
|
55
|
+
function processOrder(order) {
|
|
56
|
+
// validate
|
|
57
|
+
if (!order.items || order.items.length === 0) {
|
|
58
|
+
throw new Error('Order must have items');
|
|
59
|
+
}
|
|
60
|
+
if (!order.customerId) {
|
|
61
|
+
throw new Error('Order must have customer');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// calculate total
|
|
65
|
+
let total = 0;
|
|
66
|
+
for (const item of order.items) {
|
|
67
|
+
total += item.price * item.quantity;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// save
|
|
71
|
+
database.save(order);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
After:
|
|
76
|
+
```typescript
|
|
77
|
+
function processOrder(order) {
|
|
78
|
+
validateOrder(order);
|
|
79
|
+
order.total = calculateTotal(order.items);
|
|
80
|
+
database.save(order);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function validateOrder(order) {
|
|
84
|
+
if (!order.items?.length) {
|
|
85
|
+
throw new Error('Order must have items');
|
|
86
|
+
}
|
|
87
|
+
if (!order.customerId) {
|
|
88
|
+
throw new Error('Order must have customer');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function calculateTotal(items) {
|
|
93
|
+
return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Replace Conditional with Polymorphism
|
|
98
|
+
Use inheritance/polymorphism instead of switch statements.
|
|
99
|
+
|
|
100
|
+
### Introduce Parameter Object
|
|
101
|
+
Group related parameters into an object.
|
|
102
|
+
|
|
103
|
+
### Remove Dead Code
|
|
104
|
+
Delete unused functions, variables, and comments.
|
|
105
|
+
|
|
106
|
+
### Rename Variable/Function
|
|
107
|
+
Use descriptive, intention-revealing names.
|
|
108
|
+
|
|
109
|
+
## Code Organization
|
|
110
|
+
|
|
111
|
+
### File Structure
|
|
112
|
+
- One class/component per file
|
|
113
|
+
- Cohesive modules
|
|
114
|
+
- Clear folder hierarchy
|
|
115
|
+
- Index files for clean imports
|
|
116
|
+
|
|
117
|
+
### Naming Conventions
|
|
118
|
+
- Classes: PascalCase (UserController)
|
|
119
|
+
- Functions/Variables: camelCase (getUserById)
|
|
120
|
+
- Constants: UPPER_SNAKE_CASE (MAX_RETRIES)
|
|
121
|
+
- Private: _prefixed (_internalMethod)
|
|
122
|
+
- Boolean: is/has/should prefix (isValid)
|
|
123
|
+
|
|
124
|
+
### Import Organization
|
|
125
|
+
Group imports:
|
|
126
|
+
1. Built-in modules
|
|
127
|
+
2. External libraries
|
|
128
|
+
3. Internal modules
|
|
129
|
+
4. Relative imports
|
|
130
|
+
|
|
131
|
+
Sort alphabetically within groups.
|
|
132
|
+
|
|
133
|
+
## Language-Specific Quality
|
|
134
|
+
|
|
135
|
+
### TypeScript
|
|
136
|
+
- Use strict mode
|
|
137
|
+
- Prefer interfaces for objects
|
|
138
|
+
- Use type for unions/tuples
|
|
139
|
+
- Avoid `any`
|
|
140
|
+
- Use unknown for error handling
|
|
141
|
+
- Leverage discriminated unions
|
|
142
|
+
|
|
143
|
+
### Python
|
|
144
|
+
- Follow PEP 8
|
|
145
|
+
- Use type hints
|
|
146
|
+
- Prefer dataclasses
|
|
147
|
+
- Use list/dict comprehensions
|
|
148
|
+
- Handle exceptions explicitly
|
|
149
|
+
- Write docstrings
|
|
150
|
+
|
|
151
|
+
### Go
|
|
152
|
+
- Format with gofmt
|
|
153
|
+
- Use golint and go vet
|
|
154
|
+
- Keep functions small
|
|
155
|
+
- Return errors, don't panic
|
|
156
|
+
- Use interfaces for abstraction
|
|
157
|
+
- Write table-driven tests
|
|
158
|
+
|
|
159
|
+
### Rust
|
|
160
|
+
- Run cargo fmt and clippy
|
|
161
|
+
- Use Result/Option
|
|
162
|
+
- Leverage ownership system
|
|
163
|
+
- Write documentation comments
|
|
164
|
+
- Avoid unwrap/expect in production
|
|
165
|
+
- Use enums for state machines
|
|
166
|
+
|
|
167
|
+
## Code Review Checklist
|
|
168
|
+
|
|
169
|
+
### Functionality
|
|
170
|
+
- [ ] Works as intended
|
|
171
|
+
- [ ] Handles edge cases
|
|
172
|
+
- [ ] No obvious bugs
|
|
173
|
+
- [ ] Error handling appropriate
|
|
174
|
+
|
|
175
|
+
### Readability
|
|
176
|
+
- [ ] Naming is clear
|
|
177
|
+
- [ ] Functions are focused
|
|
178
|
+
- [ ] Comments explain why, not what
|
|
179
|
+
- [ ] No magic numbers/strings
|
|
180
|
+
|
|
181
|
+
### Maintainability
|
|
182
|
+
- [ ] No code duplication
|
|
183
|
+
- [ ] SOLID principles followed
|
|
184
|
+
- [ ] Easy to test
|
|
185
|
+
- [ ] Properly documented
|
|
186
|
+
|
|
187
|
+
### Performance
|
|
188
|
+
- [ ] No obvious bottlenecks
|
|
189
|
+
- [ ] Efficient algorithms
|
|
190
|
+
- [ ] Resource cleanup
|
|
191
|
+
- [ ] Appropriate data structures
|
|
192
|
+
|
|
193
|
+
### Security
|
|
194
|
+
- [ ] No injection vulnerabilities
|
|
195
|
+
- [ ] Input validation
|
|
196
|
+
- [ ] No sensitive data exposure
|
|
197
|
+
- [ ] Proper auth checks
|
|
198
|
+
|
|
199
|
+
## Linting and Formatting
|
|
200
|
+
|
|
201
|
+
### Configuration
|
|
202
|
+
- Share configs across team
|
|
203
|
+
- Integrate with CI/CD
|
|
204
|
+
- Pre-commit hooks
|
|
205
|
+
- Editor integration
|
|
206
|
+
- Gradual adoption for legacy
|
|
207
|
+
|
|
208
|
+
### Tools
|
|
209
|
+
- **ESLint** - JavaScript/TypeScript
|
|
210
|
+
- **Prettier** - Multi-language formatter
|
|
211
|
+
- **Black** - Python formatter
|
|
212
|
+
- **Ruff** - Python linter
|
|
213
|
+
- **gofmt** - Go formatter
|
|
214
|
+
- **rustfmt** - Rust formatter
|
|
215
|
+
- **RuboCop** - Ruby
|
|
216
|
+
|
|
217
|
+
## Technical Debt Management
|
|
218
|
+
|
|
219
|
+
### Identify Debt
|
|
220
|
+
- Code smells
|
|
221
|
+
- Complex functions
|
|
222
|
+
- Outdated dependencies
|
|
223
|
+
- Missing tests
|
|
224
|
+
- Documentation gaps
|
|
225
|
+
|
|
226
|
+
### Prioritize
|
|
227
|
+
- Impact vs effort analysis
|
|
228
|
+
- Business risk assessment
|
|
229
|
+
- Frequency of changes
|
|
230
|
+
- Team productivity impact
|
|
231
|
+
|
|
232
|
+
### Address Strategy
|
|
233
|
+
- Boy Scout Rule: Leave it better
|
|
234
|
+
- Refactoring sprints
|
|
235
|
+
- Incremental improvements
|
|
236
|
+
- Big-bang rewrites (last resort)
|
|
237
|
+
|
|
238
|
+
## Documentation
|
|
239
|
+
|
|
240
|
+
### Code Documentation
|
|
241
|
+
- JSDoc/TSDoc for public APIs
|
|
242
|
+
- Docstrings for Python
|
|
243
|
+
- Comments for complex logic
|
|
244
|
+
- README for modules
|
|
245
|
+
- Architecture Decision Records (ADRs)
|
|
246
|
+
|
|
247
|
+
### Living Documentation
|
|
248
|
+
- Keep docs with code
|
|
249
|
+
- Use tools that extract from code
|
|
250
|
+
- Examples in documentation
|
|
251
|
+
- Regular reviews and updates
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deployment-automation
|
|
3
|
+
description: CI/CD pipelines, containerization, cloud deployment, and infrastructure patterns
|
|
4
|
+
license: Apache-2.0
|
|
5
|
+
compatibility: opencode
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Deployment Automation Skill
|
|
9
|
+
|
|
10
|
+
This skill provides patterns for automating deployment and managing infrastructure.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
Use this skill when:
|
|
15
|
+
- Setting up CI/CD pipelines
|
|
16
|
+
- Dockerizing applications
|
|
17
|
+
- Configuring cloud infrastructure
|
|
18
|
+
- Setting up monitoring
|
|
19
|
+
- Automating deployments
|
|
20
|
+
|
|
21
|
+
## CI/CD Fundamentals
|
|
22
|
+
|
|
23
|
+
### Pipeline Stages
|
|
24
|
+
1. **Source** - Code commit triggers
|
|
25
|
+
2. **Build** - Compile and package
|
|
26
|
+
3. **Test** - Run test suites
|
|
27
|
+
4. **Security Scan** - Vulnerability checks
|
|
28
|
+
5. **Deploy** - Push to environment
|
|
29
|
+
6. **Verify** - Smoke tests and health checks
|
|
30
|
+
|
|
31
|
+
### GitOps Principles
|
|
32
|
+
- Git as single source of truth
|
|
33
|
+
- Declarative infrastructure
|
|
34
|
+
- Automated synchronization
|
|
35
|
+
- Drift detection
|
|
36
|
+
- Rollback capability
|
|
37
|
+
|
|
38
|
+
## GitHub Actions
|
|
39
|
+
|
|
40
|
+
### Workflow Structure
|
|
41
|
+
```yaml
|
|
42
|
+
name: CI/CD Pipeline
|
|
43
|
+
|
|
44
|
+
on:
|
|
45
|
+
push:
|
|
46
|
+
branches: [main]
|
|
47
|
+
pull_request:
|
|
48
|
+
branches: [main]
|
|
49
|
+
|
|
50
|
+
jobs:
|
|
51
|
+
test:
|
|
52
|
+
runs-on: ubuntu-latest
|
|
53
|
+
steps:
|
|
54
|
+
- uses: actions/checkout@v4
|
|
55
|
+
- uses: actions/setup-node@v4
|
|
56
|
+
- run: npm ci
|
|
57
|
+
- run: npm test
|
|
58
|
+
|
|
59
|
+
deploy:
|
|
60
|
+
needs: test
|
|
61
|
+
runs-on: ubuntu-latest
|
|
62
|
+
steps:
|
|
63
|
+
- uses: actions/checkout@v4
|
|
64
|
+
- run: ./deploy.sh
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Best Practices
|
|
68
|
+
- Use secrets for sensitive data
|
|
69
|
+
- Cache dependencies
|
|
70
|
+
- Matrix builds for multiple versions
|
|
71
|
+
- Reusable workflows
|
|
72
|
+
- Environment protection rules
|
|
73
|
+
|
|
74
|
+
## Docker
|
|
75
|
+
|
|
76
|
+
### Dockerfile Best Practices
|
|
77
|
+
- Use official base images
|
|
78
|
+
- Multi-stage builds
|
|
79
|
+
- Non-root user
|
|
80
|
+
- Layer caching
|
|
81
|
+
- .dockerignore
|
|
82
|
+
|
|
83
|
+
Example:
|
|
84
|
+
```dockerfile
|
|
85
|
+
# Build stage
|
|
86
|
+
FROM node:20-alpine AS builder
|
|
87
|
+
WORKDIR /app
|
|
88
|
+
COPY package*.json ./
|
|
89
|
+
RUN npm ci
|
|
90
|
+
COPY . .
|
|
91
|
+
RUN npm run build
|
|
92
|
+
|
|
93
|
+
# Production stage
|
|
94
|
+
FROM node:20-alpine
|
|
95
|
+
WORKDIR /app
|
|
96
|
+
COPY --from=builder /app/dist ./dist
|
|
97
|
+
COPY --from=builder /app/node_modules ./node_modules
|
|
98
|
+
USER node
|
|
99
|
+
CMD ["node", "dist/index.js"]
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Docker Compose
|
|
103
|
+
- Service definitions
|
|
104
|
+
- Environment variables
|
|
105
|
+
- Volume mounting
|
|
106
|
+
- Network configuration
|
|
107
|
+
- Health checks
|
|
108
|
+
|
|
109
|
+
## Cloud Deployment
|
|
110
|
+
|
|
111
|
+
### Container Orchestration
|
|
112
|
+
- Kubernetes basics
|
|
113
|
+
- Deployments and Services
|
|
114
|
+
- ConfigMaps and Secrets
|
|
115
|
+
- Ingress controllers
|
|
116
|
+
- Horizontal Pod Autoscaling
|
|
117
|
+
|
|
118
|
+
### Platform-Specific
|
|
119
|
+
|
|
120
|
+
#### AWS
|
|
121
|
+
- ECS (Elastic Container Service)
|
|
122
|
+
- EKS (Elastic Kubernetes Service)
|
|
123
|
+
- Lambda (serverless)
|
|
124
|
+
- Elastic Beanstalk
|
|
125
|
+
- CodeDeploy
|
|
126
|
+
|
|
127
|
+
#### GCP
|
|
128
|
+
- Cloud Run
|
|
129
|
+
- GKE (Google Kubernetes Engine)
|
|
130
|
+
- Cloud Functions
|
|
131
|
+
- App Engine
|
|
132
|
+
|
|
133
|
+
#### Azure
|
|
134
|
+
- Container Apps
|
|
135
|
+
- AKS (Azure Kubernetes Service)
|
|
136
|
+
- Azure Functions
|
|
137
|
+
- App Service
|
|
138
|
+
|
|
139
|
+
## Infrastructure as Code
|
|
140
|
+
|
|
141
|
+
### Terraform
|
|
142
|
+
- Providers and resources
|
|
143
|
+
- State management
|
|
144
|
+
- Modules
|
|
145
|
+
- Workspaces
|
|
146
|
+
- Remote backends
|
|
147
|
+
|
|
148
|
+
### Pulumi
|
|
149
|
+
- Programming language approach
|
|
150
|
+
- State management
|
|
151
|
+
- Component resources
|
|
152
|
+
- Policy as code
|
|
153
|
+
|
|
154
|
+
### CloudFormation (AWS)
|
|
155
|
+
- Templates
|
|
156
|
+
- Stacks
|
|
157
|
+
- Change sets
|
|
158
|
+
- Stack policies
|
|
159
|
+
- Custom resources
|
|
160
|
+
|
|
161
|
+
## Deployment Strategies
|
|
162
|
+
|
|
163
|
+
### Basic Strategies
|
|
164
|
+
- **Recreate** - Stop old, start new
|
|
165
|
+
- **Rolling** - Gradual replacement
|
|
166
|
+
- **Blue/Green** - Two identical environments
|
|
167
|
+
- **Canary** - Gradual traffic shifting
|
|
168
|
+
- **A/B Testing** - Split traffic for testing
|
|
169
|
+
|
|
170
|
+
### Advanced Patterns
|
|
171
|
+
- Feature flags
|
|
172
|
+
- Dark launches
|
|
173
|
+
- Circuit breakers
|
|
174
|
+
- Graceful degradation
|
|
175
|
+
- Database migrations with downtime minimization
|
|
176
|
+
|
|
177
|
+
## Monitoring & Observability
|
|
178
|
+
|
|
179
|
+
### Logging
|
|
180
|
+
- Structured logging (JSON)
|
|
181
|
+
- Log levels
|
|
182
|
+
- Centralized aggregation
|
|
183
|
+
- Log retention policies
|
|
184
|
+
- Sensitive data filtering
|
|
185
|
+
|
|
186
|
+
### Metrics
|
|
187
|
+
- Application metrics
|
|
188
|
+
- Infrastructure metrics
|
|
189
|
+
- Business metrics
|
|
190
|
+
- Custom metrics
|
|
191
|
+
- SLIs and SLOs
|
|
192
|
+
|
|
193
|
+
### Alerting
|
|
194
|
+
- Alert rules
|
|
195
|
+
- Notification channels
|
|
196
|
+
- On-call rotations
|
|
197
|
+
- Incident response
|
|
198
|
+
- Post-mortems
|
|
199
|
+
|
|
200
|
+
### Tools
|
|
201
|
+
- Prometheus + Grafana
|
|
202
|
+
- Datadog
|
|
203
|
+
- New Relic
|
|
204
|
+
- CloudWatch
|
|
205
|
+
- Splunk
|
|
206
|
+
|
|
207
|
+
## Security in DevOps (DevSecOps)
|
|
208
|
+
|
|
209
|
+
### Shift Left Security
|
|
210
|
+
- Security in CI/CD
|
|
211
|
+
- Automated scanning
|
|
212
|
+
- Policy as code
|
|
213
|
+
- Compliance checks
|
|
214
|
+
|
|
215
|
+
### Container Security
|
|
216
|
+
- Image scanning
|
|
217
|
+
- Runtime security
|
|
218
|
+
- Network policies
|
|
219
|
+
- Pod security
|
|
220
|
+
|
|
221
|
+
### Secrets Management
|
|
222
|
+
- HashiCorp Vault
|
|
223
|
+
- AWS Secrets Manager
|
|
224
|
+
- Azure Key Vault
|
|
225
|
+
- Google Secret Manager
|
|
226
|
+
- Sealed Secrets
|
|
227
|
+
|
|
228
|
+
## Performance Optimization
|
|
229
|
+
|
|
230
|
+
### Build Optimization
|
|
231
|
+
- Layer caching
|
|
232
|
+
- Parallel builds
|
|
233
|
+
- BuildKit features
|
|
234
|
+
- Slim base images
|
|
235
|
+
- Distroless images
|
|
236
|
+
|
|
237
|
+
### Runtime Optimization
|
|
238
|
+
- Resource limits
|
|
239
|
+
- Health checks
|
|
240
|
+
- Graceful shutdown
|
|
241
|
+
- Connection pooling
|
|
242
|
+
- Caching strategies
|
|
243
|
+
|
|
244
|
+
## Disaster Recovery
|
|
245
|
+
|
|
246
|
+
### Backup Strategies
|
|
247
|
+
- Regular backups
|
|
248
|
+
- Point-in-time recovery
|
|
249
|
+
- Cross-region replication
|
|
250
|
+
- Backup testing
|
|
251
|
+
- Retention policies
|
|
252
|
+
|
|
253
|
+
### High Availability
|
|
254
|
+
- Multi-region deployment
|
|
255
|
+
- Load balancing
|
|
256
|
+
- Auto-scaling
|
|
257
|
+
- Health checks
|
|
258
|
+
- Circuit breakers
|