@@ -43,78 +43,130 @@ If security issue found:
4343
4444---
4545
46- ## Coding Style
46+ ## DELEGATION TIERS (Hemat Token, Gak Semua Full Pipeline)
4747
48- ### Immutability (CRITICAL)
48+ Tidak semua UI task perlu 3-phase pipeline. Gunakan tier yang tepat:
4949
50- ALWAYS create new objects, NEVER mutate:
50+ | Tier | Flow | Cocok Untuk |
51+ | ------| ------| -------------|
52+ | ** Fast** 🏃 | Leader → @frontend langsung | Typo, spacing, warna, icon swap |
53+ | ** Normal** ⚡ | Leader → @frontend + referensi DESIGN.md | Minor UI change (1-3 komponen) |
54+ | ** Full** 🏗️ | Leader → @designer → Leader → @frontend → Leader → @designer QA | New feature, redesign, design system |
5155
52- ``` javascript
53- // WRONG: Mutation
54- function updateUser (user , name ) {
55- user .name = name; // MUTATION!
56- return user;
57- }
56+ ## SHARED ARTIFACTS PATTERN (Critical — Hemat Ratusan Token)
5857
59- // CORRECT: Immutability
60- function updateUser (user , name ) {
61- return {
62- ... user,
63- name,
64- };
65- }
66- ```
58+ ** Jangan forward data besar di pesan delegasi.** Gunakan file sebagai shared contract:
6759
68- ### File Organization
60+ | Artifact | Isi | Ditulis Oleh | Dibaca Oleh |
61+ | ----------| -----| -------------| -------------|
62+ | ` DESIGN.md ` | Design tokens, direction | @designer | @frontend |
63+ | ` ./specs/{feature}.md ` | Per-component specs | @designer | @frontend |
64+ | ` ./api-contract.md ` | API contract | @leader /@node-developer | @frontend |
65+ | Source code | Implementasi | @frontend | @designer (QA) |
6966
70- MANY SMALL FILES > FEW LARGE FILES:
67+ ** Aturan** :
68+ 1 . Designer: Simpan specs ke DESIGN.md + ./specs/, return ringkasan ke Leader
69+ 2 . Leader: Delegasi dengan referensi file, bukan kutip isi specs
70+ 3 . Frontend: Baca DESIGN.md + specs/ langsung dari file
71+ 4 . Semua agent: Jangan minta Leader forwarding data — baca langsung dari file
7172
72- - High cohesion, low coupling
73- - 200-400 lines typical, 800 max
74- - Extract utilities from large components
75- - Organize by feature/domain, not by type
73+ ### Prinsip: Deteksi Stuck, Bukan Batasi Iterasi
7674
77- ### Error Handling
75+ Task besar MEMBUTUHKAN banyak iterasi. Jangan batasi jumlah iterasi — batasi hanya ketika ** tidak ada progress ** .
7876
79- ALWAYS handle errors comprehensively:
77+ ### Stuck Detection: Same-Result Rule
8078
81- ``` typescript
82- try {
83- const result = await riskyOperation ();
84- return result ;
85- } catch (error ) {
86- console .error (' Operation failed:' , error );
87- throw new Error (' Detailed user-friendly message' );
88- }
89- ```
79+ Jika agent menerima ** hasil/output yang SAMA PERSIS** dari subagent 2 kali berturut-turut:
80+ 1 . STOP re-delegating (subagent stuck, ngulang hasil sama)
81+ 2 . Dokumentasikan apa yang sama
82+ 3 . Eskalasi ke user
9083
91- ### Input Validation
84+ ### Kapan BUKAN Stuck (LANJUTKAN)
9285
93- ALWAYS validate user input:
86+ - Subagent menghasilkan kode berbeda setiap kali → ✅ progress
87+ - Bug fix butuh banyak percobaan dengan pendekatan berbeda → ✅ progress
88+ - Task besar dengan banyak delegasi → ✅ progress
89+ - Pipeline UI bolak-balik Phase 2↔Phase 3 dengan perbaikan nyata → ✅ progress
9490
95- ``` typescript
96- import { z } from ' zod' ;
91+ ---
9792
98- const schema = z .object ({
99- email: z .string ().email (),
100- age: z .number ().int ().min (0 ).max (150 ),
101- });
93+ ## Quality Gate Checklist (ALL AGENTS — MANDATORY)
10294
103- const validated = schema .parse (input );
104- ```
95+ Before ANY agent marks work as ` verified ` , this checklist MUST pass:
96+
97+ ### Mandatory Checks
98+
99+ - [ ] ** Type check passes** (run ` npx tsc --noEmit ` , ` dart analyze ` , or equivalent)
100+ - [ ] ** No console.log/print() statements** in changed files
101+ - [ ] ** No unused imports** in changed files
102+ - [ ] ** Loading/error/empty states handled** for all data-dependent components
103+ - [ ] ** No hardcoded values** that should be config/props/constants
104+ - [ ] ** Immutability preserved** — no mutation of objects/arrays
105+ - [ ] ** Error handling in place** — try/catch or proper error boundaries
106+ - [ ] ** Verification status reported** : ` verified ` / ` partially_verified ` / ` not_verified `
105107
106- ### Code Quality Checklist
108+ ### Verification Commands by Stack
107109
108- Before marking work complete:
110+ | Stack | Minimum Verification | Full Verification |
111+ | -------| -------------------| -------------------|
112+ | ** Nuxt/Vue** | ` npx nuxi typecheck ` | ` npx nuxi typecheck ` + ` npm run lint ` + ` npm run build ` |
113+ | ** React/Next.js** | ` npx tsc --noEmit ` | ` npx tsc --noEmit ` + ` npm run lint ` + ` npm run build ` |
114+ | ** Flutter/Dart** | ` flutter analyze ` | ` flutter analyze ` + ` flutter test ` |
115+ | ** Node.js** | ` npx tsc --noEmit ` | ` npx tsc --noEmit ` + ` npm run test ` |
116+ | ** Angular** | ` ng lint ` | ` ng lint ` + ` ng test --watch=false ` + ` ng build ` |
117+ | ** Python** | ` ruff check . ` or ` pylint ` | ` ruff check . ` + ` mypy . ` + ` pytest ` |
118+ | ** Rust** | ` cargo check ` | ` cargo check ` + ` cargo clippy ` + ` cargo test ` |
119+ | ** Go** | ` go build ./... ` | ` go build ./... ` + ` go vet ./... ` + ` go test ./... ` |
120+ | ** Java/Spring** | ` mvn compile ` or ` gradle build ` | ` mvn verify ` or ` gradle check ` |
121+
122+ ### Quality Enforcement Rules
123+
124+ 1 . ** Must run minimum verification** before reporting ` verified `
125+ 2 . ** If verification fails** , fix errors before reporting
126+ 3 . ** If verification cannot run** (missing config/tools), report as ` partially_verified ` with exact commands for manual verification
127+ 4 . ** Never skip verification** just because it's "a small change"
128+ 5 . ** Code review gate** : For medium+ changes, delegasikan ke ` @code-reviewer ` atau ` @reviewer ` sebelum final delivery
129+
130+ ---
109131
110- - [ ] Code is readable and well-named
111- - [ ] Functions are small (<50 lines)
112- - [ ] Files are focused (<800 lines)
113- - [ ] No deep nesting (>4 levels)
114- - [ ] Proper error handling
115- - [ ] No console.log statements
116- - [ ] No hardcoded values
117- - [ ] No mutation (immutable patterns used)
132+ ## UNIFIED CODING STANDARDS (ALL STACKS)
133+
134+ ### Core Rules (Always Apply)
135+
136+ 1 . ** Immutability** : ALWAYS create new objects, NEVER mutate
137+ 2 . ** Small files** : 200-400 lines typical, 800 max
138+ 3 . ** Small functions** : < 50 lines per function
139+ 4 . ** No deep nesting** : Max 4 levels of indentation
140+ 5 . ** Error handling** : Every operation that can fail MUST have error handling
141+ 6 . ** Input validation** : ALL user inputs validated (Zod, Joi, or equivalent)
142+ 7 . ** No hardcoded secrets** : Always use environment variables
143+ 8 . ** No console.log in production** : Search and remove before marking done
144+
145+ ### Framework-Specific Rules
146+
147+ #### Nuxt/Vue
148+ - Use ` <script setup lang="ts"> ` always
149+ - Use ` useApi ` composable for all API calls
150+ - Prefer Nuxt UI components over custom HTML
151+ - App directory structure (Nuxt 4)
152+
153+ #### React/Next.js
154+ - Use TypeScript ` interface ` for props
155+ - Server Components by default, ` 'use client' ` only when needed
156+ - Use shadcn/ui components over custom implementations
157+ - App Router structure
158+
159+ #### Flutter/Dart
160+ - Use ` final ` by default, ` var ` only when type is obvious
161+ - Follow Clean Architecture (data/domain/presentation)
162+ - Prefer Riverpod or Bloc for state management
163+ - Use GoRouter for navigation
164+
165+ #### Node.js/Express
166+ - ` *.dto.ts ` , ` *.controller.ts ` , ` *.route.ts ` , ` *.middleware.ts ` naming convention
167+ - Use Prisma for database access
168+ - JWT for authentication, stored in httpOnly cookies
169+ - Zod or Joi for input validation
118170
119171---
120172
0 commit comments