codebase-ai 0.1.4 → 0.3.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.
package/README.md CHANGED
@@ -99,7 +99,7 @@ One command. Zero manual steps.
99
99
 
100
100
  ### Level 1 — Give Claude memory of your project
101
101
 
102
- Only requires Node.js 18+.
102
+ Only requires Node.js 20+.
103
103
 
104
104
  ```bash
105
105
  cd your-project
@@ -241,8 +241,11 @@ codebase fix # auto-repairs everything doctor flags
241
241
 
242
242
  ```bash
243
243
  # Setup
244
- npx codebase # full setup run once per project
245
- codebase setup # re-run wiring (updates commands, hooks, tools)
244
+ # Use `npx codebase` / `codebase init` the first time: scans your project AND wires AI tools + hooks.
245
+ # Use `codebase setup` to re-wire AI tools and hooks only — it does NOT re-scan. Run it when you
246
+ # add a new AI tool or need to reinstall hooks on an existing project.
247
+ npx codebase # full setup — scan + wire AI tools + hooks (run once per project)
248
+ codebase setup # re-wire AI tools and hooks only (no scan)
246
249
 
247
250
  # AI interface (what AI tools call)
248
251
  codebase brief # full project briefing
@@ -300,7 +303,7 @@ npx codebase-ai # try without installing
300
303
  pnpm add -g codebase-ai
301
304
  ```
302
305
 
303
- Zero runtime dependencies. Node.js 18+ only.
306
+ Zero runtime dependencies. Node.js 20+ only.
304
307
 
305
308
  ---
306
309
 
package/commands/build.md CHANGED
@@ -70,102 +70,223 @@ gh label list --limit 1 --json name --jq '.[0].name' 2>/dev/null | grep -q "sim"
70
70
 
71
71
  ## Phase 0 — Orientation
72
72
 
73
- Load project board config, define `add_to_project()` helper, parse flags, auto-triage unlabeled issues all exactly as in `/vb-build`.
73
+ Parse flags from `$ARGUMENTS`. Surface the build queue:
74
74
 
75
- For the implementation plan, use `codebase next` to surface the highest-priority item first:
76
75
  ```bash
77
76
  npx codebase next 2>/dev/null || true
78
77
  ```
79
78
 
80
- ---
79
+ Auto-triage unlabeled open issues:
80
+ ```bash
81
+ UNLABELED=$(gh issue list --state open --json number,labels --jq '[.[] | select(.labels | length == 0)] | .[].number')
82
+ for N in $UNLABELED; do
83
+ gh issue edit $N --add-label "arch"
84
+ done
85
+ ```
81
86
 
82
- ## Phases 1–4Implementation Loop
87
+ Read `CLAUDE.md` if present follow its conventions exactly.
83
88
 
84
- Follow the complete `/vb-build` workflow:
89
+ Print orientation banner:
90
+ ```
91
+ BUILD LOOP — ROUND [R] of [max-rounds]
92
+ ════════════════════════════════════════════════════
93
+ Project: [name from brief]
94
+ Stack: [frameworks from brief]
95
+ Test runner: [commands.test]
96
+ Open arch: [N] issues
97
+ Open bugs: [N] issues
98
+ Mode: [full | --once | --issue N | --dry-run]
99
+ ════════════════════════════════════════════════════
100
+ ```
101
+
102
+ If `--dry-run`: print the issue queue and exit.
103
+
104
+ ---
85
105
 
86
- - **Phase 0.5**Mode selection, approval banner
87
- - **Phase 1** — Plan (read issues, wait for approval, dry-run exit)
88
- - **Phase 2** — Implement (read → implement → verify via Playwright → commit → close)
89
- - **Phase 3** — Carry-forward resolution
90
- - **Phase 4** — Summary
106
+ ## Phase 1Plan
91
107
 
92
- ### codebase integration points
108
+ Fetch the build queue — issues labeled `arch` or `vibekit`, state `open`, sorted by priority:
93
109
 
94
- **Before implementing each issue**, get fresh context:
95
110
  ```bash
96
- npx codebase brief 2>/dev/null > /tmp/cb-brief.json || true
111
+ QUEUE=$(gh issue list --label "arch" --label "vibekit" --state open --json number,title,labels --jq 'sort_by(.number) | .[]')
97
112
  ```
98
113
 
99
- Read `CLAUDE.md` if present follow its conventions exactly.
114
+ If `--issue N` was passed, filter to that single issue.
115
+
116
+ For each issue in the queue:
117
+ 1. Read the full issue body: `gh issue view [N] --json body --jq '.body'`
118
+ 2. Identify affected files from the issue body or `mapped_files` from `codebase next`
119
+ 3. Add to the implementation plan
120
+
121
+ If queue is empty: print "No arch/vibekit issues found. Nothing to build." and exit.
100
122
 
101
- **Branch + commit convention:**
123
+ ---
124
+
125
+ ## Phase 2 — Implement (per issue)
102
126
 
103
- For small fixes (< 50 lines): commit directly to `develop`.
104
- For arch issues (significant changes): use a feature branch → PR.
127
+ For each issue in the plan, execute this sequence:
128
+
129
+ ### 2a. Sync and branch
105
130
 
106
131
  ```bash
107
- # Pre-work: always sync first
108
132
  git fetch origin
109
- git status # abort if dirty uncommitted changes exist
133
+ git status --short # abort if dirty
110
134
  git checkout develop && git pull origin develop
135
+ ```
111
136
 
112
- # For arch issues create a feature branch
137
+ For significant changes (arch issues): create a feature branch.
138
+ For small fixes (< 50 lines): commit directly to develop.
139
+
140
+ ```bash
113
141
  SLUG=$(echo "[issue title]" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | tr -cd 'a-z0-9-' | cut -c1-40)
114
142
  git checkout -b feat/${SLUG}
143
+ ```
144
+
145
+ ### 2b. Read and understand
146
+
147
+ 1. Re-read the issue body for acceptance criteria
148
+ 2. Read all affected files identified in Phase 1
149
+ 3. Read `CLAUDE.md` conventions — follow them exactly
150
+ 4. Check `patterns.architecture` from brief — match existing patterns
151
+
152
+ ### 2c. Implement
153
+
154
+ Write the code. Follow these rules:
155
+ - One issue per implementation — never batch
156
+ - Match existing code style (indentation, naming, patterns)
157
+ - Add tests if the project has a test framework (`quality.test_framework` from brief)
158
+ - No over-engineering — solve exactly what the issue asks
159
+
160
+ ### 2d. Verify
115
161
 
116
- # ... implement the fix ...
162
+ Run the test suite:
163
+ ```bash
164
+ TEST_CMD=$(node -e "try{const b=require('/tmp/cb-brief.json');console.log(b.commands?.test||'')}catch{}" 2>/dev/null)
165
+ [ -z "$TEST_CMD" ] && TEST_CMD="npm test"
166
+ $TEST_CMD
167
+ ```
168
+
169
+ If tests fail: fix the implementation, re-run. Do not proceed with failing tests.
170
+
171
+ If the project has a running dev server and agent-browser is available, verify via browser:
172
+ ```bash
173
+ agent-browser open http://localhost:[port]
174
+ agent-browser snapshot -i
175
+ # Navigate to the affected page, verify the change works
176
+ agent-browser screenshot
177
+ ```
117
178
 
118
- # Stash if you need to switch context mid-work
119
- # git stash && git checkout develop && git stash pop
179
+ ### 2e. Commit and close
120
180
 
121
- # Atomic commit — one commit per issue, never batch unrelated changes
122
- git add [specific files changed]
181
+ For feature branches:
182
+ ```bash
183
+ git add [specific files only]
123
184
  git commit -m "feat(#[N]): [short description]
124
185
 
125
- [1-2 sentence description of what was built]
186
+ [1-2 sentence description]
126
187
  Closes #[N]"
127
188
  git push origin feat/${SLUG}
128
189
 
129
- # Raise PR do not merge directly
130
- gh pr create \
131
- --base develop \
132
- --head feat/${SLUG} \
190
+ gh pr create --base develop --head feat/${SLUG} \
133
191
  --title "feat(#[N]): [short description]" \
134
192
  --body "## What
135
193
  [description]
136
194
 
137
195
  ## Test evidence
138
- [test output or Playwright result]
196
+ [test output or screenshot]
139
197
 
140
198
  Closes #[N]"
141
199
 
142
- # After PR is merged, clean up
200
+ # Wait for PR, then clean up
143
201
  git checkout develop && git pull origin develop
144
202
  git branch -d feat/${SLUG} 2>/dev/null || true
145
203
  ```
146
204
 
147
- For direct `develop` commits (small fixes only):
205
+ For direct develop commits:
148
206
  ```bash
149
- git checkout develop && git pull origin develop
150
- git add [specific files changed]
207
+ git add [specific files only]
151
208
  git commit -m "fix(#[N]): [short description]
152
209
 
153
210
  Closes #[N]"
154
211
  git push origin develop
155
212
  ```
156
213
 
157
- **After closing each issue**, update the manifest so `codebase next` stays current:
214
+ Close the issue:
215
+ ```bash
216
+ gh issue close [N] --comment "Implemented in $(git rev-parse --short HEAD)."
217
+ npx codebase issue close [N] --reason "Implemented in $(git rev-parse --short HEAD)" 2>/dev/null || true
218
+ ```
219
+
220
+ Refresh manifest:
158
221
  ```bash
159
222
  npx codebase scan-only --incremental --quiet --sync
160
223
  ```
161
224
 
162
- **When closing an issue via gh**:
225
+ ### 2f. Repeat
226
+
227
+ Return to Phase 2a for the next issue in the queue.
228
+
229
+ ---
230
+
231
+ ## Phase 3 — Simulate (full loop mode only)
232
+
233
+ Skip if `--once` or `--issue N` was passed.
234
+
235
+ On even rounds: invoke `/simulate --journey-only` (quick verification).
236
+ On odd rounds: invoke `/simulate` (full UX audit + journeys).
237
+
238
+ If `/simulate` creates new bug issues, they enter the queue for the next round.
239
+
240
+ ---
241
+
242
+ ## Phase 4 — Poll and Loop
243
+
244
+ Skip if `--once` or `--issue N` was passed.
245
+
246
+ ```bash
247
+ npx codebase scan-only --quiet --sync
248
+ ```
249
+
250
+ Check for new issues:
163
251
  ```bash
164
- gh issue close [N] --comment "Implemented in $(git rev-parse --short HEAD). Verified via Playwright."
165
- # Also update codebase issue tracking
166
- npx codebase issue close [N] --reason "Implemented in $(git rev-parse --short HEAD)" 2>/dev/null || true
252
+ NEW=$(gh issue list --label "arch" --label "vibekit" --state open --json number --jq 'length')
253
+ ```
254
+
255
+ Check launch readiness:
256
+ ```bash
257
+ BUGS=$(gh issue list --label "bug" --state open --json number --jq 'length')
258
+ ```
259
+
260
+ If `$NEW == 0` and `$BUGS == 0`: print "All issues resolved. Ready for /launch." and exit.
261
+ If round >= `--max-rounds`: print "Max rounds reached. Stopping." and exit.
262
+ Otherwise: increment round counter, return to Phase 1.
263
+
264
+ ---
265
+
266
+ ## Phase 5 — Summary
267
+
268
+ ```
269
+ /build COMPLETE — [R] rounds
270
+ ════════════════════════════════════════════════════
271
+ Issues implemented: [N]
272
+ Issues remaining: [N]
273
+ Tests: [pass/fail]
274
+ Simulate cycles: [N]
275
+
276
+ [If all clear: "Ready for /launch"]
277
+ [If issues remain: "Run /build again or /launch --dry-run to check gates"]
278
+ ════════════════════════════════════════════════════
167
279
  ```
168
280
 
169
- **simulate step** (in full loop mode): invoke `/simulate` with `--journey-only` on even rounds, full on odd rounds.
281
+ ---
282
+
283
+ ## Ground Rules
170
284
 
171
- All other behavior (Playwright verification, project board updates, auto-launch gate, polling) follows the `/vb-build` specification exactly.
285
+ 1. **One issue, one commit** never batch unrelated changes
286
+ 2. **Tests must pass** — do not close an issue with failing tests
287
+ 3. **Follow CLAUDE.md** — project conventions are law
288
+ 4. **Feature branches for arch** — small fixes can go to develop directly
289
+ 5. **Atomic commits** — `git add [specific files]`, never `git add .`
290
+ 6. **No force push** — use `git revert` to undo
291
+ 7. **Refresh manifest after every close** — keeps `codebase next` current
292
+ 8. **Read the issue body** — acceptance criteria are in the body, not just the title
@@ -2,7 +2,7 @@
2
2
  description: Code review (security, quality, deps health, UI/accessibility) + test generation. Outputs GitHub Issues. Uses codebase context.
3
3
  argument-hint: [--security] [--quality] [--deps] [--ui] [--test] [--pr N] [--fix]
4
4
  model: sonnet
5
- allowed-tools: Agent, Bash(gh:*), Bash(git add:*), Bash(git commit:*), Bash(git push:*), Bash(git checkout:*), Bash(git pull:*), Bash(git fetch:*), Bash(git stash:*), Bash(git log:*), Bash(git status:*), Bash(git diff:*), Bash(git rev-parse:*), Bash(git branch:*), Bash(npx:*), Bash(npm:*), Bash(node:*), Bash(pnpm:*), Bash(uv:*), Bash(pip:*), Read, Write, Edit, Glob, Grep
5
+ allowed-tools: Agent, Bash(gh:*), Bash(git add:*), Bash(git commit:*), Bash(git push:*), Bash(git checkout:*), Bash(git pull:*), Bash(git fetch:*), Bash(git stash:*), Bash(git log:*), Bash(git status:*), Bash(git diff:*), Bash(git rev-parse:*), Bash(git branch:*), Bash(npx:*), Bash(npm:*), Bash(node:*), Bash(python:*), Bash(python3:*), Bash(pnpm:*), Bash(uv:*), Bash(pip:*), Read, Write, Edit, Glob, Grep
6
6
  ---
7
7
 
8
8
  # /review
@@ -68,6 +68,7 @@ Follow the complete `/vb-review` workflow across all phases:
68
68
  - **Phase 0** — Scope (`--pr N` or full codebase)
69
69
  - **Phase 1** — Security Review (OWASP top 10, CVEs, secrets, auth/authz)
70
70
  - **Phase 2** — Quality Review (CLAUDE.md conventions, dead code, lint, complexity, defensive programming, minimal code)
71
+ - **Phase 2b** — Dead Code Declutter (stack-aware — runs `/py-declutter` for Python, `/nextjs-declutter` for Next.js)
71
72
  - **Phase 3** — Dependency Health (outdated, vulnerable, alternatives)
72
73
  - **Phase 4** — UI/Accessibility (contrast, ARIA, keyboard, responsive)
73
74
  - **Phase 5** — Consolidate & prioritize
@@ -151,6 +152,49 @@ All other behavior (security agent prompts, CVE research, accessibility checks,
151
152
 
152
153
  ---
153
154
 
155
+ ## Phase 2b — Dead Code Declutter (Stack-Aware)
156
+
157
+ After the quality review, detect the project stack from the brief and run the appropriate declutter skill if installed. This is automatic — no flags needed.
158
+
159
+ ### Detection logic
160
+
161
+ ```bash
162
+ # Read stack from brief (already loaded in Phase 0)
163
+ LANGUAGES=$(node -e "try{const b=require('/tmp/cb-brief.json');console.log((b.stack?.languages||[]).join(','))}catch{}" 2>/dev/null)
164
+ FRAMEWORKS=$(node -e "try{const b=require('/tmp/cb-brief.json');console.log((b.stack?.frameworks||[]).join(','))}catch{}" 2>/dev/null)
165
+ ```
166
+
167
+ ### Dispatch rules
168
+
169
+ | Condition | Action |
170
+ |-----------|--------|
171
+ | `LANGUAGES` contains `python` | Run `/py-declutter` |
172
+ | `FRAMEWORKS` contains `next` or `nextjs` | Run `/nextjs-declutter` |
173
+ | Both match | Run both sequentially (Python first, then Next.js) |
174
+ | Neither matches | Skip Phase 2b — log: "No declutter skill matches this stack" |
175
+
176
+ ### Execution
177
+
178
+ When a matching skill is detected:
179
+ 1. Call `list_skills` via MCP (or `codebase skills` via bash) to confirm the skill is installed
180
+ 2. Read the skill's SKILL.md to understand its workflow (the skill file is at `~/.claude/skills/<name>.skill`)
181
+ 3. Follow the workflow defined in SKILL.md using the tools available in the /review context (Agent, Bash, Read, Write, Edit, Glob, Grep)
182
+ 4. For Python skills: run the analysis scripts via `Bash(python:*)`
183
+ 5. For Node.js skills: run the analysis scripts via `Bash(node:*)`
184
+ 6. Findings with confidence <80% are reported as GitHub Issues (labeled `review,quality,dead-code`)
185
+ 7. Findings with confidence >=80% are auto-removed if `--fix` is active, otherwise reported as issues
186
+ 8. After the skill completes, include its KPI summary (files removed, lines eliminated, functions cleaned) in the Phase 8 summary
187
+
188
+ ### If skill is not installed
189
+
190
+ If the matching skill file is not found in `~/.claude/skills/`, log:
191
+ ```
192
+ Skill [name] not installed — run: codebase setup
193
+ ```
194
+ Then continue to Phase 3. Do not fail the review.
195
+
196
+ ---
197
+
154
198
  ## Phase 2 — Quality Review (Extended Rules)
155
199
 
156
200
  The quality agent must check the following **in addition** to the base `/vb-review` quality rules.
@@ -108,70 +108,253 @@ PREFLIGHT — CYCLE [N]
108
108
 
109
109
  ---
110
110
 
111
- ## Phases 1–7Full Simulation Loop
111
+ ## Phase 1 — Customer Journeys
112
112
 
113
- Follow the complete `/vb-simulate` workflow:
113
+ Skip if `--cx-only` was passed.
114
114
 
115
- - **Phase 1** Customer Journeys (agent-browser, profile generation, triage, inline fixes)
116
- - **Phase 2** — UX Audit (9 dimensions, 3 iterations, page inventory, IA audit, fixes)
117
- - **Phase 3** — Performance Audit (Core Web Vitals via CDP)
118
- - **Phase 4** — Dedup
119
- - **Phase 5** — GitHub Output ([Sim] Cycle N parent issue, Highlights Index update)
120
- - **Phase 6** — GTM Sync (DEMO-SEQUENCE.md)
121
- - **Phase 7** — Status → Loop
115
+ ### 1a. Generate customer profiles
122
116
 
123
- ### codebase integration points
117
+ For each of `--count N` customers (default 3), generate a realistic persona:
118
+ - **Name, role, company** — from roles in `docs/PRODUCT.md`
119
+ - **Country** — from `$ARGUMENTS` or random if not specified
120
+ - **Goals** — 3-5 tasks this persona would do in the app (derived from PRODUCT.md role tasks)
121
+ - **Tech comfort** — varies (some savvy, some not)
124
122
 
125
- **After every inline fix commit**, refresh the manifest so `codebase next` stays current:
126
- ```bash
127
- npx codebase scan-only --incremental --quiet --sync
128
- ```
123
+ ### 1b. Run each journey sequentially
124
+
125
+ For each customer, run a browser session via agent-browser:
129
126
 
130
- **Issue creation** uses the standard `gh issue create` flow. After creating any issue, also run:
131
127
  ```bash
132
- npx codebase issue create "[title]" --message "[body summary]" 2>/dev/null || true
128
+ # Sync before starting
129
+ git fetch origin && git checkout develop && git pull origin develop
130
+
131
+ # Start browser session
132
+ agent-browser open http://localhost:[port]
133
+ agent-browser snapshot -i # accessibility tree → @e1, @e2 refs
133
134
  ```
134
- This keeps the codebase manifest's issue list in sync.
135
135
 
136
- **Pre-work sync (run once at the start of each cycle):**
136
+ **Login** using the detected mechanism from Phase 0:
137
137
  ```bash
138
- git fetch origin
139
- git status # if dirty, stash first: git stash
140
- git checkout develop && git pull origin develop
138
+ agent-browser auth login [role] # if saved
139
+ # OR navigate to login page and fill credentials from PRODUCT.md
141
140
  ```
142
141
 
143
- **Commit convention one atomic commit per fix, never batch:**
142
+ **Execute each goal** as a sequence of browser actions:
143
+ 1. Navigate to the relevant page
144
+ 2. `agent-browser snapshot -i` to read the accessibility tree
145
+ 3. Interact: `click @eN`, `fill @eN "value"`, navigate
146
+ 4. After each action, `snapshot -i` again to verify state changed
147
+ 5. `agent-browser screenshot` to capture evidence
148
+
149
+ **Triage findings** during the journey:
150
+
151
+ | Severity | Criteria | Action |
152
+ |----------|----------|--------|
153
+ | `critical` | App crash, data loss, security hole, blank page | Create issue immediately |
154
+ | `high` | Feature broken, workflow blocked, wrong data shown | Create issue immediately |
155
+ | `medium` | UI glitch, slow load, confusing UX, missing feedback | Create issue, fix inline if < 30 min |
156
+ | `low` | Cosmetic, minor copy, alignment | Create issue, fix inline if < 10 min |
157
+
158
+ **Inline fix flow** (for fixable bugs):
159
+ 1. Read the source file causing the bug
160
+ 2. Fix it
161
+ 3. Verify the fix via browser (`snapshot -i` → confirm change)
162
+ 4. Commit atomically:
144
163
  ```bash
145
- git add [specific files only — never git add .]
164
+ git add [specific files only]
146
165
  git commit -m "fix([severity]): [short description]
147
166
 
148
167
  Simulation cycle [N] — [role] at [company]
149
168
  Page: [route]
150
169
  Closes #[issue-N if exists]"
151
170
  git push origin develop
171
+ npx codebase scan-only --incremental --quiet --sync
152
172
  ```
153
173
 
154
- **If working files are dirty before checkout:**
174
+ **Create GitHub issues** for everything found:
155
175
  ```bash
156
- git stash
157
- git checkout develop && git pull origin develop
158
- git stash pop
176
+ gh issue create --title "[Sim] [severity]: [description]" \
177
+ --label "bug,[severity],sim" \
178
+ --body "## Bug Report
179
+ **Cycle:** [N]
180
+ **Customer:** [name] ([role] at [company])
181
+ **Page:** [route]
182
+ **Steps to reproduce:**
183
+ 1. [step]
184
+ 2. [step]
185
+
186
+ **Expected:** [what should happen]
187
+ **Actual:** [what happened]
188
+ **Screenshot:** [attached or described]
189
+ **Fixed inline:** [yes/no — if yes, commit SHA]"
159
190
  ```
160
191
 
161
- **After each full cycle** run a fresh scan:
192
+ ### 1c. Session log
193
+
194
+ After each customer journey, write an HTML session log to `.vibekit/sessions/cycle-[N]-[role].html` with all screenshots, accessibility trees, and actions taken.
195
+
196
+ ---
197
+
198
+ ## Phase 2 — UX Audit
199
+
200
+ Skip if `--journey-only` was passed.
201
+
202
+ ### 2a. Page inventory
203
+
204
+ Crawl the app to build a page list:
162
205
  ```bash
163
- npx codebase scan-only --quiet --sync
206
+ agent-browser open http://localhost:[port]
207
+ agent-browser snapshot -i
164
208
  ```
209
+ Navigate each link in the accessibility tree. Build a list of all unique routes.
165
210
 
166
- Use agent-browser for all browser automation. One sequential browser session per journey — no parallel tabs. Example session:
211
+ ### 2b. Audit each page across 9 dimensions
212
+
213
+ For each page, evaluate:
214
+
215
+ | # | Dimension | What to check |
216
+ |---|-----------|---------------|
217
+ | 1 | **Visual hierarchy** | Clear heading structure, logical reading order, emphasis on primary actions |
218
+ | 2 | **Navigation** | Breadcrumbs, back buttons, consistent nav, no dead ends |
219
+ | 3 | **Forms & input** | Labels, validation messages, error recovery, tab order |
220
+ | 4 | **Feedback** | Loading states, success/error messages, progress indicators |
221
+ | 5 | **Accessibility** | Contrast ratios, ARIA labels, keyboard navigation, screen reader text |
222
+ | 6 | **Responsive** | Layout at different viewport widths (if testable) |
223
+ | 7 | **Content** | Spelling, grammar, placeholder text, missing copy |
224
+ | 8 | **Performance** | Perceived speed, unnecessary spinners, layout shift |
225
+ | 9 | **Consistency** | Same patterns used across pages, no style drift |
226
+
227
+ Score each dimension 1-10. Repeat for `--iterations N` passes (default 3), improving scores each pass by fixing what you can inline.
228
+
229
+ ### 2c. Fix and commit
230
+
231
+ Same inline fix flow as Phase 1. One commit per fix, push to develop.
232
+
233
+ ---
234
+
235
+ ## Phase 3 — Performance Audit
236
+
237
+ Quick performance check on the top 5 most-visited pages:
238
+ 1. Navigate to each page
239
+ 2. Note perceived load time (fast/medium/slow)
240
+ 3. Check for layout shifts (`snapshot -i` before and after full load)
241
+ 4. Check for unnecessary network requests if visible in page behavior
242
+
243
+ Create issues for any `medium` or `slow` pages with label `performance,sim`.
244
+
245
+ ---
246
+
247
+ ## Phase 4 — Dedup
248
+
249
+ Before creating the cycle summary, deduplicate findings:
167
250
  ```bash
168
- agent-browser open http://localhost:[port]
169
- agent-browser snapshot -i # get @e1, @e2 refs from accessibility tree
170
- agent-browser click @e1
171
- agent-browser fill @e2 "value"
172
- agent-browser screenshot # capture evidence
251
+ EXISTING=$(gh issue list --label "sim" --state open --json title --jq '.[].title')
173
252
  ```
253
+ Skip creating any issue whose title matches an existing open issue (fuzzy — same key words).
174
254
 
175
- Auth persistence: `agent-browser auth save <role>` after login, `agent-browser auth login <role>` to restore. State: `agent-browser state save/load <name>` between pages.
255
+ ---
176
256
 
177
- All other behavior follows the `/vb-simulate` specification exactly.
257
+ ## Phase 5 GitHub Output
258
+
259
+ ### 5a. Create cycle parent issue
260
+
261
+ ```bash
262
+ gh issue create \
263
+ --title "[Sim] Cycle [N] — [date]" \
264
+ --label "cycle,sim" \
265
+ --body "## Simulation Cycle [N]
266
+
267
+ **Date:** [ISO date]
268
+ **Customers:** [count]
269
+ **Bugs found:** [N] (critical: [N], high: [N], medium: [N], low: [N])
270
+ **Fixed inline:** [N]
271
+ **Issues created:** [list of #numbers]
272
+
273
+ ### UX Audit Scores
274
+ | Dimension | Score |
275
+ |-----------|-------|
276
+ | Visual hierarchy | [N]/10 |
277
+ | Navigation | [N]/10 |
278
+ | Forms & input | [N]/10 |
279
+ | Feedback | [N]/10 |
280
+ | Accessibility | [N]/10 |
281
+ | Responsive | [N]/10 |
282
+ | Content | [N]/10 |
283
+ | Performance | [N]/10 |
284
+ | Consistency | [N]/10 |
285
+ | **Average** | **[N]/10** |
286
+
287
+ ### Highlights
288
+ [Notable positive findings — things working well]
289
+
290
+ ### Session Logs
291
+ [Links to .vibekit/sessions/ HTML files]"
292
+ ```
293
+
294
+ ### 5b. Update Highlights Index
295
+
296
+ Find the Highlights Index issue and append new highlights:
297
+ ```bash
298
+ HIGHLIGHTS_N=$(gh issue list --label "highlight" --state all --limit 1 --json number --jq '.[0].number // empty')
299
+ if [ -n "$HIGHLIGHTS_N" ]; then
300
+ gh issue comment $HIGHLIGHTS_N --body "## Cycle [N] Highlights
301
+ [list of positive findings]"
302
+ fi
303
+ ```
304
+
305
+ ---
306
+
307
+ ## Phase 6 — Refresh
308
+
309
+ ```bash
310
+ npx codebase scan-only --quiet --sync
311
+ ```
312
+
313
+ ---
314
+
315
+ ## Phase 7 — Loop
316
+
317
+ Print cycle summary:
318
+ ```
319
+ CYCLE [N] COMPLETE
320
+ ════════════════════════════════════════════════════
321
+ Bugs found: [N]
322
+ Fixed inline: [N]
323
+ Issues created: [N]
324
+ UX average: [N]/10
325
+ Carry bugs: [N]
326
+ ════════════════════════════════════════════════════
327
+ ```
328
+
329
+ If running in continuous mode (no `--journey-only` or `--cx-only`): increment cycle number, return to Phase 0 preflight.
330
+
331
+ Otherwise: exit.
332
+
333
+ ---
334
+
335
+ ## Ground Rules
336
+
337
+ 1. **One fix, one commit** — never batch unrelated changes
338
+ 2. **`git add [specific files]`** — never `git add .`
339
+ 3. **Always push to develop** — no feature branches for inline fixes
340
+ 4. **Create issues for everything** — even things you fix, so there's a record
341
+ 5. **No force push** — use `git revert` to undo
342
+ 6. **Read PRODUCT.md** — personas and roles come from there, never hardcoded
343
+ 7. **Sequential browser sessions** — one tab at a time, no parallel navigation
344
+ 8. **Screenshot evidence** — every bug needs visual proof
345
+ 9. **Dedup before creating** — don't file duplicate issues
346
+ 10. **Refresh manifest after every fix** — keeps `codebase next` current
347
+
348
+ ## Browser Automation Reference (agent-browser)
349
+
350
+ ```bash
351
+ agent-browser open <url> # navigate to URL
352
+ agent-browser snapshot -i # accessibility tree → @e1, @e2 element refs
353
+ agent-browser click @e1 # click element
354
+ agent-browser fill @e2 "text" # type into input
355
+ agent-browser screenshot # capture current page
356
+ agent-browser auth save <profile> # save auth state
357
+ agent-browser auth login <profile> # restore auth state
358
+ agent-browser state save <name> # save page state
359
+ agent-browser state load <name> # restore page state
360
+ ```