vibe-me 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,848 @@
1
+ # The .vibe Standard — A Complete Guide to Semantic Repository Layers
2
+
3
+ > **For AI agents and humans.** This document contains everything you need to create a `.vibe/` semantic layer for any software project, in any language, of any size. Read this entire document before starting.
4
+
5
+ ---
6
+
7
+ ## Table of Contents
8
+
9
+ 1. [What is .vibe and Why Does It Exist?](#what-is-vibe-and-why-does-it-exist)
10
+ 2. [The Core Principle](#the-core-principle)
11
+ 3. [Folder Structure](#folder-structure)
12
+ 4. [Before You Start — The Discovery Phase](#before-you-start--the-discovery-phase)
13
+ 5. [File 1: purpose.md](#file-1-purposemd)
14
+ 6. [File 2: architecture.md](#file-2-architecturemd)
15
+ 7. [File 3: flows.md](#file-3-flowsmd)
16
+ 8. [File 4: entities.md](#file-4-entitiesmd)
17
+ 9. [File 5: decisions.md](#file-5-decisionsmd)
18
+ 10. [File 6: state.json](#file-6-statejson)
19
+ 11. [The Update Protocol](#the-update-protocol)
20
+ 12. [Quality Checklist](#quality-checklist)
21
+ 13. [Common Mistakes](#common-mistakes)
22
+ 14. [FAQ](#faq)
23
+
24
+ ---
25
+
26
+ ## What is .vibe and Why Does It Exist?
27
+
28
+ Most repositories are impossible to understand without reading the source code. Documentation, when it exists, describes *how* things work (API routes, function signatures, config options) but never captures *why* things exist, *what* the system actually is, or *how* a user moves through it.
29
+
30
+ The `.vibe/` folder is a **semantic repository layer** — a small set of files that lets any human or AI understand a project without reading the source code. It describes **intent** rather than **implementation**.
31
+
32
+ ### The Problem It Solves
33
+
34
+ When a new developer (or AI agent) encounters a codebase, they face these questions:
35
+
36
+ 1. **What is this thing?** (Not "what framework does it use" — what *problem* does it solve?)
37
+ 2. **How is it structured?** (Not "what files exist" — what *systems* exist and how do they talk?)
38
+ 3. **What do users actually do with it?** (Not component descriptions — actual *journeys*)
39
+ 4. **What are the important concepts?** (Not class hierarchies — the *nouns* of the domain)
40
+ 5. **Why was it built this way?** (Not "how does X work" — why X instead of Y?)
41
+ 6. **What's the current state?** (What works? What's broken? What are the constraints?)
42
+
43
+ If you can answer these 6 questions, you can understand any project. The 6 files in `.vibe/` answer exactly these 6 questions.
44
+
45
+ ---
46
+
47
+ ## The Core Principle
48
+
49
+ > **Describe intent, not implementation.**
50
+
51
+ Every line in `.vibe/` should pass this test: *"Would this still be true if we rewrote the entire codebase in a different language?"*
52
+
53
+ If yes → it belongs in `.vibe/`.
54
+ If no → it belongs in code comments, READMEs, or docs.
55
+
56
+ Examples:
57
+ - ✅ "We chose SQLite because the access pattern is <100 writes/hour" → Intent
58
+ - ❌ "The `DatabaseService` class has a `connect()` method" → Implementation
59
+ - ✅ "User uploads a document → AI analyzes it → results displayed" → Intent
60
+ - ❌ "POST /api/documents calls `processDocument()` in `services/ai.ts`" → Implementation
61
+
62
+ ---
63
+
64
+ ## Folder Structure
65
+
66
+ ```
67
+ your-project/
68
+ └── .vibe/
69
+ ├── purpose.md — What this is, who it's for, what it doesn't do
70
+ ├── architecture.md — Systems and their connections
71
+ ├── flows.md — User journeys from start to finish
72
+ ├── entities.md — Important nouns and their relationships
73
+ ├── decisions.md — Why things exist the way they do
74
+ └── state.json — Machine-readable health snapshot
75
+ ```
76
+
77
+ **Rules:**
78
+ - The `.vibe/` folder lives at the **root** of the repository.
79
+ - All 6 files are required. If a file would be empty (e.g., a library has no user flows), write "N/A — this is a library, not an application" rather than omitting it.
80
+ - Files should be concise. If a `.vibe/` file exceeds ~300 lines, you're probably describing implementation, not intent.
81
+ - Use Markdown for the 5 `.md` files. Use JSON for `state.json`.
82
+
83
+ ---
84
+
85
+ ## Before You Start — The Discovery Phase
86
+
87
+ Before writing any `.vibe/` files, you must understand the project. Here is your research protocol:
88
+
89
+ ### Step 1: Scan the Repository Structure
90
+
91
+ List every directory and understand the top-level organization. Look for:
92
+ - Source code directories (src/, lib/, app/, pkg/)
93
+ - Configuration files (package.json, Cargo.toml, go.mod, pyproject.toml, *.csproj)
94
+ - Existing documentation (README.md, docs/, wiki/)
95
+ - Tests (tests/, __tests__/, *_test.go, *.spec.ts)
96
+ - Infrastructure (Dockerfile, docker-compose.yml, terraform/, .github/workflows/)
97
+ - Build artifacts (dist/, build/, out/, target/)
98
+
99
+ ### Step 2: Read Existing Documentation
100
+
101
+ Read everything that exists:
102
+ - README.md (often contains the "what" and "how to run")
103
+ - CONTRIBUTING.md (often contains architectural decisions)
104
+ - CHANGELOG.md (reveals what's changed and why)
105
+ - Architecture Decision Records (ADRs) if they exist
106
+ - API docs, OpenAPI specs, or GraphQL schemas
107
+ - Comments in configuration files (these often explain "why")
108
+
109
+ ### Step 3: Identify the Language and Framework Stack
110
+
111
+ Determine what you're working with:
112
+ - **Language:** Python, TypeScript, Go, Rust, C#, Java, C++, Swift, etc.
113
+ - **Frameworks:** React, Next.js, Django, FastAPI, Spring, Rails, Unity, Unreal, etc.
114
+ - **Database:** PostgreSQL, SQLite, MongoDB, Supabase, Firebase, none
115
+ - **Deployment:** Docker, Kubernetes, Vercel, AWS Lambda, bare metal, mobile app stores
116
+ - **AI/ML:** OpenAI, Anthropic, local models, Hugging Face, none
117
+
118
+ ### Step 4: Read the Entry Points
119
+
120
+ Every project has entry points. Find and read them:
121
+ - **Web apps:** `index.html`, `App.tsx`, `main.py`, `app.py`, `server.ts`
122
+ - **CLI tools:** `main.go`, `__main__.py`, `cli.rs`, `Program.cs`
123
+ - **Libraries:** The main exported module and its public API
124
+ - **Games:** `GameManager`, `main.cpp`, `App.swift`
125
+ - **Mobile apps:** `MainActivity.kt`, `AppDelegate.swift`, `App.tsx`
126
+
127
+ ### Step 5: Ask the User
128
+
129
+ Some information **cannot** be inferred from code. If any of the following are unclear after your research, ask the user directly:
130
+
131
+ **Questions you should ask:**
132
+
133
+ 1. "What problem does this project solve, in one sentence?"
134
+ 2. "Who uses this? Is it a tool for developers, an app for consumers, an internal service?"
135
+ 3. "What are the things this project deliberately does NOT do?"
136
+ 4. "Were there any major architectural decisions where you chose between alternatives? What were they and why did you choose what you chose?"
137
+ 5. "What's currently broken, incomplete, or known to be problematic?"
138
+ 6. "Are there any hard constraints? (e.g., must run offline, must support IE11, can't use GPL libraries, must stay under 50MB)"
139
+
140
+ **Do not ask** questions that you can answer by reading the code. Asking "what language is this in?" when there's a `package.json` in the root is insulting.
141
+
142
+ ---
143
+
144
+ ## File 1: purpose.md
145
+
146
+ ### What It Answers
147
+ "What is this? Why does it exist?"
148
+
149
+ ### Structure
150
+
151
+ ```markdown
152
+ # Purpose
153
+
154
+ ## What is this?
155
+ [1-3 sentences. No jargon. A non-technical person should understand.]
156
+
157
+ ## Who is it for?
158
+ [Specific user personas. Not "developers" — what KIND of developers? Not "businesses" — what KIND of businesses?]
159
+
160
+ ## What problem does it solve?
161
+ [The pain point that existed before this project. What was the user doing before? Why was that bad?]
162
+
163
+ ## What does success look like?
164
+ [A concrete scenario. "A user does X, then Y, then Z, and it feels like W."]
165
+
166
+ ## What does it explicitly NOT do?
167
+ [Hard boundaries. Things users might expect but will never get. This section prevents scope creep and misguided PRs.]
168
+ ```
169
+
170
+ ### How to Research It
171
+
172
+ 1. Read the first paragraph of README.md — it usually has the "what"
173
+ 2. Read the project's website or landing page if it exists
174
+ 3. Check the package description in package.json / Cargo.toml / setup.py
175
+ 4. If none of this is clear, **ask the user**
176
+
177
+ ### Examples Across Different Project Types
178
+
179
+ **SaaS Web App (Legal Tech):**
180
+ ```markdown
181
+ ## What is this?
182
+ An AI-powered legal motion drafting platform that generates court filings from plain-English case descriptions.
183
+
184
+ ## Who is it for?
185
+ Solo practitioners and small law firms (1-5 attorneys) who can't afford dedicated legal research staff.
186
+
187
+ ## What does it explicitly NOT do?
188
+ - Not legal advice. The output requires attorney review.
189
+ - Does not handle federal court filings (only state courts).
190
+ - Does not store client data beyond the active session.
191
+ ```
192
+
193
+ **Python CLI Tool:**
194
+ ```markdown
195
+ ## What is this?
196
+ A command-line tool that converts Figma design files into production-ready React components.
197
+
198
+ ## Who is it for?
199
+ Frontend developers who receive designs from Figma and want to skip the manual conversion step.
200
+
201
+ ## What does it explicitly NOT do?
202
+ - Does not handle animations or transitions.
203
+ - Does not generate tests.
204
+ - Requires a Figma API token — does not scrape the web interface.
205
+ ```
206
+
207
+ **Game (Unity):**
208
+ ```markdown
209
+ ## What is this?
210
+ A roguelike deckbuilder where players navigate a procedurally generated dungeon using cards that represent spells, items, and movement.
211
+
212
+ ## Who is it for?
213
+ Fans of Slay the Spire and Inscryption who want a more tactical, grid-based experience.
214
+
215
+ ## What does it explicitly NOT do?
216
+ - No multiplayer.
217
+ - No microtransactions or loot boxes.
218
+ - No procedural narrative — story is hand-written.
219
+ ```
220
+
221
+ ### Anti-Patterns
222
+
223
+ - ❌ "This is a Next.js app with Tailwind and Supabase" — That's a tech stack, not a purpose.
224
+ - ❌ "This solves problems for users" — Too vague. WHAT problems? WHICH users?
225
+ - ❌ Omitting the "NOT do" section — This is the most valuable section. Every project has boundaries.
226
+
227
+ ---
228
+
229
+ ## File 2: architecture.md
230
+
231
+ ### What It Answers
232
+ "What are the big pieces and how do they connect?"
233
+
234
+ ### Structure
235
+
236
+ ```markdown
237
+ # Architecture
238
+
239
+ ## Systems
240
+ [A visual diagram showing the major systems — NOT files or classes, but conceptual systems like "Frontend", "API", "Database", "Auth", "Queue", "AI Layer"]
241
+
242
+ ## How They Connect
243
+ [A table or description showing what protocol/method each system uses to talk to another]
244
+
245
+ ## Trust Boundaries
246
+ [Where does trusted data end and untrusted data begin? Where are the security gates?]
247
+ ```
248
+
249
+ ### How to Research It
250
+
251
+ 1. Look at the directory structure — top-level folders often map to systems
252
+ 2. Read `docker-compose.yml` — each service is usually a system
253
+ 3. Read import/dependency graphs — what modules depend on what?
254
+ 4. Look for HTTP clients, database connections, queue publishers, API calls
255
+ 5. Check environment variables — they usually point at external services
256
+
257
+ ### The Diagram
258
+
259
+ Use ASCII art or Mermaid diagrams. The goal is a picture that shows all major systems and their connections **on one screen**. If your diagram doesn't fit on one screen, you're describing too many things.
260
+
261
+ **Good diagram (web app):**
262
+ ```
263
+ ┌────────────┐ HTTP ┌────────────┐ SQL ┌──────────┐
264
+ │ React SPA │ ───────────── │ FastAPI │ ──────────── │ Postgres │
265
+ │ (Vercel) │ │ (Railway) │ │ (Supabase)│
266
+ └────────────┘ └──────┬─────┘ └──────────┘
267
+ │ HTTP
268
+
269
+ ┌──────────────┐
270
+ │ OpenAI API │
271
+ │ (external) │
272
+ └──────────────┘
273
+ ```
274
+
275
+ **Good diagram (mobile app):**
276
+ ```
277
+ ┌──────────────┐ REST ┌──────────────┐
278
+ │ Flutter App │ ──────────► │ Node.js API │
279
+ │ (iOS/Droid) │ │ (AWS Lambda)│
280
+ └──────────────┘ └──────┬───────┘
281
+
282
+ ┌───────────────┼───────────────┐
283
+ ▼ ▼ ▼
284
+ ┌──────────┐ ┌──────────┐ ┌──────────────┐
285
+ │ DynamoDB │ │ S3 Bucket│ │ Stripe API │
286
+ │ (users) │ │ (uploads)│ │ (payments) │
287
+ └──────────┘ └──────────┘ └──────────────┘
288
+ ```
289
+
290
+ ### Trust Boundaries
291
+
292
+ This section is optional for simple projects but critical for anything with auth, payments, or user data:
293
+
294
+ ```
295
+ UNTRUSTED GATE TRUSTED
296
+ ────────────────────────────────────────────────────────
297
+ Browser input → Zod validation → API handler
298
+ API request → JWT verification → Database query
299
+ File upload → MIME type check → S3 storage
300
+ Webhook payload → Signature verify → Event processing
301
+ ```
302
+
303
+ ### Anti-Patterns
304
+
305
+ - ❌ Listing every file in the project — That's a file tree, not an architecture.
306
+ - ❌ Describing internal class hierarchies — That's implementation.
307
+ - ❌ Including arrows without labels — Every connection should say *what* travels over it.
308
+
309
+ ---
310
+
311
+ ## File 3: flows.md
312
+
313
+ ### What It Answers
314
+ "What do users actually DO with this system, step by step?"
315
+
316
+ ### Structure
317
+
318
+ ```markdown
319
+ # Flows
320
+
321
+ ## 1. [Flow Name]
322
+ [Step-by-step journey using simple arrow notation]
323
+
324
+ ## 2. [Flow Name]
325
+ ...
326
+ ```
327
+
328
+ ### How to Research It
329
+
330
+ 1. **Read the UI code** — pages, routes, screens, and components reveal user paths
331
+ 2. **Read API routes** — they often follow CRUD patterns that map to user actions
332
+ 3. **Read tests** — integration tests often describe user scenarios
333
+ 4. **Look for onboarding/wizard flows** — these are always important
334
+ 5. **Check for auth flows** — signup, login, password reset, OAuth
335
+ 6. **If unclear, ask the user:** "Walk me through what a new user does from first visit to getting value."
336
+
337
+ ### The Arrow Notation
338
+
339
+ Use simple step-by-step arrows. Each step should be something a user *does* or *sees*, not a technical operation:
340
+
341
+ ```
342
+ User visits landing page
343
+
344
+ Clicks "Sign Up" → enters email and password
345
+
346
+ Receives verification email → clicks link
347
+
348
+ Redirected to onboarding wizard
349
+
350
+ Uploads first document
351
+
352
+ AI processes document (loading spinner, ~10 seconds)
353
+
354
+ Results displayed in dashboard with highlights
355
+ ```
356
+
357
+ ### What Flows to Include
358
+
359
+ Every project should have:
360
+ 1. **The primary value flow** — The main thing users come to do
361
+ 2. **The onboarding flow** — How a new user gets started
362
+ 3. **The error/recovery flow** — What happens when something goes wrong
363
+
364
+ Optional but valuable:
365
+ - Admin/management flows
366
+ - Payment/billing flows
367
+ - Data export flows
368
+ - Integration/API flows (if it's a platform)
369
+
370
+ ### Examples Across Different Project Types
371
+
372
+ **E-commerce:**
373
+ ```
374
+ ## 1. Purchase Flow
375
+ Customer browses catalog → filters by category
376
+
377
+ Clicks product → views details, reviews, sizing
378
+
379
+ Selects size and quantity → adds to cart
380
+
381
+ Clicks checkout → enters shipping address
382
+
383
+ Selects payment method → Stripe checkout
384
+
385
+ Order confirmed → email receipt sent
386
+
387
+ Warehouse notified → shipping label generated
388
+ ```
389
+
390
+ **CLI Tool:**
391
+ ```
392
+ ## 1. First Run
393
+ User installs via pip: `pip install figma2react`
394
+
395
+ Runs `figma2react init` → prompted for Figma API token
396
+
397
+ Token stored in ~/.figma2react/config.json
398
+
399
+ Runs `figma2react convert <figma-url>` → fetches design
400
+
401
+ Components generated in ./output/ directory
402
+
403
+ User reviews and copies into their project
404
+ ```
405
+
406
+ **Library (no user flows):**
407
+ ```
408
+ # Flows
409
+
410
+ N/A — This is a library, not an application. Developers import it and call functions.
411
+
412
+ The typical integration pattern is:
413
+
414
+ Developer installs the package
415
+
416
+ Imports the client: `from omniauth import Client`
417
+
418
+ Configures with API key: `client = Client(api_key="...")`
419
+
420
+ Calls methods: `client.authenticate(user, password)`
421
+
422
+ Handles response or error
423
+ ```
424
+
425
+ ### Anti-Patterns
426
+
427
+ - ❌ Describing API request/response payloads — That's API docs, not flows.
428
+ - ❌ Including technical middleware steps ("JWT decoded, rate limiter checked") — Users don't see those.
429
+ - ❌ Only one flow — Every project has at least 2-3 important journeys.
430
+
431
+ ---
432
+
433
+ ## File 4: entities.md
434
+
435
+ ### What It Answers
436
+ "What are the important nouns in this system?"
437
+
438
+ ### Structure
439
+
440
+ For each entity:
441
+
442
+ ```markdown
443
+ ## [Entity Name]
444
+
445
+ [One sentence: what is this thing?]
446
+
447
+ - **What is it?** [Detailed explanation]
448
+ - **Who creates it?** [What user action or system process brings it into existence]
449
+ - **Who modifies it?** [What can change it after creation]
450
+ - **What depends on it?** [What breaks or changes if this entity is deleted/modified]
451
+ ```
452
+
453
+ ### How to Research It
454
+
455
+ 1. **Database schema** — Every table/collection is likely an entity
456
+ 2. **TypeScript/Python types** — Interface definitions, dataclasses, structs
457
+ 3. **API routes** — Resources in REST URLs are entities (`/users`, `/projects`, `/invoices`)
458
+ 4. **UI labels** — What nouns appear in the interface? What do users talk about?
459
+ 5. **Domain language** — What words does the README/docs use repeatedly?
460
+
461
+ ### How to Choose What's an Entity
462
+
463
+ **Include:**
464
+ - Things users create, view, edit, or delete
465
+ - Things the system generates that users care about
466
+ - Configuration objects that change system behavior
467
+ - Credentials, tokens, or keys
468
+
469
+ **Exclude:**
470
+ - Internal data structures (linked lists, hashmaps, caches)
471
+ - Framework-specific concepts (middleware, reducers, controllers)
472
+ - Temporary objects (request context, session state)
473
+
474
+ ### Examples Across Different Project Types
475
+
476
+ **SaaS (Project Management):**
477
+ ```markdown
478
+ ## Project
479
+ A container for related tasks, files, and team members.
480
+
481
+ - **What is it?** A workspace where a team organizes their work. Has a name, description, and member list.
482
+ - **Who creates it?** Any user can create a project from the dashboard.
483
+ - **Who modifies it?** Project owner and admins can rename, archive, or delete.
484
+ - **What depends on it?** All Tasks, Files, and Comments belong to a Project. Deleting a Project cascades to everything inside it.
485
+
486
+ ## Task
487
+ A unit of work assigned to a team member.
488
+
489
+ - **What is it?** An item with a title, description, status (todo/in-progress/done), assignee, and due date.
490
+ - **Who creates it?** Any project member.
491
+ - **Who modifies it?** The assignee or project admin can change status, reassign, or close.
492
+ - **What depends on it?** Comments are attached to Tasks. Time entries reference Tasks. Sprint velocity is calculated from completed Tasks.
493
+ ```
494
+
495
+ **Game (RPG):**
496
+ ```markdown
497
+ ## Character
498
+ The player's in-game avatar.
499
+
500
+ - **What is it?** A persistent game entity with stats (HP, STR, DEX, INT), inventory, equipped items, and quest progress.
501
+ - **Who creates it?** The player, during the character creation screen.
502
+ - **Who modifies it?** The game engine (leveling up, taking damage), the player (equipping items, spending stat points).
503
+ - **What depends on it?** Save files, leaderboards, multiplayer matchmaking.
504
+
505
+ ## Card
506
+ A spell, item, or ability the player can play during combat.
507
+
508
+ - **What is it?** A game object with a name, mana cost, effect description, rarity, and type (attack/defense/utility).
509
+ - **Who creates it?** Game designers (defined in card_database.json). Players discover cards through loot drops.
510
+ - **Who modifies it?** Cards are immutable. Upgrades create a new variant (e.g., "Fireball+" replaces "Fireball").
511
+ - **What depends on it?** Decks are collections of Cards. Combat resolution depends on Card effects. Balance patches modify Card stats globally.
512
+ ```
513
+
514
+ ### Anti-Patterns
515
+
516
+ - ❌ Listing database columns — "User has id, email, password_hash, created_at" is a schema dump, not an entity description.
517
+ - ❌ Including framework concepts — "Controller", "Middleware", "Reducer" are not domain entities.
518
+ - ❌ Skipping "What depends on it?" — This is the most important field. It reveals hidden coupling.
519
+
520
+ ---
521
+
522
+ ## File 5: decisions.md
523
+
524
+ ### What It Answers
525
+ "Why was it built this way instead of some other way?"
526
+
527
+ ### This Is the Most Important File
528
+
529
+ This single file can save weeks of confusion. Most repositories are impossible to understand because nobody recorded *why* architectural choices were made. Without this context, every new contributor (human or AI) will:
530
+ - Try to "fix" things that were intentional
531
+ - Propose alternatives that were already considered and rejected
532
+ - Repeat mistakes that were already learned from
533
+
534
+ ### Structure
535
+
536
+ Each decision follows this pattern:
537
+
538
+ ```markdown
539
+ ## Why [decision]?
540
+
541
+ [Explanation of the context and constraints that led to this choice]
542
+
543
+ [What alternatives were considered and why they were rejected]
544
+
545
+ [What tradeoffs were accepted]
546
+ ```
547
+
548
+ ### How to Research It
549
+
550
+ This is the hardest file to create from code alone. Decisions live in:
551
+
552
+ 1. **Git history** — `git log --oneline` for major refactors or dependency changes
553
+ 2. **Pull request descriptions** — Often explain "why" in the body text
554
+ 3. **Issue tracker** — Closed issues often contain design discussions
555
+ 4. **Code comments** — Look for comments that say "NOTE:", "HACK:", "WORKAROUND:", "TODO:"
556
+ 5. **Config files** — Pinned dependency versions often have a reason
557
+ 6. **Architecture Decision Records (ADRs)** — If they exist, copy them into decisions.md
558
+ 7. **Ask the user** — This is the file where user input is most valuable
559
+
560
+ **Questions to ask the user for this file:**
561
+
562
+ - "Were there any major decisions where you debated between two approaches?"
563
+ - "Is there anything in the codebase that looks weird but has a good reason for existing?"
564
+ - "What dependencies did you evaluate before choosing the ones you use?"
565
+ - "Are there any constraints imposed by external factors (client requirements, hosting limits, compliance, legacy systems)?"
566
+
567
+ ### What Decisions to Document
568
+
569
+ **Always document:**
570
+ - Programming language choice (if it's not obvious)
571
+ - Framework choice
572
+ - Database choice
573
+ - Authentication method
574
+ - Hosting/deployment strategy
575
+ - Any pinned dependency versions
576
+ - Anything that deviates from "the obvious choice"
577
+
578
+ **Document if relevant:**
579
+ - Why monolith vs. microservices
580
+ - Why SQL vs. NoSQL
581
+ - Why REST vs. GraphQL
582
+ - Why SSR vs. SPA vs. static
583
+ - Why self-hosted vs. managed services
584
+ - Why a specific third-party API was chosen
585
+
586
+ ### Examples Across Different Project Types
587
+
588
+ **Web App:**
589
+ ```markdown
590
+ ## Why Next.js instead of Vite or Create React App?
591
+
592
+ We need server-side rendering for SEO (the landing page and public case studies must be indexable). Vite is faster for development but doesn't provide SSR without additional configuration. CRA is deprecated.
593
+
594
+ The tradeoff: Next.js imposes its own routing conventions and makes it harder to eject to a custom setup later.
595
+
596
+ ## Why Supabase instead of Firebase?
597
+
598
+ Supabase gives us a real PostgreSQL database, which means we can write complex queries (joins, CTEs) without learning a proprietary query language. Firebase's Firestore has no joins.
599
+
600
+ The tradeoff: Supabase's auth and storage are less mature than Firebase's, and the community is smaller.
601
+
602
+ ## Why we don't use an ORM
603
+
604
+ The database schema has 4 tables and will likely never exceed 10. Prisma, Drizzle, and TypeORM all add complexity (code generation, migration files, type mapping) that isn't justified at this scale. We use raw SQL with parameterized queries.
605
+
606
+ The tradeoff: If the schema grows significantly, we'll revisit this.
607
+ ```
608
+
609
+ **Embedded Firmware:**
610
+ ```markdown
611
+ ## Why C instead of Rust?
612
+
613
+ The target microcontroller (STM32F103) has 64KB of flash. Rust's core library and panic handling alone consume ~20KB. Our C firmware uses 31KB. We can't afford the overhead.
614
+
615
+ The tradeoff: No borrow checker, manual memory management, and classic C footguns. We mitigate this with -Wall -Wextra -Werror and a CI pipeline that runs static analysis (cppcheck).
616
+
617
+ ## Why polling instead of interrupt-driven I/O?
618
+
619
+ The sensor sampling rate is 10 Hz. At this frequency, the overhead of setting up and tearing down interrupt contexts exceeds the cost of a simple polling loop. We poll on a 50ms timer tick.
620
+
621
+ The tradeoff: If we add a sensor requiring >100 Hz sampling, we'll need to refactor to interrupts.
622
+ ```
623
+
624
+ ### Anti-Patterns
625
+
626
+ - ❌ "We use React because it's popular" — That's not a reason. WHY is popularity relevant? (Community support? Hiring pool? Existing team knowledge?)
627
+ - ❌ Documenting only technology choices — Also document *design* choices ("Why is the cart stored in localStorage instead of the database?")
628
+ - ❌ Being defensive — Don't justify bad decisions. If something is known to be suboptimal, say so: "We chose X because of time constraints. The better long-term choice would be Y."
629
+
630
+ ---
631
+
632
+ ## File 6: state.json
633
+
634
+ ### What It Answers
635
+ "What's the current health and status of this project, in machine-readable form?"
636
+
637
+ ### Structure
638
+
639
+ ```json
640
+ {
641
+ "version": "1.0.0",
642
+ "health": "active",
643
+ "status": "production",
644
+ "last_audit": "2025-01-15",
645
+ "languages": {},
646
+ "known_issues": [],
647
+ "dependencies": [],
648
+ "constraints": [],
649
+ "vibe_version": "1.0",
650
+ "vibe_updated": "2025-01-15T10:00:00Z"
651
+ }
652
+ ```
653
+
654
+ ### Field Definitions
655
+
656
+ | Field | Type | Required | Description |
657
+ |---|---|---|---|
658
+ | `version` | string | ✅ | Project version (semver preferred) |
659
+ | `health` | enum | ✅ | `"active"`, `"maintenance"`, `"archived"`, `"experimental"` |
660
+ | `status` | string | ✅ | `"prototype"`, `"alpha"`, `"beta"`, `"production"`, `"deprecated"` |
661
+ | `last_audit` | string | ✅ | ISO date of last .vibe review |
662
+ | `languages` | object | ✅ | Map of language → version/details |
663
+ | `known_issues` | string[] | ✅ | Human-readable list of known problems |
664
+ | `dependencies` | string[] or object | ✅ | Major external dependencies (not every npm package — just the important ones) |
665
+ | `constraints` | string[] | ✅ | Hard rules that must not be violated |
666
+ | `vibe_version` | string | ✅ | Version of the .vibe spec used (currently `"1.0"`) |
667
+ | `vibe_updated` | string | ✅ | ISO timestamp of last .vibe update |
668
+
669
+ ### What to Include in `known_issues`
670
+
671
+ Only items that affect the user experience or developer workflow:
672
+ - ✅ "Search is slow on datasets larger than 10,000 records"
673
+ - ✅ "OAuth login fails on Safari due to cookie SameSite issue"
674
+ - ❌ "The utils.ts file needs refactoring" (internal, doesn't affect anyone)
675
+
676
+ ### What to Include in `constraints`
677
+
678
+ Rules that a new contributor must not violate:
679
+ - ✅ "Must support Node.js 18+ (LTS only)"
680
+ - ✅ "No GPL-licensed dependencies (client requirement)"
681
+ - ✅ "Bundle size must stay under 500KB gzipped"
682
+ - ✅ "All API responses must complete in under 200ms"
683
+
684
+ ### Example (Simple Web App)
685
+
686
+ ```json
687
+ {
688
+ "version": "2.1.0",
689
+ "health": "active",
690
+ "status": "production",
691
+ "last_audit": "2025-06-01",
692
+ "languages": {
693
+ "typescript": "5.4",
694
+ "python": "3.12"
695
+ },
696
+ "known_issues": [
697
+ "PDF export occasionally fails for documents with >50 pages",
698
+ "Dark mode has contrast issues on the settings page"
699
+ ],
700
+ "dependencies": [
701
+ "next.js",
702
+ "supabase",
703
+ "openai",
704
+ "stripe",
705
+ "resend"
706
+ ],
707
+ "constraints": [
708
+ "Node.js 18+ required",
709
+ "Must work offline after initial load",
710
+ "No tracking or analytics scripts",
711
+ "OpenAI API key must be server-side only"
712
+ ],
713
+ "vibe_version": "1.0",
714
+ "vibe_updated": "2025-06-01T14:30:00Z"
715
+ }
716
+ ```
717
+
718
+ ---
719
+
720
+ ## The Update Protocol
721
+
722
+ The `.vibe/` folder is a **living document**. It must be updated whenever the project changes in a way that affects intent, architecture, flows, entities, decisions, or health.
723
+
724
+ ### When to Update
725
+
726
+ | Event | What to Update |
727
+ |---|---|
728
+ | New feature added | `flows.md` (new user journey), `entities.md` (new nouns), `state.json` (version) |
729
+ | Major refactor | `architecture.md` (if systems changed), `decisions.md` (why you refactored) |
730
+ | New dependency added | `decisions.md` (why this dep?), `state.json` (dependencies list) |
731
+ | Bug discovered | `state.json` (known_issues) |
732
+ | Bug fixed | `state.json` (remove from known_issues, bump version) |
733
+ | Constraint changed | `state.json` (constraints), `decisions.md` (why the change) |
734
+ | Project pivoted | `purpose.md` (new purpose), potentially everything |
735
+
736
+ ### The Rule
737
+
738
+ > **Every time an AI agent touches the repository, it must update the .vibe folder. Not just the code — the understanding.**
739
+
740
+ This means the workflow for an AI agent is:
741
+
742
+ ```
743
+ Receive task
744
+
745
+ Read .vibe/ to understand the project
746
+
747
+ Make code changes
748
+
749
+ Update relevant .vibe/ files to reflect new understanding
750
+
751
+ Commit code + .vibe changes together
752
+ ```
753
+
754
+ ### What "Update" Means
755
+
756
+ - **state.json**: Always update `vibe_updated` timestamp. Update `version`, `known_issues`, `dependencies`, and `constraints` as needed.
757
+ - **Other files**: Only update if the *intent* changed. Fixing a typo in code doesn't require updating `architecture.md`. Adding a new payment system does.
758
+
759
+ ---
760
+
761
+ ## Quality Checklist
762
+
763
+ After creating a `.vibe/` folder, verify it passes these checks:
764
+
765
+ ### purpose.md
766
+ - [ ] Can a non-technical person read it and understand what the project does?
767
+ - [ ] Does the "NOT do" section have at least 3 items?
768
+ - [ ] Does "success" describe a concrete scenario, not abstract goals?
769
+
770
+ ### architecture.md
771
+ - [ ] Does the diagram fit on one screen?
772
+ - [ ] Does every arrow/connection have a label (protocol, method)?
773
+ - [ ] Are there fewer than 10 boxes in the diagram? (If more, you're too granular)
774
+ - [ ] Would the diagram survive a language rewrite?
775
+
776
+ ### flows.md
777
+ - [ ] Are there at least 2 flows?
778
+ - [ ] Does each step describe something a user DOES or SEES (not internal processing)?
779
+ - [ ] Can someone follow the flow without reading any code?
780
+
781
+ ### entities.md
782
+ - [ ] Does every entity have all 4 fields (what/who creates/who modifies/what depends)?
783
+ - [ ] Are all entities domain nouns (not framework concepts)?
784
+ - [ ] Is the "what depends on it" field filled out? (This is the most commonly skipped)
785
+
786
+ ### decisions.md
787
+ - [ ] Does every decision explain the alternatives that were rejected?
788
+ - [ ] Does every decision state the tradeoff that was accepted?
789
+ - [ ] Are there at least 3 decisions? (Every project has at least language + framework + database)
790
+
791
+ ### state.json
792
+ - [ ] Is `vibe_updated` set to the current date/time?
793
+ - [ ] Does `known_issues` contain real issues (not aspirational improvements)?
794
+ - [ ] Does `constraints` contain only things that MUST NOT be violated?
795
+ - [ ] Is the JSON valid? (run through a linter)
796
+
797
+ ---
798
+
799
+ ## Common Mistakes
800
+
801
+ ### 1. Writing a second README
802
+ `.vibe/` is not a README. The README says "here's how to install and run this." `.vibe/` says "here's what this IS and WHY it exists." If your `purpose.md` has installation instructions, you're doing it wrong.
803
+
804
+ ### 2. Describing implementation instead of intent
805
+ If you find yourself writing function names, file paths, or class hierarchies, stop. Those belong in code docs. `.vibe/` should survive a complete rewrite.
806
+
807
+ ### 3. Making it too long
808
+ If `architecture.md` is 500 lines, you're describing the codebase, not the architecture. The `.vibe/` folder for a 100,000-line project should be roughly the same size as for a 1,000-line project — because it describes the same number of *systems* and *decisions*.
809
+
810
+ ### 4. Skipping decisions.md
811
+ This is the file people skip because it's hard. It requires knowing *why*, which means talking to the original developers or reading git history. It's also the most valuable file. Don't skip it.
812
+
813
+ ### 5. Not updating state.json
814
+ If `vibe_updated` is 6 months old and the project had 200 commits since then, the `.vibe/` folder is stale and untrustworthy. Always update the timestamp.
815
+
816
+ ### 6. Including sensitive information
817
+ Never put API keys, passwords, internal URLs, or customer data in `.vibe/` files. They're meant to be committed to version control.
818
+
819
+ ---
820
+
821
+ ## FAQ
822
+
823
+ **Q: What if the project is tiny (one file, 200 lines)?**
824
+ A: Still create `.vibe/`. Even a small script has a purpose, makes architectural decisions, and has constraints. The files will just be shorter.
825
+
826
+ **Q: What if I can't figure out the "why" behind a decision?**
827
+ A: Write "Reason unknown — this decision predates available documentation. Best guess: [your hypothesis]." Marking uncertainty is better than guessing or omitting.
828
+
829
+ **Q: Should `.vibe/` be committed to version control?**
830
+ A: Yes. It's part of the project, not a personal note. It should be reviewed in PRs just like code.
831
+
832
+ **Q: What if the project has multiple deployable services (monorepo)?**
833
+ A: One `.vibe/` folder at the root. The `architecture.md` diagram shows all services. If a service is complex enough to need its own `.vibe/`, it should probably be its own repository.
834
+
835
+ **Q: How is this different from Architecture Decision Records (ADRs)?**
836
+ A: ADRs are one file per decision, chronologically ordered, and often contain implementation details. `decisions.md` is a single file with all active decisions, focused on intent. If ADRs exist, use them as source material for `decisions.md`.
837
+
838
+ **Q: Can I add custom files to `.vibe/`?**
839
+ A: No. The power of the standard is that every `.vibe/` folder has exactly the same 6 files. An AI agent (or human) always knows exactly where to look. If you need project-specific documentation, put it in `docs/`.
840
+
841
+ ---
842
+
843
+ ## Version
844
+
845
+ This document describes **.vibe specification version 1.0**.
846
+
847
+ Created: 2026-06-06
848
+ Author: Developed through collaborative iteration between a human systems architect and an AI coding agent during the Omni OS project.