vibes-plug 1.0.0 → 2.5.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 (123) hide show
  1. package/.github/workflows/publish.yml +20 -0
  2. package/AGENTS.md +66 -0
  3. package/BLUEPRINT.md +152 -60
  4. package/CHANGELOG.md +50 -0
  5. package/README.md +346 -194
  6. package/package.json +25 -25
  7. package/plugin.json +1 -1
  8. package/skills/ai-cost-token-optimizer/SKILL.md +52 -0
  9. package/skills/ai-llm-integration-expert/SKILL.md +180 -162
  10. package/skills/api-design-expert/SKILL.md +314 -310
  11. package/skills/app-analyzer-optimizer/SKILL.md +193 -189
  12. package/skills/apple-ecosystem-expert/SKILL.md +142 -0
  13. package/skills/async-queue-temporal-expert/SKILL.md +54 -0
  14. package/skills/authentication-identity-expert/SKILL.md +251 -20
  15. package/skills/auto-doc-updater/SKILL.md +214 -204
  16. package/skills/autonomous-chaos-monkey/SKILL.md +63 -0
  17. package/skills/autonomous-red-teamer/SKILL.md +59 -0
  18. package/skills/autonomous-swarm-director/SKILL.md +69 -0
  19. package/skills/autonomous-tdd-debugger/SKILL.md +65 -0
  20. package/skills/bootstrap-to-modern/SKILL.md +90 -86
  21. package/skills/brainstorming/SKILL.md +373 -353
  22. package/skills/browser-automation-expert/SKILL.md +46 -0
  23. package/skills/ci-cd-devops-architect/SKILL.md +72 -45
  24. package/skills/cloud-hosting-expert/SKILL.md +244 -244
  25. package/skills/coderabbit/SKILL.md +192 -192
  26. package/skills/cron-scheduler-expert/SKILL.md +298 -0
  27. package/skills/data-telemetry-expert/SKILL.md +213 -213
  28. package/skills/database-orm-expert/SKILL.md +294 -294
  29. package/skills/dependency-upgrade-migrator/SKILL.md +295 -0
  30. package/skills/design-system-architect/SKILL.md +27 -10
  31. package/skills/doku-mcp-server/SKILL.md +251 -0
  32. package/skills/doku-payment-gateway/SKILL.md +227 -0
  33. package/skills/e2e-testing-expert/SKILL.md +315 -315
  34. package/skills/edge-serverless-db-expert/SKILL.md +43 -0
  35. package/skills/email-notification-expert/SKILL.md +362 -0
  36. package/skills/error-resilience-expert/SKILL.md +480 -0
  37. package/skills/event-driven-architect/SKILL.md +81 -81
  38. package/skills/feature-flag-analytics-expert/SKILL.md +46 -0
  39. package/skills/file-upload-media-expert/SKILL.md +431 -0
  40. package/skills/form-validation-expert/SKILL.md +401 -0
  41. package/skills/fullstack-expert/SKILL.md +202 -202
  42. package/skills/fullstack-expert/references/api_design_guide.md +466 -466
  43. package/skills/fullstack-expert/references/multi_language_backend.md +528 -528
  44. package/skills/fullstack-expert/scripts/api_contract_validator.py +253 -253
  45. package/skills/fullstack-expert/scripts/architecture_analyzer.py +326 -326
  46. package/skills/gemini-agent-booster/SKILL.md +135 -135
  47. package/skills/global-a11y-i18n-expert/SKILL.md +81 -81
  48. package/skills/glsl-shader-expert/SKILL.md +101 -0
  49. package/skills/go-programming-expert/SKILL.md +295 -295
  50. package/skills/graphql-apollo-expert/SKILL.md +108 -0
  51. package/skills/hig/SKILL.md +188 -188
  52. package/skills/hyper-context-synthesizer/SKILL.md +55 -0
  53. package/skills/js-backend-expert/SKILL.md +34 -9
  54. package/skills/legacy-code-translator/SKILL.md +65 -0
  55. package/skills/llm-cost-arbitrage-router/SKILL.md +59 -0
  56. package/skills/logging-error-tracking-expert/SKILL.md +338 -0
  57. package/skills/mcp-client-orchestrator/SKILL.md +70 -0
  58. package/skills/mcp-server-architect/SKILL.md +194 -194
  59. package/skills/micro-frontend-architect/SKILL.md +106 -0
  60. package/skills/mobile-expo-expert/SKILL.md +186 -186
  61. package/skills/mobile-push-notification-expert/SKILL.md +51 -0
  62. package/skills/monday-design-aesthetic/SKILL.md +67 -67
  63. package/skills/monorepo-architect/SKILL.md +227 -227
  64. package/skills/mpa-orchestrator/SKILL.md +101 -101
  65. package/skills/multi-agent-orchestration/SKILL.md +234 -234
  66. package/skills/multiple-entry-points/SKILL.md +55 -55
  67. package/skills/mvc-expert/SKILL.md +231 -231
  68. package/skills/payment-gateway-expert/SKILL.md +45 -45
  69. package/skills/performance-web-vitals/SKILL.md +332 -332
  70. package/skills/post-quantum-crypto-migrator/SKILL.md +57 -0
  71. package/skills/prd-architect/SKILL.md +201 -191
  72. package/skills/proactive-background-watcher/SKILL.md +62 -0
  73. package/skills/production-ready-hardener/PRODUCTION_READINESS_REPORT.md +67 -0
  74. package/skills/production-ready-hardener/SKILL.md +173 -186
  75. package/skills/production-ready-hardener/references/production_checklist.md +161 -161
  76. package/skills/production-ready-hardener/scripts/production_readiness_scanner.py +881 -875
  77. package/skills/project-context-mapper/SKILL.md +79 -0
  78. package/skills/python-programming-expert/SKILL.md +263 -132
  79. package/skills/rate-limit-abuse-prevention/SKILL.md +371 -0
  80. package/skills/realtime-collaboration-expert/SKILL.md +45 -45
  81. package/skills/rust-programming-expert/SKILL.md +235 -235
  82. package/skills/saas-billing/SKILL.md +377 -377
  83. package/skills/saas-multi-tenant/SKILL.md +251 -237
  84. package/skills/saas-mvp-launcher/SKILL.md +10 -0
  85. package/skills/saas-transformer/SKILL.md +187 -144
  86. package/skills/saas-transformer/references/billing_integration_guide.md +401 -401
  87. package/skills/saas-transformer/references/feature_gating_patterns.md +137 -137
  88. package/skills/saas-transformer/references/saas_transformation_checklist.md +121 -121
  89. package/skills/saas-transformer/scripts/saas_transformation_scanner.py +39 -29
  90. package/skills/scalability-clean-code/SKILL.md +229 -229
  91. package/skills/self-evolving-memory-graph/SKILL.md +75 -0
  92. package/skills/self-healing-cloud-orchestrator/SKILL.md +57 -0
  93. package/skills/senior-frontend/SKILL.md +161 -161
  94. package/skills/senior-fullstack/SKILL.md +167 -167
  95. package/skills/seo/SKILL.md +235 -225
  96. package/skills/seo-geo/SKILL.md +188 -188
  97. package/skills/session-context-loader/SKILL.md +77 -0
  98. package/skills/session-handoff-resume/SKILL.md +158 -158
  99. package/skills/skill_baru/SKILL.md +172 -147
  100. package/skills/spa-orchestrator/SKILL.md +288 -288
  101. package/skills/state-management-expert/SKILL.md +272 -272
  102. package/skills/supabase-security-expert/SKILL.md +243 -243
  103. package/skills/tailwind-expert/SKILL.md +188 -188
  104. package/skills/tanstack-query-expert/SKILL.md +199 -199
  105. package/skills/token-saver/SKILL.md +119 -111
  106. package/skills/typescript-expert/SKILL.md +324 -279
  107. package/skills/ui-components-expert/SKILL.md +263 -46
  108. package/skills/ui-ux-pro-max/SKILL.md +202 -201
  109. package/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-310.pyc +0 -0
  110. package/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-310.pyc +0 -0
  111. package/skills/ui_ux_expert/SKILL.md +17 -6
  112. package/skills/vector-db-rag-expert/SKILL.md +52 -0
  113. package/skills/vibe-code-gardener/SKILL.md +181 -173
  114. package/skills/visual-qa-vision-agent/SKILL.md +65 -0
  115. package/skills/vue-frontend-expert/SKILL.md +126 -0
  116. package/skills/web-3d-graphics-expert/SKILL.md +131 -0
  117. package/skills/web-game-engine-expert/SKILL.md +96 -0
  118. package/skills/web-scraper/SKILL.md +207 -205
  119. package/skills/website-design-cloner/SKILL.md +174 -0
  120. package/skills/webxr-ar-vr-expert/SKILL.md +117 -0
  121. package/skills/zero-to-prod-orchestrator/SKILL.md +206 -180
  122. package/skills/zero-trust-secret-vault/SKILL.md +40 -0
  123. package/vibes-swarm-demo.gif +0 -0
@@ -1,235 +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.
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.