vibes-plug 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 (141) hide show
  1. package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  2. package/BLUEPRINT.md +125 -0
  3. package/CHANGELOG.md +195 -0
  4. package/CONTRIBUTING.md +199 -0
  5. package/LICENSE +21 -0
  6. package/README.md +263 -0
  7. package/SECURITY.md +21 -0
  8. package/banner.png +0 -0
  9. package/package.json +25 -0
  10. package/plugin.json +8 -0
  11. package/scripts/update_skills.js +75 -0
  12. package/skills/ai-llm-integration-expert/SKILL.md +162 -0
  13. package/skills/api-design-expert/SKILL.md +310 -0
  14. package/skills/app-analyzer-optimizer/SKILL.md +189 -0
  15. package/skills/asisten_ramah/SKILL.md +41 -0
  16. package/skills/authentication-identity-expert/SKILL.md +45 -0
  17. package/skills/auto-doc-updater/SKILL.md +204 -0
  18. package/skills/bootstrap-to-modern/SKILL.md +87 -0
  19. package/skills/brainstorming/SKILL.md +353 -0
  20. package/skills/bun-runtime-expert/SKILL.md +211 -0
  21. package/skills/ci-cd-devops-architect/SKILL.md +45 -0
  22. package/skills/cloud-hosting-expert/SKILL.md +244 -0
  23. package/skills/coderabbit/SKILL.md +192 -0
  24. package/skills/data-telemetry-expert/SKILL.md +213 -0
  25. package/skills/database-orm-expert/SKILL.md +294 -0
  26. package/skills/design-system-architect/SKILL.md +243 -0
  27. package/skills/e2e-testing-expert/SKILL.md +315 -0
  28. package/skills/event-driven-architect/SKILL.md +81 -0
  29. package/skills/firebase-security-expert/SKILL.md +195 -0
  30. package/skills/fullstack-expert/SKILL.md +202 -0
  31. package/skills/fullstack-expert/references/api_design_guide.md +466 -0
  32. package/skills/fullstack-expert/references/devops_infrastructure.md +477 -0
  33. package/skills/fullstack-expert/references/multi_language_backend.md +528 -0
  34. package/skills/fullstack-expert/references/system_design_patterns.md +358 -0
  35. package/skills/fullstack-expert/scripts/api_contract_validator.py +253 -0
  36. package/skills/fullstack-expert/scripts/architecture_analyzer.py +326 -0
  37. package/skills/gemini-agent-booster/SKILL.md +135 -0
  38. package/skills/global-a11y-i18n-expert/SKILL.md +81 -0
  39. package/skills/go-programming-expert/SKILL.md +295 -0
  40. package/skills/hig/SKILL.md +188 -0
  41. package/skills/js-backend-expert/SKILL.md +192 -0
  42. package/skills/mcp-server-architect/SKILL.md +194 -0
  43. package/skills/mobile-expo-expert/SKILL.md +186 -0
  44. package/skills/monday-design-aesthetic/SKILL.md +67 -0
  45. package/skills/monorepo-architect/SKILL.md +227 -0
  46. package/skills/mpa-orchestrator/SKILL.md +101 -0
  47. package/skills/multi-agent-orchestration/SKILL.md +234 -0
  48. package/skills/multiple-entry-points/SKILL.md +55 -0
  49. package/skills/mvc-expert/SKILL.md +231 -0
  50. package/skills/payment-gateway-expert/SKILL.md +45 -0
  51. package/skills/performance-web-vitals/SKILL.md +332 -0
  52. package/skills/prd-architect/SKILL.md +191 -0
  53. package/skills/production-ready-hardener/SKILL.md +469 -0
  54. package/skills/production-ready-hardener/references/performance_optimization.md +441 -0
  55. package/skills/production-ready-hardener/references/production_checklist.md +161 -0
  56. package/skills/production-ready-hardener/references/security_hardening_guide.md +379 -0
  57. package/skills/production-ready-hardener/scripts/production_readiness_scanner.py +875 -0
  58. package/skills/python-programming-expert/SKILL.md +271 -0
  59. package/skills/realtime-collaboration-expert/SKILL.md +45 -0
  60. package/skills/rust-programming-expert/SKILL.md +235 -0
  61. package/skills/saas-billing/SKILL.md +377 -0
  62. package/skills/saas-multi-tenant/SKILL.md +237 -0
  63. package/skills/saas-mvp-launcher/SKILL.md +231 -0
  64. package/skills/saas-transformer/SKILL.md +446 -0
  65. package/skills/saas-transformer/references/billing_integration_guide.md +401 -0
  66. package/skills/saas-transformer/references/feature_gating_patterns.md +137 -0
  67. package/skills/saas-transformer/references/saas_transformation_checklist.md +121 -0
  68. package/skills/saas-transformer/scripts/saas_transformation_scanner.py +254 -0
  69. package/skills/scalability-clean-code/SKILL.md +229 -0
  70. package/skills/secure-fuzz-testing/SKILL.md +201 -0
  71. package/skills/senior-frontend/SKILL.md +161 -0
  72. package/skills/senior-frontend/references/frontend_best_practices.md +806 -0
  73. package/skills/senior-frontend/references/nextjs_optimization_guide.md +724 -0
  74. package/skills/senior-frontend/references/react_patterns.md +746 -0
  75. package/skills/senior-frontend/scripts/bundle_analyzer.py +407 -0
  76. package/skills/senior-frontend/scripts/component_generator.py +329 -0
  77. package/skills/senior-frontend/scripts/frontend_scaffolder.py +1005 -0
  78. package/skills/senior-fullstack/SKILL.md +167 -0
  79. package/skills/senior-fullstack/references/architecture_patterns.md +160 -0
  80. package/skills/senior-fullstack/references/development_workflows.md +222 -0
  81. package/skills/senior-fullstack/references/tech_stack_guide.md +190 -0
  82. package/skills/senior-fullstack/scripts/code_quality_analyzer.py +114 -0
  83. package/skills/senior-fullstack/scripts/fullstack_scaffolder.py +114 -0
  84. package/skills/senior-fullstack/scripts/project_scaffolder.py +114 -0
  85. package/skills/seo/SKILL.md +225 -0
  86. package/skills/seo/references/cwv-thresholds.md +108 -0
  87. package/skills/seo/references/eeat-framework.md +214 -0
  88. package/skills/seo/references/quality-gates.md +155 -0
  89. package/skills/seo/references/schema-types.md +118 -0
  90. package/skills/seo-aeo-landing-page-writer/SKILL.md +97 -0
  91. package/skills/seo-geo/SKILL.md +188 -0
  92. package/skills/session-handoff-resume/SKILL.md +158 -0
  93. package/skills/skill_baru/SKILL.md +147 -0
  94. package/skills/spa-orchestrator/SKILL.md +288 -0
  95. package/skills/state-management-expert/SKILL.md +272 -0
  96. package/skills/supabase-migration/SKILL.md +45 -0
  97. package/skills/supabase-security-expert/SKILL.md +243 -0
  98. package/skills/tailwind-expert/SKILL.md +188 -0
  99. package/skills/tanstack-query-expert/SKILL.md +199 -0
  100. package/skills/tauri-expert/SKILL.md +97 -0
  101. package/skills/token-saver/SKILL.md +111 -0
  102. package/skills/typescript-expert/SKILL.md +279 -0
  103. package/skills/ui-components-expert/SKILL.md +63 -0
  104. package/skills/ui-ux-pro-max/SKILL.md +201 -0
  105. package/skills/ui-ux-pro-max/data/charts.csv +26 -0
  106. package/skills/ui-ux-pro-max/data/colors.csv +97 -0
  107. package/skills/ui-ux-pro-max/data/icons.csv +101 -0
  108. package/skills/ui-ux-pro-max/data/landing.csv +31 -0
  109. package/skills/ui-ux-pro-max/data/products.csv +97 -0
  110. package/skills/ui-ux-pro-max/data/prompts.csv +24 -0
  111. package/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
  112. package/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  113. package/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  114. package/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  115. package/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  116. package/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  117. package/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  118. package/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
  119. package/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  120. package/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  121. package/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  122. package/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  123. package/skills/ui-ux-pro-max/data/styles.csv +59 -0
  124. package/skills/ui-ux-pro-max/data/typography.csv +58 -0
  125. package/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  126. package/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  127. package/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
  128. package/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-310.pyc +0 -0
  129. package/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-312.pyc +0 -0
  130. package/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-310.pyc +0 -0
  131. package/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-312.pyc +0 -0
  132. package/skills/ui-ux-pro-max/scripts/core.py +257 -0
  133. package/skills/ui-ux-pro-max/scripts/design_system.py +493 -0
  134. package/skills/ui-ux-pro-max/scripts/search.py +81 -0
  135. package/skills/ui_ux_expert/SKILL.md +114 -0
  136. package/skills/vibe-code-gardener/SKILL.md +173 -0
  137. package/skills/web-scraper/SKILL.md +205 -0
  138. package/skills/web-scraper/references/data-transforms.md +397 -0
  139. package/skills/web-scraper/references/extraction-patterns.md +475 -0
  140. package/skills/web-scraper/references/output-templates.md +481 -0
  141. package/skills/zero-to-prod-orchestrator/SKILL.md +180 -0
@@ -0,0 +1,271 @@
1
+ ---
2
+ name: python-programming-expert
3
+ description: "Expert-level skill for Python programming (Python 3.12/3.13+). Covers type safety, generic syntax (PEP 695), async/await TaskGroups, FastAPI 0.115+, Pydantic v2, uv package manager, Ruff, and pytest in English and Indonesian."
4
+ author: "Roedy Rustam"
5
+ ---
6
+
7
+ # Python Programming Expert (3.13 JIT Edition)
8
+
9
+ [English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
10
+
11
+ ---
12
+
13
+ <a name="english"></a>
14
+ ## English
15
+
16
+ ### Description
17
+ Expert-level Python development guidance for **Python 3.13+** with JIT compiler, covering type safety, async patterns, modern web frameworks (FastAPI 0.115+, Django 5.x), Pydantic v2, the `uv` package manager, Ruff linting, and production-grade testing with pytest.
18
+
19
+ ### Trigger Conditions
20
+ - Writing Python 3.12+ / 3.13+ applications or services.
21
+ - Building FastAPI 0.115+ REST APIs or Django 5.x web apps.
22
+ - Managing Python projects with the `uv` package manager.
23
+ - Implementing async/await patterns with `asyncio.TaskGroup`.
24
+ - Writing type-safe Python with Pydantic v2 and modern generics (PEP 695).
25
+ - Setting up Ruff for linting + formatting, pytest for testing.
26
+
27
+ ### Python 3.13 — Key Improvements
28
+
29
+ #### JIT Compiler (Experimental → Production-Ready)
30
+ Python 3.13 ships with an **experimental JIT compiler** based on copy-and-patch. Enable it for CPU-bound workloads:
31
+ ```bash
32
+ python3.13 --enable-experimental-jit app.py
33
+ # Or via env var:
34
+ PYTHON_JIT=1 python3.13 app.py
35
+ ```
36
+ Expected 10-20% speedup for numeric/algorithmic code. Not yet beneficial for I/O-bound async code.
37
+
38
+ #### Free-Threaded Mode (No GIL)
39
+ Python 3.13 introduces an experimental **free-threaded build** (no GIL), enabling true CPU parallelism with threads:
40
+ ```bash
41
+ # Install free-threaded build
42
+ uv python install 3.13t
43
+ python3.13t -X gil=0 my_parallel_app.py
44
+ ```
45
+
46
+ #### Improved Error Messages
47
+ Python 3.13 provides significantly better tracebacks with highlighted variable values and suggestions.
48
+
49
+ ### Modern Python Toolchain (2026)
50
+
51
+ #### uv — The 2026 Standard Package Manager
52
+ Replace `pip`, `pip-tools`, `virtualenv`, `pyenv`, and `poetry` with **uv**:
53
+ ```bash
54
+ # Create project
55
+ uv init my-project
56
+ cd my-project
57
+
58
+ # Add dependencies
59
+ uv add fastapi pydantic httpx
60
+
61
+ # Add dev dependencies
62
+ uv add --dev pytest ruff mypy
63
+
64
+ # Run scripts
65
+ uv run python main.py
66
+ uv run pytest
67
+
68
+ # Sync environment
69
+ uv sync
70
+
71
+ # Lock dependencies
72
+ uv lock
73
+ ```
74
+
75
+ #### Ruff — Linting + Formatting in One
76
+ ```bash
77
+ uv add --dev ruff
78
+
79
+ # ruff.toml
80
+ [tool.ruff]
81
+ line-length = 88
82
+ target-version = "py313"
83
+
84
+ [tool.ruff.lint]
85
+ select = ["E", "F", "I", "N", "UP", "B", "SIM", "ANN"]
86
+
87
+ # Run
88
+ uv run ruff check .
89
+ uv run ruff format .
90
+ ```
91
+
92
+ ### Type Safety — Modern Patterns (Python 3.12+)
93
+
94
+ #### PEP 695 — New Generic Syntax
95
+ ```python
96
+ # Old (Python < 3.12)
97
+ from typing import TypeVar
98
+ T = TypeVar('T')
99
+ def first[T](lst: list[T]) -> T: ...
100
+
101
+ # New (Python 3.12+) — cleaner, no TypeVar boilerplate
102
+ def first[T](lst: list[T]) -> T:
103
+ return lst[0]
104
+
105
+ type Vector = list[float] # Type alias with 'type' statement
106
+ ```
107
+
108
+ #### Pydantic v2 — Data Validation
109
+ ```python
110
+ from pydantic import BaseModel, Field, field_validator
111
+ from pydantic import EmailStr
112
+
113
+ class UserCreate(BaseModel):
114
+ name: str = Field(min_length=2, max_length=50)
115
+ email: EmailStr
116
+ age: int = Field(ge=0, le=150)
117
+
118
+ @field_validator('name')
119
+ @classmethod
120
+ def name_must_not_contain_space(cls, v: str) -> str:
121
+ if ' ' in v:
122
+ raise ValueError('Name must not have double spaces')
123
+ return v.strip()
124
+
125
+ # Usage
126
+ user = UserCreate(name="Alice", email="alice@example.com", age=30)
127
+ user.model_dump() # {'name': 'Alice', 'email': 'alice@example.com', 'age': 30}
128
+ ```
129
+
130
+ ### FastAPI 0.115+ Best Practices
131
+
132
+ #### Lifespan (Replace @app.on_event)
133
+ ```python
134
+ from contextlib import asynccontextmanager
135
+ from fastapi import FastAPI
136
+
137
+ @asynccontextmanager
138
+ async def lifespan(app: FastAPI):
139
+ # Startup: connect DB, warm caches
140
+ await db.connect()
141
+ yield
142
+ # Shutdown: clean up resources
143
+ await db.disconnect()
144
+
145
+ app = FastAPI(lifespan=lifespan)
146
+ ```
147
+
148
+ #### Dependency Injection Pattern
149
+ ```python
150
+ from fastapi import Depends, HTTPException
151
+ from sqlalchemy.ext.asyncio import AsyncSession
152
+
153
+ async def get_db() -> AsyncSession:
154
+ async with async_session_factory() as session:
155
+ yield session
156
+
157
+ @app.get("/users/{user_id}")
158
+ async def get_user(user_id: str, db: AsyncSession = Depends(get_db)):
159
+ user = await db.get(User, user_id)
160
+ if not user:
161
+ raise HTTPException(status_code=404, detail="User not found")
162
+ return user
163
+ ```
164
+
165
+ #### Structured Error Responses
166
+ ```python
167
+ from fastapi import Request
168
+ from fastapi.responses import JSONResponse
169
+
170
+ class AppError(Exception):
171
+ def __init__(self, message: str, code: str, status: int = 400):
172
+ self.message = message
173
+ self.code = code
174
+ self.status = status
175
+
176
+ @app.exception_handler(AppError)
177
+ async def app_error_handler(request: Request, exc: AppError):
178
+ return JSONResponse(
179
+ status_code=exc.status,
180
+ content={"error": exc.code, "message": exc.message}
181
+ )
182
+ ```
183
+
184
+ ### Async Patterns — asyncio.TaskGroup (Python 3.11+)
185
+ ```python
186
+ import asyncio
187
+
188
+ async def main():
189
+ async with asyncio.TaskGroup() as tg:
190
+ task_a = tg.create_task(fetch_data("A"))
191
+ task_b = tg.create_task(fetch_data("B"))
192
+ # Both tasks complete or any exception is raised
193
+ results = [task_a.result(), task_b.result()]
194
+ ```
195
+
196
+ ### Testing with pytest
197
+ ```python
198
+ import pytest
199
+ import pytest_asyncio
200
+ from httpx import AsyncClient, ASGITransport
201
+
202
+ @pytest_asyncio.fixture
203
+ async def client():
204
+ async with AsyncClient(
205
+ transport=ASGITransport(app=app), base_url="http://test"
206
+ ) as ac:
207
+ yield ac
208
+
209
+ @pytest.mark.asyncio
210
+ async def test_get_user(client: AsyncClient):
211
+ response = await client.get("/users/123")
212
+ assert response.status_code == 200
213
+ assert response.json()["id"] == "123"
214
+ ```
215
+
216
+ ---
217
+
218
+ <a name="bahasa-indonesia"></a>
219
+ ## Bahasa Indonesia
220
+
221
+ ### Deskripsi
222
+ Panduan pengembangan Python tingkat ahli untuk **Python 3.13+** dengan JIT compiler, mencakup keamanan tipe, pola async, framework web modern (FastAPI 0.115+, Django 5.x), Pydantic v2, manajer paket `uv`, Ruff, dan pengujian produksi dengan pytest.
223
+
224
+ ### Kondisi Pemicu
225
+ - Menulis aplikasi atau layanan Python 3.12+/3.13+.
226
+ - Membangun REST API FastAPI 0.115+ atau aplikasi web Django 5.x.
227
+ - Mengelola proyek Python dengan manajer paket `uv`.
228
+ - Mengimplementasikan pola async/await dengan `asyncio.TaskGroup`.
229
+ - Menulis Python type-safe dengan Pydantic v2 dan generik modern (PEP 695).
230
+ - Menyiapkan Ruff untuk linting + formatting, pytest untuk pengujian.
231
+
232
+ ### Python 3.13 — Peningkatan Utama
233
+
234
+ #### JIT Compiler
235
+ Python 3.13 hadir dengan **JIT compiler eksperimental** berbasis copy-and-patch. Aktifkan dengan `--enable-experimental-jit` atau variabel lingkungan `PYTHON_JIT=1`. Perkiraan peningkatan kecepatan 10-20% untuk kode CPU-bound.
236
+
237
+ #### Free-Threaded Mode (Tanpa GIL)
238
+ Python 3.13 memperkenalkan **build free-threaded eksperimental** (tanpa GIL), memungkinkan paralelisme CPU sejati dengan thread.
239
+
240
+ ### Toolchain Modern (2026)
241
+
242
+ #### uv — Manajer Paket Standar 2026
243
+ Gantikan `pip`, `pip-tools`, `virtualenv`, `pyenv`, dan `poetry` dengan **uv** — jauh lebih cepat dan terintegrasi dalam satu alat. Gunakan `uv init`, `uv add`, `uv run`, dan `uv sync` untuk semua operasi proyek.
244
+
245
+ #### Ruff — Linting + Formatting Dalam Satu Alat
246
+ Ruff menggantikan Flake8, isort, Black, dan pyupgrade sekaligus — jauh lebih cepat karena ditulis dalam Rust.
247
+
248
+ ### Keamanan Tipe — Pola Modern
249
+
250
+ #### PEP 695 — Sintaksis Generic Baru
251
+ Python 3.12+ memperkenalkan sintaksis generic yang lebih bersih tanpa boilerplate `TypeVar`. Gunakan pernyataan `type` untuk alias tipe.
252
+
253
+ #### Pydantic v2
254
+ Gunakan `BaseModel`, `Field`, dan `@field_validator` untuk validasi data yang ketat. `model_dump()` dan `model_validate()` menggantikan metode lama.
255
+
256
+ ### FastAPI 0.115+ Best Practices
257
+
258
+ #### Lifespan (Gantikan @app.on_event)
259
+ Gunakan `@asynccontextmanager` dengan parameter `lifespan` di `FastAPI()` untuk startup/shutdown yang bersih.
260
+
261
+ #### Dependency Injection
262
+ Gunakan `Depends()` untuk injeksi sesi database, autentikasi, dan dependensi lainnya ke route handler.
263
+
264
+ #### Error Terstruktur
265
+ Buat kelas `Exception` kustom dan daftarkan `exception_handler` global untuk respons error yang konsisten.
266
+
267
+ ### Pola Async — asyncio.TaskGroup
268
+ Gunakan `asyncio.TaskGroup` (Python 3.11+) sebagai pengganti `asyncio.gather()` yang lebih aman — secara otomatis membatalkan semua task lain jika salah satu gagal.
269
+
270
+ ### Pengujian dengan pytest
271
+ Gunakan `pytest-asyncio` dan `AsyncClient` dari `httpx` untuk pengujian endpoint async FastAPI yang bersih dan terisolasi.
@@ -0,0 +1,45 @@
1
+ ---
2
+ name: realtime-collaboration-expert
3
+ description: "Expert guide for building real-time collaboration features using WebSockets, WebRTC, CRDTs (Yjs, Automerge), and Liveblocks / Panduan ahli untuk fitur kolaborasi real-time."
4
+ author: "Antigravity"
5
+ ---
6
+
7
+ # Real-Time Collaboration Expert / Ahli Kolaborasi Real-Time
8
+
9
+ [English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
10
+
11
+ ---
12
+
13
+ <a name="english"></a>
14
+ ## English
15
+
16
+ ### Description
17
+ Expert guide for implementing multiplayer, real-time collaboration features in web applications. Covers Conflict-free Replicated Data Types (CRDTs) like Yjs/Automerge, WebSockets, WebRTC, and Managed services like Liveblocks or Pusher.
18
+
19
+ ### Instructions
20
+ - **CRDTs for State**: Use CRDTs (e.g., `yjs` or `automerge`) instead of Operational Transformation (OT) for handling distributed state and concurrent document editing smoothly.
21
+ - **Connection Resiliency**: Always implement automatic reconnection logic with exponential backoff for WebSockets. Handle offline states gracefully by syncing local changes once reconnected.
22
+ - **Presence & Awareness**: Implement presence indicators (who is online, cursor positions) separated from the core document state to reduce bandwidth and storage overhead.
23
+ - **Security in Real-time**: Authenticate and authorize every WebSocket connection upon establishment and validate all incoming socket messages to prevent malicious payloads.
24
+ - **Scale**: Be mindful of message broadcasting limits. Use Redis Pub/Sub or similar message brokers when scaling WebSocket servers across multiple instances.
25
+
26
+ ### Trigger Conditions
27
+ Active whenever the user is building multiplayer features, live cursors, document co-editing, real-time chats, or working with WebSockets, Yjs, or WebRTC.
28
+
29
+ ---
30
+
31
+ <a name="bahasa-indonesia"></a>
32
+ ## Bahasa Indonesia
33
+
34
+ ### Deskripsi
35
+ Panduan ahli untuk mengimplementasikan fitur kolaborasi real-time dan *multiplayer* pada aplikasi web. Mencakup Conflict-free Replicated Data Types (CRDTs) seperti Yjs/Automerge, WebSockets, WebRTC, dan layanan terkelola seperti Liveblocks atau Pusher.
36
+
37
+ ### Instruksi
38
+ - **CRDT untuk State**: Gunakan CRDT (misalnya `yjs` atau `automerge`) daripada Operational Transformation (OT) untuk menangani *state* terdistribusi dan pengeditan dokumen secara bersamaan dengan lancar.
39
+ - **Ketahanan Koneksi**: Selalu terapkan logika penyambungan ulang otomatis dengan *exponential backoff* untuk WebSockets. Tangani *offline state* dengan baik dengan menyinkronkan perubahan lokal setelah tersambung kembali.
40
+ - **Presence & Awareness**: Terapkan indikator kehadiran (siapa yang sedang online, posisi kursor) yang dipisahkan dari status dokumen inti untuk mengurangi *overhead* bandwidth dan penyimpanan.
41
+ - **Keamanan Real-time**: Lakukan autentikasi dan otorisasi setiap koneksi WebSocket pada saat tersambung dan validasi semua pesan *socket* yang masuk untuk mencegah *payload* berbahaya.
42
+ - **Skalabilitas**: Perhatikan batas penyiaran (broadcasting) pesan. Gunakan Redis Pub/Sub atau *message broker* serupa saat meningkatkan (scaling) server WebSocket di beberapa instans.
43
+
44
+ ### Kondisi Pemicu
45
+ Aktif setiap kali pengguna sedang membangun fitur *multiplayer*, kursor langsung (live cursors), pengeditan dokumen bersama, obrolan real-time, atau bekerja dengan WebSockets, Yjs, atau WebRTC.
@@ -0,0 +1,235 @@
1
+ ---
2
+ name: rust-programming-expert
3
+ description: "Expert-level skill for Rust programming (Rust 2024 / v1.85+). Covers memory safety, async, Axum/SQLx, CLI, and optimization in English and Indonesian."
4
+ author: "Roedy Rustam"
5
+ ---
6
+
7
+ # Rust Programming Expert (2024 Edition / v1.88+)
8
+
9
+ [English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
10
+
11
+ ---
12
+
13
+ <a name="english"></a>
14
+ ## English
15
+
16
+ ### Description
17
+ Expert-level Rust development for building memory-safe, high-performance systems, APIs, CLI tools, and WebAssembly. Covers the **Rust 2024 edition**, async/await with Tokio, Axum 0.8 web framework, SQLx for async database access, and modern Rust idioms.
18
+
19
+ ### Trigger Conditions
20
+ - Writing systems-level code requiring memory safety and zero-cost abstractions.
21
+ - Building high-performance HTTP APIs with **Axum 0.8**.
22
+ - Implementing async services with **Tokio** runtime.
23
+ - Interacting with databases using **SQLx** or **SeaORM**.
24
+ - Building CLI tools with **Clap v4**.
25
+ - Compiling to **WebAssembly (WASM)** for browser or edge deployment.
26
+ - Writing Rust for **Tauri v2** desktop application backends.
27
+
28
+ ### Rust 2024 Edition Highlights
29
+ The Rust 2024 edition (stabilized in 1.85) introduces:
30
+ - **`gen` blocks**: Generators for lazy sequence production.
31
+ - **Lifetime capture rules**: More precise lifetime inference in `impl Trait`.
32
+ - **Unsafe extern blocks**: Clearer unsafe boundary declarations.
33
+ - **`if let` chains**: `if let Some(x) = opt && x > 0` now works cleanly.
34
+ - **`async fn` in traits**: Now stable — no more `async-trait` macro needed.
35
+
36
+ ### Async `fn` in Traits (Stable in Rust 2024)
37
+ ```rust
38
+ // No longer need #[async_trait] macro!
39
+ trait DataStore {
40
+ async fn get(&self, id: &str) -> Result<Data, Error>;
41
+ async fn set(&self, id: &str, data: Data) -> Result<(), Error>;
42
+ }
43
+
44
+ impl DataStore for PostgresStore {
45
+ async fn get(&self, id: &str) -> Result<Data, Error> {
46
+ sqlx::query_as("SELECT * FROM data WHERE id = $1")
47
+ .bind(id)
48
+ .fetch_one(&self.pool)
49
+ .await
50
+ .map_err(Into::into)
51
+ }
52
+ async fn set(&self, id: &str, data: Data) -> Result<(), Error> {
53
+ sqlx::query("INSERT INTO data (id, value) VALUES ($1, $2) ON CONFLICT (id) DO UPDATE SET value = $2")
54
+ .bind(id)
55
+ .bind(&data.value)
56
+ .execute(&self.pool)
57
+ .await?;
58
+ Ok(())
59
+ }
60
+ }
61
+ ```
62
+
63
+ ### Axum 0.8 — HTTP API Framework
64
+ ```rust
65
+ use axum::{
66
+ extract::{Path, State},
67
+ response::Json,
68
+ routing::{get, post},
69
+ Router,
70
+ };
71
+ use sqlx::PgPool;
72
+ use serde::{Deserialize, Serialize};
73
+
74
+ #[derive(Clone)]
75
+ struct AppState {
76
+ db: PgPool,
77
+ }
78
+
79
+ #[derive(Serialize, Deserialize)]
80
+ struct User {
81
+ id: String,
82
+ name: String,
83
+ email: String,
84
+ }
85
+
86
+ async fn get_user(
87
+ Path(user_id): Path<String>,
88
+ State(state): State<AppState>,
89
+ ) -> Result<Json<User>, StatusCode> {
90
+ let user = sqlx::query_as!(User, "SELECT * FROM users WHERE id = $1", user_id)
91
+ .fetch_optional(&state.db)
92
+ .await
93
+ .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?
94
+ .ok_or(StatusCode::NOT_FOUND)?;
95
+
96
+ Ok(Json(user))
97
+ }
98
+
99
+ #[tokio::main]
100
+ async fn main() {
101
+ let db = PgPool::connect(&std::env::var("DATABASE_URL").unwrap())
102
+ .await
103
+ .expect("Failed to connect to database");
104
+
105
+ let state = AppState { db };
106
+
107
+ let app = Router::new()
108
+ .route("/users/:id", get(get_user))
109
+ .route("/users", post(create_user))
110
+ .with_state(state);
111
+
112
+ let listener = tokio::net::TcpListener::bind("0.0.0.0:8080").await.unwrap();
113
+ println!("Listening on :8080");
114
+ axum::serve(listener, app).await.unwrap();
115
+ }
116
+ ```
117
+
118
+ ### SQLx — Compile-Time Verified SQL
119
+ ```rust
120
+ // Compile-time SQL checking (requires DATABASE_URL at build time)
121
+ let users = sqlx::query_as!(
122
+ User,
123
+ r#"SELECT id, name, email FROM users WHERE created_at > $1 ORDER BY created_at DESC LIMIT $2"#,
124
+ since,
125
+ limit as i64
126
+ )
127
+ .fetch_all(&pool)
128
+ .await?;
129
+ ```
130
+
131
+ ### Error Handling — thiserror + anyhow
132
+ ```rust
133
+ use thiserror::Error;
134
+
135
+ // Library errors: use thiserror for typed errors
136
+ #[derive(Debug, Error)]
137
+ pub enum AppError {
138
+ #[error("User not found: {id}")]
139
+ UserNotFound { id: String },
140
+ #[error("Database error: {0}")]
141
+ Database(#[from] sqlx::Error),
142
+ #[error("Validation failed: {message}")]
143
+ Validation { message: String },
144
+ }
145
+
146
+ // Application code: use anyhow for ergonomic error propagation
147
+ use anyhow::{Context, Result};
148
+
149
+ fn process() -> Result<()> {
150
+ let config = load_config().context("Failed to load configuration")?;
151
+ let db = connect_db(&config).context("Failed to connect to database")?;
152
+ Ok(())
153
+ }
154
+ ```
155
+
156
+ ### CLI Tools with Clap v4
157
+ ```rust
158
+ use clap::{Parser, Subcommand};
159
+
160
+ #[derive(Parser)]
161
+ #[command(name = "myapp", version, about = "My CLI tool")]
162
+ struct Cli {
163
+ #[command(subcommand)]
164
+ command: Commands,
165
+ }
166
+
167
+ #[derive(Subcommand)]
168
+ enum Commands {
169
+ /// Start the server
170
+ Serve {
171
+ #[arg(short, long, default_value = "8080")]
172
+ port: u16,
173
+ },
174
+ /// Run migrations
175
+ Migrate,
176
+ }
177
+
178
+ #[tokio::main]
179
+ async fn main() -> anyhow::Result<()> {
180
+ let cli = Cli::parse();
181
+ match cli.command {
182
+ Commands::Serve { port } => serve(port).await,
183
+ Commands::Migrate => run_migrations().await,
184
+ }
185
+ }
186
+ ```
187
+
188
+ ### Performance Best Practices
189
+ - **Zero-cost abstractions**: Use iterators (`map`, `filter`, `collect`) — compiled to the same code as hand-written loops.
190
+ - **Avoid unnecessary cloning**: Use references (`&T`) and lifetimes where possible.
191
+ - **`Arc<T>` for shared state**: Use `Arc<Mutex<T>>` or `Arc<RwLock<T>>` for shared mutable state across threads.
192
+ - **SIMD**: Use `std::simd` (stable in 1.88) for data-parallel operations.
193
+ - **Profile before optimizing**: Use `cargo flamegraph` or `perf` to find actual bottlenecks.
194
+
195
+ ---
196
+
197
+ <a name="bahasa-indonesia"></a>
198
+ ## Bahasa Indonesia
199
+
200
+ ### Deskripsi
201
+ Pengembangan Rust tingkat ahli untuk membangun sistem, API, CLI tool, dan WebAssembly yang aman di memori dan berkinerja tinggi. Mencakup **edisi Rust 2024**, async/await dengan Tokio, framework web Axum 0.8, SQLx untuk akses database async, dan idiom Rust modern.
202
+
203
+ ### Kondisi Pemicu
204
+ - Menulis kode sistem yang membutuhkan keamanan memori dan zero-cost abstraction.
205
+ - Membangun HTTP API berkinerja tinggi dengan **Axum 0.8**.
206
+ - Mengimplementasikan layanan async dengan runtime **Tokio**.
207
+ - Berinteraksi dengan database menggunakan **SQLx** atau SeaORM.
208
+ - Membangun CLI tool dengan **Clap v4**.
209
+ - Mengkompilasi ke **WebAssembly (WASM)** untuk browser atau edge.
210
+ - Menulis backend Rust untuk aplikasi desktop **Tauri v2**.
211
+
212
+ ### Sorotan Edisi Rust 2024
213
+ - **`async fn` dalam trait**: Kini stabil — tidak perlu lagi macro `#[async_trait]`.
214
+ - **`if let` chains**: `if let Some(x) = opt && x > 0` kini berfungsi secara bersih.
215
+ - **`gen` blocks**: Generator untuk produksi urutan yang malas.
216
+ - **Aturan lifetime capture**: Inferensi lifetime yang lebih presisi di `impl Trait`.
217
+
218
+ ### Axum 0.8 — Framework HTTP API
219
+ Gunakan Axum untuk HTTP API yang idiomatis dan berkinerja tinggi dibangun di atas Tokio. Manfaatkan extractor (`Path`, `State`, `Json`, `Query`) untuk parameter handler yang type-safe.
220
+
221
+ ### SQLx — SQL Terverifikasi Waktu Kompilasi
222
+ SQLx memverifikasi query SQL Anda terhadap database nyata saat kompilasi — menghilangkan seluruh kelas bug runtime.
223
+
224
+ ### Penanganan Error — thiserror + anyhow
225
+ - Gunakan `thiserror` untuk error bertipe di library code.
226
+ - Gunakan `anyhow` untuk propagasi error yang ergonomis di application code.
227
+
228
+ ### CLI Tool dengan Clap v4
229
+ Clap v4 menggunakan derive macro untuk mendefinisikan antarmuka CLI secara deklaratif — perintah, subperintah, argumen, dan flag dengan parsing bawaan.
230
+
231
+ ### Praktik Terbaik Performa
232
+ - Gunakan iterator (`map`, `filter`, `collect`) — dikompilasi setara dengan loop manual.
233
+ - Hindari cloning yang tidak perlu — gunakan referensi dan lifetime.
234
+ - Gunakan `Arc<Mutex<T>>` untuk state bersama yang dapat dimutasi di antara thread.
235
+ - Profiling terlebih dahulu dengan `cargo flamegraph` sebelum mengoptimalkan.