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
@@ -0,0 +1,79 @@
1
+ ---
2
+ name: project-context-mapper
3
+ description: "Gives the agent a photographic memory of massive repositories. Forces the creation and maintenance of a highly compressed CONTEXT_MAP.md to prevent context exhaustion and hallucination."
4
+ author: "Roedy Rustam"
5
+ ---
6
+
7
+ # Project Context Mapper (Memory Optimizer)
8
+
9
+ [English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
10
+
11
+ ---
12
+
13
+ <a name="english"></a>
14
+ ## English
15
+
16
+ ### Description
17
+ LLMs struggle with repositories containing hundreds of files; they lose track of where things are, leading to hallucinations and excessive tool calls. This skill forces the agent to create, read, and maintain a `CONTEXT_MAP.md`—a highly compressed index of the repository's architecture, dependency graphs, and critical file locations. This acts as the agent's "photographic memory".
18
+
19
+ ### Trigger Conditions
20
+ Activate this skill when:
21
+ - The agent enters a massive, existing codebase for the first time.
22
+ - The user complains that the AI is "editing the wrong file" or "forgetting how the app is structured."
23
+ - Context token usage is dangerously high and needs optimization.
24
+
25
+ ### Core Concepts
26
+
27
+ #### 1. The Context Map Format
28
+ The agent should execute a script or traverse the directory to generate a compressed map in `CONTEXT_MAP.md` (or within `.agents/`).
29
+ ```markdown
30
+ # CONTEXT MAP (Do not delete)
31
+
32
+ ## Architecture
33
+ - Frontend: Next.js App Router (src/app)
34
+ - Backend: Hono RPC (src/server)
35
+ - DB: Drizzle (src/db/schema.ts)
36
+
37
+ ## Dependency Graph (Critical Paths)
38
+ - `src/app/page.tsx` -> `src/components/ui/Button.tsx`
39
+ - `src/server/routes/users.ts` -> `src/db/queries/users.ts`
40
+
41
+ ## State Locations
42
+ - Global Auth: `src/store/auth.ts` (Zustand)
43
+ ```
44
+
45
+ #### 2. Workflow
46
+ 1. **On Start:** The agent reads `CONTEXT_MAP.md` instead of blindly listing directories.
47
+ 2. **On Modification:** When the agent creates a new major component, route, or service, it MUST append that location to the context map.
48
+
49
+ ### Best Practices
50
+ - **Keep it Ultra-Compressed:** Do not store full code in the map. Store ONLY file paths, responsibilities (1 sentence), and connections.
51
+ - **BM25 Search First:** Before writing to the context map, consider using `grep_search` or semantic search for targeted lookups. The map is for *architectural* understanding, not exact variable finding.
52
+
53
+ ---
54
+
55
+ ### Integration with Other Skills (MANDATORY)
56
+ - `session-context-loader` — Integrates deeply to ensure the context map is loaded automatically on every new chat session.
57
+ - `token-saver` — The map prevents the agent from reading 10 separate files just to find one function, saving massive amounts of tokens.
58
+ - `monorepo-architect` — Essential for mapping out package boundaries in Turborepo/pnpm workspaces.
59
+
60
+ ### Referenced By Orchestrators (MANDATORY)
61
+ - `brainstorming` — Add to "Discovery & Audit".
62
+ - `zero-to-prod-orchestrator` — Phase 1 (Discovery & Architecture).
63
+
64
+ ---
65
+
66
+ <a name="bahasa-indonesia"></a>
67
+ ## Bahasa Indonesia
68
+
69
+ ### Deskripsi
70
+ Kelemahan utama agen AI adalah keterbatasan jendela konteks (*context window*). Skill ini memberi agen "ingatan fotografis" dengan mewajibkannya memelihara file `CONTEXT_MAP.md`—sebuah indeks super padat yang memetakan arsitektur proyek, lokasi file penting, dan graf dependensi.
71
+
72
+ ### Kondisi Pemicu
73
+ - Saat agen baru saja dimasukkan ke dalam repositori raksasa yang sudah ada (bukan dari nol).
74
+ - Saat agen mulai salah mengedit file atau terlihat kebingungan dengan struktur folder.
75
+
76
+ ### Panduan Singkat
77
+ - **Indeks Tersentralisasi:** Buat dan selalu perbarui `CONTEXT_MAP.md`. File ini berisi daftar *path* direktori krusial dan tanggung jawab masing-masing (misal: "Logic pembayaran ada di `src/lib/stripe.ts`").
78
+ - **Ultra-Ringkas:** Jangan menaruh baris kode di dalam peta konteks ini. Hanya gunakan format *bullet points* agar konsumsi token saat dibaca sangat rendah.
79
+ - **Baca di Awal Sesi:** Di setiap awal percakapan, agen tidak perlu lagi meraba-raba melakukan `ls` berulang kali. Cukup gunakan `view_file` pada `CONTEXT_MAP.md`, dan agen langsung mengerti seluruh topologi proyek.
@@ -1,10 +1,10 @@
1
1
  ---
2
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."
3
+ description: "Expert-level skill for Python programming (Python 3.13/3.14+). 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
4
  author: "Roedy Rustam"
5
5
  ---
6
6
 
7
- # Python Programming Expert (3.13 JIT Edition)
7
+ # Python Programming Expert (3.14 Edition)
8
8
 
9
9
  [English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
10
10
 
@@ -14,203 +14,346 @@ author: "Roedy Rustam"
14
14
  ## English
15
15
 
16
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.
17
+ Expert-level Python development guidance for **Python 3.13 / 3.14+** covering JIT compilation, free-threaded (no-GIL) mode, modern type safety patterns, async architecture, and the full production stack: **FastAPI 0.115+**, **Pydantic v2**, **SQLAlchemy 2.x / SQLModel**, **uv**, **Ruff**, and **pytest-asyncio**.
18
18
 
19
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.
20
+ - Writing Python 3.13+ / 3.14+ applications or services.
21
+ - Building **FastAPI 0.115+** REST APIs, **Django 5.x**, or **Litestar** web services.
22
+ - Managing Python projects with the **`uv`** package manager.
23
+ - Implementing async/await patterns with `asyncio.TaskGroup` or structured concurrency.
24
+ - Writing type-safe Python with **Pydantic v2** and modern generics (PEP 695/696).
25
+ - Setting up **Ruff** for linting + formatting; **pytest** with `pytest-asyncio` for testing.
26
+ - Building AI backends integrating with LLM APIs (OpenAI, Anthropic, Google GenAI).
26
27
 
27
- ### Python 3.13 — Key Improvements
28
+ ---
28
29
 
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.
30
+ ### Python Version Matrix (2026)
37
31
 
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
- ```
32
+ | Version | Status | Key Feature |
33
+ |---|---|---|
34
+ | **Python 3.14** | Latest (Oct 2025) | PEP 696 defaults, improved JIT, `@` on types |
35
+ | **Python 3.13** | Stable LTS | JIT compiler, free-threaded mode (no GIL) |
36
+ | **Python 3.12** | Supported | PEP 695 generics, `type` alias statement |
37
+ | **Python 3.11** | Security only | `asyncio.TaskGroup`, `ExceptionGroup` |
45
38
 
46
- #### Improved Error Messages
47
- Python 3.13 provides significantly better tracebacks with highlighted variable values and suggestions.
39
+ ---
48
40
 
49
41
  ### Modern Python Toolchain (2026)
50
42
 
51
- #### uv — The 2026 Standard Package Manager
52
- Replace `pip`, `pip-tools`, `virtualenv`, `pyenv`, and `poetry` with **uv**:
43
+ #### uv — The Standard Package Manager
44
+ Replace `pip`, `pip-tools`, `virtualenv`, `pyenv`, and `poetry` entirely with **uv** (written in Rust — 10-100x faster):
53
45
  ```bash
54
46
  # Create project
55
- uv init my-project
56
- cd my-project
47
+ uv init my-api
48
+ cd my-api
57
49
 
58
- # Add dependencies
59
- uv add fastapi pydantic httpx
50
+ # Add runtime dependencies
51
+ uv add fastapi pydantic httpx sqlalchemy[asyncio]
60
52
 
61
53
  # Add dev dependencies
62
- uv add --dev pytest ruff mypy
54
+ uv add --dev pytest pytest-asyncio ruff mypy httpx
63
55
 
64
- # Run scripts
56
+ # Run scripts (no activation needed)
65
57
  uv run python main.py
66
58
  uv run pytest
59
+ uv run fastapi dev main.py # Hot reload dev server
67
60
 
68
- # Sync environment
69
- uv sync
61
+ # Pin exact Python version
62
+ uv python pin 3.13
70
63
 
71
- # Lock dependencies
72
- uv lock
64
+ # Sync all environments
65
+ uv sync
73
66
  ```
74
67
 
75
- #### RuffLinting + Formatting in One
76
- ```bash
77
- uv add --dev ruff
68
+ #### `pyproject.toml`Single Config File
69
+ ```toml
70
+ [project]
71
+ name = "my-api"
72
+ version = "0.1.0"
73
+ requires-python = ">=3.13"
74
+ dependencies = [
75
+ "fastapi>=0.115",
76
+ "pydantic>=2.9",
77
+ "sqlalchemy[asyncio]>=2.0",
78
+ "asyncpg>=0.30",
79
+ ]
78
80
 
79
- # ruff.toml
80
81
  [tool.ruff]
81
82
  line-length = 88
82
83
  target-version = "py313"
83
84
 
84
85
  [tool.ruff.lint]
85
- select = ["E", "F", "I", "N", "UP", "B", "SIM", "ANN"]
86
+ select = ["E", "F", "I", "N", "UP", "B", "SIM", "ANN", "ASYNC"]
86
87
 
87
- # Run
88
- uv run ruff check .
89
- uv run ruff format .
88
+ [tool.ruff.lint.per-file-ignores]
89
+ "tests/**/*.py" = ["ANN"] # No type annotations required in tests
90
+
91
+ [tool.pytest.ini_options]
92
+ asyncio_mode = "auto" # pytest-asyncio auto mode
90
93
  ```
91
94
 
92
- ### Type Safety — Modern Patterns (Python 3.12+)
95
+ ---
93
96
 
94
- #### PEP 695New Generic Syntax
97
+ ### Type SafetyModern Patterns
98
+
99
+ #### PEP 695 — Generic Syntax (Python 3.12+)
95
100
  ```python
96
- # Old (Python < 3.12)
97
- from typing import TypeVar
101
+ # Old way (verbose)
102
+ from typing import TypeVar, Generic
98
103
  T = TypeVar('T')
99
- def first[T](lst: list[T]) -> T: ...
104
+ class Stack(Generic[T]):
105
+ def push(self, item: T) -> None: ...
106
+
107
+ # New way (Python 3.12+) — clean, no boilerplate
108
+ class Stack[T]:
109
+ def __init__(self) -> None:
110
+ self._items: list[T] = []
111
+
112
+ def push(self, item: T) -> None:
113
+ self._items.append(item)
100
114
 
101
- # New (Python 3.12+) cleaner, no TypeVar boilerplate
115
+ def pop(self) -> T:
116
+ return self._items.pop()
117
+
118
+ # Generic functions
102
119
  def first[T](lst: list[T]) -> T:
103
120
  return lst[0]
104
121
 
105
- type Vector = list[float] # Type alias with 'type' statement
122
+ # Type aliases (PEP 695)
123
+ type Vector = list[float]
124
+ type Matrix[T] = list[list[T]]
106
125
  ```
107
126
 
108
- #### Pydantic v2Data Validation
127
+ #### PEP 696TypeVar Defaults (Python 3.14+)
109
128
  ```python
110
- from pydantic import BaseModel, Field, field_validator
111
- from pydantic import EmailStr
129
+ # Default generic types reduces boilerplate in libraries
130
+ class Response[T = dict]: # T defaults to dict if not specified
131
+ def __init__(self, data: T) -> None:
132
+ self.data = data
133
+
134
+ response = Response({"key": "value"}) # T inferred as dict
135
+ ```
136
+
137
+ #### Pydantic v2 — Production Data Validation
138
+ ```python
139
+ from pydantic import BaseModel, Field, field_validator, model_validator
140
+ from pydantic import EmailStr, SecretStr
141
+ from typing import Annotated
142
+
143
+ # Annotated types for reusability
144
+ PositiveInt = Annotated[int, Field(gt=0)]
145
+ TrimmedStr = Annotated[str, Field(min_length=1, strip_whitespace=True)]
112
146
 
113
147
  class UserCreate(BaseModel):
114
- name: str = Field(min_length=2, max_length=50)
148
+ model_config = {"str_strip_whitespace": True}
149
+
150
+ name: TrimmedStr = Field(max_length=50)
115
151
  email: EmailStr
116
- age: int = Field(ge=0, le=150)
152
+ age: PositiveInt
153
+ password: SecretStr = Field(min_length=8)
117
154
 
118
155
  @field_validator('name')
119
156
  @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()
157
+ def validate_name(cls, v: str) -> str:
158
+ if not v.replace(' ', '').isalpha():
159
+ raise ValueError('Name must contain only letters')
160
+ return v.title()
161
+
162
+ @model_validator(mode='after')
163
+ def check_adult_email(self) -> 'UserCreate':
164
+ if self.age < 18 and 'kids' not in self.email:
165
+ raise ValueError('Minors must use a kids account email')
166
+ return self
124
167
 
125
168
  # Usage
126
- user = UserCreate(name="Alice", email="alice@example.com", age=30)
127
- user.model_dump() # {'name': 'Alice', 'email': 'alice@example.com', 'age': 30}
169
+ user = UserCreate(name="alice smith", email="alice@example.com", age=25, password="securepassword")
170
+ user.model_dump() # {'name': 'Alice Smith', 'email': 'alice@example.com', 'age': 25}
171
+ user.model_dump(mode='json') # JSON-serializable dict
128
172
  ```
129
173
 
130
- ### FastAPI 0.115+ Best Practices
174
+ ---
175
+
176
+ ### FastAPI 0.115+ — Production Patterns
131
177
 
132
- #### Lifespan (Replace @app.on_event)
178
+ #### Application Structure
179
+ ```
180
+ my_api/
181
+ ├── main.py # FastAPI app + lifespan
182
+ ├── routers/
183
+ │ ├── users.py # APIRouter for /users
184
+ │ └── posts.py # APIRouter for /posts
185
+ ├── models/
186
+ │ ├── user.py # Pydantic request/response models
187
+ │ └── post.py
188
+ ├── db/
189
+ │ ├── database.py # SQLAlchemy engine + session
190
+ │ └── models.py # ORM models
191
+ ├── services/
192
+ │ └── user_service.py # Business logic layer
193
+ └── core/
194
+ ├── config.py # Settings with Pydantic BaseSettings
195
+ └── security.py # JWT, hashing
196
+ ```
197
+
198
+ #### Lifespan — Startup & Shutdown
133
199
  ```python
134
200
  from contextlib import asynccontextmanager
135
201
  from fastapi import FastAPI
202
+ from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker
203
+
204
+ engine = create_async_engine(settings.DATABASE_URL, echo=False, pool_size=10)
205
+ AsyncSessionLocal = async_sessionmaker(engine, expire_on_commit=False)
136
206
 
137
207
  @asynccontextmanager
138
208
  async def lifespan(app: FastAPI):
139
- # Startup: connect DB, warm caches
140
- await db.connect()
209
+ # Startup
210
+ async with engine.begin() as conn:
211
+ await conn.run_sync(Base.metadata.create_all)
212
+ print("✅ Database connected")
141
213
  yield
142
- # Shutdown: clean up resources
143
- await db.disconnect()
214
+ # Shutdown
215
+ await engine.dispose()
216
+ print("✅ Database disconnected")
144
217
 
145
- app = FastAPI(lifespan=lifespan)
218
+ app = FastAPI(title="My API", version="1.0.0", lifespan=lifespan)
146
219
  ```
147
220
 
148
221
  #### Dependency Injection Pattern
149
222
  ```python
150
- from fastapi import Depends, HTTPException
223
+ from typing import Annotated
224
+ from fastapi import Depends, HTTPException, status
151
225
  from sqlalchemy.ext.asyncio import AsyncSession
152
226
 
153
227
  async def get_db() -> AsyncSession:
154
- async with async_session_factory() as session:
228
+ async with AsyncSessionLocal() as session:
155
229
  yield session
156
230
 
157
- @app.get("/users/{user_id}")
158
- async def get_user(user_id: str, db: AsyncSession = Depends(get_db)):
231
+ DbDep = Annotated[AsyncSession, Depends(get_db)]
232
+
233
+ # In routes
234
+ @router.get("/users/{user_id}", response_model=UserResponse)
235
+ async def get_user(user_id: str, db: DbDep):
159
236
  user = await db.get(User, user_id)
160
237
  if not user:
161
- raise HTTPException(status_code=404, detail="User not found")
238
+ raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="User not found")
162
239
  return user
163
240
  ```
164
241
 
165
- #### Structured Error Responses
242
+ #### Settings with Pydantic BaseSettings
243
+ ```python
244
+ from pydantic_settings import BaseSettings, SettingsConfigDict
245
+
246
+ class Settings(BaseSettings):
247
+ model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8")
248
+
249
+ DATABASE_URL: str
250
+ SECRET_KEY: str
251
+ ALGORITHM: str = "HS256"
252
+ ACCESS_TOKEN_EXPIRE_MINUTES: int = 15
253
+ ENVIRONMENT: str = "development"
254
+
255
+ @property
256
+ def is_production(self) -> bool:
257
+ return self.ENVIRONMENT == "production"
258
+
259
+ settings = Settings()
260
+ ```
261
+
262
+ #### Structured Error Handling (RFC 9457)
166
263
  ```python
167
264
  from fastapi import Request
168
265
  from fastapi.responses import JSONResponse
169
266
 
170
- class AppError(Exception):
171
- def __init__(self, message: str, code: str, status: int = 400):
172
- self.message = message
173
- self.code = code
267
+ class AppException(Exception):
268
+ def __init__(self, *, type: str, title: str, status: int, detail: str):
269
+ self.type = type
270
+ self.title = title
174
271
  self.status = status
272
+ self.detail = detail
175
273
 
176
- @app.exception_handler(AppError)
177
- async def app_error_handler(request: Request, exc: AppError):
274
+ @app.exception_handler(AppException)
275
+ async def app_exception_handler(request: Request, exc: AppException) -> JSONResponse:
178
276
  return JSONResponse(
179
277
  status_code=exc.status,
180
- content={"error": exc.code, "message": exc.message}
278
+ content={
279
+ "type": exc.type,
280
+ "title": exc.title,
281
+ "status": exc.status,
282
+ "detail": exc.detail,
283
+ }
181
284
  )
285
+
286
+ # Usage in routes
287
+ raise AppException(
288
+ type="https://myapi.com/errors/user-not-found",
289
+ title="User Not Found",
290
+ status=404,
291
+ detail=f"User with id '{user_id}' does not exist",
292
+ )
182
293
  ```
183
294
 
184
- ### Async Patterns — asyncio.TaskGroup (Python 3.11+)
295
+ ---
296
+
297
+ ### Async Patterns
298
+
299
+ #### asyncio.TaskGroup (Python 3.11+)
185
300
  ```python
186
301
  import asyncio
187
302
 
188
303
  async def main():
304
+ # Better than asyncio.gather — propagates exceptions immediately
189
305
  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()]
306
+ task_users = tg.create_task(fetch_users())
307
+ task_posts = tg.create_task(fetch_posts())
308
+ task_stats = tg.create_task(fetch_stats())
309
+ # All tasks complete here — exception in any task cancels all others
310
+ return task_users.result(), task_posts.result(), task_stats.result()
194
311
  ```
195
312
 
196
- ### Testing with pytest
313
+ #### Python 3.13 — JIT & Free-Threaded Mode
314
+ ```bash
315
+ # JIT compiler — 10-20% speedup on CPU-bound code
316
+ PYTHON_JIT=1 python3.13 compute_heavy.py
317
+
318
+ # Free-threaded build (no GIL) — true CPU parallelism
319
+ uv python install 3.13t # install free-threaded build
320
+ python3.13t -X gil=0 parallel_app.py
321
+ ```
322
+
323
+ ---
324
+
325
+ ### Testing with pytest + pytest-asyncio
197
326
  ```python
327
+ # conftest.py
198
328
  import pytest
199
- import pytest_asyncio
200
329
  from httpx import AsyncClient, ASGITransport
330
+ from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker
331
+
332
+ TEST_DATABASE_URL = "sqlite+aiosqlite:///:memory:"
333
+
334
+ @pytest.fixture
335
+ async def db_session():
336
+ engine = create_async_engine(TEST_DATABASE_URL)
337
+ async with engine.begin() as conn:
338
+ await conn.run_sync(Base.metadata.create_all)
339
+ async with async_sessionmaker(engine)() as session:
340
+ yield session
341
+ await engine.dispose()
201
342
 
202
- @pytest_asyncio.fixture
203
- async def client():
343
+ @pytest.fixture
344
+ async def client(db_session):
345
+ app.dependency_overrides[get_db] = lambda: db_session
204
346
  async with AsyncClient(
205
347
  transport=ASGITransport(app=app), base_url="http://test"
206
348
  ) as ac:
207
349
  yield ac
208
350
 
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"
351
+ # test_users.py
352
+ async def test_create_user(client: AsyncClient):
353
+ response = await client.post("/users", json={"name": "Alice", "email": "alice@test.com", "age": 25, "password": "password123"})
354
+ assert response.status_code == 201
355
+ data = response.json()
356
+ assert data["email"] == "alice@test.com"
214
357
  ```
215
358
 
216
359
  ---
@@ -219,53 +362,41 @@ async def test_get_user(client: AsyncClient):
219
362
  ## Bahasa Indonesia
220
363
 
221
364
  ### 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.
365
+ Panduan pengembangan Python tingkat ahli untuk **Python 3.13/3.14+** mencakup JIT compilation, mode free-threaded (tanpa GIL), pola keamanan tipe modern, arsitektur async, dan stack produksi lengkap: **FastAPI 0.115+**, **Pydantic v2**, **SQLAlchemy 2.x**, **uv**, **Ruff**, dan **pytest-asyncio**.
223
366
 
224
367
  ### 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.
368
+ - Menulis aplikasi atau layanan Python 3.13+/3.14+.
369
+ - Membangun REST API FastAPI 0.115+, Django 5.x, atau Litestar.
227
370
  - Mengelola proyek Python dengan manajer paket `uv`.
228
371
  - 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.
372
+ - Menulis Python type-safe dengan Pydantic v2 dan generik modern (PEP 695/696).
373
+ - Menyiapkan Ruff untuk linting + formatting; pytest-asyncio untuk pengujian.
239
374
 
240
375
  ### Toolchain Modern (2026)
241
376
 
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.
377
+ **`uv`** menggantikan `pip`, `pip-tools`, `virtualenv`, `pyenv`, dan `poetry` ditulis dalam Rust, 10-100x lebih cepat. Gunakan satu file `pyproject.toml` untuk semua konfigurasi.
247
378
 
248
379
  ### Keamanan Tipe — Pola Modern
249
380
 
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.
381
+ **PEP 695** (Python 3.12+): Sintaksis generic baru yang bersih tanpa boilerplate `TypeVar`. Gunakan `type` statement untuk alias tipe.
382
+
383
+ **PEP 696** (Python 3.14+): Default untuk TypeVar — mengurangi boilerplate lebih lanjut pada library dan class generic.
384
+
385
+ **Pydantic v2**: Gunakan `BaseModel`, `Field`, `@field_validator`, dan `@model_validator` untuk validasi data yang ketat. `model_dump()` dan `model_validate()` menggantikan metode v1.
252
386
 
253
- #### Pydantic v2
254
- Gunakan `BaseModel`, `Field`, dan `@field_validator` untuk validasi data yang ketat. `model_dump()` dan `model_validate()` menggantikan metode lama.
387
+ ### FastAPI 0.115+ — Pola Produksi
255
388
 
256
- ### FastAPI 0.115+ Best Practices
389
+ - **Lifespan**: Gunakan `@asynccontextmanager` dengan `lifespan=` di `FastAPI()` untuk startup/shutdown yang bersih.
390
+ - **Dependency Injection**: Gunakan `Depends()` dengan `Annotated` untuk sesi database, autentikasi, dll.
391
+ - **BaseSettings**: Gunakan `pydantic-settings` untuk konfigurasi dari environment variables dengan validasi tipe.
392
+ - **Error RFC 9457**: Format error yang konsisten dengan `type`, `title`, `status`, `detail`.
257
393
 
258
- #### Lifespan (Gantikan @app.on_event)
259
- Gunakan `@asynccontextmanager` dengan parameter `lifespan` di `FastAPI()` untuk startup/shutdown yang bersih.
394
+ ### Pola Async
260
395
 
261
- #### Dependency Injection
262
- Gunakan `Depends()` untuk injeksi sesi database, autentikasi, dan dependensi lainnya ke route handler.
396
+ Gunakan `asyncio.TaskGroup` (Python 3.11+) sebagai pengganti `asyncio.gather()` — lebih aman karena propagasi exception langsung dan membatalkan semua task lain saat ada yang gagal.
263
397
 
264
- #### Error Terstruktur
265
- Buat kelas `Exception` kustom dan daftarkan `exception_handler` global untuk respons error yang konsisten.
398
+ Python 3.13 JIT: Aktifkan dengan `PYTHON_JIT=1` untuk kode CPU-bound. Free-threaded mode (`python3.13t -X gil=0`) untuk paralelisme CPU sejati.
266
399
 
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.
400
+ ### Pengujian
269
401
 
270
- ### Pengujian dengan pytest
271
- Gunakan `pytest-asyncio` dan `AsyncClient` dari `httpx` untuk pengujian endpoint async FastAPI yang bersih dan terisolasi.
402
+ Gunakan `pytest-asyncio` dengan `asyncio_mode = "auto"` di `pyproject.toml`. Gunakan `AsyncClient` dari `httpx` dengan `ASGITransport` untuk pengujian endpoint async yang bersih dan terisolasi tanpa perlu menjalankan server.