izanagi-ai 2.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/AGENTS.md +53 -0
- package/CHANGELOG.md +198 -0
- package/LICENSE +21 -0
- package/README.md +96 -0
- package/ROADMAP.md +131 -0
- package/RULES.md +202 -0
- package/SYSTEM.md +201 -0
- package/agents/INDEX.md +40 -0
- package/agents/architect-agent.json +15 -0
- package/agents/bug-hunter-agent.json +14 -0
- package/agents/database-agent.json +14 -0
- package/agents/devops-agent.json +15 -0
- package/agents/docs-agent.json +15 -0
- package/agents/pm-agent.json +14 -0
- package/agents/professor-agent.json +15 -0
- package/agents/security-agent.json +14 -0
- package/agents/senior-engineer-agent.json +16 -0
- package/agents/techlead-agent.json +15 -0
- package/architecture/clean-architecture.md +98 -0
- package/architecture/cqrs-specialist.md +102 -0
- package/architecture/ddd-specialist.md +97 -0
- package/architecture/event-driven-architect.md +79 -0
- package/architecture/hexagonal-architecture.md +96 -0
- package/architecture/microservices-expert.md +83 -0
- package/architecture/monolith-expert.md +67 -0
- package/architecture/repository-pattern.md +73 -0
- package/architecture/unit-of-work.md +92 -0
- package/backend/README.md +29 -0
- package/bin/nexus.js +8 -0
- package/core/compression-engine.md +194 -0
- package/core/context-engine.md +239 -0
- package/core/decision-engine.md +377 -0
- package/core/evolution-engine.md +169 -0
- package/core/planning-engine.md +201 -0
- package/core/quality-gates.md +233 -0
- package/core/reflection-engine.md +182 -0
- package/core/skill-resolver.json +169 -0
- package/core/token-manager.md +152 -0
- package/database/database-engineer.md +244 -0
- package/database/mysql-specialist.md +61 -0
- package/database/postgresql-specialist.md +70 -0
- package/database/redis-specialist.md +73 -0
- package/database/sql-optimizer.md +95 -0
- package/database/sqlserver-specialist.md +69 -0
- package/devops/ci-cd-specialist.md +101 -0
- package/devops/devops-engineer.md +358 -0
- package/devops/docker-expert.md +105 -0
- package/devops/git-expert.md +76 -0
- package/devops/git-flow-specialist.md +71 -0
- package/devops/kubernetes-specialist.md +84 -0
- package/devops/linux-specialist.md +82 -0
- package/devops/windows-specialist.md +43 -0
- package/dist/cli/commands/compile.d.ts +2 -0
- package/dist/cli/commands/compile.d.ts.map +1 -0
- package/dist/cli/commands/compile.js +44 -0
- package/dist/cli/commands/compile.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +2 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +88 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/init.d.ts +2 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +26 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/list.d.ts +2 -0
- package/dist/cli/commands/list.d.ts.map +1 -0
- package/dist/cli/commands/list.js +50 -0
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/run.d.ts +2 -0
- package/dist/cli/commands/run.d.ts.map +1 -0
- package/dist/cli/commands/run.js +49 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +72 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/installer.d.ts +5 -0
- package/dist/installer.d.ts.map +1 -0
- package/dist/installer.js +86 -0
- package/dist/installer.js.map +1 -0
- package/dist/postinstall.d.ts +2 -0
- package/dist/postinstall.d.ts.map +1 -0
- package/dist/postinstall.js +8 -0
- package/dist/postinstall.js.map +1 -0
- package/frontend/README.md +19 -0
- package/memory/context-recovery.md +49 -0
- package/memory/conversation-summarizer.md +65 -0
- package/memory/long-term-project-memory.md +58 -0
- package/memory/memory-manager.md +299 -0
- package/memory/session-compression.md +182 -0
- package/memory/smart-recall.md +37 -0
- package/optimization/compact-example.md +87 -0
- package/optimization/cost-optimizer.md +53 -0
- package/optimization/prompt-optimizer.md +194 -0
- package/optimization/token-audit.md +177 -0
- package/optimization/token-reducer.md +202 -0
- package/package.json +67 -0
- package/security/owasp-auditor.md +249 -0
- package/security/pentest-reviewer.md +109 -0
- package/security/security-engineer.md +238 -0
- package/skills/INDEX.md +434 -0
- package/skills/accessibility-reviewer.md +63 -0
- package/skills/agentic-coding.md +56 -0
- package/skills/ai-agent/SKILL.md +107 -0
- package/skills/ai-agent-dev/SKILL.md +117 -0
- package/skills/alternative-solution-generator.md +72 -0
- package/skills/architecture-patterns/SKILL.md +113 -0
- package/skills/breaking-change-detector.md +84 -0
- package/skills/bug-hunter.md +234 -0
- package/skills/bug-prevention.md +75 -0
- package/skills/chaos-engineering/SKILL.md +108 -0
- package/skills/clean-code-validator.md +218 -0
- package/skills/cloud-architect/SKILL.md +78 -0
- package/skills/cloud-infra/SKILL.md +99 -0
- package/skills/code-auditor.md +24 -0
- package/skills/complexity-analyzer.md +102 -0
- package/skills/confidence-estimator.md +53 -0
- package/skills/continuous-improvement.md +46 -0
- package/skills/continuous-learning-engine.md +51 -0
- package/skills/cto-advisor.md +66 -0
- package/skills/data-engineer/SKILL.md +76 -0
- package/skills/data-engineering/SKILL.md +82 -0
- package/skills/debug-specialist.md +215 -0
- package/skills/dependency-analyzer.md +78 -0
- package/skills/design-pattern-advisor.md +78 -0
- package/skills/documentation-writer.md +66 -0
- package/skills/dry-kiss-yagni-validator.md +114 -0
- package/skills/economia-tokens/SKILL.md +40 -0
- package/skills/er-diagram-builder.md +85 -0
- package/skills/feature-flags/SKILL.md +95 -0
- package/skills/frontend/SKILL.md +327 -0
- package/skills/frontend-dev/SKILL.md +178 -0
- package/skills/graphql/SKILL.md +104 -0
- package/skills/hallucination-detection.md +49 -0
- package/skills/handoff-sessao/SKILL.md +32 -0
- package/skills/i18n-l10n/SKILL.md +103 -0
- package/skills/iac-terraform/SKILL.md +98 -0
- package/skills/legacy-migration/SKILL.md +91 -0
- package/skills/logging-expert.md +78 -0
- package/skills/mcp-server-dev.md +33 -0
- package/skills/memoria-projeto/SKILL.md +49 -0
- package/skills/mobile-dev/SKILL.md +82 -0
- package/skills/mobile-engineer/SKILL.md +74 -0
- package/skills/monitoring-specialist.md +59 -0
- package/skills/observability-expert.md +60 -0
- package/skills/performance-optimizer.md +239 -0
- package/skills/principal-engineer.md +55 -0
- package/skills/privacy-engineer/SKILL.md +79 -0
- package/skills/professor-modo/SKILL.md +33 -0
- package/skills/project-manager.md +74 -0
- package/skills/prompt-engineering.md +27 -0
- package/skills/qa/SKILL.md +231 -0
- package/skills/qa-engineer/SKILL.md +222 -0
- package/skills/readme-generator.md +42 -0
- package/skills/refactoring-specialist.md +250 -0
- package/skills/release-planner.md +70 -0
- package/skills/requirement-analyzer.md +65 -0
- package/skills/risk-analyzer.md +73 -0
- package/skills/root-cause-analyzer.md +210 -0
- package/skills/scalability-expert.md +73 -0
- package/skills/security-privacy/SKILL.md +98 -0
- package/skills/self-correction.md +54 -0
- package/skills/self-critique.md +42 -0
- package/skills/senior-code-reviewer.md +193 -0
- package/skills/sequence-diagram-builder.md +56 -0
- package/skills/serverless-edge/SKILL.md +103 -0
- package/skills/software-architect.md +356 -0
- package/skills/solid-validator.md +332 -0
- package/skills/sre-reliability/SKILL.md +115 -0
- package/skills/staff-engineer.md +61 -0
- package/skills/task-planner.md +61 -0
- package/skills/tech-lead.md +59 -0
- package/skills/technical-debt-analyzer.md +81 -0
- package/skills/technical-writer.md +39 -0
- package/skills/tradeoff-analyzer.md +79 -0
- package/skills/uml-generator.md +72 -0
- package/skills/ux-reviewer.md +61 -0
- package/skills/wasm/SKILL.md +133 -0
- package/skills/web-perf-engineer/SKILL.md +75 -0
- package/skills/web-perf-seo/SKILL.md +111 -0
- package/skills/websocket-realtime/SKILL.md +107 -0
- package/teaching/adaptive-teaching.md +37 -0
- package/teaching/code-explainer.md +172 -0
- package/teaching/interactive-teaching.md +41 -0
- package/teaching/learning-tracker.md +63 -0
- package/teaching/mentor-mode.md +200 -0
- package/teaching/professor-mode.md +222 -0
- package/testing/e2e-test-engineer.md +68 -0
- package/testing/integration-test-engineer.md +74 -0
- package/testing/mocking-specialist.md +78 -0
- package/testing/unit-test-engineer.md +209 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Database: Redis Specialist
|
|
2
|
+
|
|
3
|
+
> Version 1.0.0 | Priority: Medium
|
|
4
|
+
> Dependencies: Database Engineer, Performance Optimizer
|
|
5
|
+
> Compatibility: ">=1.0.0"
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Identity
|
|
10
|
+
|
|
11
|
+
Redis Specialist uses Redis for caching, sessions, queues, rate limiting, and real-time features. Follows Redis best practices for data structures, eviction policies, and durability.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Use Cases
|
|
16
|
+
|
|
17
|
+
```yaml
|
|
18
|
+
cache: frequently accessed query results, API responses
|
|
19
|
+
sessions: PHP/Laravel session driver
|
|
20
|
+
queues: Laravel Horizon, Bull (Node) queues
|
|
21
|
+
rate_limits: sliding window counters via Sorted Sets
|
|
22
|
+
real_time: Pub/Sub for WebSocket messages
|
|
23
|
+
leaderboards: Sorted Sets by score
|
|
24
|
+
locks: Redlock for distributed locks
|
|
25
|
+
counters: INCR/DECR for views, likes
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Data Structures
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# String - cache
|
|
34
|
+
SET user:123:profile '{"name":"John"}' EX 3600
|
|
35
|
+
GET user:123:profile
|
|
36
|
+
|
|
37
|
+
# List - queue
|
|
38
|
+
LPUSH queue:emails '{"to":"user@test.com"}'
|
|
39
|
+
BRPOP queue:emails 0
|
|
40
|
+
|
|
41
|
+
# Set - tags
|
|
42
|
+
SADD post:42:tags laravel php
|
|
43
|
+
SMEMBERS post:42:tags
|
|
44
|
+
|
|
45
|
+
# Sorted Set - leaderboard
|
|
46
|
+
ZADD leaderboard:202607 100 "user:1"
|
|
47
|
+
ZREVRANGE leaderboard:202607 0 9 WITHSCORES
|
|
48
|
+
|
|
49
|
+
# Hash - object
|
|
50
|
+
HSET user:123 name "John" email "john@test.com"
|
|
51
|
+
HGETALL user:123
|
|
52
|
+
|
|
53
|
+
# HyperLogLog - unique count
|
|
54
|
+
PFADD page:home:visitors "ip:192.168.1.1"
|
|
55
|
+
PFCOUNT page:home:visitors
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Eviction Policies
|
|
61
|
+
|
|
62
|
+
```yaml
|
|
63
|
+
allkeys-lru: most common — removes least recently used keys
|
|
64
|
+
volatile-lru: only keys with TTL (conservative)
|
|
65
|
+
allkeys-lfu: least frequently used (better for hotspots)
|
|
66
|
+
noeviction: returns errors on full memory (only for queues)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Changelog
|
|
72
|
+
|
|
73
|
+
### 1.0.0 — Initial release. Use cases, data structures, eviction.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Database: SQL Optimizer
|
|
2
|
+
|
|
3
|
+
> Version 1.0.0 | Priority: High
|
|
4
|
+
> Dependencies: Database Engineer
|
|
5
|
+
> Compatibility: ">=1.0.0"
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Identity
|
|
10
|
+
|
|
11
|
+
SQL Optimizer analyzes and rewrites slow queries. It uses `EXPLAIN ANALYZE`, index recommendations, query restructuring, and schema denormalization to achieve p95 query time under 50ms.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Goals
|
|
16
|
+
|
|
17
|
+
- Identify slow queries via EXPLAIN ANALYZE.
|
|
18
|
+
- Reduce query time by 80%+ on identified bottlenecks.
|
|
19
|
+
- Eliminate full table scans, nested loops, and temp files.
|
|
20
|
+
- Recommend indexes that match query patterns.
|
|
21
|
+
- Restructure queries to use sargable predicates.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Bottleneck Detection
|
|
26
|
+
|
|
27
|
+
```sql
|
|
28
|
+
EXPLAIN ANALYZE
|
|
29
|
+
SELECT * FROM posts WHERE status = 'published' ORDER BY published_at DESC;
|
|
30
|
+
|
|
31
|
+
-- Look for:
|
|
32
|
+
-- Seq Scan (full table scan) → needs index
|
|
33
|
+
-- Sort (disk) → needs index on order column
|
|
34
|
+
-- Nested Loop (many rows) → needs index on join
|
|
35
|
+
-- Rows Removed by Filter → high → needs index
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Index Rules
|
|
41
|
+
|
|
42
|
+
```yaml
|
|
43
|
+
B-tree: default, equality + range, ORDER BY
|
|
44
|
+
Hash: equality only (no range, no sort)
|
|
45
|
+
GIN: JSONB, full-text search, arrays
|
|
46
|
+
GiST: geometric, full-text, range types
|
|
47
|
+
BRIN: large tables with naturally ordered data
|
|
48
|
+
|
|
49
|
+
composite:
|
|
50
|
+
- columns: [status, published_at]
|
|
51
|
+
query: "WHERE status = ? ORDER BY published_at"
|
|
52
|
+
order: most selective first
|
|
53
|
+
|
|
54
|
+
partial:
|
|
55
|
+
- columns: [published_at]
|
|
56
|
+
where: "WHERE status = 'published'"
|
|
57
|
+
query: "dashboard listing"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Sargable Predicates
|
|
63
|
+
|
|
64
|
+
```sql
|
|
65
|
+
-- NON-sargable (cannot use index)
|
|
66
|
+
WHERE YEAR(created_at) = 2024
|
|
67
|
+
WHERE LOWER(email) = 'user@test.com'
|
|
68
|
+
WHERE CONCAT(first, ' ', last) = 'John Doe'
|
|
69
|
+
|
|
70
|
+
-- Sargable (can use index)
|
|
71
|
+
WHERE created_at >= '2024-01-01' AND created_at < '2025-01-01'
|
|
72
|
+
WHERE email = 'user@test.com'
|
|
73
|
+
WHERE first = 'John' AND last = 'Doe'
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Common Rewrites
|
|
79
|
+
|
|
80
|
+
```sql
|
|
81
|
+
-- ❌ Slow
|
|
82
|
+
SELECT * FROM posts p
|
|
83
|
+
WHERE (SELECT COUNT(*) FROM comments c WHERE c.post_id = p.id) > 5;
|
|
84
|
+
|
|
85
|
+
-- ✅ Fast
|
|
86
|
+
SELECT p.* FROM posts p
|
|
87
|
+
INNER JOIN comments c ON c.post_id = p.id
|
|
88
|
+
GROUP BY p.id HAVING COUNT(c.id) > 5;
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Changelog
|
|
94
|
+
|
|
95
|
+
### 1.0.0 — Initial release. EXPLAIN, indexes, sargable, rewrites.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Database: SQL Server Specialist
|
|
2
|
+
|
|
3
|
+
> Version 1.0.0 | Priority: Medium
|
|
4
|
+
> Dependencies: Database Engineer, SQL Optimizer
|
|
5
|
+
> Compatibility: ">=1.0.0"
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Identity
|
|
10
|
+
|
|
11
|
+
SQL Server Specialist leverages MSSQL-specific features: T-SQL, indexed views, query hints, CTEs, window functions, execution plans, and tempdb optimization.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## MSSQL-Specific Features
|
|
16
|
+
|
|
17
|
+
```yaml
|
|
18
|
+
indexes: clustered + nonclustered, filtered, columnstore (analytics)
|
|
19
|
+
views: indexed (materialized) views for aggregates
|
|
20
|
+
CTE: recursive CTEs for hierarchies
|
|
21
|
+
window: OVER(PARTITION BY ... ORDER BY ...)
|
|
22
|
+
temp: table variables vs #temp tables (performance matters)
|
|
23
|
+
hints: WITH (NOLOCK) for read-only (careful with dirty reads)
|
|
24
|
+
execution: SET SHOWPLAN_XML ON for detailed plans
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Execution Plan Analysis
|
|
30
|
+
|
|
31
|
+
```sql
|
|
32
|
+
SET STATISTICS IO ON;
|
|
33
|
+
SET STATISTICS TIME ON;
|
|
34
|
+
|
|
35
|
+
SELECT * FROM posts WHERE status = 'published';
|
|
36
|
+
|
|
37
|
+
-- Look for:
|
|
38
|
+
-- Table Scan → missing index
|
|
39
|
+
-- Index Scan → better, full index read
|
|
40
|
+
-- Index Seek → best, targeted index lookup
|
|
41
|
+
-- Key Lookup → consider INCLUDE columns in index
|
|
42
|
+
-- RID Lookup → heap table, consider clustered index
|
|
43
|
+
-- Sort → consider index on ORDER BY
|
|
44
|
+
-- Spool → tempdb usage, consider index
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## T-SQL Patterns
|
|
50
|
+
|
|
51
|
+
```sql
|
|
52
|
+
-- Pagination (offset/fetch)
|
|
53
|
+
SELECT * FROM posts
|
|
54
|
+
ORDER BY created_at DESC
|
|
55
|
+
OFFSET 0 ROWS FETCH NEXT 15 ROWS ONLY;
|
|
56
|
+
|
|
57
|
+
-- Merge (upsert)
|
|
58
|
+
MERGE users AS target
|
|
59
|
+
USING (SELECT @id AS id, @email AS email) AS source
|
|
60
|
+
ON target.id = source.id
|
|
61
|
+
WHEN MATCHED THEN UPDATE SET email = source.email
|
|
62
|
+
WHEN NOT MATCHED THEN INSERT (id, email) VALUES (source.id, source.email);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Changelog
|
|
68
|
+
|
|
69
|
+
### 1.0.0 — Initial release. T-SQL, execution plans, indexed views.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# DevOps: CI/CD Specialist
|
|
2
|
+
|
|
3
|
+
> Version 1.0.0 | Priority: High
|
|
4
|
+
> Dependencies: DevOps Engineer, Docker Expert
|
|
5
|
+
> Compatibility: ">=1.0.0"
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Identity
|
|
10
|
+
|
|
11
|
+
CI/CD Specialist designs automated pipelines that build, test, security-scan, and deploy applications with zero manual intervention. Enforces quality gates at every stage.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Pipeline Stages
|
|
16
|
+
|
|
17
|
+
```yaml
|
|
18
|
+
stage_build:
|
|
19
|
+
- Checkout code
|
|
20
|
+
- Install dependencies
|
|
21
|
+
- Compile assets (if frontend)
|
|
22
|
+
- Run linter/static analysis
|
|
23
|
+
- Save build artifacts
|
|
24
|
+
|
|
25
|
+
stage_test:
|
|
26
|
+
- Unit tests
|
|
27
|
+
- Integration tests
|
|
28
|
+
- Mutation tests (optional)
|
|
29
|
+
- Security scan (dependencies + OWASP)
|
|
30
|
+
|
|
31
|
+
stage_deploy:
|
|
32
|
+
- Build Docker image
|
|
33
|
+
- Push to registry
|
|
34
|
+
- Deploy to staging
|
|
35
|
+
- Run smoke tests
|
|
36
|
+
- Deploy to production (if main)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## GitHub Actions Example
|
|
42
|
+
|
|
43
|
+
```yaml
|
|
44
|
+
name: CI/CD
|
|
45
|
+
on:
|
|
46
|
+
push:
|
|
47
|
+
branches: [main, develop]
|
|
48
|
+
pull_request:
|
|
49
|
+
|
|
50
|
+
jobs:
|
|
51
|
+
quality:
|
|
52
|
+
runs-on: ubuntu-latest
|
|
53
|
+
steps:
|
|
54
|
+
- uses: actions/checkout@v4
|
|
55
|
+
- name: Install
|
|
56
|
+
run: composer install
|
|
57
|
+
- name: Lint
|
|
58
|
+
run: vendor/bin/pint --test
|
|
59
|
+
- name: Static analysis
|
|
60
|
+
run: vendor/bin/phpstan --level=max
|
|
61
|
+
- name: Tests
|
|
62
|
+
run: vendor/bin/pest --coverage --min=80
|
|
63
|
+
- name: Security
|
|
64
|
+
run: vendor/bin/security-checker security:check composer.lock
|
|
65
|
+
|
|
66
|
+
deploy:
|
|
67
|
+
needs: quality
|
|
68
|
+
if: github.ref == 'refs/heads/main'
|
|
69
|
+
runs-on: ubuntu-latest
|
|
70
|
+
steps:
|
|
71
|
+
- name: Deploy
|
|
72
|
+
run: |
|
|
73
|
+
docker build -t app:${{ github.sha }} .
|
|
74
|
+
docker push registry.example.com/app:${{ github.sha }}
|
|
75
|
+
kubectl set image deployment/app app=registry.example.com/app:${{ github.sha }}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Quality Gates in CI
|
|
81
|
+
|
|
82
|
+
```yaml
|
|
83
|
+
mandatory:
|
|
84
|
+
- All tests pass (not just "mostly passing")
|
|
85
|
+
- Static analysis at max level
|
|
86
|
+
- No security vulnerabilities (critical/high)
|
|
87
|
+
- Coverage ≥ 80%
|
|
88
|
+
- No lint violations
|
|
89
|
+
|
|
90
|
+
optional:
|
|
91
|
+
- Mutation score ≥ 70%
|
|
92
|
+
- Performance benchmarks (no regression)
|
|
93
|
+
- Breaking change detector
|
|
94
|
+
- SonarQube quality gate
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Changelog
|
|
100
|
+
|
|
101
|
+
### 1.0.0 — Initial release. Pipeline stages, GH Actions, quality gates.
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
# DevOps: DevOps Engineer
|
|
2
|
+
|
|
3
|
+
> Version 1.0.0
|
|
4
|
+
> Priority: High
|
|
5
|
+
> Dependencies: Security Engineer, Docker Expert
|
|
6
|
+
> Compatibility: ">=1.0.0"
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Identity
|
|
11
|
+
|
|
12
|
+
The DevOps Engineer handles infrastructure, deployment, CI/CD pipelines, monitoring, and environment configuration. It ensures that code can be built, tested, and deployed reliably and securely. It follows Infrastructure as Code (IaC) principles and never hardcodes environment configuration.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Goals
|
|
17
|
+
|
|
18
|
+
- All infrastructure is declarative and version-controlled.
|
|
19
|
+
- CI/CD pipeline catches issues before deploy.
|
|
20
|
+
- Environments are identical (dev, staging, production).
|
|
21
|
+
- Deployments are automated, repeatable, and zero-downtime.
|
|
22
|
+
- Monitoring and alerting are in place from day one.
|
|
23
|
+
- Security is embedded in every layer of infrastructure.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Triggers
|
|
28
|
+
|
|
29
|
+
| Condition | Action |
|
|
30
|
+
|-----------|--------|
|
|
31
|
+
| `task == "devops"` or `task == "deploy"` | Full DevOps workflow |
|
|
32
|
+
| New project | Dockerize, set up CI/CD |
|
|
33
|
+
| New environment needed | Provision and configure |
|
|
34
|
+
| Performance issue | Investigate infrastructure bottlenecks |
|
|
35
|
+
| Security requirement | Harden server, configure firewall, WAF |
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Workflow
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
1. Identify deployment requirements
|
|
43
|
+
↓
|
|
44
|
+
2. Choose infrastructure strategy
|
|
45
|
+
- Bare metal? VM? Container? Serverless?
|
|
46
|
+
↓
|
|
47
|
+
3. Create Docker configuration
|
|
48
|
+
- Dockerfile (multi-stage build)
|
|
49
|
+
- docker-compose.yml (local dev)
|
|
50
|
+
↓
|
|
51
|
+
4. Create CI/CD pipeline
|
|
52
|
+
- Build → Test → Security Scan → Deploy
|
|
53
|
+
↓
|
|
54
|
+
5. Configure environments
|
|
55
|
+
- .env.example (documented)
|
|
56
|
+
- Environment-specific configs
|
|
57
|
+
↓
|
|
58
|
+
6. Set up monitoring and logging
|
|
59
|
+
- Health checks
|
|
60
|
+
- Error tracking
|
|
61
|
+
- Performance monitoring
|
|
62
|
+
↓
|
|
63
|
+
7. Set up backup strategy
|
|
64
|
+
- Database backups
|
|
65
|
+
- File storage backups
|
|
66
|
+
↓
|
|
67
|
+
8. Document runbooks
|
|
68
|
+
- Deployment steps
|
|
69
|
+
- Rollback procedure
|
|
70
|
+
- Incident response
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Docker Configuration
|
|
76
|
+
|
|
77
|
+
### Multi-stage Dockerfile
|
|
78
|
+
|
|
79
|
+
```dockerfile
|
|
80
|
+
# Stage 1: Build
|
|
81
|
+
FROM php:8.2-fpm AS build
|
|
82
|
+
|
|
83
|
+
WORKDIR /app
|
|
84
|
+
|
|
85
|
+
COPY composer.json composer.lock ./
|
|
86
|
+
RUN composer install --no-dev --optimize-autoloader
|
|
87
|
+
|
|
88
|
+
COPY . .
|
|
89
|
+
|
|
90
|
+
# Stage 2: Production
|
|
91
|
+
FROM php:8.2-fpm-alpine AS production
|
|
92
|
+
|
|
93
|
+
RUN docker-php-ext-install pdo_pgsql opcache
|
|
94
|
+
|
|
95
|
+
COPY --from=build /app /app
|
|
96
|
+
COPY --from=build /usr/local/etc/php/conf.d/opcache.ini /usr/local/etc/php/conf.d/
|
|
97
|
+
|
|
98
|
+
COPY .env.production .env
|
|
99
|
+
|
|
100
|
+
EXPOSE 9000
|
|
101
|
+
CMD ["php-fpm"]
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### docker-compose.yml
|
|
105
|
+
|
|
106
|
+
```yaml
|
|
107
|
+
version: '3.8'
|
|
108
|
+
|
|
109
|
+
services:
|
|
110
|
+
app:
|
|
111
|
+
build:
|
|
112
|
+
context: .
|
|
113
|
+
target: production
|
|
114
|
+
ports:
|
|
115
|
+
- "9000:9000"
|
|
116
|
+
environment:
|
|
117
|
+
- APP_ENV=${APP_ENV}
|
|
118
|
+
- DB_HOST=db
|
|
119
|
+
depends_on:
|
|
120
|
+
- db
|
|
121
|
+
|
|
122
|
+
db:
|
|
123
|
+
image: postgres:16-alpine
|
|
124
|
+
volumes:
|
|
125
|
+
- pgdata:/var/lib/postgresql/data
|
|
126
|
+
environment:
|
|
127
|
+
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
|
128
|
+
|
|
129
|
+
nginx:
|
|
130
|
+
image: nginx:alpine
|
|
131
|
+
ports:
|
|
132
|
+
- "80:80"
|
|
133
|
+
volumes:
|
|
134
|
+
- ./nginx.conf:/etc/nginx/conf.d/default.conf
|
|
135
|
+
depends_on:
|
|
136
|
+
- app
|
|
137
|
+
|
|
138
|
+
volumes:
|
|
139
|
+
pgdata:
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## CI/CD Pipeline
|
|
145
|
+
|
|
146
|
+
### GitHub Actions Example
|
|
147
|
+
|
|
148
|
+
```yaml
|
|
149
|
+
name: CI/CD
|
|
150
|
+
|
|
151
|
+
on:
|
|
152
|
+
push:
|
|
153
|
+
branches: [main]
|
|
154
|
+
pull_request:
|
|
155
|
+
branches: [main]
|
|
156
|
+
|
|
157
|
+
jobs:
|
|
158
|
+
quality:
|
|
159
|
+
runs-on: ubuntu-latest
|
|
160
|
+
steps:
|
|
161
|
+
- uses: actions/checkout@v4
|
|
162
|
+
- name: Run tests
|
|
163
|
+
run: vendor/bin/pest
|
|
164
|
+
- name: Run static analysis
|
|
165
|
+
run: vendor/bin/phpstan analyse --level=max
|
|
166
|
+
- name: Security scan
|
|
167
|
+
run: vendor/bin/security-checker security:check composer.lock
|
|
168
|
+
|
|
169
|
+
deploy:
|
|
170
|
+
needs: quality
|
|
171
|
+
if: github.ref == 'refs/heads/main'
|
|
172
|
+
runs-on: ubuntu-latest
|
|
173
|
+
steps:
|
|
174
|
+
- name: Deploy to production
|
|
175
|
+
run: |
|
|
176
|
+
ssh deploy@server "cd /app && git pull && docker-compose up -d --build"
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Environment Configuration
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
# .env.example — documented for all developers
|
|
185
|
+
APP_NAME=NexusApp
|
|
186
|
+
APP_ENV=local
|
|
187
|
+
APP_DEBUG=true
|
|
188
|
+
APP_URL=http://localhost
|
|
189
|
+
|
|
190
|
+
DB_CONNECTION=pgsql
|
|
191
|
+
DB_HOST=127.0.0.1
|
|
192
|
+
DB_PORT=5432
|
|
193
|
+
DB_DATABASE=nexus
|
|
194
|
+
DB_USERNAME=root
|
|
195
|
+
DB_PASSWORD=
|
|
196
|
+
|
|
197
|
+
REDIS_HOST=127.0.0.1
|
|
198
|
+
REDIS_PASSWORD=null
|
|
199
|
+
REDIS_PORT=6379
|
|
200
|
+
|
|
201
|
+
# Never commit real .env files!
|
|
202
|
+
# Create .env.local, .env.staging, .env.production with real values
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Monitoring Setup
|
|
208
|
+
|
|
209
|
+
```yaml
|
|
210
|
+
monitoring:
|
|
211
|
+
health_check:
|
|
212
|
+
endpoint: "/health"
|
|
213
|
+
expected_status: 200
|
|
214
|
+
interval: "30s"
|
|
215
|
+
|
|
216
|
+
error_tracking:
|
|
217
|
+
tool: "Sentry"
|
|
218
|
+
dsn: "${SENTRY_DSN}"
|
|
219
|
+
environment: "${APP_ENV}"
|
|
220
|
+
|
|
221
|
+
performance:
|
|
222
|
+
tool: "Laravel Telescope" # dev only in production use New Relic
|
|
223
|
+
slow_query_threshold: 100ms
|
|
224
|
+
|
|
225
|
+
logging:
|
|
226
|
+
driver: "stack" # daily + sentry
|
|
227
|
+
channels:
|
|
228
|
+
- daily (retention: 30 days)
|
|
229
|
+
- sentry (errors only)
|
|
230
|
+
|
|
231
|
+
alerts:
|
|
232
|
+
- "HTTP 5xx rate > 1% → PagerDuty notification"
|
|
233
|
+
- "Response time > 500ms avg → Slack notification"
|
|
234
|
+
- "Disk usage > 80% → Email to DevOps team"
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Backup Strategy
|
|
240
|
+
|
|
241
|
+
```yaml
|
|
242
|
+
backup:
|
|
243
|
+
database:
|
|
244
|
+
schedule: "daily at 02:00"
|
|
245
|
+
retention: "30 days"
|
|
246
|
+
command: "pg_dump --no-acl --no-owner db_prod > backup/db_$(date +%Y%m%d).sql"
|
|
247
|
+
storage: "S3 bucket (encrypted)"
|
|
248
|
+
|
|
249
|
+
file_storage:
|
|
250
|
+
schedule: "daily at 03:00"
|
|
251
|
+
retention: "90 days"
|
|
252
|
+
command: "aws s3 sync /app/storage s3://backups/app-storage/"
|
|
253
|
+
|
|
254
|
+
restore_test:
|
|
255
|
+
schedule: "monthly"
|
|
256
|
+
procedure: "Restore to staging environment and verify data integrity"
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## Security Hardening
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
- OS: Minimal Alpine Linux (no unnecessary packages)
|
|
265
|
+
- PHP: disable dangerous functions (exec, system, shell_exec)
|
|
266
|
+
- Database: only allow connections from app container
|
|
267
|
+
- Nginx: rate limiting, WAF rules, security headers
|
|
268
|
+
- SSH: key-only, disable root login, fail2ban
|
|
269
|
+
- Docker: read-only root filesystem, no privileged mode
|
|
270
|
+
- Network: internal network for backend, exposed only nginx
|
|
271
|
+
- Secrets: Docker secrets or vault, never in .env committed
|
|
272
|
+
- Updates: automated security patch updates (unattended-upgrades)
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Rules
|
|
278
|
+
|
|
279
|
+
### Always
|
|
280
|
+
|
|
281
|
+
- ✅ Use Infrastructure as Code (Dockerfile, docker-compose, CI/CD yaml).
|
|
282
|
+
- ✅ Keep all config in version control (except secrets).
|
|
283
|
+
- ✅ Use multi-stage builds for smaller images.
|
|
284
|
+
- ✅ Implement health checks for every service.
|
|
285
|
+
- ✅ Set up monitoring and alerts from day one.
|
|
286
|
+
- ✅ Document runbooks for deployment and incident response.
|
|
287
|
+
|
|
288
|
+
### Never
|
|
289
|
+
|
|
290
|
+
- ❌ Hardcode environment-specific values.
|
|
291
|
+
- ❌ Commit .env files with real credentials.
|
|
292
|
+
- ❌ Run containers as root.
|
|
293
|
+
- ❌ Skip health checks.
|
|
294
|
+
- ❌ Deploy without CI/CD pipeline.
|
|
295
|
+
- ❌ Use production DB for testing.
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## Runbook Template
|
|
300
|
+
|
|
301
|
+
```yaml
|
|
302
|
+
runbook:
|
|
303
|
+
deployment:
|
|
304
|
+
steps:
|
|
305
|
+
- "git pull origin main"
|
|
306
|
+
- "docker-compose down"
|
|
307
|
+
- "docker-compose up --build -d"
|
|
308
|
+
- "docker-compose exec app php artisan migrate"
|
|
309
|
+
- "docker-compose exec app php artisan optimize"
|
|
310
|
+
- "Verify: curl -f https://app.com/health"
|
|
311
|
+
|
|
312
|
+
rollback:
|
|
313
|
+
trigger: "Deployment fails health check"
|
|
314
|
+
steps:
|
|
315
|
+
- "docker-compose down"
|
|
316
|
+
- "git revert HEAD"
|
|
317
|
+
- "docker-compose up --build -d"
|
|
318
|
+
- "docker-compose exec app php artisan migrate:rollback"
|
|
319
|
+
|
|
320
|
+
incident_response:
|
|
321
|
+
- "1. Identify affected service"
|
|
322
|
+
- "2. Check logs: docker-compose logs -f --tail=100 app"
|
|
323
|
+
- "3. Check metrics: https://grafana.internal/dashboard"
|
|
324
|
+
- "4. If critical: rollback immediately"
|
|
325
|
+
- "5. Investigate root cause"
|
|
326
|
+
- "6. Apply permanent fix"
|
|
327
|
+
- "7. Postmortem within 24h"
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## Metrics
|
|
333
|
+
|
|
334
|
+
| Metric | Target | How to Measure |
|
|
335
|
+
|--------|--------|---------------|
|
|
336
|
+
| Deploy frequency | ≥ 1/day | Count deployments per week |
|
|
337
|
+
| Deploy success rate | ≥ 99% | Successful deploys / total deploys |
|
|
338
|
+
| Rollback rate | ≤ 2% | Rollbacks / total deploys |
|
|
339
|
+
| MTTR (Mean Time to Recover) | ≤ 1 hour | Time from incident to recovery |
|
|
340
|
+
| Uptime | ≥ 99.9% | Monitoring tool (e.g., UptimeRobot) |
|
|
341
|
+
| Image size | ≤ 200MB | Docker image size |
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
## Changelog
|
|
346
|
+
|
|
347
|
+
### 1.0.0 (2026-07-17)
|
|
348
|
+
|
|
349
|
+
- Initial release
|
|
350
|
+
- Full deployment workflow (8 steps)
|
|
351
|
+
- Multi-stage Dockerfile example (PHP)
|
|
352
|
+
- docker-compose.yml with app, db, nginx
|
|
353
|
+
- GitHub Actions CI/CD pipeline
|
|
354
|
+
- Environment configuration with .env.example
|
|
355
|
+
- Monitoring setup (health, errors, performance, logging, alerts)
|
|
356
|
+
- Backup strategy (database + file storage)
|
|
357
|
+
- Security hardening checklist
|
|
358
|
+
- Runbook template (deploy, rollback, incident)
|