skillstore-cli 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.
Files changed (231) hide show
  1. package/README.md +95 -0
  2. package/data/bundles/devflow-complete.json +19 -0
  3. package/data/free-skills/devflow-agile/manifest.json +19 -0
  4. package/data/free-skills/devflow-agile/plugin/commands/agile/retro.md +23 -0
  5. package/data/free-skills/devflow-agile/plugin/commands/agile/review.md +21 -0
  6. package/data/free-skills/devflow-agile/plugin/commands/agile/sprint.md +30 -0
  7. package/data/free-skills/devflow-agile/plugin/commands/agile/standup.md +20 -0
  8. package/data/free-skills/devflow-agile/plugin/commands/agile.md +35 -0
  9. package/data/free-skills/devflow-agile/plugin/commands/devflow.md +42 -0
  10. package/data/free-skills/devflow-agile/plugin/skills/developer/SKILL.md +93 -0
  11. package/data/free-skills/devflow-agile/plugin/skills/developer/assets/sample-output.md +182 -0
  12. package/data/free-skills/devflow-agile/plugin/skills/developer/references/clean-architecture.md +361 -0
  13. package/data/free-skills/devflow-agile/plugin/skills/developer/references/clean-code-guide.md +207 -0
  14. package/data/free-skills/devflow-agile/plugin/skills/developer/references/debugging-methodology.md +191 -0
  15. package/data/free-skills/devflow-agile/template/agents/agile-coach.md +76 -0
  16. package/data/free-skills/devflow-agile/template/workflows/agile-sprint-workflow.md +81 -0
  17. package/data/free-skills/devflow-bootstrap/manifest.json +8 -0
  18. package/data/free-skills/devflow-bootstrap/plugin/commands/bootstrap/auto.md +31 -0
  19. package/data/free-skills/devflow-bootstrap/plugin/commands/bootstrap.md +38 -0
  20. package/data/free-skills/devflow-bootstrap/plugin/commands/devflow.md +20 -0
  21. package/data/free-skills/devflow-bootstrap/plugin/skills/project-scaffold/SKILL.md +56 -0
  22. package/data/free-skills/devflow-bootstrap/plugin/skills/project-scaffold/assets/sample-output.md +216 -0
  23. package/data/free-skills/devflow-bootstrap/plugin/skills/project-scaffold/references/architecture-decisions.md +254 -0
  24. package/data/free-skills/devflow-bootstrap/plugin/skills/project-scaffold/references/stack-templates.md +400 -0
  25. package/data/free-skills/devflow-bootstrap/template/agents/bootstrap-specialist.md +56 -0
  26. package/data/free-skills/devflow-bootstrap/template/workflows/bootstrap-workflow.md +70 -0
  27. package/data/free-skills/devflow-docs/manifest.json +8 -0
  28. package/data/free-skills/devflow-docs/plugin/commands/devflow.md +20 -0
  29. package/data/free-skills/devflow-docs/plugin/commands/docs/generate.md +17 -0
  30. package/data/free-skills/devflow-docs/plugin/commands/docs/parse.md +19 -0
  31. package/data/free-skills/devflow-docs/plugin/commands/docs.md +26 -0
  32. package/data/free-skills/devflow-docs/plugin/skills/pdf-processor/SKILL.md +59 -0
  33. package/data/free-skills/devflow-docs/plugin/skills/pdf-processor/assets/sample-output.md +114 -0
  34. package/data/free-skills/devflow-docs/plugin/skills/pdf-processor/references/extraction-techniques.md +115 -0
  35. package/data/free-skills/devflow-docs/plugin/skills/pdf-processor/references/ocr-strategies.md +167 -0
  36. package/data/free-skills/devflow-docs/template/agents/docs-specialist.md +35 -0
  37. package/data/free-skills/devflow-docs/template/workflows/docs-workflow.md +70 -0
  38. package/data/free-skills/devflow-postproject/manifest.json +13 -0
  39. package/data/free-skills/devflow-postproject/plugin/commands/devflow.md +34 -0
  40. package/data/free-skills/devflow-postproject/plugin/commands/postproject/handover.md +21 -0
  41. package/data/free-skills/devflow-postproject/plugin/commands/postproject/retro.md +21 -0
  42. package/data/free-skills/devflow-postproject/plugin/commands/postproject/support.md +21 -0
  43. package/data/free-skills/devflow-postproject/plugin/commands/postproject.md +32 -0
  44. package/data/free-skills/devflow-postproject/plugin/skills/retrospective/SKILL.md +70 -0
  45. package/data/free-skills/devflow-postproject/plugin/skills/retrospective/assets/sample-output.md +79 -0
  46. package/data/free-skills/devflow-postproject/plugin/skills/retrospective/references/facilitation-techniques.md +178 -0
  47. package/data/free-skills/devflow-postproject/plugin/skills/retrospective/references/lessons-learned-template.md +118 -0
  48. package/data/free-skills/devflow-postproject/plugin/skills/retrospective/references/retro-techniques.md +100 -0
  49. package/data/free-skills/devflow-postproject/template/agents/transition-manager.md +71 -0
  50. package/data/free-skills/devflow-postproject/template/workflows/transition-workflow.md +72 -0
  51. package/data/free-skills/devflow-presale/manifest.json +15 -0
  52. package/data/free-skills/devflow-presale/plugin/commands/devflow.md +47 -0
  53. package/data/free-skills/devflow-presale/plugin/commands/presale/analyze.md +30 -0
  54. package/data/free-skills/devflow-presale/plugin/commands/presale/estimate.md +30 -0
  55. package/data/free-skills/devflow-presale/plugin/commands/presale/price.md +30 -0
  56. package/data/free-skills/devflow-presale/plugin/commands/presale/propose.md +30 -0
  57. package/data/free-skills/devflow-presale/plugin/commands/presale.md +42 -0
  58. package/data/free-skills/devflow-presale/plugin/skills/requirement-analysis/SKILL.md +63 -0
  59. package/data/free-skills/devflow-presale/plugin/skills/requirement-analysis/assets/sample-output.md +129 -0
  60. package/data/free-skills/devflow-presale/plugin/skills/requirement-analysis/references/extraction-framework.md +140 -0
  61. package/data/free-skills/devflow-presale/plugin/skills/requirement-analysis/references/output-template.md +132 -0
  62. package/data/free-skills/devflow-presale/template/agents/presale-lead.md +83 -0
  63. package/data/free-skills/devflow-presale/template/agents/proposal-reviewer.md +63 -0
  64. package/data/free-skills/devflow-presale/template/workflows/presale-workflow.md +70 -0
  65. package/data/registry/categories.json +7 -0
  66. package/data/registry/packages.json +184 -0
  67. package/data/shared/framework/agents/brainstormer.md +74 -0
  68. package/data/shared/framework/agents/code-reviewer.md +87 -0
  69. package/data/shared/framework/agents/debugger.md +84 -0
  70. package/data/shared/framework/agents/docs-manager.md +55 -0
  71. package/data/shared/framework/agents/git-manager.md +59 -0
  72. package/data/shared/framework/agents/planner.md +68 -0
  73. package/data/shared/framework/agents/researcher.md +66 -0
  74. package/data/shared/framework/agents/tester.md +65 -0
  75. package/data/shared/framework/commands/cook/auto.md +27 -0
  76. package/data/shared/framework/commands/cook.md +45 -0
  77. package/data/shared/framework/commands/fix/ci.md +21 -0
  78. package/data/shared/framework/commands/fix/test.md +26 -0
  79. package/data/shared/framework/commands/fix/types.md +29 -0
  80. package/data/shared/framework/commands/fix.md +26 -0
  81. package/data/shared/framework/commands/git/cm.md +37 -0
  82. package/data/shared/framework/commands/git/pr.md +40 -0
  83. package/data/shared/framework/config/CLAUDE.md.template +26 -0
  84. package/data/shared/framework/config/settings.json +41 -0
  85. package/data/shared/framework/config/skillstore.config.json +29 -0
  86. package/data/shared/framework/hooks/discord-notify.sh +85 -0
  87. package/data/shared/framework/hooks/docs-sync.sh +53 -0
  88. package/data/shared/framework/hooks/modularization-hook.js +103 -0
  89. package/data/shared/framework/hooks/notification.js +94 -0
  90. package/data/shared/framework/hooks/quality-gate.js +109 -0
  91. package/data/shared/framework/hooks/scout-block.js +77 -0
  92. package/data/shared/framework/hooks/telegram-notify.sh +77 -0
  93. package/data/shared/framework/protocols/error-recovery.md +80 -0
  94. package/data/shared/framework/protocols/orchestration-protocol.md +112 -0
  95. package/data/shared/framework/quality/review-protocol.md +76 -0
  96. package/data/shared/framework/quality/verification-protocol.md +66 -0
  97. package/data/shared/framework/rules/development-rules.md +75 -0
  98. package/data/shared/framework/skills/backend-development/SKILL.md +77 -0
  99. package/data/shared/framework/skills/backend-development/assets/sample-output.md +175 -0
  100. package/data/shared/framework/skills/backend-development/references/advanced-patterns.md +180 -0
  101. package/data/shared/framework/skills/backend-development/references/api-design-guide.md +160 -0
  102. package/data/shared/framework/skills/backend-development/references/architecture-patterns.md +183 -0
  103. package/data/shared/framework/skills/backend-development/references/observability-resilience.md +155 -0
  104. package/data/shared/framework/skills/backend-development/references/troubleshooting.md +199 -0
  105. package/data/shared/framework/skills/codebase-analysis/SKILL.md +72 -0
  106. package/data/shared/framework/skills/codebase-analysis/assets/sample-output.md +263 -0
  107. package/data/shared/framework/skills/codebase-analysis/references/analysis-techniques.md +241 -0
  108. package/data/shared/framework/skills/codebase-analysis/references/dependency-mapping.md +280 -0
  109. package/data/shared/framework/skills/codebase-analysis/references/tech-debt-assessment.md +208 -0
  110. package/data/shared/framework/skills/databases/SKILL.md +72 -0
  111. package/data/shared/framework/skills/databases/assets/sample-output.md +212 -0
  112. package/data/shared/framework/skills/databases/references/advanced-data-patterns.md +259 -0
  113. package/data/shared/framework/skills/databases/references/query-optimization.md +214 -0
  114. package/data/shared/framework/skills/databases/references/schema-design.md +159 -0
  115. package/data/shared/framework/skills/databases/references/troubleshooting.md +214 -0
  116. package/data/shared/framework/skills/debugging-investigation/SKILL.md +84 -0
  117. package/data/shared/framework/skills/debugging-investigation/assets/sample-output.md +314 -0
  118. package/data/shared/framework/skills/debugging-investigation/references/systematic-debugging.md +197 -0
  119. package/data/shared/framework/skills/debugging-investigation/references/tool-specific-guides.md +202 -0
  120. package/data/shared/framework/skills/debugging-investigation/references/troubleshooting-patterns.md +196 -0
  121. package/data/shared/framework/skills/frontend-development/SKILL.md +67 -0
  122. package/data/shared/framework/skills/frontend-development/assets/sample-output.md +110 -0
  123. package/data/shared/framework/skills/frontend-development/references/component-patterns.md +112 -0
  124. package/data/shared/framework/skills/frontend-development/references/performance-guide.md +169 -0
  125. package/data/shared/framework/skills/frontend-development/references/routing-forms-realtime.md +374 -0
  126. package/data/shared/framework/skills/frontend-development/references/ssr-rsc-patterns.md +284 -0
  127. package/data/shared/framework/skills/frontend-development/references/troubleshooting.md +154 -0
  128. package/data/shared/framework/skills/mobile-development/SKILL.md +67 -0
  129. package/data/shared/framework/skills/mobile-development/assets/sample-output.md +382 -0
  130. package/data/shared/framework/skills/mobile-development/references/mobile-patterns.md +681 -0
  131. package/data/shared/framework/skills/mobile-development/references/mobile-performance.md +524 -0
  132. package/data/shared/framework/skills/mobile-development/references/troubleshooting.md +158 -0
  133. package/data/shared/framework/skills/security-audit/SKILL.md +83 -0
  134. package/data/shared/framework/skills/security-audit/assets/sample-output.md +451 -0
  135. package/data/shared/framework/skills/security-audit/references/owasp-checklist.md +580 -0
  136. package/data/shared/framework/skills/security-audit/references/secure-coding-patterns.md +433 -0
  137. package/data/shared/framework/skills/security-audit/references/vulnerability-remediation.md +331 -0
  138. package/data/shared/framework/skills/ui-generation/SKILL.md +70 -0
  139. package/data/shared/framework/skills/ui-generation/assets/sample-output.md +139 -0
  140. package/data/shared/framework/skills/ui-generation/references/accessibility-responsive.md +127 -0
  141. package/data/shared/framework/skills/ui-generation/references/compound-components.md +252 -0
  142. package/data/shared/framework/skills/ui-generation/references/generation-patterns.md +110 -0
  143. package/data/shared/framework/skills/ui-generation/references/storybook-design-system.md +278 -0
  144. package/data/shared/framework/skills/ui-generation/references/troubleshooting.md +198 -0
  145. package/data/shared/framework/workflows/documentation-management.md +58 -0
  146. package/data/shared/framework/workflows/primary-workflow.md +88 -0
  147. package/dist/commands/activate.d.ts +3 -0
  148. package/dist/commands/activate.d.ts.map +1 -0
  149. package/dist/commands/activate.js +34 -0
  150. package/dist/commands/activate.js.map +1 -0
  151. package/dist/commands/bundle.d.ts +3 -0
  152. package/dist/commands/bundle.d.ts.map +1 -0
  153. package/dist/commands/bundle.js +64 -0
  154. package/dist/commands/bundle.js.map +1 -0
  155. package/dist/commands/install.d.ts +3 -0
  156. package/dist/commands/install.d.ts.map +1 -0
  157. package/dist/commands/install.js +99 -0
  158. package/dist/commands/install.js.map +1 -0
  159. package/dist/commands/list.d.ts +3 -0
  160. package/dist/commands/list.d.ts.map +1 -0
  161. package/dist/commands/list.js +37 -0
  162. package/dist/commands/list.js.map +1 -0
  163. package/dist/commands/search.d.ts +3 -0
  164. package/dist/commands/search.d.ts.map +1 -0
  165. package/dist/commands/search.js +30 -0
  166. package/dist/commands/search.js.map +1 -0
  167. package/dist/commands/status.d.ts +3 -0
  168. package/dist/commands/status.d.ts.map +1 -0
  169. package/dist/commands/status.js +35 -0
  170. package/dist/commands/status.js.map +1 -0
  171. package/dist/commands/update.d.ts +3 -0
  172. package/dist/commands/update.d.ts.map +1 -0
  173. package/dist/commands/update.js +68 -0
  174. package/dist/commands/update.js.map +1 -0
  175. package/dist/download/cache.d.ts +3 -0
  176. package/dist/download/cache.d.ts.map +1 -0
  177. package/dist/download/cache.js +18 -0
  178. package/dist/download/cache.js.map +1 -0
  179. package/dist/download/client.d.ts +2 -0
  180. package/dist/download/client.d.ts.map +1 -0
  181. package/dist/download/client.js +58 -0
  182. package/dist/download/client.js.map +1 -0
  183. package/dist/index.d.ts +3 -0
  184. package/dist/index.d.ts.map +1 -0
  185. package/dist/index.js +23 -0
  186. package/dist/index.js.map +1 -0
  187. package/dist/installer/file-copier.d.ts +6 -0
  188. package/dist/installer/file-copier.d.ts.map +1 -0
  189. package/dist/installer/file-copier.js +32 -0
  190. package/dist/installer/file-copier.js.map +1 -0
  191. package/dist/installer/plugin-installer.d.ts +12 -0
  192. package/dist/installer/plugin-installer.d.ts.map +1 -0
  193. package/dist/installer/plugin-installer.js +33 -0
  194. package/dist/installer/plugin-installer.js.map +1 -0
  195. package/dist/installer/template-installer.d.ts +12 -0
  196. package/dist/installer/template-installer.d.ts.map +1 -0
  197. package/dist/installer/template-installer.js +45 -0
  198. package/dist/installer/template-installer.js.map +1 -0
  199. package/dist/license/crypto.d.ts +16 -0
  200. package/dist/license/crypto.d.ts.map +1 -0
  201. package/dist/license/crypto.js +50 -0
  202. package/dist/license/crypto.js.map +1 -0
  203. package/dist/license/license-store.d.ts +19 -0
  204. package/dist/license/license-store.d.ts.map +1 -0
  205. package/dist/license/license-store.js +99 -0
  206. package/dist/license/license-store.js.map +1 -0
  207. package/dist/license/validator.d.ts +32 -0
  208. package/dist/license/validator.d.ts.map +1 -0
  209. package/dist/license/validator.js +81 -0
  210. package/dist/license/validator.js.map +1 -0
  211. package/dist/registry/loader.d.ts +30 -0
  212. package/dist/registry/loader.d.ts.map +1 -0
  213. package/dist/registry/loader.js +22 -0
  214. package/dist/registry/loader.js.map +1 -0
  215. package/dist/registry/search-engine.d.ts +9 -0
  216. package/dist/registry/search-engine.d.ts.map +1 -0
  217. package/dist/registry/search-engine.js +30 -0
  218. package/dist/registry/search-engine.js.map +1 -0
  219. package/dist/utils/config.d.ts +14 -0
  220. package/dist/utils/config.d.ts.map +1 -0
  221. package/dist/utils/config.js +28 -0
  222. package/dist/utils/config.js.map +1 -0
  223. package/dist/utils/logger.d.ts +9 -0
  224. package/dist/utils/logger.d.ts.map +1 -0
  225. package/dist/utils/logger.js +22 -0
  226. package/dist/utils/logger.js.map +1 -0
  227. package/dist/utils/paths.d.ts +20 -0
  228. package/dist/utils/paths.d.ts.map +1 -0
  229. package/dist/utils/paths.js +79 -0
  230. package/dist/utils/paths.js.map +1 -0
  231. package/package.json +54 -0
@@ -0,0 +1,155 @@
1
+ # Observability & Resilience
2
+
3
+ ## Circuit Breaker Pattern
4
+
5
+ Prevent cascading failures by stopping calls to a failing service.
6
+
7
+ ```typescript
8
+ import CircuitBreaker from 'opossum';
9
+
10
+ const breaker = new CircuitBreaker(callExternalService, {
11
+ timeout: 3000, // Trip if call exceeds 3s
12
+ errorThresholdPercentage: 50, // Trip if 50% fail
13
+ resetTimeout: 10000, // Retry after 10s (half-open)
14
+ volumeThreshold: 10, // Min requests before tripping
15
+ });
16
+
17
+ breaker.fallback(() => getCachedResponse());
18
+ const result = await breaker.fire(requestParams);
19
+ ```
20
+
21
+ **States:** Closed (normal) → Open (all rejected, fallback used) → Half-Open (test call) → Closed if test succeeds.
22
+
23
+ ---
24
+
25
+ ## Distributed Tracing (OpenTelemetry)
26
+
27
+ ### Setup
28
+
29
+ ```typescript
30
+ import { NodeSDK } from '@opentelemetry/sdk-node';
31
+ import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
32
+ import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
33
+ import { Resource } from '@opentelemetry/resources';
34
+ import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
35
+
36
+ const sdk = new NodeSDK({
37
+ resource: new Resource({ [ATTR_SERVICE_NAME]: 'order-service' }),
38
+ traceExporter: new OTLPTraceExporter({ url: 'http://otel-collector:4318/v1/traces' }),
39
+ instrumentations: [getNodeAutoInstrumentations()],
40
+ });
41
+ sdk.start();
42
+ ```
43
+
44
+ ### Span Creation & Context Propagation
45
+
46
+ ```typescript
47
+ import { trace, context, propagation, SpanStatusCode } from '@opentelemetry/api';
48
+ const tracer = trace.getTracer('order-service');
49
+
50
+ async function processOrder(order: Order) {
51
+ return tracer.startActiveSpan('processOrder', async (span) => {
52
+ span.setAttribute('order.id', order.id);
53
+ // Manual propagation (e.g., for message queues):
54
+ const carrier: Record<string, string> = {};
55
+ propagation.inject(context.active(), carrier);
56
+ await queue.publish('orders', { ...order, _traceContext: carrier });
57
+ span.end();
58
+ });
59
+ }
60
+ ```
61
+
62
+ ---
63
+
64
+ ## Health Checks (Kubernetes)
65
+
66
+ ```yaml
67
+ spec:
68
+ containers:
69
+ - name: api
70
+ livenessProbe: # Restart if failing — never check dependencies here
71
+ httpGet: { path: /healthz/live, port: 8080 }
72
+ periodSeconds: 15
73
+ failureThreshold: 3
74
+ readinessProbe: # Remove from LB if failing — checks DB, cache, downstream
75
+ httpGet: { path: /healthz/ready, port: 8080 }
76
+ periodSeconds: 10
77
+ failureThreshold: 2
78
+ startupProbe: # Block other probes until app finishes init
79
+ httpGet: { path: /healthz/startup, port: 8080 }
80
+ periodSeconds: 5
81
+ failureThreshold: 30
82
+ ```
83
+
84
+ ---
85
+
86
+ ## Structured Logging Pipeline
87
+
88
+ ```typescript
89
+ import pino from 'pino';
90
+
91
+ const logger = pino({
92
+ level: process.env.LOG_LEVEL || 'info',
93
+ formatters: { level(label) { return { level: label }; } },
94
+ base: { service: 'order-service', environment: process.env.NODE_ENV },
95
+ });
96
+
97
+ logger.info({ orderId: '123', duration: 45 }, 'Order processed');
98
+ ```
99
+
100
+ ### Collection (Vector)
101
+
102
+ ```toml
103
+ [sources.app_logs]
104
+ type = "file"
105
+ include = ["/var/log/app/*.log"]
106
+
107
+ [transforms.parse]
108
+ type = "remap"
109
+ inputs = ["app_logs"]
110
+ source = '. = parse_json!(.message)'
111
+
112
+ [sinks.loki]
113
+ type = "loki"
114
+ inputs = ["parse"]
115
+ endpoint = "http://loki:3100"
116
+ labels = { service = "{{ service }}", level = "{{ level }}" }
117
+ ```
118
+
119
+ **Pipeline:** App (JSON stdout) → Vector/Fluentd → Loki/Elasticsearch → Grafana/Kibana
120
+
121
+ ---
122
+
123
+ ## RED Metrics & Golden Signals
124
+
125
+ **RED Method** (request-driven services):
126
+ - **Rate** — Requests/sec (`http_requests_total`)
127
+ - **Errors** — Failed requests/sec (`http_requests_total{status=~"5.."}`)
128
+ - **Duration** — Latency histogram (`http_request_duration_seconds`)
129
+
130
+ **Golden Signals** (Google SRE): Latency, Traffic, Errors, Saturation (CPU%, memory%, queue depth).
131
+
132
+ ---
133
+
134
+ ## Alerting Strategy
135
+
136
+ | Severity | Response | Example | Action |
137
+ |---|---|---|---|
138
+ | **P1** | 15 min | Service down, data loss | Page on-call, incident bridge |
139
+ | **P2** | 1 hour | Error rate > 5%, p99 > 2s | Page during business hours |
140
+ | **P3** | 4 hours | Disk > 80%, elevated errors | Slack, next available engineer |
141
+ | **P4** | Next day | Deprecation warnings | Auto-create ticket |
142
+
143
+ **Rules:** Alert on symptoms, not causes. Use multi-window burn-rate alerts. Every alert needs a runbook. Suppress downstream when upstream is alerting.
144
+
145
+ ---
146
+
147
+ ## Graceful Degradation
148
+
149
+ **Fallback strategies:**
150
+ - **Cache fallback** — Serve stale data when upstream is down
151
+ - **Default response** — Return safe defaults (empty list, default config)
152
+ - **Feature toggle** — Disable non-critical features under load
153
+ - **Read-only mode** — Allow reads, reject writes during partial outages
154
+
155
+ **Priorities:** Map critical vs non-critical paths. Set timeouts on every external call. Use bulkheads (separate pools per dependency). Test degraded modes with chaos engineering.
@@ -0,0 +1,199 @@
1
+ # Backend Troubleshooting Guide
2
+
3
+ ## Connection Pool Exhaustion
4
+
5
+ **Symptoms:** Application hangs on database queries, errors like "too many connections", "connection pool timeout", latency spikes under moderate load.
6
+
7
+ **Diagnosis:**
8
+ ```sql
9
+ -- PostgreSQL: check active connections
10
+ SELECT count(*), state FROM pg_stat_activity GROUP BY state;
11
+
12
+ -- Check max connections setting
13
+ SHOW max_connections;
14
+
15
+ -- Find long-running queries holding connections
16
+ SELECT pid, now() - pg_stat_activity.query_start AS duration, query, state
17
+ FROM pg_stat_activity
18
+ WHERE state != 'idle'
19
+ ORDER BY duration DESC;
20
+ ```
21
+
22
+ **Fix patterns:**
23
+ 1. **Pool size too small** — Increase `max` in pool config. Rule of thumb: `pool_size = (core_count * 2) + disk_count`.
24
+ 2. **Connections not released** — Missing `.release()` or `finally` block after query.
25
+ - Fix: Always use try/finally or connection wrapper that auto-releases.
26
+ 3. **Long-running transactions** — Holding connections for external API calls.
27
+ - Fix: Fetch external data first, then open transaction only for DB writes.
28
+ 4. **Idle connection timeout not set** — Add `idleTimeoutMillis` (e.g., 30000ms) to pool config.
29
+
30
+ ## Node.js Memory Leaks
31
+
32
+ **Diagnosis workflow:**
33
+ ```bash
34
+ # Start with inspector
35
+ node --inspect --max-old-space-size=512 app.js
36
+
37
+ # Take heap snapshots via Chrome DevTools
38
+ # chrome://inspect → Open dedicated DevTools
39
+
40
+ # CLI heap dump (production-safe)
41
+ kill -USR2 <pid> # If using heapdump module
42
+
43
+ # Monitor memory over time
44
+ node -e "setInterval(() => console.log(process.memoryUsage()), 5000)"
45
+ ```
46
+
47
+ **Common causes:**
48
+ 1. **Global caches without eviction** — Objects accumulate in module-level Maps/Sets.
49
+ - Fix: Use LRU cache (`lru-cache` package) with maxSize and TTL.
50
+ 2. **Event emitter listeners accumulating** — `emitter.on()` called repeatedly without `off()`.
51
+ - Fix: Use `once()` where possible, track and remove listeners on cleanup.
52
+ 3. **Closures in request handlers** — Large objects captured in closure scope.
53
+ - Fix: Nullify references after use, avoid closing over request/response objects in async callbacks.
54
+ 4. **Unreferenced timers** — `setInterval` created per request without `clearInterval`.
55
+ - Fix: Track timer IDs, clear on connection close.
56
+
57
+ **Heap snapshot comparison:**
58
+ 1. Take snapshot A (baseline).
59
+ 2. Run load test or wait for traffic.
60
+ 3. Take snapshot B.
61
+ 4. In DevTools: select snapshot B → Comparison view → sort by "Size Delta".
62
+
63
+ ## 502/504 Gateway Timeout Tracing
64
+
65
+ **502 Bad Gateway — upstream server returned invalid response:**
66
+ 1. Check if the application process is running: `ps aux | grep node`.
67
+ 2. Check application logs for crashes or uncaught exceptions.
68
+ 3. Verify the upstream port matches the proxy config (nginx/ALB).
69
+ 4. Check health check endpoint: `curl -v http://localhost:PORT/health`.
70
+
71
+ **504 Gateway Timeout — upstream did not respond in time:**
72
+ 1. Identify the slow endpoint from access logs.
73
+ 2. Check database query times for that endpoint.
74
+ 3. Verify timeout chain: client (30s) < proxy (60s) < app server (90s).
75
+ 4. Look for external API calls without timeouts.
76
+
77
+ **Fix patterns:**
78
+ - Set explicit timeouts on all outbound HTTP calls: `fetch(url, { signal: AbortSignal.timeout(5000) })`.
79
+ - Configure proxy timeouts: `proxy_read_timeout 60s;` in nginx.
80
+ - Add request-level timeout middleware: kill requests exceeding SLA.
81
+ - Implement circuit breaker for flaky upstream dependencies.
82
+
83
+ ## Database Deadlocks Detection and Prevention
84
+
85
+ **Detection:**
86
+ ```sql
87
+ -- PostgreSQL: find blocked and blocking queries
88
+ SELECT blocked.pid AS blocked_pid,
89
+ blocked.query AS blocked_query,
90
+ blocking.pid AS blocking_pid,
91
+ blocking.query AS blocking_query
92
+ FROM pg_stat_activity blocked
93
+ JOIN pg_locks bl ON bl.pid = blocked.pid
94
+ JOIN pg_locks kl ON kl.locktype = bl.locktype
95
+ AND kl.database IS NOT DISTINCT FROM bl.database
96
+ AND kl.relation IS NOT DISTINCT FROM bl.relation
97
+ AND kl.page IS NOT DISTINCT FROM bl.page
98
+ AND kl.tuple IS NOT DISTINCT FROM bl.tuple
99
+ AND kl.pid != bl.pid
100
+ JOIN pg_stat_activity blocking ON kl.pid = blocking.pid
101
+ WHERE NOT bl.granted;
102
+ ```
103
+
104
+ **Prevention patterns:**
105
+ 1. **Consistent lock ordering** — Always acquire locks on tables/rows in the same order across all transactions.
106
+ 2. **Short transactions** — Minimize the work done inside a transaction.
107
+ 3. **Use `SELECT ... FOR UPDATE SKIP LOCKED`** for queue-like patterns.
108
+ 4. **Set lock timeout**: `SET lock_timeout = '5s';` to fail fast instead of deadlocking.
109
+ 5. **Retry with backoff** — Catch deadlock errors (code 40P01) and retry the transaction.
110
+
111
+ ## JWT / Auth Token Debugging Checklist
112
+
113
+ **Token rejected — systematic diagnosis:**
114
+ 1. Decode the token: `echo "<token>" | cut -d. -f2 | base64 -d 2>/dev/null | jq .`
115
+ 2. Check `exp` claim — is it expired? Compare with `date +%s`.
116
+ 3. Check `iss` (issuer) — does it match your auth server?
117
+ 4. Check `aud` (audience) — does it match your API's expected audience?
118
+ 5. Verify signature — is the server using the correct public key / secret?
119
+ 6. Check clock skew — is the server clock synchronized? (>30s drift causes failures).
120
+
121
+ **Common issues:**
122
+ - **Token works locally but not in production** — Different JWT secrets in environments.
123
+ - **Token expires too fast** — Short `exp`, no refresh token mechanism.
124
+ - **JWKS endpoint unreachable** — Auth server DNS or firewall issue.
125
+ - **"Algorithm none" vulnerability** — Ensure server rejects `alg: none`.
126
+
127
+ ## Rate Limiting Misconfiguration Symptoms
128
+
129
+ **Symptoms:** Legitimate users get 429 errors, rate limits don't apply to abusers, inconsistent behavior across instances.
130
+
131
+ **Diagnosis:**
132
+ 1. Check rate limit headers in response: `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`.
133
+ 2. Verify the key used for rate limiting — IP? User ID? API key?
134
+ 3. If behind a load balancer: is each instance counting independently? (Need shared store like Redis.)
135
+
136
+ **Fix patterns:**
137
+ - **Shared store required** — Use Redis with `INCR` + `EXPIRE` for distributed rate limiting.
138
+ - **Wrong client IP** — Behind proxy, use `X-Forwarded-For` header (validate trust chain).
139
+ - **Missing bypass for health checks** — Internal health probes consuming rate limit quota.
140
+ - **Sliding window vs fixed window** — Fixed window allows burst at boundary; use sliding window for smoother limiting.
141
+
142
+ ## Container OOM Kills
143
+
144
+ **Symptoms:** Container restarts with exit code 137, `dmesg` shows "Out of memory: Killed process".
145
+
146
+ **Diagnosis:**
147
+ ```bash
148
+ # Check container memory usage
149
+ docker stats <container_id>
150
+
151
+ # Check OOM kill events
152
+ dmesg | grep -i "oom\|killed"
153
+
154
+ # Kubernetes: check pod events
155
+ kubectl describe pod <pod_name> | grep -A5 "Last State"
156
+ kubectl top pod <pod_name>
157
+
158
+ # Node.js: log memory at intervals
159
+ node -e "setInterval(() => { const m = process.memoryUsage(); console.log('RSS:', (m.rss/1024/1024).toFixed(1), 'MB, Heap:', (m.heapUsed/1024/1024).toFixed(1), 'MB'); }, 10000)"
160
+ ```
161
+
162
+ **Fix patterns:**
163
+ 1. **Set Node.js heap limit below container limit** — `--max-old-space-size=384` for a 512MB container (leave room for native memory).
164
+ 2. **Stream large data** — Don't load entire files/datasets into memory; use Node.js streams.
165
+ 3. **Limit concurrency** — Use `p-limit` or similar to cap parallel async operations.
166
+ 4. **Right-size the container** — Profile actual usage and set memory request/limit accordingly.
167
+
168
+ ## Event Loop Blocking Diagnosis
169
+
170
+ **Symptoms:** All requests slow down simultaneously, health checks timeout, high latency with low CPU usage.
171
+
172
+ **Detection:**
173
+ ```javascript
174
+ // Detect event loop delays
175
+ const { monitorEventLoopDelay } = require('perf_hooks');
176
+ const h = monitorEventLoopDelay({ resolution: 20 });
177
+ h.enable();
178
+ setInterval(() => {
179
+ console.log(`Event loop p99: ${(h.percentile(99) / 1e6).toFixed(1)}ms`);
180
+ h.reset();
181
+ }, 5000);
182
+
183
+ // Blocked-at module (development only)
184
+ // npm install blocked-at
185
+ const blocked = require('blocked-at');
186
+ blocked((time, stack) => {
187
+ console.log(`Blocked for ${time}ms`, stack);
188
+ });
189
+ ```
190
+
191
+ **Common blockers:**
192
+ 1. **Synchronous file operations** — `fs.readFileSync`, `fs.writeFileSync` in request handlers.
193
+ - Fix: Use async versions `fs.promises.readFile`.
194
+ 2. **JSON.parse/stringify on large payloads** — Blocks for 100ms+ on multi-MB objects.
195
+ - Fix: Use streaming JSON parser (`stream-json`) or move to worker thread.
196
+ 3. **CPU-intensive computation** — Crypto, image processing, data transformation.
197
+ - Fix: Offload to `worker_threads` or a separate microservice.
198
+ 4. **DNS resolution** — `dns.lookup` is synchronous by default in libuv.
199
+ - Fix: Use `dns.resolve` (async) or configure DNS caching.
@@ -0,0 +1,72 @@
1
+ ---
2
+ name: codebase-analysis
3
+ description: Systematic codebase exploration — dependency mapping, architecture assessment, tech debt inventory, impact analysis for informed decision-making
4
+ ---
5
+
6
+ # Codebase Analysis
7
+
8
+ ## Triggers
9
+
10
+ Activate this skill when:
11
+ - Joining a new project and need to understand the codebase
12
+ - Before major refactoring to assess scope and risk
13
+ - Performing impact analysis before significant changes
14
+ - Conducting a tech debt review or sprint planning
15
+ - Running a dependency audit (security, outdated, license)
16
+ - Documenting architecture for onboarding or decision records
17
+
18
+ ## Process
19
+
20
+ ### 1. Scope Definition
21
+ - Clarify what to analyze: full codebase, specific package, or change blast radius
22
+ - Identify stakeholders and what decisions the analysis will inform
23
+ - Set time-box — analysis should enable action, not become a project itself
24
+
25
+ ### 2. Structure Scan
26
+ - Map directory layout to identify architectural pattern (layered, feature-based, domain-driven)
27
+ - Identify entry points: HTTP handlers, CLI commands, event consumers, cron jobs
28
+ - Catalog build configuration: bundlers, compilers, CI/CD pipelines
29
+ - Note framework and language versions
30
+
31
+ ### 3. Dependency Mapping
32
+ - Generate module dependency graph (internal imports)
33
+ - Detect circular dependencies and tightly coupled modules
34
+ - Audit external dependencies: outdated, vulnerable, abandoned, license issues
35
+ - Map service-to-service and API dependencies
36
+
37
+ ### 4. Quality Assessment
38
+ - Measure complexity hotspots (cyclomatic/cognitive complexity × change frequency)
39
+ - Review test coverage distribution across modules
40
+ - Count linter warnings, TODO/FIXME/HACK markers
41
+ - Assess type coverage and strict mode adoption
42
+ - Identify dead code and unused exports
43
+
44
+ ### 5. Report Generation
45
+ - Summarize architecture with a clear overview
46
+ - List findings grouped by category with severity scores
47
+ - Prioritize recommendations: quick wins first, then planned improvements
48
+ - Include evidence (file paths, metrics, examples) for every finding
49
+
50
+ ## Quick Reference
51
+
52
+ | Analysis Goal | Technique | Key Tool/Command |
53
+ |---|---|---|
54
+ | Understand structure | Directory analysis | `tree -L 3 -d`, `find . -name 'index.*'` |
55
+ | Map dependencies | Import graph traversal | `madge --image`, `go mod graph` |
56
+ | Find dead code | Unused export detection | `knip`, `ts-prune` |
57
+ | Measure complexity | Cyclomatic complexity | `eslint --rule complexity`, `radon` |
58
+ | Detect hotspots | Git change frequency | `git log --format='%H' --follow <file>` |
59
+ | Audit packages | Outdated/vulnerable check | `npm outdated`, `npm audit` |
60
+ | Assess test gaps | Coverage by module | `jest --coverage`, `coverage.py` |
61
+ | Trace request flow | Entry point tracing | Read handler → service → repository |
62
+ | Quantify tech debt | Marker grep + scoring | `grep -rn 'TODO\|FIXME\|HACK'` |
63
+
64
+ ## References
65
+
66
+ - [Analysis Techniques](references/analysis-techniques.md) — directory analysis, complexity metrics, hotspot detection, entry point tracing
67
+ - [Dependency Mapping](references/dependency-mapping.md) — import graphs, circular dependency resolution, external audit, upgrade strategy
68
+ - [Tech Debt Assessment](references/tech-debt-assessment.md) — debt taxonomy, severity scoring, discovery checklist, remediation prioritization
69
+
70
+ ## Assets
71
+
72
+ - [Sample Output](assets/sample-output.md) — complete analysis report for a Node.js + React monorepo
@@ -0,0 +1,263 @@
1
+ # Codebase Analysis Report: TaskFlow
2
+
3
+ **Project**: TaskFlow — Task management application
4
+ **Date**: 2026-03-15
5
+ **Scope**: Full codebase analysis
6
+ **Analyst**: Engineering Team
7
+
8
+ ---
9
+
10
+ ## 1. Architecture Overview
11
+
12
+ ### Project Structure
13
+
14
+ ```
15
+ taskflow/
16
+ packages/
17
+ api/ # Express.js REST API (Node.js 18)
18
+ web/ # React 18 + Vite SPA
19
+ shared/ # Shared types, validation, utilities
20
+ infrastructure/
21
+ docker/ # Docker Compose for local dev
22
+ terraform/ # AWS infrastructure (ECS, RDS, S3)
23
+ docs/
24
+ scripts/ # Build, deploy, migration scripts
25
+ ```
26
+
27
+ ### Architecture Style
28
+
29
+ **API** — Layered architecture:
30
+ - `routes/` → `controllers/` → `services/` → `repositories/`
31
+ - Clear separation of concerns
32
+ - Dependency injection via `tsyringe`
33
+
34
+ **Web** — Feature-based structure:
35
+ - `features/auth/`, `features/tasks/`, `features/projects/`
36
+ - Each feature contains components, hooks, and API calls
37
+ - Shared components in `shared/ui/`
38
+
39
+ ### Tech Stack
40
+
41
+ | Layer | Technology | Version |
42
+ |---|---|---|
43
+ | Runtime | Node.js | 18.19.0 |
44
+ | API Framework | Express.js | 4.18.2 |
45
+ | Frontend | React | 18.2.0 |
46
+ | Build Tool | Vite | 5.1.4 |
47
+ | Database | PostgreSQL | 15.4 |
48
+ | ORM | Prisma | 5.10.2 |
49
+ | Monorepo | Turborepo | 1.12.4 |
50
+ | Testing | Jest + React Testing Library | 29.7 / 14.2 |
51
+ | Language | TypeScript | 5.3.3 |
52
+
53
+ ### Entry Points
54
+
55
+ | Entry Point | File | Purpose |
56
+ |---|---|---|
57
+ | API Server | `packages/api/src/server.ts` | Express app bootstrap |
58
+ | Web App | `packages/web/src/main.tsx` | React SPA entry |
59
+ | DB Migrations | `packages/api/prisma/migrations/` | Schema migrations (47 files) |
60
+ | Seed Script | `scripts/seed.ts` | Development data seeding |
61
+ | CI Pipeline | `.github/workflows/ci.yml` | Build + test + deploy |
62
+
63
+ ---
64
+
65
+ ## 2. Dependency Graph Summary
66
+
67
+ ### Internal Dependencies
68
+
69
+ ```
70
+ web → shared (types, validation)
71
+ api → shared (types, validation)
72
+ web → api (via HTTP — no direct import)
73
+ ```
74
+
75
+ No circular dependencies between packages.
76
+
77
+ ### Circular Dependencies Within API Package
78
+
79
+ 3 circular dependencies detected via `madge --circular packages/api/src/`:
80
+
81
+ | Cycle | Files | Severity |
82
+ |---|---|---|
83
+ | 1 | `services/taskService.ts` ↔ `services/notificationService.ts` | High — causes import order bugs |
84
+ | 2 | `repositories/projectRepo.ts` ↔ `repositories/taskRepo.ts` | Medium — shared query logic |
85
+ | 3 | `utils/permissions.ts` ↔ `services/authService.ts` | Low — only type imports |
86
+
87
+ **Recommendation**: Extract shared logic into dedicated modules. Cycle 1 should use an event emitter pattern instead of direct service-to-service calls.
88
+
89
+ ### External Dependencies
90
+
91
+ **Outdated packages** (12 major versions behind):
92
+
93
+ | Package | Current | Latest | Risk |
94
+ |---|---|---|---|
95
+ | express | 4.18.2 | 5.0.1 | Medium — major API changes |
96
+ | react-router-dom | 6.22.0 | 7.1.0 | Medium — loader API changes |
97
+ | @types/node | 18.19.0 | 22.1.0 | Low — type definitions only |
98
+ | helmet | 6.2.0 | 8.0.0 | Low — minor config changes |
99
+ | zod | 3.22.4 | 4.0.0 | High — schema API changes |
100
+ | eslint | 8.57.0 | 9.12.0 | Medium — config format change |
101
+ | prisma | 5.10.2 | 6.2.0 | High — query engine changes |
102
+ | axios | 0.27.2 | 1.7.9 | Medium — interceptor API changes |
103
+ | winston | 3.11.0 | 4.0.0 | Low — transport config changes |
104
+ | multer | 1.4.5 | 2.0.0 | Low — middleware signature change |
105
+ | jsonwebtoken | 9.0.0 | 10.0.0 | Medium — algorithm defaults change |
106
+ | dotenv | 16.4.1 | 17.0.0 | Low — minimal breaking changes |
107
+
108
+ **Vulnerabilities** (2 high severity):
109
+
110
+ | Package | Vulnerability | Severity | Fix |
111
+ |---|---|---|---|
112
+ | axios@0.27.2 | SSRF via proxy config (CVE-2023-45857) | High | Upgrade to 1.6.0+ |
113
+ | jsonwebtoken@9.0.0 | Algorithm confusion (CVE-2024-33663) | High | Upgrade to 10.0.0+ |
114
+
115
+ **Abandoned packages** (0 detected): All dependencies are actively maintained.
116
+
117
+ **License issues** (0 detected): All dependencies use MIT or Apache-2.0 licenses.
118
+
119
+ ---
120
+
121
+ ## 3. Hotspot Analysis
122
+
123
+ ### Top 10 Most Changed Files (Last 6 Months)
124
+
125
+ | Rank | File | Changes | Complexity | Bug Fixes | Risk |
126
+ |---|---|---|---|---|---|
127
+ | 1 | `api/src/services/taskService.ts` | 47 | High (CC: 23) | 8 | **Critical** |
128
+ | 2 | `web/src/features/tasks/TaskBoard.tsx` | 38 | High (CC: 18) | 5 | **Critical** |
129
+ | 3 | `api/src/controllers/taskController.ts` | 31 | Medium (CC: 12) | 3 | High |
130
+ | 4 | `shared/src/validation/taskSchema.ts` | 28 | Low (CC: 4) | 2 | Medium |
131
+ | 5 | `web/src/features/tasks/TaskFilters.tsx` | 25 | Medium (CC: 11) | 4 | High |
132
+ | 6 | `api/src/services/notificationService.ts` | 22 | Medium (CC: 14) | 3 | High |
133
+ | 7 | `api/src/repositories/taskRepo.ts` | 20 | Medium (CC: 10) | 2 | Medium |
134
+ | 8 | `web/src/shared/ui/DataTable.tsx` | 19 | High (CC: 16) | 6 | **Critical** |
135
+ | 9 | `api/src/middleware/auth.ts` | 17 | Low (CC: 6) | 1 | Low |
136
+ | 10 | `web/src/features/auth/LoginForm.tsx` | 15 | Low (CC: 5) | 1 | Low |
137
+
138
+ ### Correlation with Bug Reports
139
+
140
+ Files #1, #2, and #8 appear in 60% of all bug-fix commits. The task service alone accounts for 8 of 31 total bug fixes in the past 6 months.
141
+
142
+ ### Files Changed Together (Coupling)
143
+
144
+ | File Pair | Co-change Count | Expected? |
145
+ |---|---|---|
146
+ | `taskService.ts` + `taskController.ts` | 24 | Yes — same feature |
147
+ | `taskService.ts` + `notificationService.ts` | 18 | No — should be decoupled |
148
+ | `TaskBoard.tsx` + `TaskFilters.tsx` | 15 | Yes — same UI feature |
149
+ | `taskSchema.ts` + `taskService.ts` | 14 | Yes — validation + logic |
150
+ | `DataTable.tsx` + `TaskBoard.tsx` | 12 | No — generic component coupled to feature |
151
+
152
+ **Recommendation**: `notificationService` should subscribe to task events rather than being called directly. `DataTable` needs a cleaner props interface to reduce coupling to specific features.
153
+
154
+ ---
155
+
156
+ ## 4. Tech Debt Inventory
157
+
158
+ ### Summary by Category
159
+
160
+ | Category | Items | Critical | High | Medium | Low |
161
+ |---|---|---|---|---|---|
162
+ | Code | 4 | 1 | 1 | 1 | 1 |
163
+ | Design | 3 | 0 | 2 | 1 | 0 |
164
+ | Infrastructure | 2 | 1 | 1 | 0 | 0 |
165
+ | Testing | 4 | 1 | 2 | 1 | 0 |
166
+ | Documentation | 2 | 0 | 0 | 1 | 1 |
167
+ | **Total** | **15** | **3** | **6** | **4** | **2** |
168
+
169
+ ### Full Inventory
170
+
171
+ | ID | Category | Description | Impact | Effort | Priority | Status |
172
+ |---|---|---|---|---|---|---|
173
+ | TD-001 | Code | `taskService.ts` has CC of 23, 480 lines — needs splitting | 5 | 3 | 15 | New |
174
+ | TD-002 | Code | Duplicated validation logic in 3 controllers (task, project, user) | 3 | 2 | 12 | New |
175
+ | TD-003 | Code | 43 TODO/FIXME markers across the codebase | 2 | 2 | 8 | Backlog |
176
+ | TD-004 | Code | `DataTable.tsx` has 16 props — abstraction too leaky | 3 | 3 | 9 | New |
177
+ | TD-005 | Design | Task ↔ Notification circular dependency | 4 | 3 | 12 | New |
178
+ | TD-006 | Design | Auth logic spread across middleware, service, and utils | 4 | 4 | 8 | New |
179
+ | TD-007 | Design | API error responses inconsistent — 3 different formats in use | 3 | 2 | 12 | New |
180
+ | TD-008 | Infra | 2 high-severity vulnerabilities in dependencies | 5 | 2 | 20 | **Urgent** |
181
+ | TD-009 | Infra | Node.js 18 approaching EOL (April 2025) — need upgrade to 22 | 4 | 3 | 12 | Planned |
182
+ | TD-010 | Testing | No E2E tests — critical user flows untested end-to-end | 5 | 4 | 10 | New |
183
+ | TD-011 | Testing | Service layer coverage at 45% — business logic at risk | 4 | 3 | 12 | New |
184
+ | TD-012 | Testing | 7 flaky tests in CI — `TaskBoard` integration tests | 4 | 2 | 16 | New |
185
+ | TD-013 | Testing | No contract tests between web and API | 3 | 3 | 9 | Backlog |
186
+ | TD-014 | Docs | API documentation 4 months stale — missing 8 endpoints | 3 | 2 | 12 | Backlog |
187
+ | TD-015 | Docs | No Architecture Decision Records (ADRs) | 2 | 1 | 10 | Backlog |
188
+
189
+ ---
190
+
191
+ ## 5. Test Coverage Analysis
192
+
193
+ ### Coverage by Package
194
+
195
+ | Package | Statements | Branches | Functions | Lines |
196
+ |---|---|---|---|---|
197
+ | api/controllers | 85% | 72% | 88% | 85% |
198
+ | api/services | 45% | 38% | 50% | 45% |
199
+ | api/repositories | 62% | 55% | 65% | 62% |
200
+ | api/middleware | 90% | 85% | 92% | 90% |
201
+ | web/features | 58% | 42% | 55% | 58% |
202
+ | web/shared/ui | 72% | 60% | 75% | 72% |
203
+ | shared/validation | 95% | 90% | 98% | 95% |
204
+ | **Overall** | **65%** | **55%** | **68%** | **65%** |
205
+
206
+ ### Critical Coverage Gaps
207
+
208
+ | Module | Coverage | Risk Level | Concern |
209
+ |---|---|---|---|
210
+ | `api/services/taskService.ts` | 38% | **Critical** | Core business logic, most bug-prone file |
211
+ | `api/services/notificationService.ts` | 42% | High | User-facing notifications, failure = silent bugs |
212
+ | `api/services/paymentService.ts` | 35% | **Critical** | Financial transactions, error = revenue loss |
213
+ | `web/features/tasks/TaskBoard.tsx` | 30% | High | Primary user interface, 5 bug fixes in 6 months |
214
+
215
+ ### E2E Test Status
216
+
217
+ **No E2E tests exist.** Critical untested flows:
218
+ - User registration → email verification → login
219
+ - Create project → add members → create tasks → assign
220
+ - Task status transitions → notification triggers
221
+ - File upload → attachment to task → download
222
+
223
+ ---
224
+
225
+ ## 6. Recommendations
226
+
227
+ Prioritized list of improvements, ordered by impact and effort:
228
+
229
+ ### Immediate (This Sprint)
230
+
231
+ | # | Action | Effort | Resolves |
232
+ |---|---|---|---|
233
+ | 1 | Upgrade axios to 1.7.x and jsonwebtoken to 10.x | 2 hours | TD-008 (vulnerabilities) |
234
+ | 2 | Fix 7 flaky tests in TaskBoard integration | 4 hours | TD-012 |
235
+ | 3 | Standardize API error response format | 1 day | TD-007 |
236
+
237
+ ### Next 2-3 Sprints
238
+
239
+ | # | Action | Effort | Resolves |
240
+ |---|---|---|---|
241
+ | 4 | Split `taskService.ts` into domain-specific services | 3 days | TD-001, partially TD-005 |
242
+ | 5 | Add tests for service layer (target: 80% coverage) | 3 days | TD-011 |
243
+ | 6 | Break circular dependency with event emitter pattern | 2 days | TD-005 |
244
+ | 7 | Upgrade Node.js from 18 to 22 | 2 days | TD-009 |
245
+
246
+ ### Next Quarter
247
+
248
+ | # | Action | Effort | Resolves |
249
+ |---|---|---|---|
250
+ | 8 | Implement E2E test suite for 5 critical user flows | 2 weeks | TD-010 |
251
+
252
+ ### Estimated Impact
253
+
254
+ If all recommendations are implemented:
255
+ - **Bug rate reduction**: ~40% (based on hotspot coverage improvement)
256
+ - **Developer velocity**: +20% (less debugging, clearer architecture)
257
+ - **Security posture**: 2 critical vulnerabilities eliminated
258
+ - **Test confidence**: coverage from 65% to ~82% overall
259
+ - **Onboarding time**: reduced from ~3 weeks to ~1 week (with ADRs and updated docs)
260
+
261
+ ---
262
+
263
+ *Report generated using codebase-analysis skill. Metrics collected via madge, eslint, jest --coverage, git log analysis, and npm audit.*