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,231 +1,231 @@
1
- ---
2
- name: mvc-expert
3
- description: "Expert guidelines to refactor legacy PHP codebases into clean, modern, and scalable MVC-structured projects / Pedoman ahli untuk merefaktor codebase PHP lama menjadi proyek terstruktur MVC yang bersih, modern, dan skalabel."
4
- author: "Antigravity"
5
- ---
6
-
7
- # PHP MVC Expert & Modernization
8
-
9
- [English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
10
-
11
- ---
12
-
13
- <a name="english"></a>
14
- ## English
15
-
16
- ### Description
17
- This skill provides the agent with structured protocols, coding patterns, and architectural guidelines to audit, refactor, and modernize legacy/obsolete PHP codebases (plain spaghetti PHP) into a clean, modern, secure, and scalable Model-View-Controller (MVC) structure adhering to PSR standards and modern PHP (v8.2+) capabilities.
18
-
19
- ### Instructions
20
-
21
- #### 1. Audit Protocol for Legacy PHP
22
- Before writing new structures, run a detailed audit on the legacy files to map out:
23
- - **Routing & Entry Points**: Identify raw `.php` files acting as endpoints (e.g., `about.php`, `contact.php`, `process.php`).
24
- - **Data Access & SQL**: Find inline SQL queries, string-concatenated queries (SQL Injection risks), and direct `mysqli` or `mysql_*` usages.
25
- - **Session & Global State**: Identify direct session mutations (`$_SESSION`), raw cookies, and unchecked global variables (`$_GET`, `$_POST`, `$_REQUEST`).
26
- - **Spaghetti Mixing**: Locate files where database connection, business logic, session validation, and HTML rendering are in a single script.
27
- - **Hardcoded Secrets**: Identify database credentials, API keys, and configurations defined inside individual files.
28
-
29
- #### 2. Modernization Strategy & Composer Setup
30
- Apply a standard project directory structure and initialize dependency management:
31
- - **PSR-4 Autoloading**: Create a `composer.json` file and define namespace mappings:
32
- ```json
33
- {
34
- "autoload": {
35
- "psr-4": {
36
- "App\\": "src/"
37
- }
38
- }
39
- }
40
- ```
41
- - **Standard Directory Structure**:
42
- - `public/`: Single entry point containing `index.php` (Front Controller), assets (CSS, JS), and uploaded files.
43
- - `src/`: Root namespace for MVC structure (`src/Models/`, `src/Controllers/`, `src/Views/`, `src/Core/`).
44
- - `config/`: Database configurations, router configurations, and app configurations.
45
- - `.env` & `.env.example`: Store environment configurations.
46
-
47
- #### 3. Implementing MVC Architecture
48
- Refactor the spaghetti code into distinct MVC layers:
49
- - **Front Controller (Unified Routing)**:
50
- Use a clean routing engine (like AltoRouter or a lightweight custom router) in `public/index.php`. Map all requests through a single file using `.htaccess` or server redirects:
51
- ```php
52
- // public/index.php
53
- require_once __DIR__ . '/../vendor/autoload.php';
54
-
55
- $router = new App\Core\Router();
56
- $router->add('GET', '/', 'HomeController@index');
57
- $router->add('GET', '/users', 'UserController@index');
58
- $router->dispatch($_SERVER['REQUEST_URI'], $_SERVER['REQUEST_METHOD']);
59
- ```
60
- - **Models**:
61
- Isolate all database access inside Model classes. Implement prepared statements using PDO:
62
- ```php
63
- namespace App\Models;
64
- use App\Core\Database;
65
- use PDO;
66
-
67
- class User {
68
- private PDO $db;
69
- public function __construct() {
70
- $this->db = Database::getInstance()->getConnection();
71
- }
72
- public function getAll(): array {
73
- $stmt = $this->db->prepare("SELECT id, name, email FROM users ORDER BY name ASC");
74
- $stmt->execute();
75
- return $stmt->fetchAll(PDO::FETCH_ASSOC);
76
- }
77
- }
78
- ```
79
- - **Controllers**:
80
- Extract requests and input parameters, invoke models, and return/render views:
81
- ```php
82
- namespace App\Controllers;
83
- use App\Models\User;
84
-
85
- class UserController {
86
- public function index(): void {
87
- $model = new User();
88
- $users = $model->getAll();
89
- render_view('users/index', ['users' => $users]);
90
- }
91
- }
92
- ```
93
- - **Views**:
94
- Never echo HTML directly in controllers. Implement clean PHP template rendering or integrate a lightweight template engine like Twig. Ensure all HTML output is properly escaped.
95
-
96
- #### 4. Security Enhancements
97
- Integrate the following standard security gates during refactoring:
98
- - **SQL Injection Prevention**: Enforce prepared statements with parameters for every SQL query.
99
- - **XSS Prevention**: Build or use a global escape helper (e.g., `htmlspecialchars($str, ENT_QUOTES, 'UTF-8')`) for all dynamic view output.
100
- - **CSRF Protection**: Generate and validate CSRF tokens for all state-changing requests (`POST`, `PUT`, `DELETE`).
101
- - **Secrets Management**: Load configuration via `.env` files using `vlucas/phpdotenv`.
102
-
103
- #### 5. Leveraging Modern PHP (v8.2+)
104
- Refactor old PHP logic to use modern constructs:
105
- - **Constructor Property Promotion** and **Typed Properties**.
106
- - **Readonly Classes** for immutable service/data classes.
107
- - **Strict Types Declaration**: Add `declare(strict_types=1);` to all class files.
108
-
109
- #### 6. Multi-Page Application (MPA) Approach in a Single Repository
110
- When organizing a project as a Multi-Page Application within a single repository, adhere to the following guidelines:
111
- - **Centralized Routing**: Use the Front Controller (`public/index.php`) to handle all page requests. Route each request to its respective controller and view, ensuring each page load is fully processed on the server side.
112
- - **Shared Layouts & Partials**: Avoid duplicating HTML (headers, footers, navigation). Create a `src/Views/layouts/` directory for base templates and a `src/Views/partials/` directory for reusable UI components. Controllers should inject page-specific content into the base layout.
113
- - **Asset Management**: Store all static assets (CSS, JS, images) in the `public/` directory. Use cache-busting techniques (e.g., appending file modification time `?v=123`) when linking assets in the views.
114
- - **State Management**: Use server-side sessions securely for user authentication, flash messages, and tracking state across full page reloads.
115
-
116
- ### Trigger Conditions
117
- Active whenever the user requests to:
118
- - Modernize a legacy PHP project or spaghetti PHP script.
119
- - Design an MVC architecture or introduce a clean routing pattern in plain PHP.
120
- - Implement object-oriented programming (OOP), Composer namespaces (PSR-4), or clean up database access via PDO in a PHP application.
121
-
122
- ---
123
-
124
- <a name="bahasa-indonesia"></a>
125
- ## Bahasa Indonesia
126
-
127
- ### Deskripsi
128
- Skill ini memberikan protokol terstruktur, pola penulisan kode, dan panduan arsitektur bagi agen untuk melakukan audit, refaktorisasi, dan modernisasi terhadap codebase PHP lama yang usang (Plain Spaghetti PHP) menjadi struktur Model-View-Controller (MVC) yang bersih, modern, aman, dan skalabel yang mematuhi standar PSR serta kemampuan PHP modern (v8.2+).
129
-
130
- ### Instruksi
131
-
132
- #### 1. Protokol Audit Kode PHP Lama
133
- Sebelum membuat struktur baru, jalankan langkah audit terperinci pada file-file proyek lama untuk memetakan:
134
- - **Titik Entri & Routing**: Identifikasi file-file `.php` mentah yang bertindak langsung sebagai endpoint (misal `about.php`, `contact.php`, `process.php`).
135
- - **Akses Data & SQL**: Cari query SQL inline, penggabungan query menggunakan string concatenation (berisiko SQL Injection), dan penggunaan langsung `mysqli` atau `mysql_*`.
136
- - **Session & State Global**: Identifikasi mutasi langsung session (`$_SESSION`), cookie mentah, dan variabel global yang tidak divalidasi (`$_GET`, `$_POST`, `$_REQUEST`).
137
- - **Pencampuran Logika (Spaghetti)**: Temukan file di mana koneksi database, logika bisnis, validasi session, dan render HTML berada dalam satu berkas tunggal.
138
- - **Secret Hardcoded**: Identifikasi kredensial database, API key, dan konfigurasi lainnya yang didefinisikan di dalam file.
139
-
140
- #### 2. Strategi Modernisasi & Konfigurasi Composer
141
- Terapkan struktur direktori proyek standar dan inisialisasi manajemen dependensi:
142
- - **PSR-4 Autoloading**: Buat file `composer.json` dan definisikan pemetaan namespace:
143
- ```json
144
- {
145
- "autoload": {
146
- "psr-4": {
147
- "App\\": "src/"
148
- }
149
- }
150
- }
151
- ```
152
- - **Struktur Direktori Standar**:
153
- - `public/`: Titik entri tunggal yang berisi `index.php` (Front Controller), aset (CSS, JS), serta file upload.
154
- - `src/`: Namespace root untuk struktur MVC (`src/Models/`, `src/Controllers/`, `src/Views/`, `src/Core/`).
155
- - `config/`: Konfigurasi database, konfigurasi router, dan konfigurasi aplikasi.
156
- - `.env` & `.env.example`: Menyimpan konfigurasi environment.
157
-
158
- #### 3. Menerapkan Arsitektur MVC
159
- Refaktorkan kode spageti ke dalam lapisan MVC yang terpisah:
160
- - **Front Controller (Routing Terpusat)**:
161
- Gunakan library routing yang bersih (seperti AltoRouter atau router kustom ringan) di `public/index.php`. Arahkan semua request melalui satu file menggunakan `.htaccess` atau pengalihan server:
162
- ```php
163
- // public/index.php
164
- require_once __DIR__ . '/../vendor/autoload.php';
165
-
166
- $router = new App\Core\Router();
167
- $router->add('GET', '/', 'HomeController@index');
168
- $router->add('GET', '/users', 'UserController@index');
169
- $router->dispatch($_SERVER['REQUEST_URI'], $_SERVER['REQUEST_METHOD']);
170
- ```
171
- - **Models**:
172
- Pisahkan semua akses database di dalam kelas Model. Gunakan prepared statements dengan PDO:
173
- ```php
174
- namespace App\Models;
175
- use App\Core\Database;
176
- use PDO;
177
-
178
- class User {
179
- private PDO $db;
180
- public function __construct() {
181
- $this->db = Database::getInstance()->getConnection();
182
- }
183
- public function getAll(): array {
184
- $stmt = $this->db->prepare("SELECT id, name, email FROM users ORDER BY name ASC");
185
- $stmt->execute();
186
- return $stmt->fetchAll(PDO::FETCH_ASSOC);
187
- }
188
- }
189
- ```
190
- - **Controllers**:
191
- Ekstrak request dan parameter input, panggil model, lalu return/render view:
192
- ```php
193
- namespace App\Controllers;
194
- use App\Models\User;
195
-
196
- class UserController {
197
- public function index(): void {
198
- $model = new User();
199
- $users = $model->getAll();
200
- render_view('users/index', ['users' => $users]);
201
- }
202
- }
203
- ```
204
- - **Views**:
205
- Jangan pernah me-render atau menggunakan `echo` HTML langsung di dalam controller. Terapkan render template PHP yang bersih atau gunakan template engine ringan seperti Twig. Pastikan semua output HTML divalidasi dan lolos proses escaping.
206
-
207
- #### 4. Peningkatan Keamanan
208
- Integrasikan filter keamanan standar berikut selama refaktorisasi:
209
- - **Pencegahan SQL Injection**: Wajibkan prepared statements dengan parameter terikat untuk setiap query SQL.
210
- - **Pencegahan XSS**: Buat atau gunakan fungsi helper escape global (misal `htmlspecialchars($str, ENT_QUOTES, 'UTF-8')`) pada setiap output dinamis pada view.
211
- - **Proteksi CSRF**: Hasilkan dan validasi token CSRF untuk setiap request yang mengubah state data (`POST`, `PUT`, `DELETE`).
212
- - **Manajemen Secrets**: Muat konfigurasi via file `.env` menggunakan library `vlucas/phpdotenv`.
213
-
214
- #### 5. Memanfaatkan PHP Modern (v8.2+)
215
- Refaktorkan logika PHP lama agar menggunakan fitur modern:
216
- - **Constructor Property Promotion** dan **Typed Properties** untuk properti kelas.
217
- - **Readonly Classes** untuk kelas layanan atau data yang bersifat immutable (tidak dapat diubah).
218
- - **Deklarasi Strict Types**: Tambahkan `declare(strict_types=1);` di bagian paling atas setiap file kelas.
219
-
220
- #### 6. Pendekatan Multi-Page Application (MPA) dalam Satu Repositori
221
- Saat mengatur proyek sebagai Multi-Page Application di dalam satu repositori, ikuti panduan berikut:
222
- - **Routing Terpusat (Centralized Routing)**: Gunakan Front Controller (`public/index.php`) untuk menangani semua permintaan halaman. Arahkan setiap permintaan ke controller dan view masing-masing, memastikan setiap pemuatan halaman diproses sepenuhnya di sisi server.
223
- - **Layout & Parsial Bersama (Shared Layouts & Partials)**: Hindari duplikasi HTML (header, footer, navigasi). Buat direktori `src/Views/layouts/` untuk template dasar dan direktori `src/Views/partials/` untuk komponen UI yang dapat digunakan kembali. Controller harus menyuntikkan konten spesifik halaman ke dalam layout dasar.
224
- - **Manajemen Aset**: Simpan semua aset statis (CSS, JS, gambar) di direktori `public/`. Gunakan teknik cache-busting (misalnya, menambahkan waktu modifikasi file `?v=123`) saat menautkan aset di dalam view.
225
- - **Manajemen State**: Gunakan session sisi server secara aman untuk autentikasi pengguna, pesan flash, dan melacak state di seluruh proses reload halaman secara penuh.
226
-
227
- ### Kondisi Pemicu
228
- Aktif setiap kali pengguna meminta untuk:
229
- - Memodernisasi proyek PHP lama atau script PHP spageti.
230
- - Merancang arsitektur MVC atau memperkenalkan pola routing yang bersih di plain PHP.
231
- - Menerapkan pemrograman berorientasi objek (OOP), namespace Composer (PSR-4), atau membersihkan akses database via PDO pada aplikasi PHP.
1
+ ---
2
+ name: mvc-expert
3
+ description: "Expert guidelines to refactor legacy PHP codebases into clean, modern, and scalable MVC-structured projects / Pedoman ahli untuk merefaktor codebase PHP lama menjadi proyek terstruktur MVC yang bersih, modern, dan skalabel."
4
+ author: "Antigravity"
5
+ ---
6
+
7
+ # PHP MVC Expert & Modernization
8
+
9
+ [English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
10
+
11
+ ---
12
+
13
+ <a name="english"></a>
14
+ ## English
15
+
16
+ ### Description
17
+ This skill provides the agent with structured protocols, coding patterns, and architectural guidelines to audit, refactor, and modernize legacy/obsolete PHP codebases (plain spaghetti PHP) into a clean, modern, secure, and scalable Model-View-Controller (MVC) structure adhering to PSR standards and modern PHP (v8.2+) capabilities.
18
+
19
+ ### Instructions
20
+
21
+ #### 1. Audit Protocol for Legacy PHP
22
+ Before writing new structures, run a detailed audit on the legacy files to map out:
23
+ - **Routing & Entry Points**: Identify raw `.php` files acting as endpoints (e.g., `about.php`, `contact.php`, `process.php`).
24
+ - **Data Access & SQL**: Find inline SQL queries, string-concatenated queries (SQL Injection risks), and direct `mysqli` or `mysql_*` usages.
25
+ - **Session & Global State**: Identify direct session mutations (`$_SESSION`), raw cookies, and unchecked global variables (`$_GET`, `$_POST`, `$_REQUEST`).
26
+ - **Spaghetti Mixing**: Locate files where database connection, business logic, session validation, and HTML rendering are in a single script.
27
+ - **Hardcoded Secrets**: Identify database credentials, API keys, and configurations defined inside individual files.
28
+
29
+ #### 2. Modernization Strategy & Composer Setup
30
+ Apply a standard project directory structure and initialize dependency management:
31
+ - **PSR-4 Autoloading**: Create a `composer.json` file and define namespace mappings:
32
+ ```json
33
+ {
34
+ "autoload": {
35
+ "psr-4": {
36
+ "App\\": "src/"
37
+ }
38
+ }
39
+ }
40
+ ```
41
+ - **Standard Directory Structure**:
42
+ - `public/`: Single entry point containing `index.php` (Front Controller), assets (CSS, JS), and uploaded files.
43
+ - `src/`: Root namespace for MVC structure (`src/Models/`, `src/Controllers/`, `src/Views/`, `src/Core/`).
44
+ - `config/`: Database configurations, router configurations, and app configurations.
45
+ - `.env` & `.env.example`: Store environment configurations.
46
+
47
+ #### 3. Implementing MVC Architecture
48
+ Refactor the spaghetti code into distinct MVC layers:
49
+ - **Front Controller (Unified Routing)**:
50
+ Use a clean routing engine (like AltoRouter or a lightweight custom router) in `public/index.php`. Map all requests through a single file using `.htaccess` or server redirects:
51
+ ```php
52
+ // public/index.php
53
+ require_once __DIR__ . '/../vendor/autoload.php';
54
+
55
+ $router = new App\Core\Router();
56
+ $router->add('GET', '/', 'HomeController@index');
57
+ $router->add('GET', '/users', 'UserController@index');
58
+ $router->dispatch($_SERVER['REQUEST_URI'], $_SERVER['REQUEST_METHOD']);
59
+ ```
60
+ - **Models**:
61
+ Isolate all database access inside Model classes. Implement prepared statements using PDO:
62
+ ```php
63
+ namespace App\Models;
64
+ use App\Core\Database;
65
+ use PDO;
66
+
67
+ class User {
68
+ private PDO $db;
69
+ public function __construct() {
70
+ $this->db = Database::getInstance()->getConnection();
71
+ }
72
+ public function getAll(): array {
73
+ $stmt = $this->db->prepare("SELECT id, name, email FROM users ORDER BY name ASC");
74
+ $stmt->execute();
75
+ return $stmt->fetchAll(PDO::FETCH_ASSOC);
76
+ }
77
+ }
78
+ ```
79
+ - **Controllers**:
80
+ Extract requests and input parameters, invoke models, and return/render views:
81
+ ```php
82
+ namespace App\Controllers;
83
+ use App\Models\User;
84
+
85
+ class UserController {
86
+ public function index(): void {
87
+ $model = new User();
88
+ $users = $model->getAll();
89
+ render_view('users/index', ['users' => $users]);
90
+ }
91
+ }
92
+ ```
93
+ - **Views**:
94
+ Never echo HTML directly in controllers. Implement clean PHP template rendering or integrate a lightweight template engine like Twig. Ensure all HTML output is properly escaped.
95
+
96
+ #### 4. Security Enhancements
97
+ Integrate the following standard security gates during refactoring:
98
+ - **SQL Injection Prevention**: Enforce prepared statements with parameters for every SQL query.
99
+ - **XSS Prevention**: Build or use a global escape helper (e.g., `htmlspecialchars($str, ENT_QUOTES, 'UTF-8')`) for all dynamic view output.
100
+ - **CSRF Protection**: Generate and validate CSRF tokens for all state-changing requests (`POST`, `PUT`, `DELETE`).
101
+ - **Secrets Management**: Load configuration via `.env` files using `vlucas/phpdotenv`.
102
+
103
+ #### 5. Leveraging Modern PHP (v8.2+)
104
+ Refactor old PHP logic to use modern constructs:
105
+ - **Constructor Property Promotion** and **Typed Properties**.
106
+ - **Readonly Classes** for immutable service/data classes.
107
+ - **Strict Types Declaration**: Add `declare(strict_types=1);` to all class files.
108
+
109
+ #### 6. Multi-Page Application (MPA) Approach in a Single Repository
110
+ When organizing a project as a Multi-Page Application within a single repository, adhere to the following guidelines:
111
+ - **Centralized Routing**: Use the Front Controller (`public/index.php`) to handle all page requests. Route each request to its respective controller and view, ensuring each page load is fully processed on the server side.
112
+ - **Shared Layouts & Partials**: Avoid duplicating HTML (headers, footers, navigation). Create a `src/Views/layouts/` directory for base templates and a `src/Views/partials/` directory for reusable UI components. Controllers should inject page-specific content into the base layout.
113
+ - **Asset Management**: Store all static assets (CSS, JS, images) in the `public/` directory. Use cache-busting techniques (e.g., appending file modification time `?v=123`) when linking assets in the views.
114
+ - **State Management**: Use server-side sessions securely for user authentication, flash messages, and tracking state across full page reloads.
115
+
116
+ ### Trigger Conditions
117
+ Active whenever the user requests to:
118
+ - Modernize a legacy PHP project or spaghetti PHP script.
119
+ - Design an MVC architecture or introduce a clean routing pattern in plain PHP.
120
+ - Implement object-oriented programming (OOP), Composer namespaces (PSR-4), or clean up database access via PDO in a PHP application.
121
+
122
+ ---
123
+
124
+ <a name="bahasa-indonesia"></a>
125
+ ## Bahasa Indonesia
126
+
127
+ ### Deskripsi
128
+ Skill ini memberikan protokol terstruktur, pola penulisan kode, dan panduan arsitektur bagi agen untuk melakukan audit, refaktorisasi, dan modernisasi terhadap codebase PHP lama yang usang (Plain Spaghetti PHP) menjadi struktur Model-View-Controller (MVC) yang bersih, modern, aman, dan skalabel yang mematuhi standar PSR serta kemampuan PHP modern (v8.2+).
129
+
130
+ ### Instruksi
131
+
132
+ #### 1. Protokol Audit Kode PHP Lama
133
+ Sebelum membuat struktur baru, jalankan langkah audit terperinci pada file-file proyek lama untuk memetakan:
134
+ - **Titik Entri & Routing**: Identifikasi file-file `.php` mentah yang bertindak langsung sebagai endpoint (misal `about.php`, `contact.php`, `process.php`).
135
+ - **Akses Data & SQL**: Cari query SQL inline, penggabungan query menggunakan string concatenation (berisiko SQL Injection), dan penggunaan langsung `mysqli` atau `mysql_*`.
136
+ - **Session & State Global**: Identifikasi mutasi langsung session (`$_SESSION`), cookie mentah, dan variabel global yang tidak divalidasi (`$_GET`, `$_POST`, `$_REQUEST`).
137
+ - **Pencampuran Logika (Spaghetti)**: Temukan file di mana koneksi database, logika bisnis, validasi session, dan render HTML berada dalam satu berkas tunggal.
138
+ - **Secret Hardcoded**: Identifikasi kredensial database, API key, dan konfigurasi lainnya yang didefinisikan di dalam file.
139
+
140
+ #### 2. Strategi Modernisasi & Konfigurasi Composer
141
+ Terapkan struktur direktori proyek standar dan inisialisasi manajemen dependensi:
142
+ - **PSR-4 Autoloading**: Buat file `composer.json` dan definisikan pemetaan namespace:
143
+ ```json
144
+ {
145
+ "autoload": {
146
+ "psr-4": {
147
+ "App\\": "src/"
148
+ }
149
+ }
150
+ }
151
+ ```
152
+ - **Struktur Direktori Standar**:
153
+ - `public/`: Titik entri tunggal yang berisi `index.php` (Front Controller), aset (CSS, JS), serta file upload.
154
+ - `src/`: Namespace root untuk struktur MVC (`src/Models/`, `src/Controllers/`, `src/Views/`, `src/Core/`).
155
+ - `config/`: Konfigurasi database, konfigurasi router, dan konfigurasi aplikasi.
156
+ - `.env` & `.env.example`: Menyimpan konfigurasi environment.
157
+
158
+ #### 3. Menerapkan Arsitektur MVC
159
+ Refaktorkan kode spageti ke dalam lapisan MVC yang terpisah:
160
+ - **Front Controller (Routing Terpusat)**:
161
+ Gunakan library routing yang bersih (seperti AltoRouter atau router kustom ringan) di `public/index.php`. Arahkan semua request melalui satu file menggunakan `.htaccess` atau pengalihan server:
162
+ ```php
163
+ // public/index.php
164
+ require_once __DIR__ . '/../vendor/autoload.php';
165
+
166
+ $router = new App\Core\Router();
167
+ $router->add('GET', '/', 'HomeController@index');
168
+ $router->add('GET', '/users', 'UserController@index');
169
+ $router->dispatch($_SERVER['REQUEST_URI'], $_SERVER['REQUEST_METHOD']);
170
+ ```
171
+ - **Models**:
172
+ Pisahkan semua akses database di dalam kelas Model. Gunakan prepared statements dengan PDO:
173
+ ```php
174
+ namespace App\Models;
175
+ use App\Core\Database;
176
+ use PDO;
177
+
178
+ class User {
179
+ private PDO $db;
180
+ public function __construct() {
181
+ $this->db = Database::getInstance()->getConnection();
182
+ }
183
+ public function getAll(): array {
184
+ $stmt = $this->db->prepare("SELECT id, name, email FROM users ORDER BY name ASC");
185
+ $stmt->execute();
186
+ return $stmt->fetchAll(PDO::FETCH_ASSOC);
187
+ }
188
+ }
189
+ ```
190
+ - **Controllers**:
191
+ Ekstrak request dan parameter input, panggil model, lalu return/render view:
192
+ ```php
193
+ namespace App\Controllers;
194
+ use App\Models\User;
195
+
196
+ class UserController {
197
+ public function index(): void {
198
+ $model = new User();
199
+ $users = $model->getAll();
200
+ render_view('users/index', ['users' => $users]);
201
+ }
202
+ }
203
+ ```
204
+ - **Views**:
205
+ Jangan pernah me-render atau menggunakan `echo` HTML langsung di dalam controller. Terapkan render template PHP yang bersih atau gunakan template engine ringan seperti Twig. Pastikan semua output HTML divalidasi dan lolos proses escaping.
206
+
207
+ #### 4. Peningkatan Keamanan
208
+ Integrasikan filter keamanan standar berikut selama refaktorisasi:
209
+ - **Pencegahan SQL Injection**: Wajibkan prepared statements dengan parameter terikat untuk setiap query SQL.
210
+ - **Pencegahan XSS**: Buat atau gunakan fungsi helper escape global (misal `htmlspecialchars($str, ENT_QUOTES, 'UTF-8')`) pada setiap output dinamis pada view.
211
+ - **Proteksi CSRF**: Hasilkan dan validasi token CSRF untuk setiap request yang mengubah state data (`POST`, `PUT`, `DELETE`).
212
+ - **Manajemen Secrets**: Muat konfigurasi via file `.env` menggunakan library `vlucas/phpdotenv`.
213
+
214
+ #### 5. Memanfaatkan PHP Modern (v8.2+)
215
+ Refaktorkan logika PHP lama agar menggunakan fitur modern:
216
+ - **Constructor Property Promotion** dan **Typed Properties** untuk properti kelas.
217
+ - **Readonly Classes** untuk kelas layanan atau data yang bersifat immutable (tidak dapat diubah).
218
+ - **Deklarasi Strict Types**: Tambahkan `declare(strict_types=1);` di bagian paling atas setiap file kelas.
219
+
220
+ #### 6. Pendekatan Multi-Page Application (MPA) dalam Satu Repositori
221
+ Saat mengatur proyek sebagai Multi-Page Application di dalam satu repositori, ikuti panduan berikut:
222
+ - **Routing Terpusat (Centralized Routing)**: Gunakan Front Controller (`public/index.php`) untuk menangani semua permintaan halaman. Arahkan setiap permintaan ke controller dan view masing-masing, memastikan setiap pemuatan halaman diproses sepenuhnya di sisi server.
223
+ - **Layout & Parsial Bersama (Shared Layouts & Partials)**: Hindari duplikasi HTML (header, footer, navigasi). Buat direktori `src/Views/layouts/` untuk template dasar dan direktori `src/Views/partials/` untuk komponen UI yang dapat digunakan kembali. Controller harus menyuntikkan konten spesifik halaman ke dalam layout dasar.
224
+ - **Manajemen Aset**: Simpan semua aset statis (CSS, JS, gambar) di direktori `public/`. Gunakan teknik cache-busting (misalnya, menambahkan waktu modifikasi file `?v=123`) saat menautkan aset di dalam view.
225
+ - **Manajemen State**: Gunakan session sisi server secara aman untuk autentikasi pengguna, pesan flash, dan melacak state di seluruh proses reload halaman secara penuh.
226
+
227
+ ### Kondisi Pemicu
228
+ Aktif setiap kali pengguna meminta untuk:
229
+ - Memodernisasi proyek PHP lama atau script PHP spageti.
230
+ - Merancang arsitektur MVC atau memperkenalkan pola routing yang bersih di plain PHP.
231
+ - Menerapkan pemrograman berorientasi objek (OOP), namespace Composer (PSR-4), atau membersihkan akses database via PDO pada aplikasi PHP.
@@ -1,45 +1,45 @@
1
- ---
2
- name: payment-gateway-expert
3
- description: "Expert guide for integrating payment gateways (Stripe, PayPal, Xendit, Midtrans, DOKU) and secure webhooks into SaaS platforms / Panduan ahli integrasi payment gateway dan webhook aman."
4
- author: "Antigravity"
5
- ---
6
-
7
- # Payment Gateway Expert / Ahli Payment Gateway
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 integrating major payment gateways (Stripe, PayPal, Xendit, Midtrans, DOKU) into modern SaaS platforms. Covers checkout flows, secure webhook handling, subscription management, and synchronization with local databases.
18
-
19
- ### Instructions
20
- - **Security First**: Always validate webhook signatures before processing any payment event. Never trust client-side data for prices or payment status. For DOKU, ensure signature components (like request target) are arranged strictly according to documentation.
21
- - **Idempotency**: Implement idempotency keys for all payment creation requests to avoid duplicate charges. Webhook handlers must also be idempotent. For DOKU, include a unique `Request-Id` header.
22
- - **State Synchronization**: Ensure the local database (e.g., PostgreSQL, Supabase) is updated immediately and transactionally upon receiving successful webhook events.
23
- - **Subscription Management**: Map the provider's subscription statuses (e.g., `active`, `past_due`, `canceled`) accurately to the SaaS platform's internal state machine.
24
- - **Testing**: Use sandbox/test environments provided by the gateways and simulate webhooks using CLI tools (like Stripe CLI) during development.
25
-
26
- ### Trigger Conditions
27
- Active whenever the user is working on billing integration, payment checkout, webhook handling, or integrating platforms like PayPal, Stripe, Xendit, Midtrans, or DOKU.
28
-
29
- ---
30
-
31
- <a name="bahasa-indonesia"></a>
32
- ## Bahasa Indonesia
33
-
34
- ### Deskripsi
35
- Panduan ahli untuk mengintegrasikan payment gateway utama (Stripe, PayPal, Xendit, Midtrans, DOKU) ke platform SaaS modern. Mencakup alur checkout, penanganan webhook yang aman, manajemen langganan, dan sinkronisasi dengan database lokal.
36
-
37
- ### Instruksi
38
- - **Keamanan Utama**: Selalu validasi signature webhook sebelum memproses event pembayaran apa pun. Jangan pernah mempercayai data dari sisi klien untuk harga atau status pembayaran. Untuk DOKU, pastikan komponen signature (seperti request target) disusun secara ketat sesuai dokumentasi.
39
- - **Idempotensi**: Implementasikan kunci idempotensi (idempotency keys) untuk semua permintaan pembuatan pembayaran untuk menghindari tagihan ganda. Handler webhook juga harus idempoten. Untuk DOKU, sertakan header `Request-Id` unik.
40
- - **Sinkronisasi State**: Pastikan database lokal (misal: PostgreSQL, Supabase) diperbarui secara langsung dan transaksional saat menerima event webhook yang berhasil.
41
- - **Manajemen Langganan**: Petakan status langganan dari provider (misal: `active`, `past_due`, `canceled`) secara akurat ke state machine internal platform SaaS.
42
- - **Pengujian**: Gunakan lingkungan sandbox/test yang disediakan oleh gateway dan simulasikan webhook menggunakan tool CLI (seperti Stripe CLI) selama pengembangan.
43
-
44
- ### Kondisi Pemicu
45
- Aktif setiap kali pengguna sedang mengerjakan integrasi billing, checkout pembayaran, penanganan webhook, atau mengintegrasikan platform seperti PayPal, Stripe, Xendit, Midtrans, atau DOKU.
1
+ ---
2
+ name: payment-gateway-expert
3
+ description: "Expert guide for integrating payment gateways (Stripe, PayPal, Xendit, Midtrans, DOKU) and secure webhooks into SaaS platforms / Panduan ahli integrasi payment gateway dan webhook aman."
4
+ author: "Antigravity"
5
+ ---
6
+
7
+ # Payment Gateway Expert / Ahli Payment Gateway
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 integrating major payment gateways (Stripe, PayPal, Xendit, Midtrans, DOKU) into modern SaaS platforms. Covers checkout flows, secure webhook handling, subscription management, and synchronization with local databases.
18
+
19
+ ### Instructions
20
+ - **Security First**: Always validate webhook signatures before processing any payment event. Never trust client-side data for prices or payment status. For DOKU, ensure signature components (like request target) are arranged strictly according to documentation.
21
+ - **Idempotency**: Implement idempotency keys for all payment creation requests to avoid duplicate charges. Webhook handlers must also be idempotent. For DOKU, include a unique `Request-Id` header.
22
+ - **State Synchronization**: Ensure the local database (e.g., PostgreSQL, Supabase) is updated immediately and transactionally upon receiving successful webhook events.
23
+ - **Subscription Management**: Map the provider's subscription statuses (e.g., `active`, `past_due`, `canceled`) accurately to the SaaS platform's internal state machine.
24
+ - **Testing**: Use sandbox/test environments provided by the gateways and simulate webhooks using CLI tools (like Stripe CLI) during development.
25
+
26
+ ### Trigger Conditions
27
+ Active whenever the user is working on billing integration, payment checkout, webhook handling, or integrating platforms like PayPal, Stripe, Xendit, Midtrans, or DOKU.
28
+
29
+ ---
30
+
31
+ <a name="bahasa-indonesia"></a>
32
+ ## Bahasa Indonesia
33
+
34
+ ### Deskripsi
35
+ Panduan ahli untuk mengintegrasikan payment gateway utama (Stripe, PayPal, Xendit, Midtrans, DOKU) ke platform SaaS modern. Mencakup alur checkout, penanganan webhook yang aman, manajemen langganan, dan sinkronisasi dengan database lokal.
36
+
37
+ ### Instruksi
38
+ - **Keamanan Utama**: Selalu validasi signature webhook sebelum memproses event pembayaran apa pun. Jangan pernah mempercayai data dari sisi klien untuk harga atau status pembayaran. Untuk DOKU, pastikan komponen signature (seperti request target) disusun secara ketat sesuai dokumentasi.
39
+ - **Idempotensi**: Implementasikan kunci idempotensi (idempotency keys) untuk semua permintaan pembuatan pembayaran untuk menghindari tagihan ganda. Handler webhook juga harus idempoten. Untuk DOKU, sertakan header `Request-Id` unik.
40
+ - **Sinkronisasi State**: Pastikan database lokal (misal: PostgreSQL, Supabase) diperbarui secara langsung dan transaksional saat menerima event webhook yang berhasil.
41
+ - **Manajemen Langganan**: Petakan status langganan dari provider (misal: `active`, `past_due`, `canceled`) secara akurat ke state machine internal platform SaaS.
42
+ - **Pengujian**: Gunakan lingkungan sandbox/test yang disediakan oleh gateway dan simulasikan webhook menggunakan tool CLI (seperti Stripe CLI) selama pengembangan.
43
+
44
+ ### Kondisi Pemicu
45
+ Aktif setiap kali pengguna sedang mengerjakan integrasi billing, checkout pembayaran, penanganan webhook, atau mengintegrasikan platform seperti PayPal, Stripe, Xendit, Midtrans, atau DOKU.