tech-hub-skills 1.2.0 → 1.5.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.
Files changed (198) hide show
  1. package/{LICENSE → .claude/LICENSE} +21 -21
  2. package/.claude/README.md +291 -0
  3. package/.claude/bin/cli.js +266 -0
  4. package/{bin → .claude/bin}/copilot.js +182 -182
  5. package/{bin → .claude/bin}/postinstall.js +42 -42
  6. package/{tech_hub_skills/skills → .claude/commands}/README.md +336 -336
  7. package/{tech_hub_skills/skills → .claude/commands}/ai-engineer.md +104 -104
  8. package/{tech_hub_skills/skills → .claude/commands}/aws.md +143 -143
  9. package/{tech_hub_skills/skills → .claude/commands}/azure.md +149 -149
  10. package/{tech_hub_skills/skills → .claude/commands}/backend-developer.md +108 -108
  11. package/{tech_hub_skills/skills → .claude/commands}/code-review.md +399 -399
  12. package/{tech_hub_skills/skills → .claude/commands}/compliance-automation.md +747 -747
  13. package/{tech_hub_skills/skills → .claude/commands}/compliance-officer.md +108 -108
  14. package/{tech_hub_skills/skills → .claude/commands}/data-engineer.md +113 -113
  15. package/{tech_hub_skills/skills → .claude/commands}/data-governance.md +102 -102
  16. package/{tech_hub_skills/skills → .claude/commands}/data-scientist.md +123 -123
  17. package/{tech_hub_skills/skills → .claude/commands}/database-admin.md +109 -109
  18. package/{tech_hub_skills/skills → .claude/commands}/devops.md +160 -160
  19. package/{tech_hub_skills/skills → .claude/commands}/docker.md +160 -160
  20. package/{tech_hub_skills/skills → .claude/commands}/enterprise-dashboard.md +613 -613
  21. package/{tech_hub_skills/skills → .claude/commands}/finops.md +184 -184
  22. package/{tech_hub_skills/skills → .claude/commands}/frontend-developer.md +108 -108
  23. package/{tech_hub_skills/skills → .claude/commands}/gcp.md +143 -143
  24. package/{tech_hub_skills/skills → .claude/commands}/ml-engineer.md +115 -115
  25. package/{tech_hub_skills/skills → .claude/commands}/mlops.md +187 -187
  26. package/{tech_hub_skills/skills → .claude/commands}/network-engineer.md +109 -109
  27. package/{tech_hub_skills/skills → .claude/commands}/optimization-advisor.md +329 -329
  28. package/{tech_hub_skills/skills → .claude/commands}/orchestrator.md +623 -623
  29. package/{tech_hub_skills/skills → .claude/commands}/platform-engineer.md +102 -102
  30. package/{tech_hub_skills/skills → .claude/commands}/process-automation.md +226 -226
  31. package/{tech_hub_skills/skills → .claude/commands}/process-changelog.md +184 -184
  32. package/{tech_hub_skills/skills → .claude/commands}/process-documentation.md +484 -484
  33. package/{tech_hub_skills/skills → .claude/commands}/process-kanban.md +324 -324
  34. package/{tech_hub_skills/skills → .claude/commands}/process-versioning.md +214 -214
  35. package/{tech_hub_skills/skills → .claude/commands}/product-designer.md +104 -104
  36. package/{tech_hub_skills/skills → .claude/commands}/project-starter.md +443 -443
  37. package/{tech_hub_skills/skills → .claude/commands}/qa-engineer.md +109 -109
  38. package/{tech_hub_skills/skills → .claude/commands}/security-architect.md +135 -135
  39. package/{tech_hub_skills/skills → .claude/commands}/sre.md +109 -109
  40. package/{tech_hub_skills/skills → .claude/commands}/system-design.md +126 -126
  41. package/{tech_hub_skills/skills → .claude/commands}/technical-writer.md +101 -101
  42. package/.claude/package.json +46 -0
  43. package/{tech_hub_skills → .claude}/roles/ai-engineer/skills/01-prompt-engineering/README.md +252 -252
  44. package/.claude/roles/ai-engineer/skills/01-prompt-engineering/prompt_ab_tester.py +356 -0
  45. package/.claude/roles/ai-engineer/skills/01-prompt-engineering/prompt_template_manager.py +274 -0
  46. package/.claude/roles/ai-engineer/skills/01-prompt-engineering/token_cost_estimator.py +324 -0
  47. package/{tech_hub_skills → .claude}/roles/ai-engineer/skills/02-rag-pipeline/README.md +448 -448
  48. package/.claude/roles/ai-engineer/skills/02-rag-pipeline/document_chunker.py +336 -0
  49. package/.claude/roles/ai-engineer/skills/02-rag-pipeline/rag_pipeline.sql +213 -0
  50. package/{tech_hub_skills → .claude}/roles/ai-engineer/skills/03-agent-orchestration/README.md +599 -599
  51. package/{tech_hub_skills → .claude}/roles/ai-engineer/skills/04-llm-guardrails/README.md +735 -735
  52. package/{tech_hub_skills → .claude}/roles/ai-engineer/skills/05-vector-embeddings/README.md +711 -711
  53. package/{tech_hub_skills → .claude}/roles/ai-engineer/skills/06-llm-evaluation/README.md +777 -777
  54. package/{tech_hub_skills → .claude}/roles/azure/skills/01-infrastructure-fundamentals/README.md +264 -264
  55. package/{tech_hub_skills → .claude}/roles/azure/skills/02-data-factory/README.md +264 -264
  56. package/{tech_hub_skills → .claude}/roles/azure/skills/03-synapse-analytics/README.md +264 -264
  57. package/{tech_hub_skills → .claude}/roles/azure/skills/04-databricks/README.md +264 -264
  58. package/{tech_hub_skills → .claude}/roles/azure/skills/05-functions/README.md +264 -264
  59. package/{tech_hub_skills → .claude}/roles/azure/skills/06-kubernetes-service/README.md +264 -264
  60. package/{tech_hub_skills → .claude}/roles/azure/skills/07-openai-service/README.md +264 -264
  61. package/{tech_hub_skills → .claude}/roles/azure/skills/08-machine-learning/README.md +264 -264
  62. package/{tech_hub_skills → .claude}/roles/azure/skills/09-storage-adls/README.md +264 -264
  63. package/{tech_hub_skills → .claude}/roles/azure/skills/10-networking/README.md +264 -264
  64. package/{tech_hub_skills → .claude}/roles/azure/skills/11-sql-cosmos/README.md +264 -264
  65. package/{tech_hub_skills → .claude}/roles/azure/skills/12-event-hubs/README.md +264 -264
  66. package/{tech_hub_skills → .claude}/roles/code-review/skills/01-automated-code-review/README.md +394 -394
  67. package/{tech_hub_skills → .claude}/roles/code-review/skills/02-pr-review-workflow/README.md +427 -427
  68. package/{tech_hub_skills → .claude}/roles/code-review/skills/03-code-quality-gates/README.md +518 -518
  69. package/{tech_hub_skills → .claude}/roles/code-review/skills/04-reviewer-assignment/README.md +504 -504
  70. package/{tech_hub_skills → .claude}/roles/code-review/skills/05-review-analytics/README.md +540 -540
  71. package/{tech_hub_skills → .claude}/roles/data-engineer/skills/01-lakehouse-architecture/README.md +550 -550
  72. package/.claude/roles/data-engineer/skills/01-lakehouse-architecture/bronze_ingestion.py +337 -0
  73. package/.claude/roles/data-engineer/skills/01-lakehouse-architecture/medallion_queries.sql +300 -0
  74. package/{tech_hub_skills → .claude}/roles/data-engineer/skills/02-etl-pipeline/README.md +580 -580
  75. package/{tech_hub_skills → .claude}/roles/data-engineer/skills/03-data-quality/README.md +579 -579
  76. package/{tech_hub_skills → .claude}/roles/data-engineer/skills/04-streaming-pipelines/README.md +608 -608
  77. package/{tech_hub_skills → .claude}/roles/data-engineer/skills/05-performance-optimization/README.md +547 -547
  78. package/{tech_hub_skills → .claude}/roles/data-governance/skills/01-data-catalog/README.md +112 -112
  79. package/{tech_hub_skills → .claude}/roles/data-governance/skills/02-data-lineage/README.md +129 -129
  80. package/{tech_hub_skills → .claude}/roles/data-governance/skills/03-data-quality-framework/README.md +182 -182
  81. package/{tech_hub_skills → .claude}/roles/data-governance/skills/04-access-control/README.md +39 -39
  82. package/{tech_hub_skills → .claude}/roles/data-governance/skills/05-master-data-management/README.md +40 -40
  83. package/{tech_hub_skills → .claude}/roles/data-governance/skills/06-compliance-privacy/README.md +46 -46
  84. package/{tech_hub_skills → .claude}/roles/data-scientist/skills/01-eda-automation/README.md +230 -230
  85. package/.claude/roles/data-scientist/skills/01-eda-automation/eda_generator.py +446 -0
  86. package/{tech_hub_skills → .claude}/roles/data-scientist/skills/02-statistical-modeling/README.md +264 -264
  87. package/{tech_hub_skills → .claude}/roles/data-scientist/skills/03-feature-engineering/README.md +264 -264
  88. package/{tech_hub_skills → .claude}/roles/data-scientist/skills/04-predictive-modeling/README.md +264 -264
  89. package/{tech_hub_skills → .claude}/roles/data-scientist/skills/05-customer-analytics/README.md +264 -264
  90. package/{tech_hub_skills → .claude}/roles/data-scientist/skills/06-campaign-analysis/README.md +264 -264
  91. package/{tech_hub_skills → .claude}/roles/data-scientist/skills/07-experimentation/README.md +264 -264
  92. package/{tech_hub_skills → .claude}/roles/data-scientist/skills/08-data-visualization/README.md +264 -264
  93. package/{tech_hub_skills → .claude}/roles/devops/skills/01-cicd-pipeline/README.md +264 -264
  94. package/{tech_hub_skills → .claude}/roles/devops/skills/02-container-orchestration/README.md +264 -264
  95. package/{tech_hub_skills → .claude}/roles/devops/skills/03-infrastructure-as-code/README.md +264 -264
  96. package/{tech_hub_skills → .claude}/roles/devops/skills/04-gitops/README.md +264 -264
  97. package/{tech_hub_skills → .claude}/roles/devops/skills/05-environment-management/README.md +264 -264
  98. package/{tech_hub_skills → .claude}/roles/devops/skills/06-automated-testing/README.md +264 -264
  99. package/{tech_hub_skills → .claude}/roles/devops/skills/07-release-management/README.md +264 -264
  100. package/{tech_hub_skills → .claude}/roles/devops/skills/08-monitoring-alerting/README.md +264 -264
  101. package/{tech_hub_skills → .claude}/roles/devops/skills/09-devsecops/README.md +265 -265
  102. package/{tech_hub_skills → .claude}/roles/finops/skills/01-cost-visibility/README.md +264 -264
  103. package/{tech_hub_skills → .claude}/roles/finops/skills/02-resource-tagging/README.md +264 -264
  104. package/{tech_hub_skills → .claude}/roles/finops/skills/03-budget-management/README.md +264 -264
  105. package/{tech_hub_skills → .claude}/roles/finops/skills/04-reserved-instances/README.md +264 -264
  106. package/{tech_hub_skills → .claude}/roles/finops/skills/05-spot-optimization/README.md +264 -264
  107. package/{tech_hub_skills → .claude}/roles/finops/skills/06-storage-tiering/README.md +264 -264
  108. package/{tech_hub_skills → .claude}/roles/finops/skills/07-compute-rightsizing/README.md +264 -264
  109. package/{tech_hub_skills → .claude}/roles/finops/skills/08-chargeback/README.md +264 -264
  110. package/{tech_hub_skills → .claude}/roles/ml-engineer/skills/01-mlops-pipeline/README.md +566 -566
  111. package/{tech_hub_skills → .claude}/roles/ml-engineer/skills/02-feature-engineering/README.md +655 -655
  112. package/{tech_hub_skills → .claude}/roles/ml-engineer/skills/03-model-training/README.md +704 -704
  113. package/{tech_hub_skills → .claude}/roles/ml-engineer/skills/04-model-serving/README.md +845 -845
  114. package/{tech_hub_skills → .claude}/roles/ml-engineer/skills/05-model-monitoring/README.md +874 -874
  115. package/{tech_hub_skills → .claude}/roles/mlops/skills/01-ml-pipeline-orchestration/README.md +264 -264
  116. package/{tech_hub_skills → .claude}/roles/mlops/skills/02-experiment-tracking/README.md +264 -264
  117. package/{tech_hub_skills → .claude}/roles/mlops/skills/03-model-registry/README.md +264 -264
  118. package/{tech_hub_skills → .claude}/roles/mlops/skills/04-feature-store/README.md +264 -264
  119. package/{tech_hub_skills → .claude}/roles/mlops/skills/05-model-deployment/README.md +264 -264
  120. package/{tech_hub_skills → .claude}/roles/mlops/skills/06-model-observability/README.md +264 -264
  121. package/{tech_hub_skills → .claude}/roles/mlops/skills/07-data-versioning/README.md +264 -264
  122. package/{tech_hub_skills → .claude}/roles/mlops/skills/08-ab-testing/README.md +264 -264
  123. package/{tech_hub_skills → .claude}/roles/mlops/skills/09-automated-retraining/README.md +264 -264
  124. package/{tech_hub_skills → .claude}/roles/platform-engineer/skills/01-internal-developer-platform/README.md +153 -153
  125. package/{tech_hub_skills → .claude}/roles/platform-engineer/skills/02-self-service-infrastructure/README.md +57 -57
  126. package/{tech_hub_skills → .claude}/roles/platform-engineer/skills/03-slo-sli-management/README.md +59 -59
  127. package/{tech_hub_skills → .claude}/roles/platform-engineer/skills/04-developer-experience/README.md +57 -57
  128. package/{tech_hub_skills → .claude}/roles/platform-engineer/skills/05-incident-management/README.md +73 -73
  129. package/{tech_hub_skills → .claude}/roles/platform-engineer/skills/06-capacity-management/README.md +59 -59
  130. package/{tech_hub_skills → .claude}/roles/product-designer/skills/01-requirements-discovery/README.md +407 -407
  131. package/{tech_hub_skills → .claude}/roles/product-designer/skills/02-user-research/README.md +382 -382
  132. package/{tech_hub_skills → .claude}/roles/product-designer/skills/03-brainstorming-ideation/README.md +437 -437
  133. package/{tech_hub_skills → .claude}/roles/product-designer/skills/04-ux-design/README.md +496 -496
  134. package/{tech_hub_skills → .claude}/roles/product-designer/skills/05-product-market-fit/README.md +376 -376
  135. package/{tech_hub_skills → .claude}/roles/product-designer/skills/06-stakeholder-management/README.md +412 -412
  136. package/{tech_hub_skills → .claude}/roles/security-architect/skills/01-pii-detection/README.md +319 -319
  137. package/{tech_hub_skills → .claude}/roles/security-architect/skills/02-threat-modeling/README.md +264 -264
  138. package/{tech_hub_skills → .claude}/roles/security-architect/skills/03-infrastructure-security/README.md +264 -264
  139. package/{tech_hub_skills → .claude}/roles/security-architect/skills/04-iam/README.md +264 -264
  140. package/{tech_hub_skills → .claude}/roles/security-architect/skills/05-application-security/README.md +264 -264
  141. package/{tech_hub_skills → .claude}/roles/security-architect/skills/06-secrets-management/README.md +264 -264
  142. package/{tech_hub_skills → .claude}/roles/security-architect/skills/07-security-monitoring/README.md +264 -264
  143. package/{tech_hub_skills → .claude}/roles/system-design/skills/01-architecture-patterns/README.md +337 -337
  144. package/{tech_hub_skills → .claude}/roles/system-design/skills/02-requirements-engineering/README.md +264 -264
  145. package/{tech_hub_skills → .claude}/roles/system-design/skills/03-scalability/README.md +264 -264
  146. package/{tech_hub_skills → .claude}/roles/system-design/skills/04-high-availability/README.md +264 -264
  147. package/{tech_hub_skills → .claude}/roles/system-design/skills/05-cost-optimization-design/README.md +264 -264
  148. package/{tech_hub_skills → .claude}/roles/system-design/skills/06-api-design/README.md +264 -264
  149. package/{tech_hub_skills → .claude}/roles/system-design/skills/07-observability-architecture/README.md +264 -264
  150. package/{tech_hub_skills → .claude}/roles/system-design/skills/08-process-automation/PROCESS_TEMPLATE.md +336 -336
  151. package/{tech_hub_skills → .claude}/roles/system-design/skills/08-process-automation/README.md +521 -521
  152. package/.claude/roles/system-design/skills/08-process-automation/ai_prompt_generator.py +744 -0
  153. package/.claude/roles/system-design/skills/08-process-automation/automation_recommender.py +688 -0
  154. package/.claude/roles/system-design/skills/08-process-automation/plan_generator.py +679 -0
  155. package/.claude/roles/system-design/skills/08-process-automation/process_analyzer.py +528 -0
  156. package/.claude/roles/system-design/skills/08-process-automation/process_parser.py +684 -0
  157. package/.claude/roles/system-design/skills/08-process-automation/role_matcher.py +615 -0
  158. package/.claude/skills/README.md +336 -0
  159. package/.claude/skills/ai-engineer.md +104 -0
  160. package/.claude/skills/aws.md +143 -0
  161. package/.claude/skills/azure.md +149 -0
  162. package/.claude/skills/backend-developer.md +108 -0
  163. package/.claude/skills/code-review.md +399 -0
  164. package/.claude/skills/compliance-automation.md +747 -0
  165. package/.claude/skills/compliance-officer.md +108 -0
  166. package/.claude/skills/data-engineer.md +113 -0
  167. package/.claude/skills/data-governance.md +102 -0
  168. package/.claude/skills/data-scientist.md +123 -0
  169. package/.claude/skills/database-admin.md +109 -0
  170. package/.claude/skills/devops.md +160 -0
  171. package/.claude/skills/docker.md +160 -0
  172. package/.claude/skills/enterprise-dashboard.md +613 -0
  173. package/.claude/skills/finops.md +184 -0
  174. package/.claude/skills/frontend-developer.md +108 -0
  175. package/.claude/skills/gcp.md +143 -0
  176. package/.claude/skills/ml-engineer.md +115 -0
  177. package/.claude/skills/mlops.md +187 -0
  178. package/.claude/skills/network-engineer.md +109 -0
  179. package/.claude/skills/optimization-advisor.md +329 -0
  180. package/.claude/skills/orchestrator.md +623 -0
  181. package/.claude/skills/platform-engineer.md +102 -0
  182. package/.claude/skills/process-automation.md +226 -0
  183. package/.claude/skills/process-changelog.md +184 -0
  184. package/.claude/skills/process-documentation.md +484 -0
  185. package/.claude/skills/process-kanban.md +324 -0
  186. package/.claude/skills/process-versioning.md +214 -0
  187. package/.claude/skills/product-designer.md +104 -0
  188. package/.claude/skills/project-starter.md +443 -0
  189. package/.claude/skills/qa-engineer.md +109 -0
  190. package/.claude/skills/security-architect.md +135 -0
  191. package/.claude/skills/sre.md +109 -0
  192. package/.claude/skills/system-design.md +126 -0
  193. package/.claude/skills/technical-writer.md +101 -0
  194. package/.gitattributes +2 -0
  195. package/GITHUB_COPILOT.md +106 -0
  196. package/README.md +192 -291
  197. package/package.json +16 -46
  198. package/bin/cli.js +0 -241
@@ -1,394 +1,394 @@
1
- # cr-01: Automated Code Review
2
-
3
- AI-powered automated code analysis for consistent quality enforcement.
4
-
5
- ## Overview
6
-
7
- Automated code review integrates static analysis, security scanning, and AI-powered suggestions to catch issues before human review. This reduces review burden and ensures consistent quality standards.
8
-
9
- ## Capabilities
10
-
11
- ### Static Analysis
12
- - **Linting**: ESLint, Pylint, RuboCop, golangci-lint
13
- - **Formatting**: Prettier, Black, gofmt
14
- - **Type checking**: TypeScript, mypy, Pyright
15
- - **Complexity**: Cyclomatic, cognitive complexity metrics
16
-
17
- ### Security Scanning
18
- - **SAST**: SonarQube, Semgrep, CodeQL
19
- - **Dependency scanning**: Snyk, Dependabot, npm audit
20
- - **Secret detection**: GitLeaks, TruffleHog
21
- - **Container scanning**: Trivy, Grype
22
-
23
- ### AI-Powered Analysis
24
- - Code suggestions and improvements
25
- - Bug prediction and detection
26
- - Performance anti-pattern identification
27
- - Documentation gap detection
28
-
29
- ## Implementation
30
-
31
- ### GitHub Actions Workflow
32
-
33
- ```yaml
34
- name: Automated Code Review
35
- on:
36
- pull_request:
37
- types: [opened, synchronize, reopened]
38
-
39
- permissions:
40
- contents: read
41
- pull-requests: write
42
- security-events: write
43
-
44
- jobs:
45
- lint:
46
- runs-on: ubuntu-latest
47
- steps:
48
- - uses: actions/checkout@v4
49
-
50
- - name: Setup Node.js
51
- uses: actions/setup-node@v4
52
- with:
53
- node-version: '20'
54
- cache: 'npm'
55
-
56
- - name: Install dependencies
57
- run: npm ci
58
-
59
- - name: Run ESLint
60
- run: |
61
- npx eslint . --format=json --output-file=eslint-report.json || true
62
-
63
- - name: Annotate PR with ESLint results
64
- uses: ataylorme/eslint-annotate-action@v2
65
- with:
66
- report-json: "eslint-report.json"
67
-
68
- security:
69
- runs-on: ubuntu-latest
70
- steps:
71
- - uses: actions/checkout@v4
72
-
73
- - name: Run Semgrep
74
- uses: returntocorp/semgrep-action@v1
75
- with:
76
- config: p/security-audit p/secrets
77
-
78
- - name: Run Snyk
79
- uses: snyk/actions/node@master
80
- continue-on-error: true
81
- env:
82
- SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
83
-
84
- - name: Upload SARIF
85
- uses: github/codeql-action/upload-sarif@v2
86
- with:
87
- sarif_file: snyk.sarif
88
-
89
- complexity:
90
- runs-on: ubuntu-latest
91
- steps:
92
- - uses: actions/checkout@v4
93
-
94
- - name: Check complexity
95
- run: |
96
- npx complexity-report --format json --output complexity.json src/
97
-
98
- - name: Comment complexity report
99
- uses: actions/github-script@v7
100
- with:
101
- script: |
102
- const fs = require('fs');
103
- const report = JSON.parse(fs.readFileSync('complexity.json'));
104
- const high = report.filter(f => f.complexity > 15);
105
- if (high.length > 0) {
106
- const body = '## Complexity Warning\n\n' +
107
- high.map(f => `- \`${f.file}\`: ${f.complexity}`).join('\n');
108
- github.rest.issues.createComment({
109
- issue_number: context.issue.number,
110
- owner: context.repo.owner,
111
- repo: context.repo.repo,
112
- body
113
- });
114
- }
115
- ```
116
-
117
- ### Azure DevOps Pipeline
118
-
119
- ```yaml
120
- trigger: none
121
- pr:
122
- branches:
123
- include:
124
- - main
125
- - develop
126
-
127
- pool:
128
- vmImage: 'ubuntu-latest'
129
-
130
- stages:
131
- - stage: AutomatedReview
132
- displayName: 'Automated Code Review'
133
- jobs:
134
- - job: StaticAnalysis
135
- displayName: 'Static Analysis'
136
- steps:
137
- - task: NodeTool@0
138
- inputs:
139
- versionSpec: '20.x'
140
-
141
- - script: npm ci
142
- displayName: 'Install dependencies'
143
-
144
- - script: |
145
- npx eslint . --format stylish --output-file $(Build.ArtifactStagingDirectory)/eslint.txt
146
- displayName: 'Run ESLint'
147
- continueOnError: true
148
-
149
- - task: PublishBuildArtifacts@1
150
- inputs:
151
- pathToPublish: '$(Build.ArtifactStagingDirectory)'
152
- artifactName: 'code-review'
153
-
154
- - job: SecurityScan
155
- displayName: 'Security Scanning'
156
- steps:
157
- - task: SonarQubePrepare@5
158
- inputs:
159
- SonarQube: 'SonarQube-Connection'
160
- scannerMode: 'CLI'
161
- configMode: 'manual'
162
- cliProjectKey: '$(Build.Repository.Name)'
163
-
164
- - task: SonarQubeAnalyze@5
165
-
166
- - task: SonarQubePublish@5
167
- inputs:
168
- pollingTimeoutSec: '300'
169
-
170
- - task: sonar-buildbreaker@8
171
- inputs:
172
- SonarQube: 'SonarQube-Connection'
173
- ```
174
-
175
- ### Python Analysis Script
176
-
177
- ```python
178
- #!/usr/bin/env python3
179
- """Automated code review analyzer."""
180
-
181
- import json
182
- import subprocess
183
- from dataclasses import dataclass
184
- from pathlib import Path
185
- from typing import List, Dict, Any
186
-
187
- @dataclass
188
- class ReviewFinding:
189
- """Represents a code review finding."""
190
- file: str
191
- line: int
192
- severity: str # critical, high, medium, low, info
193
- category: str # security, quality, performance, style
194
- message: str
195
- rule: str
196
- suggestion: str = ""
197
-
198
- class AutomatedReviewer:
199
- """Enterprise automated code reviewer."""
200
-
201
- def __init__(self, project_path: str = "."):
202
- self.project_path = Path(project_path)
203
- self.findings: List[ReviewFinding] = []
204
-
205
- def run_eslint(self) -> List[ReviewFinding]:
206
- """Run ESLint for JavaScript/TypeScript."""
207
- result = subprocess.run(
208
- ["npx", "eslint", ".", "--format=json"],
209
- capture_output=True,
210
- text=True,
211
- cwd=self.project_path
212
- )
213
-
214
- findings = []
215
- if result.stdout:
216
- data = json.loads(result.stdout)
217
- for file_result in data:
218
- for msg in file_result.get("messages", []):
219
- findings.append(ReviewFinding(
220
- file=file_result["filePath"],
221
- line=msg.get("line", 0),
222
- severity=self._map_severity(msg.get("severity", 1)),
223
- category="style" if "style" in msg.get("ruleId", "") else "quality",
224
- message=msg.get("message", ""),
225
- rule=msg.get("ruleId", ""),
226
- suggestion=msg.get("fix", {}).get("text", "") if msg.get("fix") else ""
227
- ))
228
- return findings
229
-
230
- def run_semgrep(self) -> List[ReviewFinding]:
231
- """Run Semgrep for security analysis."""
232
- result = subprocess.run(
233
- ["semgrep", "--config=auto", "--json", "."],
234
- capture_output=True,
235
- text=True,
236
- cwd=self.project_path
237
- )
238
-
239
- findings = []
240
- if result.stdout:
241
- data = json.loads(result.stdout)
242
- for finding in data.get("results", []):
243
- findings.append(ReviewFinding(
244
- file=finding["path"],
245
- line=finding["start"]["line"],
246
- severity=finding.get("extra", {}).get("severity", "medium"),
247
- category="security",
248
- message=finding["extra"].get("message", ""),
249
- rule=finding["check_id"],
250
- suggestion=finding.get("extra", {}).get("fix", "")
251
- ))
252
- return findings
253
-
254
- def run_complexity_check(self) -> List[ReviewFinding]:
255
- """Check code complexity."""
256
- # Implementation depends on language
257
- # This is a placeholder for complexity analysis
258
- return []
259
-
260
- def _map_severity(self, eslint_severity: int) -> str:
261
- """Map ESLint severity to standard levels."""
262
- return {1: "low", 2: "medium"}.get(eslint_severity, "info")
263
-
264
- def run_all_checks(self) -> Dict[str, Any]:
265
- """Run all automated checks."""
266
- self.findings.extend(self.run_eslint())
267
- self.findings.extend(self.run_semgrep())
268
- self.findings.extend(self.run_complexity_check())
269
-
270
- return {
271
- "total_findings": len(self.findings),
272
- "by_severity": self._count_by_severity(),
273
- "by_category": self._count_by_category(),
274
- "blocking": self._get_blocking_issues(),
275
- "findings": [f.__dict__ for f in self.findings]
276
- }
277
-
278
- def _count_by_severity(self) -> Dict[str, int]:
279
- """Count findings by severity."""
280
- counts = {"critical": 0, "high": 0, "medium": 0, "low": 0, "info": 0}
281
- for f in self.findings:
282
- counts[f.severity] = counts.get(f.severity, 0) + 1
283
- return counts
284
-
285
- def _count_by_category(self) -> Dict[str, int]:
286
- """Count findings by category."""
287
- counts = {}
288
- for f in self.findings:
289
- counts[f.category] = counts.get(f.category, 0) + 1
290
- return counts
291
-
292
- def _get_blocking_issues(self) -> List[Dict]:
293
- """Get issues that should block merge."""
294
- blocking = [f for f in self.findings
295
- if f.severity in ("critical", "high") or f.category == "security"]
296
- return [f.__dict__ for f in blocking]
297
-
298
- def generate_pr_comment(self) -> str:
299
- """Generate a PR comment with findings."""
300
- counts = self._count_by_severity()
301
- blocking = self._get_blocking_issues()
302
-
303
- comment = "## Automated Code Review Results\n\n"
304
-
305
- if blocking:
306
- comment += "### Blocking Issues\n"
307
- for issue in blocking[:10]: # Limit to 10
308
- comment += f"- **{issue['severity'].upper()}** [{issue['rule']}] "
309
- comment += f"`{issue['file']}:{issue['line']}` - {issue['message']}\n"
310
- comment += "\n"
311
-
312
- comment += "### Summary\n"
313
- comment += f"- Critical: {counts['critical']}\n"
314
- comment += f"- High: {counts['high']}\n"
315
- comment += f"- Medium: {counts['medium']}\n"
316
- comment += f"- Low: {counts['low']}\n"
317
-
318
- if not blocking:
319
- comment += "\n All automated checks passed.\n"
320
- else:
321
- comment += "\n Please address blocking issues before merge.\n"
322
-
323
- return comment
324
-
325
-
326
- if __name__ == "__main__":
327
- reviewer = AutomatedReviewer()
328
- results = reviewer.run_all_checks()
329
- print(json.dumps(results, indent=2))
330
- ```
331
-
332
- ## Configuration
333
-
334
- ### ESLint Configuration (.eslintrc.json)
335
- ```json
336
- {
337
- "extends": [
338
- "eslint:recommended",
339
- "plugin:@typescript-eslint/recommended",
340
- "plugin:security/recommended"
341
- ],
342
- "plugins": ["security", "@typescript-eslint"],
343
- "rules": {
344
- "complexity": ["error", 15],
345
- "max-depth": ["error", 4],
346
- "max-lines-per-function": ["error", 100],
347
- "no-eval": "error",
348
- "security/detect-eval-with-expression": "error",
349
- "security/detect-non-literal-regexp": "warn"
350
- }
351
- }
352
- ```
353
-
354
- ### Semgrep Configuration (.semgrep.yml)
355
- ```yaml
356
- rules:
357
- - id: hardcoded-secret
358
- patterns:
359
- - pattern-regex: (password|secret|key|token)\s*=\s*["'][^"']+["']
360
- message: "Potential hardcoded secret detected"
361
- severity: ERROR
362
- languages: [python, javascript, typescript]
363
-
364
- - id: sql-injection
365
- patterns:
366
- - pattern: $QUERY = "..." + $INPUT + "..."
367
- - pattern: f"SELECT ... {$INPUT} ..."
368
- message: "Potential SQL injection vulnerability"
369
- severity: ERROR
370
- languages: [python, javascript]
371
- ```
372
-
373
- ## Metrics
374
-
375
- | Metric | Target | Description |
376
- |--------|--------|-------------|
377
- | False positive rate | < 10% | Minimize noise |
378
- | Detection rate | > 90% | Catch real issues |
379
- | Scan time | < 5 min | Fast feedback |
380
- | Coverage | 100% changed files | Review all changes |
381
-
382
- ## Connections
383
-
384
- - **Inputs from**: Developer push, PR creation
385
- - **Outputs to**: PR comments, quality gates (cr-03)
386
- - **Integrates with**: Security Architect (sa-05), DevOps (do-09)
387
-
388
- ## Best Practices
389
-
390
- 1. Run automated checks on every push, not just PRs
391
- 2. Fix tool configuration issues quickly to maintain trust
392
- 3. Suppress false positives with inline comments, not config
393
- 4. Review and update rules quarterly
394
- 5. Track false positive rate and tune accordingly
1
+ # cr-01: Automated Code Review
2
+
3
+ AI-powered automated code analysis for consistent quality enforcement.
4
+
5
+ ## Overview
6
+
7
+ Automated code review integrates static analysis, security scanning, and AI-powered suggestions to catch issues before human review. This reduces review burden and ensures consistent quality standards.
8
+
9
+ ## Capabilities
10
+
11
+ ### Static Analysis
12
+ - **Linting**: ESLint, Pylint, RuboCop, golangci-lint
13
+ - **Formatting**: Prettier, Black, gofmt
14
+ - **Type checking**: TypeScript, mypy, Pyright
15
+ - **Complexity**: Cyclomatic, cognitive complexity metrics
16
+
17
+ ### Security Scanning
18
+ - **SAST**: SonarQube, Semgrep, CodeQL
19
+ - **Dependency scanning**: Snyk, Dependabot, npm audit
20
+ - **Secret detection**: GitLeaks, TruffleHog
21
+ - **Container scanning**: Trivy, Grype
22
+
23
+ ### AI-Powered Analysis
24
+ - Code suggestions and improvements
25
+ - Bug prediction and detection
26
+ - Performance anti-pattern identification
27
+ - Documentation gap detection
28
+
29
+ ## Implementation
30
+
31
+ ### GitHub Actions Workflow
32
+
33
+ ```yaml
34
+ name: Automated Code Review
35
+ on:
36
+ pull_request:
37
+ types: [opened, synchronize, reopened]
38
+
39
+ permissions:
40
+ contents: read
41
+ pull-requests: write
42
+ security-events: write
43
+
44
+ jobs:
45
+ lint:
46
+ runs-on: ubuntu-latest
47
+ steps:
48
+ - uses: actions/checkout@v4
49
+
50
+ - name: Setup Node.js
51
+ uses: actions/setup-node@v4
52
+ with:
53
+ node-version: '20'
54
+ cache: 'npm'
55
+
56
+ - name: Install dependencies
57
+ run: npm ci
58
+
59
+ - name: Run ESLint
60
+ run: |
61
+ npx eslint . --format=json --output-file=eslint-report.json || true
62
+
63
+ - name: Annotate PR with ESLint results
64
+ uses: ataylorme/eslint-annotate-action@v2
65
+ with:
66
+ report-json: "eslint-report.json"
67
+
68
+ security:
69
+ runs-on: ubuntu-latest
70
+ steps:
71
+ - uses: actions/checkout@v4
72
+
73
+ - name: Run Semgrep
74
+ uses: returntocorp/semgrep-action@v1
75
+ with:
76
+ config: p/security-audit p/secrets
77
+
78
+ - name: Run Snyk
79
+ uses: snyk/actions/node@master
80
+ continue-on-error: true
81
+ env:
82
+ SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
83
+
84
+ - name: Upload SARIF
85
+ uses: github/codeql-action/upload-sarif@v2
86
+ with:
87
+ sarif_file: snyk.sarif
88
+
89
+ complexity:
90
+ runs-on: ubuntu-latest
91
+ steps:
92
+ - uses: actions/checkout@v4
93
+
94
+ - name: Check complexity
95
+ run: |
96
+ npx complexity-report --format json --output complexity.json src/
97
+
98
+ - name: Comment complexity report
99
+ uses: actions/github-script@v7
100
+ with:
101
+ script: |
102
+ const fs = require('fs');
103
+ const report = JSON.parse(fs.readFileSync('complexity.json'));
104
+ const high = report.filter(f => f.complexity > 15);
105
+ if (high.length > 0) {
106
+ const body = '## Complexity Warning\n\n' +
107
+ high.map(f => `- \`${f.file}\`: ${f.complexity}`).join('\n');
108
+ github.rest.issues.createComment({
109
+ issue_number: context.issue.number,
110
+ owner: context.repo.owner,
111
+ repo: context.repo.repo,
112
+ body
113
+ });
114
+ }
115
+ ```
116
+
117
+ ### Azure DevOps Pipeline
118
+
119
+ ```yaml
120
+ trigger: none
121
+ pr:
122
+ branches:
123
+ include:
124
+ - main
125
+ - develop
126
+
127
+ pool:
128
+ vmImage: 'ubuntu-latest'
129
+
130
+ stages:
131
+ - stage: AutomatedReview
132
+ displayName: 'Automated Code Review'
133
+ jobs:
134
+ - job: StaticAnalysis
135
+ displayName: 'Static Analysis'
136
+ steps:
137
+ - task: NodeTool@0
138
+ inputs:
139
+ versionSpec: '20.x'
140
+
141
+ - script: npm ci
142
+ displayName: 'Install dependencies'
143
+
144
+ - script: |
145
+ npx eslint . --format stylish --output-file $(Build.ArtifactStagingDirectory)/eslint.txt
146
+ displayName: 'Run ESLint'
147
+ continueOnError: true
148
+
149
+ - task: PublishBuildArtifacts@1
150
+ inputs:
151
+ pathToPublish: '$(Build.ArtifactStagingDirectory)'
152
+ artifactName: 'code-review'
153
+
154
+ - job: SecurityScan
155
+ displayName: 'Security Scanning'
156
+ steps:
157
+ - task: SonarQubePrepare@5
158
+ inputs:
159
+ SonarQube: 'SonarQube-Connection'
160
+ scannerMode: 'CLI'
161
+ configMode: 'manual'
162
+ cliProjectKey: '$(Build.Repository.Name)'
163
+
164
+ - task: SonarQubeAnalyze@5
165
+
166
+ - task: SonarQubePublish@5
167
+ inputs:
168
+ pollingTimeoutSec: '300'
169
+
170
+ - task: sonar-buildbreaker@8
171
+ inputs:
172
+ SonarQube: 'SonarQube-Connection'
173
+ ```
174
+
175
+ ### Python Analysis Script
176
+
177
+ ```python
178
+ #!/usr/bin/env python3
179
+ """Automated code review analyzer."""
180
+
181
+ import json
182
+ import subprocess
183
+ from dataclasses import dataclass
184
+ from pathlib import Path
185
+ from typing import List, Dict, Any
186
+
187
+ @dataclass
188
+ class ReviewFinding:
189
+ """Represents a code review finding."""
190
+ file: str
191
+ line: int
192
+ severity: str # critical, high, medium, low, info
193
+ category: str # security, quality, performance, style
194
+ message: str
195
+ rule: str
196
+ suggestion: str = ""
197
+
198
+ class AutomatedReviewer:
199
+ """Enterprise automated code reviewer."""
200
+
201
+ def __init__(self, project_path: str = "."):
202
+ self.project_path = Path(project_path)
203
+ self.findings: List[ReviewFinding] = []
204
+
205
+ def run_eslint(self) -> List[ReviewFinding]:
206
+ """Run ESLint for JavaScript/TypeScript."""
207
+ result = subprocess.run(
208
+ ["npx", "eslint", ".", "--format=json"],
209
+ capture_output=True,
210
+ text=True,
211
+ cwd=self.project_path
212
+ )
213
+
214
+ findings = []
215
+ if result.stdout:
216
+ data = json.loads(result.stdout)
217
+ for file_result in data:
218
+ for msg in file_result.get("messages", []):
219
+ findings.append(ReviewFinding(
220
+ file=file_result["filePath"],
221
+ line=msg.get("line", 0),
222
+ severity=self._map_severity(msg.get("severity", 1)),
223
+ category="style" if "style" in msg.get("ruleId", "") else "quality",
224
+ message=msg.get("message", ""),
225
+ rule=msg.get("ruleId", ""),
226
+ suggestion=msg.get("fix", {}).get("text", "") if msg.get("fix") else ""
227
+ ))
228
+ return findings
229
+
230
+ def run_semgrep(self) -> List[ReviewFinding]:
231
+ """Run Semgrep for security analysis."""
232
+ result = subprocess.run(
233
+ ["semgrep", "--config=auto", "--json", "."],
234
+ capture_output=True,
235
+ text=True,
236
+ cwd=self.project_path
237
+ )
238
+
239
+ findings = []
240
+ if result.stdout:
241
+ data = json.loads(result.stdout)
242
+ for finding in data.get("results", []):
243
+ findings.append(ReviewFinding(
244
+ file=finding["path"],
245
+ line=finding["start"]["line"],
246
+ severity=finding.get("extra", {}).get("severity", "medium"),
247
+ category="security",
248
+ message=finding["extra"].get("message", ""),
249
+ rule=finding["check_id"],
250
+ suggestion=finding.get("extra", {}).get("fix", "")
251
+ ))
252
+ return findings
253
+
254
+ def run_complexity_check(self) -> List[ReviewFinding]:
255
+ """Check code complexity."""
256
+ # Implementation depends on language
257
+ # This is a placeholder for complexity analysis
258
+ return []
259
+
260
+ def _map_severity(self, eslint_severity: int) -> str:
261
+ """Map ESLint severity to standard levels."""
262
+ return {1: "low", 2: "medium"}.get(eslint_severity, "info")
263
+
264
+ def run_all_checks(self) -> Dict[str, Any]:
265
+ """Run all automated checks."""
266
+ self.findings.extend(self.run_eslint())
267
+ self.findings.extend(self.run_semgrep())
268
+ self.findings.extend(self.run_complexity_check())
269
+
270
+ return {
271
+ "total_findings": len(self.findings),
272
+ "by_severity": self._count_by_severity(),
273
+ "by_category": self._count_by_category(),
274
+ "blocking": self._get_blocking_issues(),
275
+ "findings": [f.__dict__ for f in self.findings]
276
+ }
277
+
278
+ def _count_by_severity(self) -> Dict[str, int]:
279
+ """Count findings by severity."""
280
+ counts = {"critical": 0, "high": 0, "medium": 0, "low": 0, "info": 0}
281
+ for f in self.findings:
282
+ counts[f.severity] = counts.get(f.severity, 0) + 1
283
+ return counts
284
+
285
+ def _count_by_category(self) -> Dict[str, int]:
286
+ """Count findings by category."""
287
+ counts = {}
288
+ for f in self.findings:
289
+ counts[f.category] = counts.get(f.category, 0) + 1
290
+ return counts
291
+
292
+ def _get_blocking_issues(self) -> List[Dict]:
293
+ """Get issues that should block merge."""
294
+ blocking = [f for f in self.findings
295
+ if f.severity in ("critical", "high") or f.category == "security"]
296
+ return [f.__dict__ for f in blocking]
297
+
298
+ def generate_pr_comment(self) -> str:
299
+ """Generate a PR comment with findings."""
300
+ counts = self._count_by_severity()
301
+ blocking = self._get_blocking_issues()
302
+
303
+ comment = "## Automated Code Review Results\n\n"
304
+
305
+ if blocking:
306
+ comment += "### Blocking Issues\n"
307
+ for issue in blocking[:10]: # Limit to 10
308
+ comment += f"- **{issue['severity'].upper()}** [{issue['rule']}] "
309
+ comment += f"`{issue['file']}:{issue['line']}` - {issue['message']}\n"
310
+ comment += "\n"
311
+
312
+ comment += "### Summary\n"
313
+ comment += f"- Critical: {counts['critical']}\n"
314
+ comment += f"- High: {counts['high']}\n"
315
+ comment += f"- Medium: {counts['medium']}\n"
316
+ comment += f"- Low: {counts['low']}\n"
317
+
318
+ if not blocking:
319
+ comment += "\n All automated checks passed.\n"
320
+ else:
321
+ comment += "\n Please address blocking issues before merge.\n"
322
+
323
+ return comment
324
+
325
+
326
+ if __name__ == "__main__":
327
+ reviewer = AutomatedReviewer()
328
+ results = reviewer.run_all_checks()
329
+ print(json.dumps(results, indent=2))
330
+ ```
331
+
332
+ ## Configuration
333
+
334
+ ### ESLint Configuration (.eslintrc.json)
335
+ ```json
336
+ {
337
+ "extends": [
338
+ "eslint:recommended",
339
+ "plugin:@typescript-eslint/recommended",
340
+ "plugin:security/recommended"
341
+ ],
342
+ "plugins": ["security", "@typescript-eslint"],
343
+ "rules": {
344
+ "complexity": ["error", 15],
345
+ "max-depth": ["error", 4],
346
+ "max-lines-per-function": ["error", 100],
347
+ "no-eval": "error",
348
+ "security/detect-eval-with-expression": "error",
349
+ "security/detect-non-literal-regexp": "warn"
350
+ }
351
+ }
352
+ ```
353
+
354
+ ### Semgrep Configuration (.semgrep.yml)
355
+ ```yaml
356
+ rules:
357
+ - id: hardcoded-secret
358
+ patterns:
359
+ - pattern-regex: (password|secret|key|token)\s*=\s*["'][^"']+["']
360
+ message: "Potential hardcoded secret detected"
361
+ severity: ERROR
362
+ languages: [python, javascript, typescript]
363
+
364
+ - id: sql-injection
365
+ patterns:
366
+ - pattern: $QUERY = "..." + $INPUT + "..."
367
+ - pattern: f"SELECT ... {$INPUT} ..."
368
+ message: "Potential SQL injection vulnerability"
369
+ severity: ERROR
370
+ languages: [python, javascript]
371
+ ```
372
+
373
+ ## Metrics
374
+
375
+ | Metric | Target | Description |
376
+ |--------|--------|-------------|
377
+ | False positive rate | < 10% | Minimize noise |
378
+ | Detection rate | > 90% | Catch real issues |
379
+ | Scan time | < 5 min | Fast feedback |
380
+ | Coverage | 100% changed files | Review all changes |
381
+
382
+ ## Connections
383
+
384
+ - **Inputs from**: Developer push, PR creation
385
+ - **Outputs to**: PR comments, quality gates (cr-03)
386
+ - **Integrates with**: Security Architect (sa-05), DevOps (do-09)
387
+
388
+ ## Best Practices
389
+
390
+ 1. Run automated checks on every push, not just PRs
391
+ 2. Fix tool configuration issues quickly to maintain trust
392
+ 3. Suppress false positives with inline comments, not config
393
+ 4. Review and update rules quarterly
394
+ 5. Track false positive rate and tune accordingly