javi-forge 1.1.0 → 1.3.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 (238) hide show
  1. package/ci-local/ci-local.sh +38 -10
  2. package/ci-local/hooks/pre-commit +10 -155
  3. package/ci-local/hooks/pre-push +12 -29
  4. package/dist/commands/ci.d.ts +33 -0
  5. package/dist/commands/ci.js +341 -0
  6. package/dist/commands/init.js +5 -0
  7. package/dist/index.js +39 -5
  8. package/dist/lib/docker.d.ts +43 -0
  9. package/dist/lib/docker.js +223 -0
  10. package/dist/ui/CI.d.ts +9 -0
  11. package/dist/ui/CI.js +91 -0
  12. package/package.json +9 -1
  13. package/ai-config/.skillignore +0 -15
  14. package/ai-config/AUTO_INVOKE.md +0 -300
  15. package/ai-config/agents/_TEMPLATE.md +0 -93
  16. package/ai-config/agents/business/api-designer.md +0 -1657
  17. package/ai-config/agents/business/business-analyst.md +0 -1331
  18. package/ai-config/agents/business/product-strategist.md +0 -206
  19. package/ai-config/agents/business/project-manager.md +0 -178
  20. package/ai-config/agents/business/requirements-analyst.md +0 -1277
  21. package/ai-config/agents/business/technical-writer.md +0 -1679
  22. package/ai-config/agents/creative/ux-designer.md +0 -205
  23. package/ai-config/agents/data-ai/ai-engineer.md +0 -487
  24. package/ai-config/agents/data-ai/analytics-engineer.md +0 -953
  25. package/ai-config/agents/data-ai/data-engineer.md +0 -173
  26. package/ai-config/agents/data-ai/data-scientist.md +0 -672
  27. package/ai-config/agents/data-ai/mlops-engineer.md +0 -814
  28. package/ai-config/agents/data-ai/prompt-engineer.md +0 -772
  29. package/ai-config/agents/development/angular-expert.md +0 -620
  30. package/ai-config/agents/development/backend-architect.md +0 -795
  31. package/ai-config/agents/development/database-specialist.md +0 -212
  32. package/ai-config/agents/development/frontend-specialist.md +0 -686
  33. package/ai-config/agents/development/fullstack-engineer.md +0 -668
  34. package/ai-config/agents/development/golang-pro.md +0 -338
  35. package/ai-config/agents/development/java-enterprise.md +0 -400
  36. package/ai-config/agents/development/javascript-pro.md +0 -422
  37. package/ai-config/agents/development/nextjs-pro.md +0 -474
  38. package/ai-config/agents/development/python-pro.md +0 -570
  39. package/ai-config/agents/development/react-pro.md +0 -487
  40. package/ai-config/agents/development/rust-pro.md +0 -246
  41. package/ai-config/agents/development/spring-boot-4-expert.md +0 -326
  42. package/ai-config/agents/development/typescript-pro.md +0 -336
  43. package/ai-config/agents/development/vue-specialist.md +0 -605
  44. package/ai-config/agents/infrastructure/cloud-architect.md +0 -472
  45. package/ai-config/agents/infrastructure/deployment-manager.md +0 -358
  46. package/ai-config/agents/infrastructure/devops-engineer.md +0 -455
  47. package/ai-config/agents/infrastructure/incident-responder.md +0 -519
  48. package/ai-config/agents/infrastructure/kubernetes-expert.md +0 -705
  49. package/ai-config/agents/infrastructure/monitoring-specialist.md +0 -674
  50. package/ai-config/agents/infrastructure/performance-engineer.md +0 -658
  51. package/ai-config/agents/orchestrator.md +0 -241
  52. package/ai-config/agents/quality/accessibility-auditor.md +0 -1204
  53. package/ai-config/agents/quality/code-reviewer-compact.md +0 -123
  54. package/ai-config/agents/quality/code-reviewer.md +0 -363
  55. package/ai-config/agents/quality/dependency-manager.md +0 -743
  56. package/ai-config/agents/quality/e2e-test-specialist.md +0 -1005
  57. package/ai-config/agents/quality/performance-tester.md +0 -1086
  58. package/ai-config/agents/quality/security-auditor.md +0 -133
  59. package/ai-config/agents/quality/test-engineer.md +0 -453
  60. package/ai-config/agents/specialists/api-designer.md +0 -87
  61. package/ai-config/agents/specialists/backend-architect.md +0 -73
  62. package/ai-config/agents/specialists/code-reviewer.md +0 -77
  63. package/ai-config/agents/specialists/db-optimizer.md +0 -75
  64. package/ai-config/agents/specialists/devops-engineer.md +0 -83
  65. package/ai-config/agents/specialists/documentation-writer.md +0 -78
  66. package/ai-config/agents/specialists/frontend-developer.md +0 -75
  67. package/ai-config/agents/specialists/performance-analyst.md +0 -82
  68. package/ai-config/agents/specialists/refactor-specialist.md +0 -74
  69. package/ai-config/agents/specialists/security-auditor.md +0 -74
  70. package/ai-config/agents/specialists/test-engineer.md +0 -81
  71. package/ai-config/agents/specialists/ux-consultant.md +0 -76
  72. package/ai-config/agents/specialized/agent-generator.md +0 -1190
  73. package/ai-config/agents/specialized/blockchain-developer.md +0 -149
  74. package/ai-config/agents/specialized/code-migrator.md +0 -892
  75. package/ai-config/agents/specialized/context-manager.md +0 -978
  76. package/ai-config/agents/specialized/documentation-writer.md +0 -1078
  77. package/ai-config/agents/specialized/ecommerce-expert.md +0 -1756
  78. package/ai-config/agents/specialized/embedded-engineer.md +0 -1714
  79. package/ai-config/agents/specialized/error-detective.md +0 -1034
  80. package/ai-config/agents/specialized/fintech-specialist.md +0 -1659
  81. package/ai-config/agents/specialized/freelance-project-planner-v2.md +0 -1988
  82. package/ai-config/agents/specialized/freelance-project-planner-v3.md +0 -2136
  83. package/ai-config/agents/specialized/freelance-project-planner-v4.md +0 -4503
  84. package/ai-config/agents/specialized/freelance-project-planner.md +0 -722
  85. package/ai-config/agents/specialized/game-developer.md +0 -1963
  86. package/ai-config/agents/specialized/healthcare-dev.md +0 -1620
  87. package/ai-config/agents/specialized/mobile-developer.md +0 -188
  88. package/ai-config/agents/specialized/parallel-plan-executor.md +0 -506
  89. package/ai-config/agents/specialized/plan-executor.md +0 -485
  90. package/ai-config/agents/specialized/solo-dev-planner-modular/00-INDEX.md +0 -485
  91. package/ai-config/agents/specialized/solo-dev-planner-modular/01-CORE.md +0 -3493
  92. package/ai-config/agents/specialized/solo-dev-planner-modular/02-SELF-CORRECTION.md +0 -778
  93. package/ai-config/agents/specialized/solo-dev-planner-modular/03-PROGRESSIVE-SETUP.md +0 -918
  94. package/ai-config/agents/specialized/solo-dev-planner-modular/04-DEPLOYMENT.md +0 -1537
  95. package/ai-config/agents/specialized/solo-dev-planner-modular/05-TESTING.md +0 -2633
  96. package/ai-config/agents/specialized/solo-dev-planner-modular/06-OPERATIONS.md +0 -5610
  97. package/ai-config/agents/specialized/solo-dev-planner-modular/INSTALL.md +0 -335
  98. package/ai-config/agents/specialized/solo-dev-planner-modular/QUICK-REFERENCE.txt +0 -215
  99. package/ai-config/agents/specialized/solo-dev-planner-modular/README.md +0 -260
  100. package/ai-config/agents/specialized/solo-dev-planner-modular/START-HERE.md +0 -379
  101. package/ai-config/agents/specialized/solo-dev-planner-modular/WORKFLOW-DIAGRAM.md +0 -355
  102. package/ai-config/agents/specialized/solo-dev-planner-modular/solo-dev-planner.md +0 -279
  103. package/ai-config/agents/specialized/template-writer.md +0 -347
  104. package/ai-config/agents/specialized/test-runner.md +0 -99
  105. package/ai-config/agents/specialized/vibekanban-smart-worker.md +0 -244
  106. package/ai-config/agents/specialized/wave-executor.md +0 -138
  107. package/ai-config/agents/specialized/workflow-optimizer.md +0 -1114
  108. package/ai-config/commands/git/changelog.md +0 -32
  109. package/ai-config/commands/git/ci-local.md +0 -70
  110. package/ai-config/commands/git/commit.md +0 -35
  111. package/ai-config/commands/git/fix-issue.md +0 -23
  112. package/ai-config/commands/git/pr-create.md +0 -42
  113. package/ai-config/commands/git/pr-review.md +0 -50
  114. package/ai-config/commands/git/worktree.md +0 -39
  115. package/ai-config/commands/refactoring/cleanup.md +0 -24
  116. package/ai-config/commands/refactoring/dead-code.md +0 -40
  117. package/ai-config/commands/refactoring/extract.md +0 -31
  118. package/ai-config/commands/testing/e2e.md +0 -30
  119. package/ai-config/commands/testing/tdd.md +0 -36
  120. package/ai-config/commands/testing/test-coverage.md +0 -30
  121. package/ai-config/commands/testing/test-fix.md +0 -24
  122. package/ai-config/commands/workflow/generate-agents-md.md +0 -85
  123. package/ai-config/commands/workflow/planning.md +0 -47
  124. package/ai-config/commands/workflows/compound.md +0 -89
  125. package/ai-config/commands/workflows/diagnose.md +0 -70
  126. package/ai-config/commands/workflows/discover.md +0 -86
  127. package/ai-config/commands/workflows/plan.md +0 -77
  128. package/ai-config/commands/workflows/review.md +0 -78
  129. package/ai-config/commands/workflows/work.md +0 -75
  130. package/ai-config/config.yaml +0 -18
  131. package/ai-config/hooks/_TEMPLATE.md +0 -96
  132. package/ai-config/hooks/block-dangerous-commands.md +0 -75
  133. package/ai-config/hooks/commit-guard.md +0 -90
  134. package/ai-config/hooks/context-loader.md +0 -73
  135. package/ai-config/hooks/improve-prompt.md +0 -91
  136. package/ai-config/hooks/learning-log.md +0 -72
  137. package/ai-config/hooks/model-router.md +0 -86
  138. package/ai-config/hooks/secret-scanner.md +0 -64
  139. package/ai-config/hooks/skill-validator.md +0 -102
  140. package/ai-config/hooks/task-artifact.md +0 -114
  141. package/ai-config/hooks/validate-workflow.md +0 -100
  142. package/ai-config/prompts/base.md +0 -71
  143. package/ai-config/prompts/modes/debug.md +0 -34
  144. package/ai-config/prompts/modes/deploy.md +0 -40
  145. package/ai-config/prompts/modes/research.md +0 -32
  146. package/ai-config/prompts/modes/review.md +0 -33
  147. package/ai-config/prompts/review-policy.md +0 -79
  148. package/ai-config/skills/_TEMPLATE.md +0 -157
  149. package/ai-config/skills/backend/api-gateway/SKILL.md +0 -254
  150. package/ai-config/skills/backend/bff-concepts/SKILL.md +0 -239
  151. package/ai-config/skills/backend/bff-spring/SKILL.md +0 -364
  152. package/ai-config/skills/backend/chi-router/SKILL.md +0 -396
  153. package/ai-config/skills/backend/error-handling/SKILL.md +0 -255
  154. package/ai-config/skills/backend/exceptions-spring/SKILL.md +0 -323
  155. package/ai-config/skills/backend/fastapi/SKILL.md +0 -302
  156. package/ai-config/skills/backend/gateway-spring/SKILL.md +0 -390
  157. package/ai-config/skills/backend/go-backend/SKILL.md +0 -457
  158. package/ai-config/skills/backend/gradle-multimodule/SKILL.md +0 -274
  159. package/ai-config/skills/backend/graphql-concepts/SKILL.md +0 -352
  160. package/ai-config/skills/backend/graphql-spring/SKILL.md +0 -398
  161. package/ai-config/skills/backend/grpc-concepts/SKILL.md +0 -283
  162. package/ai-config/skills/backend/grpc-spring/SKILL.md +0 -445
  163. package/ai-config/skills/backend/jwt-auth/SKILL.md +0 -412
  164. package/ai-config/skills/backend/notifications-concepts/SKILL.md +0 -259
  165. package/ai-config/skills/backend/recommendations-concepts/SKILL.md +0 -261
  166. package/ai-config/skills/backend/search-concepts/SKILL.md +0 -263
  167. package/ai-config/skills/backend/search-spring/SKILL.md +0 -375
  168. package/ai-config/skills/backend/spring-boot-4/SKILL.md +0 -172
  169. package/ai-config/skills/backend/websockets/SKILL.md +0 -532
  170. package/ai-config/skills/data-ai/ai-ml/SKILL.md +0 -423
  171. package/ai-config/skills/data-ai/analytics-concepts/SKILL.md +0 -195
  172. package/ai-config/skills/data-ai/analytics-spring/SKILL.md +0 -340
  173. package/ai-config/skills/data-ai/duckdb-analytics/SKILL.md +0 -440
  174. package/ai-config/skills/data-ai/langchain/SKILL.md +0 -238
  175. package/ai-config/skills/data-ai/mlflow/SKILL.md +0 -302
  176. package/ai-config/skills/data-ai/onnx-inference/SKILL.md +0 -290
  177. package/ai-config/skills/data-ai/powerbi/SKILL.md +0 -352
  178. package/ai-config/skills/data-ai/pytorch/SKILL.md +0 -274
  179. package/ai-config/skills/data-ai/scikit-learn/SKILL.md +0 -321
  180. package/ai-config/skills/data-ai/vector-db/SKILL.md +0 -301
  181. package/ai-config/skills/database/graph-databases/SKILL.md +0 -218
  182. package/ai-config/skills/database/graph-spring/SKILL.md +0 -361
  183. package/ai-config/skills/database/pgx-postgres/SKILL.md +0 -512
  184. package/ai-config/skills/database/redis-cache/SKILL.md +0 -343
  185. package/ai-config/skills/database/sqlite-embedded/SKILL.md +0 -388
  186. package/ai-config/skills/database/timescaledb/SKILL.md +0 -320
  187. package/ai-config/skills/docs/api-documentation/SKILL.md +0 -293
  188. package/ai-config/skills/docs/docs-spring/SKILL.md +0 -377
  189. package/ai-config/skills/docs/mustache-templates/SKILL.md +0 -190
  190. package/ai-config/skills/docs/technical-docs/SKILL.md +0 -447
  191. package/ai-config/skills/frontend/astro-ssr/SKILL.md +0 -441
  192. package/ai-config/skills/frontend/frontend-design/SKILL.md +0 -54
  193. package/ai-config/skills/frontend/frontend-web/SKILL.md +0 -368
  194. package/ai-config/skills/frontend/mantine-ui/SKILL.md +0 -396
  195. package/ai-config/skills/frontend/tanstack-query/SKILL.md +0 -439
  196. package/ai-config/skills/frontend/zod-validation/SKILL.md +0 -417
  197. package/ai-config/skills/frontend/zustand-state/SKILL.md +0 -350
  198. package/ai-config/skills/infrastructure/chaos-engineering/SKILL.md +0 -244
  199. package/ai-config/skills/infrastructure/chaos-spring/SKILL.md +0 -378
  200. package/ai-config/skills/infrastructure/devops-infra/SKILL.md +0 -435
  201. package/ai-config/skills/infrastructure/docker-containers/SKILL.md +0 -420
  202. package/ai-config/skills/infrastructure/kubernetes/SKILL.md +0 -456
  203. package/ai-config/skills/infrastructure/opentelemetry/SKILL.md +0 -546
  204. package/ai-config/skills/infrastructure/traefik-proxy/SKILL.md +0 -474
  205. package/ai-config/skills/infrastructure/woodpecker-ci/SKILL.md +0 -315
  206. package/ai-config/skills/mobile/ionic-capacitor/SKILL.md +0 -504
  207. package/ai-config/skills/mobile/mobile-ionic/SKILL.md +0 -448
  208. package/ai-config/skills/prompt-improver/SKILL.md +0 -125
  209. package/ai-config/skills/quality/ghagga-review/SKILL.md +0 -216
  210. package/ai-config/skills/references/hooks-patterns/SKILL.md +0 -238
  211. package/ai-config/skills/references/mcp-servers/SKILL.md +0 -275
  212. package/ai-config/skills/references/plugins-reference/SKILL.md +0 -110
  213. package/ai-config/skills/references/skills-reference/SKILL.md +0 -420
  214. package/ai-config/skills/references/subagent-templates/SKILL.md +0 -193
  215. package/ai-config/skills/systems-iot/modbus-protocol/SKILL.md +0 -410
  216. package/ai-config/skills/systems-iot/mqtt-rumqttc/SKILL.md +0 -408
  217. package/ai-config/skills/systems-iot/rust-systems/SKILL.md +0 -386
  218. package/ai-config/skills/systems-iot/tokio-async/SKILL.md +0 -324
  219. package/ai-config/skills/testing/playwright-e2e/SKILL.md +0 -289
  220. package/ai-config/skills/testing/testcontainers/SKILL.md +0 -299
  221. package/ai-config/skills/testing/vitest-testing/SKILL.md +0 -381
  222. package/ai-config/skills/workflow/ci-local-guide/SKILL.md +0 -118
  223. package/ai-config/skills/workflow/claude-automation-recommender/SKILL.md +0 -299
  224. package/ai-config/skills/workflow/claude-md-improver/SKILL.md +0 -158
  225. package/ai-config/skills/workflow/finishing-a-development-branch/SKILL.md +0 -117
  226. package/ai-config/skills/workflow/git-github/SKILL.md +0 -334
  227. package/ai-config/skills/workflow/git-github/references/examples.md +0 -160
  228. package/ai-config/skills/workflow/git-workflow/SKILL.md +0 -214
  229. package/ai-config/skills/workflow/ide-plugins/SKILL.md +0 -277
  230. package/ai-config/skills/workflow/ide-plugins-intellij/SKILL.md +0 -401
  231. package/ai-config/skills/workflow/obsidian-brain-workflow/SKILL.md +0 -199
  232. package/ai-config/skills/workflow/using-git-worktrees/SKILL.md +0 -100
  233. package/ai-config/skills/workflow/verification-before-completion/SKILL.md +0 -73
  234. package/ai-config/skills/workflow/wave-workflow/SKILL.md +0 -178
  235. package/schemas/agent.schema.json +0 -34
  236. package/schemas/ai-config.schema.json +0 -28
  237. package/schemas/plugin.schema.json +0 -62
  238. package/schemas/skill.schema.json +0 -44
@@ -1,440 +0,0 @@
1
- ---
2
- name: duckdb-analytics
3
- description: >
4
- DuckDB OLAP analytics with Parquet, S3, and columnar queries for BI/ML.
5
- Trigger: duckdb, olap, analytics, parquet, columnar, data warehouse, BI
6
-
7
- tools:
8
- - Read
9
- - Write
10
- - Bash
11
- - Grep
12
-
13
- metadata:
14
- author: plataforma-industrial
15
- version: "2.0"
16
- tags: [duckdb, olap, analytics, parquet, bi]
17
- updated: "2026-02"
18
- ---
19
-
20
- # DuckDB OLAP Analytics
21
-
22
- > Columnar analytics engine for Parquet files, S3 data lakes, and BI workloads.
23
-
24
- ## Stack
25
-
26
- ```yaml
27
- DuckDB: 0.10+
28
- Go Driver: github.com/marcboeker/go-duckdb
29
- Python: duckdb 0.10+
30
- Extensions: httpfs, parquet, postgres
31
- ```
32
-
33
- ## When to Use
34
-
35
- - Analytical queries over historical data
36
- - Reading Parquet files from S3/MinIO
37
- - BI reports and aggregations
38
- - ML feature engineering
39
- - Time-series analysis on archived data
40
-
41
- ### Data Architecture
42
-
43
- ```
44
- TimescaleDB (OLTP - Hot, <90 days)
45
- |
46
- | ETL / Export
47
- v
48
- Parquet Files (S3/MinIO - Warm)
49
- |
50
- | Direct read
51
- v
52
- DuckDB (OLAP - Analytical queries)
53
- |
54
- v
55
- BI Tools / Reports / ML
56
- ```
57
-
58
- ## Python Setup
59
-
60
- ```python
61
- import duckdb
62
-
63
- class DuckDBAnalytics:
64
- def __init__(self, db_path: str = ":memory:"):
65
- self.conn = duckdb.connect(db_path)
66
- self._setup()
67
-
68
- def _setup(self):
69
- self.conn.execute("INSTALL httpfs; LOAD httpfs;")
70
- self.conn.execute("INSTALL parquet; LOAD parquet;")
71
-
72
- def configure_s3(self, endpoint: str, access_key: str, secret_key: str):
73
- self.conn.execute(f"SET s3_endpoint = '{endpoint}';")
74
- self.conn.execute(f"SET s3_access_key_id = '{access_key}';")
75
- self.conn.execute(f"SET s3_secret_access_key = '{secret_key}';")
76
- self.conn.execute("SET s3_use_ssl = false;")
77
-
78
- def query_df(self, sql: str):
79
- return self.conn.execute(sql).fetchdf()
80
-
81
- def query(self, sql: str) -> list[dict]:
82
- result = self.conn.execute(sql)
83
- columns = [desc[0] for desc in result.description]
84
- return [dict(zip(columns, row)) for row in result.fetchall()]
85
- ```
86
-
87
- ## Go Setup
88
-
89
- ```go
90
- package analytics
91
-
92
- import (
93
- "database/sql"
94
- _ "github.com/marcboeker/go-duckdb"
95
- )
96
-
97
- type DuckDB struct {
98
- db *sql.DB
99
- }
100
-
101
- func NewDuckDB(path string) (*DuckDB, error) {
102
- db, err := sql.Open("duckdb", path)
103
- if err != nil {
104
- return nil, err
105
- }
106
- db.Exec("INSTALL parquet; LOAD parquet;")
107
- return &DuckDB{db: db}, nil
108
- }
109
- ```
110
-
111
- ## Schema for Analytics
112
-
113
- ### Fact Tables
114
-
115
- ```sql
116
- CREATE SCHEMA IF NOT EXISTS analytics;
117
-
118
- CREATE TABLE IF NOT EXISTS analytics.sensor_readings (
119
- time TIMESTAMP NOT NULL,
120
- sensor_id UUID NOT NULL,
121
- sensor_name VARCHAR,
122
- tenant_id UUID,
123
- value DOUBLE,
124
- unit VARCHAR,
125
- -- Pre-computed time dimensions
126
- year INTEGER,
127
- month INTEGER,
128
- week INTEGER,
129
- day_of_week INTEGER,
130
- hour INTEGER,
131
- partition_date DATE
132
- );
133
-
134
- CREATE TABLE IF NOT EXISTS analytics.events (
135
- id UUID,
136
- event_type VARCHAR,
137
- entity_id UUID,
138
- tenant_id UUID,
139
- payload JSON,
140
- occurred_at TIMESTAMP NOT NULL,
141
- year INTEGER,
142
- month INTEGER,
143
- partition_date DATE
144
- );
145
- ```
146
-
147
- ### Dimension Tables
148
-
149
- ```sql
150
- -- Date dimension
151
- CREATE TABLE IF NOT EXISTS analytics.dim_date (
152
- date_key DATE PRIMARY KEY,
153
- year INTEGER,
154
- quarter INTEGER,
155
- month INTEGER,
156
- month_name VARCHAR,
157
- week INTEGER,
158
- day_of_week INTEGER,
159
- day_name VARCHAR,
160
- is_weekend BOOLEAN
161
- );
162
-
163
- -- Populate 10 years
164
- INSERT INTO analytics.dim_date
165
- SELECT
166
- date_key,
167
- YEAR(date_key), QUARTER(date_key), MONTH(date_key),
168
- MONTHNAME(date_key), WEEKOFYEAR(date_key),
169
- DAYOFWEEK(date_key), DAYNAME(date_key),
170
- DAYOFWEEK(date_key) IN (0, 6)
171
- FROM (
172
- SELECT UNNEST(generate_series(
173
- DATE '2020-01-01', DATE '2030-12-31', INTERVAL 1 DAY
174
- ))::DATE as date_key
175
- );
176
- ```
177
-
178
- ## Loading from Parquet
179
-
180
- ### Direct Query (No Load)
181
-
182
- ```sql
183
- -- Query directly from Parquet files
184
- SELECT
185
- sensor_id,
186
- AVG(value) as avg_value,
187
- COUNT(*) as readings
188
- FROM read_parquet('s3://data/readings/**/*.parquet')
189
- WHERE partition_date >= '2024-01-01'
190
- GROUP BY sensor_id;
191
- ```
192
-
193
- ### Load into Table
194
-
195
- ```sql
196
- -- Load with transformation
197
- INSERT INTO analytics.sensor_readings
198
- SELECT
199
- time::TIMESTAMP,
200
- sensor_id::UUID,
201
- sensor_name,
202
- tenant_id::UUID,
203
- value,
204
- unit,
205
- YEAR(time), MONTH(time), WEEKOFYEAR(time),
206
- DAYOFWEEK(time), HOUR(time),
207
- time::DATE as partition_date
208
- FROM read_parquet('s3://data/readings/date=2024-01-15/*.parquet')
209
- WHERE partition_date NOT IN (SELECT DISTINCT partition_date FROM analytics.sensor_readings);
210
- ```
211
-
212
- ### Python ETL
213
-
214
- ```python
215
- from datetime import datetime, timedelta
216
-
217
- conn = duckdb.connect("analytics.duckdb")
218
- conn.execute("SET s3_endpoint = 'minio:9000';")
219
- conn.execute("SET s3_access_key_id = 'admin';")
220
- conn.execute("SET s3_secret_access_key = 'password';")
221
-
222
- # Load last 30 days
223
- for i in range(30):
224
- date = (datetime.now() - timedelta(days=i)).strftime("%Y-%m-%d")
225
- conn.execute(f"""
226
- INSERT INTO analytics.sensor_readings
227
- SELECT * FROM read_parquet('s3://data/readings/date={date}/*.parquet')
228
- """)
229
- ```
230
-
231
- ## Analytical Views
232
-
233
- ### Daily Summary
234
-
235
- ```sql
236
- CREATE OR REPLACE VIEW reports.daily_summary AS
237
- SELECT
238
- partition_date,
239
- sensor_id,
240
- sensor_name,
241
- COUNT(*) as reading_count,
242
- AVG(value) as avg_value,
243
- MIN(value) as min_value,
244
- MAX(value) as max_value,
245
- STDDEV(value) as stddev_value
246
- FROM analytics.sensor_readings
247
- GROUP BY partition_date, sensor_id, sensor_name;
248
- ```
249
-
250
- ### Monthly KPIs
251
-
252
- ```sql
253
- CREATE OR REPLACE VIEW reports.monthly_kpis AS
254
- SELECT
255
- tenant_id,
256
- year,
257
- month,
258
- COUNT(DISTINCT sensor_id) as active_sensors,
259
- SUM(reading_count) as total_readings,
260
- AVG(avg_value) as overall_avg
261
- FROM reports.daily_summary
262
- GROUP BY tenant_id, year, month;
263
- ```
264
-
265
- ## Advanced Analytics
266
-
267
- ### Z-Score Anomaly Detection
268
-
269
- ```sql
270
- WITH stats AS (
271
- SELECT
272
- sensor_id,
273
- AVG(value) as avg_val,
274
- STDDEV(value) as std_val
275
- FROM analytics.sensor_readings
276
- WHERE partition_date >= CURRENT_DATE - INTERVAL 90 DAY
277
- GROUP BY sensor_id
278
- )
279
- SELECT
280
- r.time,
281
- r.sensor_id,
282
- r.value,
283
- (r.value - s.avg_val) / NULLIF(s.std_val, 0) as z_score,
284
- CASE
285
- WHEN ABS(r.value - s.avg_val) > 3 * s.std_val THEN 'ANOMALY'
286
- WHEN ABS(r.value - s.avg_val) > 2 * s.std_val THEN 'WARNING'
287
- ELSE 'NORMAL'
288
- END as status
289
- FROM analytics.sensor_readings r
290
- JOIN stats s ON s.sensor_id = r.sensor_id
291
- WHERE r.partition_date >= CURRENT_DATE - INTERVAL 7 DAY
292
- AND ABS(r.value - s.avg_val) > 2 * s.std_val;
293
- ```
294
-
295
- ### Correlation Analysis
296
-
297
- ```sql
298
- SELECT
299
- sensor_name,
300
- CORR(temperature, gas_flow) as temp_gas_correlation,
301
- COUNT(*) as samples
302
- FROM analytics.readings
303
- WHERE partition_date >= CURRENT_DATE - INTERVAL 30 DAY
304
- GROUP BY sensor_name
305
- HAVING COUNT(*) > 100;
306
- ```
307
-
308
- ### Window Functions
309
-
310
- ```sql
311
- SELECT
312
- partition_date,
313
- sensor_id,
314
- value,
315
- -- Month cumulative
316
- SUM(value) OVER (
317
- PARTITION BY sensor_id, year, month
318
- ORDER BY partition_date
319
- ) as month_cumulative,
320
- -- 7-day moving average
321
- AVG(value) OVER (
322
- PARTITION BY sensor_id
323
- ORDER BY partition_date
324
- ROWS BETWEEN 6 PRECEDING AND CURRENT ROW
325
- ) as ma7,
326
- -- Week-over-week change
327
- value - LAG(value, 7) OVER (
328
- PARTITION BY sensor_id ORDER BY partition_date
329
- ) as wow_change
330
- FROM analytics.daily_agg;
331
- ```
332
-
333
- ### Percentiles
334
-
335
- ```sql
336
- SELECT
337
- sensor_name,
338
- MIN(value) as min,
339
- PERCENTILE_CONT(0.25) WITHIN GROUP (ORDER BY value) as p25,
340
- PERCENTILE_CONT(0.50) WITHIN GROUP (ORDER BY value) as median,
341
- PERCENTILE_CONT(0.75) WITHIN GROUP (ORDER BY value) as p75,
342
- MAX(value) as max
343
- FROM analytics.sensor_readings
344
- WHERE partition_date >= CURRENT_DATE - INTERVAL 30 DAY
345
- GROUP BY sensor_name;
346
- ```
347
-
348
- ## Export to Parquet
349
-
350
- ```sql
351
- -- Simple export
352
- COPY (SELECT * FROM reports.monthly_kpis)
353
- TO 'monthly_kpis.parquet' (FORMAT PARQUET);
354
-
355
- -- Partitioned export
356
- COPY analytics.sensor_readings
357
- TO 'sensor_readings' (FORMAT PARQUET, PARTITION_BY (year, month));
358
-
359
- -- Export to S3
360
- COPY reports.daily_summary
361
- TO 's3://data/reports/daily_summary.parquet' (FORMAT PARQUET);
362
- ```
363
-
364
- ## Python/Pandas Integration
365
-
366
- ```python
367
- # Query to DataFrame
368
- df = conn.execute("""
369
- SELECT partition_date, sensor_id, AVG(value) as avg
370
- FROM analytics.sensor_readings
371
- GROUP BY partition_date, sensor_id
372
- """).fetchdf()
373
-
374
- # DataFrame to DuckDB
375
- import pandas as pd
376
- df = pd.DataFrame({'date': [...], 'value': [...]})
377
- conn.register('temp_data', df)
378
- conn.execute("INSERT INTO analytics.processed SELECT * FROM temp_data")
379
- ```
380
-
381
- ## DuckDB vs TimescaleDB
382
-
383
- | Aspect | DuckDB | TimescaleDB |
384
- |--------|--------|-------------|
385
- | Type | OLAP (analytical) | OLTP (transactional) |
386
- | Storage | Columnar | Row-based + chunks |
387
- | Inserts | Batch (slow individual) | Streaming (fast) |
388
- | Queries | Massive aggregations | Point + range |
389
- | Latency | Seconds | Milliseconds |
390
- | Use case | Reports, BI, ML | Dashboard, alerts |
391
-
392
- ## Performance Tips
393
-
394
- ```sql
395
- -- Filter early (pushdown to Parquet)
396
- SELECT * FROM read_parquet('data/*.parquet')
397
- WHERE year = 2024 AND month = 3; -- Good
398
-
399
- -- Project only needed columns
400
- SELECT sensor_id, AVG(value)
401
- FROM read_parquet('data.parquet')
402
- GROUP BY sensor_id; -- Columnar = efficient
403
-
404
- -- Configure resources
405
- SET threads = 4;
406
- SET memory_limit = '4GB';
407
-
408
- -- Analyze query plan
409
- EXPLAIN ANALYZE SELECT ...;
410
- ```
411
-
412
- ## Quick Reference
413
-
414
- | Task | Command |
415
- |------|---------|
416
- | Load Parquet | `SELECT * FROM read_parquet('file.parquet')` |
417
- | Load from S3 | `SELECT * FROM read_parquet('s3://bucket/path/*.parquet')` |
418
- | Export Parquet | `COPY (query) TO 'file.parquet' (FORMAT PARQUET)` |
419
- | In-memory DB | `duckdb.connect(':memory:')` |
420
- | Check tables | `SELECT * FROM duckdb_tables()` |
421
- | Memory usage | `SELECT * FROM duckdb_memory()` |
422
-
423
- ## Resources
424
-
425
- - [DuckDB Documentation](https://duckdb.org/docs/)
426
- - [go-duckdb](https://github.com/marcboeker/go-duckdb)
427
- - [DuckDB Python API](https://duckdb.org/docs/api/python/overview)
428
-
429
- ---
430
-
431
- ## Changelog
432
-
433
- - **2.0** - Condensed from Plataforma Industrial SKILL-DUCKDB
434
-
435
- ## Related Skills
436
-
437
- - `timescaledb`: Time-series source data
438
- - `scikit-learn`: ML data preparation
439
- - `powerbi`: BI visualization
440
- - `sqlite-embedded`: Embedded alternative
@@ -1,238 +0,0 @@
1
- ---
2
- name: langchain
3
- description: >
4
- Build LLM applications with chains, agents, and RAG using LangChain and LangGraph.
5
- Trigger: langchain, llm app, agent, rag, chains, langgraph
6
- tools:
7
- - Read
8
- - Write
9
- - Bash
10
- - Grep
11
- metadata:
12
- author: plataforma-industrial
13
- version: "2.0"
14
- tags: [langchain, llm, agents, rag, ai]
15
- updated: "2026-02"
16
- ---
17
-
18
- # LangChain Skill
19
-
20
- Build LLM-powered applications with chains, agents, RAG, and streaming.
21
-
22
- ## Stack
23
-
24
- ```yaml
25
- langchain: 0.1+
26
- langchain-openai: 0.0.8+
27
- langchain-community: 0.0.20+
28
- langgraph: 0.0.26+
29
- langsmith: 0.1+
30
- ```
31
-
32
- ## Project Structure
33
-
34
- ```
35
- src/
36
- ├── agents/ # LangGraph agents
37
- ├── chains/ # LCEL chains
38
- ├── prompts/ # Prompt templates
39
- ├── tools/ # Custom tools
40
- └── vectorstore/ # RAG components
41
- ```
42
-
43
- ## Basic Chain with Structured Output
44
-
45
- ```python
46
- from langchain_openai import ChatOpenAI
47
- from langchain_core.prompts import ChatPromptTemplate
48
- from langchain_core.output_parsers import PydanticOutputParser
49
- from pydantic import BaseModel, Field
50
-
51
- class Analysis(BaseModel):
52
- status: str = Field(description="Status: normal, warning, critical")
53
- findings: list[str] = Field(description="Key findings")
54
- confidence: float = Field(description="Confidence 0-1")
55
-
56
- def create_analysis_chain():
57
- llm = ChatOpenAI(model="gpt-4-turbo-preview", temperature=0)
58
- parser = PydanticOutputParser(pydantic_object=Analysis)
59
-
60
- prompt = ChatPromptTemplate.from_messages([
61
- ("system", "Analyze data.\n{format_instructions}"),
62
- ("human", "{input}")
63
- ])
64
-
65
- chain = prompt | llm | parser
66
- return chain
67
-
68
- # Usage
69
- result = await chain.ainvoke({
70
- "input": data,
71
- "format_instructions": parser.get_format_instructions()
72
- })
73
- ```
74
-
75
- ## Custom Tools
76
-
77
- ```python
78
- from langchain_core.tools import tool
79
- import httpx
80
-
81
- @tool
82
- async def fetch_data(resource_id: str, hours: int = 24) -> str:
83
- """Fetch data for a resource.
84
-
85
- Args:
86
- resource_id: The resource UUID
87
- hours: Hours to look back (default 24)
88
- """
89
- async with httpx.AsyncClient() as client:
90
- response = await client.get(
91
- f"http://api:8080/resources/{resource_id}",
92
- params={"hours": hours}
93
- )
94
- return response.text
95
-
96
- @tool
97
- async def update_status(resource_id: str, status: str) -> str:
98
- """Update resource status."""
99
- async with httpx.AsyncClient() as client:
100
- response = await client.patch(
101
- f"http://api:8080/resources/{resource_id}",
102
- json={"status": status}
103
- )
104
- return "Updated" if response.status_code == 200 else f"Failed: {response.text}"
105
- ```
106
-
107
- ## LangGraph Agent
108
-
109
- ```python
110
- from typing import TypedDict, Annotated, Sequence
111
- from langchain_core.messages import BaseMessage, HumanMessage
112
- from langgraph.graph import StateGraph, END
113
- from langgraph.prebuilt import ToolNode
114
- import operator
115
-
116
- class AgentState(TypedDict):
117
- messages: Annotated[Sequence[BaseMessage], operator.add]
118
- context: dict
119
-
120
- def create_agent(tools: list):
121
- llm = ChatOpenAI(model="gpt-4-turbo-preview", temperature=0)
122
- llm_with_tools = llm.bind_tools(tools)
123
-
124
- def agent_node(state: AgentState):
125
- system_message = f"Context: {state['context']}"
126
- response = llm_with_tools.invoke([
127
- {"role": "system", "content": system_message},
128
- *state["messages"]
129
- ])
130
- return {"messages": [response]}
131
-
132
- def should_continue(state: AgentState):
133
- last_message = state["messages"][-1]
134
- if hasattr(last_message, "tool_calls") and last_message.tool_calls:
135
- return "tools"
136
- return END
137
-
138
- workflow = StateGraph(AgentState)
139
- workflow.add_node("agent", agent_node)
140
- workflow.add_node("tools", ToolNode(tools))
141
- workflow.set_entry_point("agent")
142
- workflow.add_conditional_edges("agent", should_continue, {"tools": "tools", END: END})
143
- workflow.add_edge("tools", "agent")
144
-
145
- return workflow.compile()
146
-
147
- # Usage
148
- agent = create_agent([fetch_data, update_status])
149
- result = await agent.ainvoke({
150
- "messages": [HumanMessage(content="Check resource status")],
151
- "context": {"user_id": "123"}
152
- })
153
- ```
154
-
155
- ## RAG Chain
156
-
157
- ```python
158
- from langchain_openai import OpenAIEmbeddings
159
- from langchain_community.vectorstores import Chroma
160
- from langchain_text_splitters import RecursiveCharacterTextSplitter
161
- from langchain_core.runnables import RunnablePassthrough
162
-
163
- def create_rag_chain(vectorstore):
164
- llm = ChatOpenAI(model="gpt-4-turbo-preview", temperature=0)
165
- retriever = vectorstore.as_retriever(search_type="mmr", search_kwargs={"k": 5})
166
-
167
- prompt = ChatPromptTemplate.from_messages([
168
- ("system", "Answer using context:\n{context}"),
169
- ("human", "{question}")
170
- ])
171
-
172
- def format_docs(docs):
173
- return "\n\n".join(doc.page_content for doc in docs)
174
-
175
- chain = (
176
- {"context": retriever | format_docs, "question": RunnablePassthrough()}
177
- | prompt
178
- | llm
179
- )
180
- return chain
181
- ```
182
-
183
- ## Streaming Response (FastAPI)
184
-
185
- ```python
186
- from fastapi import APIRouter
187
- from fastapi.responses import StreamingResponse
188
-
189
- router = APIRouter()
190
-
191
- @router.post("/chat/stream")
192
- async def chat_stream(request: ChatRequest):
193
- llm = ChatOpenAI(model="gpt-4-turbo-preview", streaming=True)
194
- prompt = ChatPromptTemplate.from_messages([
195
- ("system", "You are a helpful assistant."),
196
- ("human", "{message}")
197
- ])
198
- chain = prompt | llm
199
-
200
- async def generate():
201
- async for chunk in chain.astream({"message": request.message}):
202
- if chunk.content:
203
- yield f"data: {chunk.content}\n\n"
204
- yield "data: [DONE]\n\n"
205
-
206
- return StreamingResponse(generate(), media_type="text/event-stream")
207
- ```
208
-
209
- ## LangSmith Tracing
210
-
211
- ```python
212
- import os
213
- from langsmith import Client
214
-
215
- def setup_langsmith():
216
- os.environ["LANGCHAIN_TRACING_V2"] = "true"
217
- os.environ["LANGCHAIN_PROJECT"] = "my-project"
218
- os.environ["LANGCHAIN_API_KEY"] = os.getenv("LANGSMITH_API_KEY")
219
-
220
- # Add feedback
221
- async def log_feedback(run_id: str, score: float):
222
- Client().create_feedback(run_id=run_id, key="user-rating", score=score)
223
- ```
224
-
225
- ## Best Practices
226
-
227
- 1. **Use structured outputs** - PydanticOutputParser for reliable parsing
228
- 2. **Async operations** - Always use `ainvoke`, `astream` for I/O
229
- 3. **Error handling** - Use RunnableConfig with retries and timeouts
230
- 4. **Cache embeddings** - CacheBackedEmbeddings for repeated queries
231
- 5. **Tracing** - Enable LangSmith for debugging and monitoring
232
-
233
- ## Related Skills
234
-
235
- - `ai-ml`: Full AI/ML patterns
236
- - `vector-db`: RAG with vector stores
237
- - `fastapi`: API integration
238
- - `redis-cache`: LLM response caching