@agentikos/omega-os 0.19.5 → 0.19.7

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,462 @@
1
+ ---
2
+ name: QUALITY-ARSENAL-PREAMBLE
3
+ description: >
4
+ Shared doctrine, invariants, and contracts for all 15 Quality Arsenal forensic
5
+ audits (/codeaudit, /debugaudit, /uiuxaudit, /flowaudit, /featureaudit, /perfaudit,
6
+ /secaudit, /a11yaudit, /seoaudit, /copyaudit, /dxaudit, /motionaudit, /dataaudit,
7
+ /apiaudit, /automationaudit, /logicaudit). Every audit MUST implement these contracts.
8
+ Referenced by /metaudit for compliance verification.
9
+ NOT a user-invokable skill — this is a shared source of truth.
10
+ ---
11
+
12
+ # Quality Arsenal Preamble v1.0
13
+
14
+ > *"One doctrine, fourteen implementations, zero drift."*
15
+
16
+ Every Gestalt-Popper forensic audit in the Quality Arsenal inherits the contracts below. Deviations are either (a) declared explicitly with rationale, or (b) a bug caught by `/metaudit`.
17
+
18
+ ---
19
+
20
+ ## 0. THE FIRST LAW (universal, above all others)
21
+
22
+ > **Code lies. Comments lie. Only runtime tells the truth.**
23
+
24
+ Before any finding, any fix, any conclusion: **observe the actual runtime behavior**. Reading code reveals what the author *intended*. Reading logs, traces, outputs, network dumps, file states reveals what *actually happens*. When they disagree, reality wins.
25
+
26
+ **Applied to every audit:**
27
+ - Before claiming "X is broken" → show the runtime evidence (log line, trace, output, screenshot).
28
+ - Before claiming "X works" → verify at runtime, not by reading the code.
29
+ - Before the 3rd code change on the same bug → add logging, reproduce, observe.
30
+ - When a comment says "X is required" but X's purpose is unclear → test the alternative in isolation.
31
+ - When a fix "should work" but symptoms persist → runtime observation is mandatory before the next attempt.
32
+
33
+ **Anti-pattern catastrophe (2026-04-14):** 2h35 wasted on `tmux paste-buffer -p` because the comment said "-p is required". Runtime test with and without `-p`: only *without* worked. The comment lied for years. See `~/.claude/projects/-home-hacker/memory/feedback_live_debug_first.md` for the full protocol.
34
+
35
+ ---
36
+
37
+ ## 1. GESTALT-POPPER DOCTRINE (universal)
38
+
39
+ - **Gestalt clarity gate** — Before any phase runs, identify the *hinge point* of the system under audit (the one element that, if broken, makes everything else worthless). Audit the hinge with 10x scrutiny. Proportional scrutiny elsewhere.
40
+ - **Popper falsification** — Every claim gets a test that could disprove it. A claim that can't be falsified is not a finding, it's an opinion.
41
+ - **Evidence chain** — Every finding has: file:line → what's wrong → why it matters → blast radius → suggested fix. Missing any link = invalid finding.
42
+ - **Adversarial thinking** — For every component: "How would I break this? What if the inputs lie?"
43
+ - **The target is guilty until proven innocent.**
44
+ - **Runtime > code > comments.** When the three disagree, trust them in that order.
45
+
46
+ ---
47
+
48
+ ## 2. SCOPED INVOCATION FLAGS (MANDATORY across all 14)
49
+
50
+ Every audit parses these flags identically. Rule 43 (Linear pipeline) depends on this compatibility.
51
+
52
+ | Flag | Effect | Required when |
53
+ |------|--------|---------------|
54
+ | `--url={page_url}` | Scope URL-based walkthroughs to this page | Linear ticket audits |
55
+ | `--files={comma-separated-paths}` | Scope code-side checks to these files | Targeted code fixes |
56
+ | `--scope={1-line description}` | Free-text scope note in outputs | Multi-audit orchestration |
57
+ | `--ticket={TICKET_ID}` | Link audit to Linear ticket, write results to `.linear-fix/{TICKET}/{audit}.json` | Rule 43 pipeline |
58
+ | `--no-fix` | Dry-run scoring only; skip fix execution | Review before authorize |
59
+ | `--focus={area}` | Per-audit narrower scope with FULL phase depth | Targeted concerns |
60
+
61
+ **FORBIDDEN (rule 46):** `--quick`, `--streamlined`, `--lightweight`, `--light`, `--fast`, `--custom`. If present in user prompt → REFUSE with reference to rule 46. Narrower scope uses `--focus` with full depth per phase.
62
+
63
+ **Mandatory combinations:**
64
+ - `--ticket=X` requires `--url=Y` (can't audit a ticket without knowing the page)
65
+ - Rule 43 dispatches MUST provide `--files`, `--url`, `--ticket`
66
+
67
+ ---
68
+
69
+ ## 3. CONCURRENCY LOCK (MANDATORY)
70
+
71
+ Every audit acquires a lock at Phase 0 to prevent simultaneous runs from stomping outputs.
72
+
73
+ ```bash
74
+ LOCKFILE=".{audit}/.lock"
75
+ mkdir -p ".{audit}"
76
+ if [ -f "$LOCKFILE" ]; then
77
+ LOCK_AGE=$(($(date +%s) - $(stat -c %Y "$LOCKFILE" 2>/dev/null || echo 0)))
78
+ if [ $LOCK_AGE -lt 14400 ]; then # 4h max; rule 46 allows long audits
79
+ echo "ABORT: another /{audit} holds $LOCKFILE (age ${LOCK_AGE}s, PID $(cat $LOCKFILE))."
80
+ echo "Wait or rm $LOCKFILE if stale."
81
+ exit 1
82
+ fi
83
+ echo "WARNING: stale lockfile (>4h), reclaiming"
84
+ fi
85
+ echo $$ > "$LOCKFILE"
86
+ trap "rm -f $LOCKFILE" EXIT
87
+ ```
88
+
89
+ Rule 43's parallel DYNAMIC audit chain (`/codeaudit` + `/uiuxaudit` + `/flowaudit` + `/debugaudit` on the same ticket) uses distinct `.{audit}/` directories, so locks don't collide across different audits — only duplicate invocations of the same audit are blocked.
90
+
91
+ ---
92
+
93
+ ## 4. PHASE RE-AUDIT CAP (MANDATORY)
94
+
95
+ Fix-and-reaudit loops cap at **5 iterations** (aligned with rule 43 step 8b).
96
+
97
+ ```
98
+ iteration = 0
99
+ while score < target_threshold (80 for solo run, 100 for rule-43 ticket audit):
100
+ iteration += 1
101
+ apply fixes from fix-plan.json
102
+ re-run failing phases
103
+ record score trajectory in .{audit}/iterations.md
104
+ if iteration >= 5:
105
+ mark remaining findings as NEEDS_REVIEW in verdict.json
106
+ send Telegram SOS with iterations.md path
107
+ exit loop (do NOT continue indefinitely)
108
+ ```
109
+
110
+ Zero tolerance for silent infinite loops. 5 is a hard cap, not a suggestion.
111
+
112
+ ---
113
+
114
+ ## 5. NON-UI CONTEXT HANDLING (MANDATORY per audit)
115
+
116
+ Not every project has UI/URLs/flows. Each audit declares its compatibility:
117
+
118
+ | Project type | /codeaudit | /debugaudit | /uiuxaudit | /flowaudit | /featureaudit | /perfaudit | /secaudit | /a11yaudit | /seoaudit | /copyaudit | /dxaudit | /motionaudit | /dataaudit | /apiaudit |
119
+ |--------------|-----------|-------------|-----------|-----------|---------------|-----------|-----------|-----------|-----------|-----------|----------|--------------|-----------|-----------|
120
+ | Web app (URLs) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ (if DB) | ✅ (if API) |
121
+ | Mobile (RN/Expo) | ✅ | partial | ✅ | mobile mode | ✅ | ✅ | ✅ | ✅ | N/A | ✅ | ✅ | ✅ | ✅ | ✅ |
122
+ | CLI tool | ✅ | ⚠️ (log-based) | **ABORT** | **ABORT** | ✅ | ✅ (startup/CPU) | ✅ | ✅ (output text) | N/A | ✅ | ✅ (primary!) | **ABORT** | ✅ (if DB) | N/A |
123
+ | Library / SDK | ✅ | N/A | **ABORT** | **ABORT** | ✅ | ✅ | ✅ | N/A | N/A | ✅ (docs) | ✅ | **ABORT** | N/A | ✅ (if API) |
124
+ | Backend-only API | ✅ | partial | **ABORT** | **ABORT** | ✅ | ✅ | ✅ | N/A | N/A | ✅ (docs) | ✅ | **ABORT** | ✅ | ✅ (primary!) |
125
+ | Headless service | ✅ | log-based | **ABORT** | **ABORT** | ✅ | ✅ | ✅ | N/A | N/A | ✅ | ✅ | **ABORT** | ✅ | ✅ |
126
+
127
+ **ABORT behavior**: exit with clear error naming the detected project type and suggesting alternative audits. Never hallucinate findings for missing surfaces.
128
+
129
+ ---
130
+
131
+ ## 6. OUTPUT CONTRACT VERIFICATION (MANDATORY)
132
+
133
+ Every audit declares outputs. Before reporting success, verify they exist with valid schema.
134
+
135
+ ### Required outputs per audit
136
+
137
+ ```
138
+ .{audit}/
139
+ ├── session.log # timestamps, scope, args, duration
140
+ ├── verdict.json # machine-readable score + findings (schema below)
141
+ ├── verdict.md # human-readable final report
142
+ ├── fix-plan.json # prioritized fix tasks (schema below)
143
+ ├── fix-plan.md # human-readable fix plan
144
+ ├── iterations.md # score trajectory (iteration 1..N)
145
+ ├── progress.json # live progress (for watchers)
146
+ ├── telemetry.json # cost + duration (schema below)
147
+ ├── fix-log.md # append-only fix execution log
148
+ └── discovery/ # audit-specific inventories
149
+ ```
150
+
151
+ ### verdict.json schema (MANDATORY)
152
+
153
+ ```json
154
+ {
155
+ "audit": "<audit-name>", // e.g. "codeaudit"
156
+ "version": "<audit-version>", // e.g. "v2.1"
157
+ "preamble_version": "1.0", // MUST match this file's version
158
+ "skill_used": "<audit-name>", // for rule 43 gate compliance
159
+ "score": 95, // /100 normalized
160
+ "raw_score": 395, // raw score
161
+ "raw_max": 420, // applicable max (N/A phases excluded)
162
+ "grade": "A", // S/A/B/C/D/F
163
+ "scope": {
164
+ "url": "...", // if --url provided
165
+ "files": ["..."], // if --files provided
166
+ "ticket": "...", // if --ticket provided
167
+ "free_text": "..." // if --scope provided
168
+ },
169
+ "phases": [
170
+ {"id": 1, "name": "...", "score": 30, "max": 30, "applicable": true}
171
+ ],
172
+ "findings": [
173
+ {
174
+ "id": "F-001",
175
+ "severity": "CRITICAL|HIGH|MEDIUM|LOW",
176
+ "phase": 3,
177
+ "file": "src/auth.ts",
178
+ "line": 42,
179
+ "description": "...",
180
+ "evidence": "...",
181
+ "blast_radius": "...",
182
+ "suggested_fix": "...",
183
+ "cross_audit_confirmations": [] // see below
184
+ }
185
+ ],
186
+ "cross_audit_confirmations": [ // ELEVATION MECHANISM
187
+ {
188
+ "finding_id": "F-001", // this audit's finding
189
+ "confirmed_by": "secaudit", // which other audit confirmed
190
+ "confirmed_finding_id": "F-012", // that audit's corresponding finding
191
+ "elevation": "CRITICAL", // elevated severity (both agree = CRITICAL)
192
+ "evidence_path": "audits/.secaudit/verdict.json"
193
+ }
194
+ ],
195
+ "iterations": 3, // how many fix-and-reaudit loops
196
+ "needs_review": [], // findings that hit 5-iter cap
197
+ "project_signals_detected": [], // auto-detected from package.json (see §16)
198
+ "timestamp_start": "...",
199
+ "timestamp_end": "..."
200
+ }
201
+ ```
202
+
203
+ ### Cross-audit finding elevation (ENFORCEMENT)
204
+
205
+ When two audits produce findings on the same file:line or same concern:
206
+ 1. The later-running audit checks `.{producer_audit}/verdict.json` for matching findings
207
+ 2. If match found: add a `cross_audit_confirmations` entry to its own verdict.json
208
+ 3. Both audits agreeing on same file:line = automatic elevation to CRITICAL
209
+ 4. /metaudit verifies elevation consistency in its Phase 1 compliance check
210
+
211
+ ### telemetry.json schema (MANDATORY)
212
+
213
+ ```json
214
+ {
215
+ "audit": "<name>",
216
+ "version": "<version>",
217
+ "duration_sec": 12840,
218
+ "tokens_used": {"input": 450000, "output": 120000},
219
+ "phases_completed": 23,
220
+ "phases_skipped": [14, 18],
221
+ "phases_applicable": 21,
222
+ "fixes_applied": 47,
223
+ "fix_reverts": 3,
224
+ "telegram_notifications_sent": 9,
225
+ "model": "claude-opus-4-6",
226
+ "preamble_version": "1.0"
227
+ }
228
+ ```
229
+
230
+ ### fix-plan.json schema (MANDATORY)
231
+
232
+ ```json
233
+ {
234
+ "audit": "<name>",
235
+ "generated_at": "...",
236
+ "tasks": [
237
+ {
238
+ "id": "FIX-001",
239
+ "finding_id": "F-001",
240
+ "severity": "HIGH",
241
+ "file": "src/auth.ts",
242
+ "line": 42,
243
+ "description": "...",
244
+ "fix": "...",
245
+ "status": "pending|applied|reverted|needs_review",
246
+ "depends_on": ["FIX-000"],
247
+ "attempts": 0
248
+ }
249
+ ]
250
+ }
251
+ ```
252
+
253
+ ### Output gate (MANDATORY, runs at end of audit)
254
+
255
+ ```
256
+ 1. For each file in the required outputs list:
257
+ - Does it exist? (fail-stop)
258
+ - Does it parse? (JSON: schema check; MD: non-empty)
259
+ - verdict.json.score is a number 0-100
260
+ - verdict.json.skill_used == <audit-name>
261
+ - verdict.json.preamble_version == "1.0"
262
+ 2. If any check fails:
263
+ - Do NOT report success
264
+ - Write .{audit}/OUTPUT_GATE_FAILED.md with details
265
+ - Exit non-zero, Telegram SOS
266
+ 3. Only mark audit "complete" when all checks pass.
267
+ ```
268
+
269
+ ---
270
+
271
+ ## 7. TELEGRAM PROGRESS CHANNEL (MANDATORY)
272
+
273
+ Every audit sends structured notifications. Use helper: `~/.aisb/bin/audit-notify.sh <audit> <event> <details>`.
274
+
275
+ | Event | Timing | Content |
276
+ |-------|--------|---------|
277
+ | `start` | Phase 0 begin | `🚦 /{audit} started on {project} — scope: {scope}` |
278
+ | `progress` | Every 3 phases completed | `📊 /{audit} phase {N}/{total} complete — {phase_name}` |
279
+ | `iteration` | Each fix-and-reaudit cycle | `🔁 /{audit} iteration {N}/5 — score trajectory: {prev} → {curr}` |
280
+ | `verdict` | Phase 21 (final score) | `🎯 /{audit} done — score {X}/100 — see {verdict.md path}` |
281
+ | `abort` | Any ABORT condition | `🛑 /{audit} aborted — reason: {reason}` |
282
+ | `sos` | 5-iter cap, lock collision, output-gate fail, unrecoverable error | `🆘 /{audit} SOS — {diag_file_path}` |
283
+
284
+ ---
285
+
286
+ ## 8. DISCOVERY-DRIFT CHECK (MANDATORY on resumed audits)
287
+
288
+ If `.{audit}/discovery/` exists and is older than 1h:
289
+ 1. Re-run light discovery pass
290
+ 2. Diff against existing inventory
291
+ 3. If diff detected: flag as DRIFT, abort or user-confirm
292
+ 4. Never trust stale discovery — the codebase moves
293
+
294
+ ---
295
+
296
+ ## 9. SELF-TELEMETRY (MANDATORY)
297
+
298
+ Emit `.{audit}/telemetry.json` at completion (schema in §6). Used by `/metaudit` + capacity planning.
299
+
300
+ ---
301
+
302
+ ## 10. DEPRECATION REGISTRY
303
+
304
+ Check `~/.claude/DEPRECATED.md` for deprecated skill/command names before invoking cross-references. If an audit references a deprecated name, surface it as a finding.
305
+
306
+ Current known deprecations (as of 2026-04-14):
307
+ - `/hunt` → `/debugaudit` (renamed 2026-03-26)
308
+ - `/delegate` → route via `/ceo`, `/cto`, `/cmo`, `/cpo` (never implemented as standalone)
309
+ - `/remotion` → removed (no replacement; use `/creative_director` pipeline instead)
310
+ - `/head_of_marketing` → `/cmo` or `/content-strategy` skill
311
+ - `/landing_page_analysis` → `/market landing`
312
+ - `/website_brand_analysis` → `/market brand`
313
+ - `/ad_creative_analysis` → `/ads_analyst`
314
+ - `/performance_marketer` → `/market` suite skills
315
+ - `/bmad` → removed
316
+
317
+ ---
318
+
319
+ ## 11. INTEGRATION SMOKE TEST (MANDATORY in fix gate for code-touching audits)
320
+
321
+ Any audit that modifies code (/codeaudit, /debugaudit, /uiuxaudit, /flowaudit, /featureaudit, /perfaudit, /a11yaudit, /apiaudit, /dataaudit, /copyaudit, /seoaudit, /motionaudit) MUST run integration smoke tests in Phase 23 fix gate:
322
+
323
+ ```
324
+ 1. Detect integrations from package.json + env vars:
325
+ - Composio: @composio/sdk, COMPOSIO_API_KEY
326
+ - MCP: @modelcontextprotocol/*, MCP server configs
327
+ - Stripe: stripe, STRIPE_SECRET_KEY
328
+ - Clerk: @clerk/*, CLERK_SECRET_KEY
329
+ - Convex: convex, CONVEX_URL
330
+ - Trigger.dev: @trigger.dev/sdk, TRIGGER_SECRET_KEY
331
+ - Linear: LINEAR_API_KEY
332
+ 2. For each detected integration, run smoke test:
333
+ - Stripe: fetch account.retrieve() with test key
334
+ - Clerk: verify JWT template exists
335
+ - Convex: npx convex dev --once (dry validate)
336
+ - Composio: npx composio ping
337
+ - MCP: test handshake
338
+ 3. Post-fix, re-run the same smoke tests
339
+ 4. If any integration breaks post-fix → revert → mark NEEDS_REVIEW
340
+ 5. Memory basis: "fixes must NEVER break working integrations"
341
+ ```
342
+
343
+ Read-only audits (/copyaudit text-only mode, /secaudit in dry-run) may skip this gate.
344
+
345
+ ---
346
+
347
+ ## 12. RATE-LIMIT SAFETY (MANDATORY for audits that fuzz or hit APIs)
348
+
349
+ /secaudit + /apiaudit make external requests. They MUST respect:
350
+
351
+ ```
352
+ - Max 10 req/s default (override: --rate-limit-override=<N> for authorized tests)
353
+ - Abort on 3 consecutive 429 or 503 responses
354
+ - Never run against production without explicit --prod flag + confirmation
355
+ - Self-pentest (target = own audit infra) ABORT with "not supported — manual review required"
356
+ ```
357
+
358
+ ---
359
+
360
+ ## 13. SCORE NORMALIZATION (MANDATORY)
361
+
362
+ Each audit has its own raw max (varies 280-420 across family). All report to /100:
363
+
364
+ ```
365
+ normalized = round((raw_score / applicable_raw_max) * 100)
366
+ ```
367
+
368
+ Where `applicable_raw_max` excludes phases marked N/A for the project type.
369
+
370
+ Grade boundaries:
371
+ - 90-100: S (Fortress)
372
+ - 80-89: A (Solid)
373
+ - 70-79: B (Good)
374
+ - 60-69: C (Acceptable)
375
+ - 50-59: D (Risky)
376
+ - <50: F (Condemned)
377
+
378
+ ---
379
+
380
+ ## 14. RULE-46 COMPLIANCE (MANDATORY)
381
+
382
+ No audit may:
383
+ - Offer `--quick` / `--streamlined` / `--lightweight` / `--light` / `--fast` / `--custom` modes
384
+ - Substitute "lighter" protocols for phases
385
+ - Skip phases "to save time"
386
+ - Accept "streamlined" instructions from orchestrators — REFUSE and raise alert
387
+
388
+ Narrower scope is achieved via `--focus` flag with FULL phase depth, never degraded depth.
389
+
390
+ ---
391
+
392
+ ## 15. AUDIT REGISTRY
393
+
394
+ | Audit | Max | Phases | Non-UI ABORT | Code-touching | External-fetch | Specialty |
395
+ |-------|-----|--------|-------------|---------------|----------------|-----------|
396
+ | /codeaudit | 420 | 24 | No | Yes | No | SOLID, phantoms, deps |
397
+ | /debugaudit | 360 | 23 | Partial | Yes | No | Runtime bugs, console |
398
+ | /uiuxaudit | 420 | 25 | Yes | Yes | No | Visual coherence |
399
+ | /flowaudit | 400 | 25 | Yes | Yes | No | User journeys |
400
+ | /featureaudit | 320 | 19 | No | Yes | Yes (WebSearch) | PRD completeness |
401
+ | /perfaudit | 360 | 23 | No | Yes | No | Core Web Vitals |
402
+ | /secaudit | 400 | 25 | No | Yes | Yes (fuzz) | OWASP Top 10 |
403
+ | /a11yaudit | 320 | 21 | Partial | Yes | No | WCAG 2.1 AA |
404
+ | /seoaudit | 400 | 25 | Partial | Yes | Yes (crawl) | Crawlability, GEO |
405
+ | /copyaudit | 280 | 19 | No | Yes | No | Claims vs reality |
406
+ | /dxaudit | 320 | 21 | No | Yes | No | Developer onboarding |
407
+ | /motionaudit | 360 | 23 | Yes | Yes | No | Motion purpose |
408
+ | /dataaudit | 320 | 21 | No | **Yes (DESTRUCTIVE)** | No | Schema + integrity |
409
+ | /apiaudit | 360 | 23 | No | Yes | Yes (fuzz) | REST/GraphQL contracts |
410
+
411
+ ---
412
+
413
+ ## 16. PROJECT SIGNAL DETECTION (auto-dispatch intelligence)
414
+
415
+ Before dispatching audits based on keyword matching alone, Oracle/AISB SHOULD read the project's actual signals to auto-suggest relevant audit focuses:
416
+
417
+ ```bash
418
+ # Auto-detect from package.json + env vars + file structure
419
+ has_convex = grep -q "convex" package.json → /dataaudit relevant
420
+ has_clerk = grep -q "@clerk" package.json → /secaudit --focus=auth
421
+ has_stripe = grep -q "stripe" package.json → /flowaudit --focus=payment
422
+ has_i18n = grep -qE "next-intl|i18next|lingui" → /copyaudit --focus=i18n + /a11yaudit --focus=rtl
423
+ has_prisma = test -d prisma/ → /dataaudit + /apiaudit
424
+ has_graphql = test -f schema.graphql → /apiaudit --mode=graphql
425
+ has_ci = test -f .github/workflows/*.yml → /dxaudit --focus=cicd
426
+ has_motion = grep -qE "framer-motion|gsap|three" → /motionaudit relevant
427
+ has_tailwind = test -f tailwind.config.* → /uiuxaudit relevant
428
+ no_ui = ! grep -qE "react|vue|svelte|next" → ABORT /uiuxaudit /flowaudit /motionaudit
429
+ ```
430
+
431
+ Emit detected signals in verdict.json as `project_signals_detected: ["convex", "clerk", "stripe", ...]`.
432
+
433
+ This makes dispatch SMARTER than keyword-only routing. Example: user says "audit everything" on a Convex+Clerk+Stripe project → system auto-focuses /dataaudit on Convex schema, /secaudit on Clerk auth, /flowaudit on Stripe payment flows — without the user having to specify.
434
+
435
+ ---
436
+
437
+ ## 17. PREAMBLE SELF-CHECK (auto-drift detection)
438
+
439
+ Every audit invocation runs a lightweight Phase 0 pre-flight that verifies its OWN preamble compliance before starting the full pipeline:
440
+
441
+ ```bash
442
+ # 10-second pre-flight (negligible cost)
443
+ AUDIT_FILE="~/.claude/commands/${AUDIT_NAME}.md"
444
+ PREAMBLE="~/.claude/commands/QUALITY-ARSENAL-PREAMBLE.md"
445
+
446
+ # Check preamble exists
447
+ test -f "$PREAMBLE" || { echo "ABORT: Preamble missing. Run /metaudit."; exit 1; }
448
+
449
+ # Check own file declares preamble_version
450
+ grep -q 'preamble_version.*1\.0' "$AUDIT_FILE" || { echo "WARN: ${AUDIT_NAME} may not be preamble-compliant. Run /metaudit --focus preamble."; }
451
+
452
+ # Check own compliance_score
453
+ grep -q '"compliance_score": 100' "$AUDIT_FILE" || { echo "WARN: ${AUDIT_NAME} compliance < 100. Run /metaudit --focus arsenal."; }
454
+ ```
455
+
456
+ This catches drift at the moment it matters — when an audit is about to execute — rather than waiting for a manual /metaudit invocation.
457
+
458
+ ---
459
+
460
+ *Preamble v1.1 — 2026-04-14. Added §16 (project signal detection) + §17 (preamble self-check).*
461
+ *Referenced by all 14 audits + /metaudit compliance scanner.*
462
+ *One doctrine, fourteen implementations, zero drift.*
@@ -0,0 +1,212 @@
1
+ ---
2
+ name: audit-orchestrator
3
+ description: >
4
+ Intelligent audit orchestrator — detects project type + user intent, recommends
5
+ optimal audits with 3 power levels (Quick/Standard/Forensic). Use when user
6
+ says "/audit", "what should I audit", "full audit", "audit my project",
7
+ "audit fast", "audit deep", "find issues", "improve quality", "production
8
+ ready check", "ship-ready audit". Auto-detects project stack and intent
9
+ keywords (speed, security, design, content, accessibility, full) to pick
10
+ best 1-N audits. Dispatches in parallel waves. Reads results from
11
+ audits/.{name}audit/verdict.json after each run.
12
+ disable-model-invocation: false
13
+ ---
14
+
15
+ # /audit-orchestrator — Intelligent Audit Selection + Power Levels
16
+
17
+ You are the **audit conductor**. Given a user request and a project, pick the
18
+ RIGHT audits at the RIGHT power level, dispatch them, and synthesize results.
19
+
20
+ ## How to invoke
21
+
22
+ ```bash
23
+ /audit-orchestrator # interactive: ask user what to audit
24
+ /audit-orchestrator full # run all 17 audits in parallel
25
+ /audit-orchestrator quick # top 5 most-impactful audits at Quick level
26
+ /audit-orchestrator standard # smart selection at Standard level (default)
27
+ /audit-orchestrator forensic # deep Gestalt-Popper on selected audits
28
+ /audit-orchestrator security # secaudit + apiaudit + dataaudit
29
+ /audit-orchestrator performance # perfaudit + seoaudit
30
+ /audit-orchestrator design # uiuxaudit + motionaudit + a11yaudit + copyaudit
31
+ ```
32
+
33
+ ## The 17 audits in the Quality Arsenal
34
+
35
+ | Audit | Domain | When to pick |
36
+ |---|---|---|
37
+ | `/codeaudit` | Code architecture | New codebase, refactor, technical debt |
38
+ | `/secaudit` | Security (OWASP) | Pre-prod, payment handling, auth surfaces |
39
+ | `/uiuxaudit` | Design quality | Visual consistency, design system audit |
40
+ | `/flowaudit` | User journeys | Onboarding, conversion drops, dead-ends |
41
+ | `/debugaudit` | Runtime bugs | Console errors, broken features, smoke test |
42
+ | `/featureaudit` | Completeness | PRD validation, ship-readiness, "what's missing" |
43
+ | `/perfaudit` | Core Web Vitals | Slow site, lighthouse improvement |
44
+ | `/a11yaudit` | WCAG 2.1 AA | Accessibility, screen readers, contrast |
45
+ | `/seoaudit` | Discoverability | Search ranking, GEO/AEO, schema markup |
46
+ | `/dataaudit` | Schema integrity | Orphaned records, migrations, RGPD |
47
+ | `/apiaudit` | API contracts | Endpoint quality, auth matrix, rate limits |
48
+ | `/copyaudit` | Messaging | Claims vs reality, CTA, tone |
49
+ | `/dxaudit` | Dev experience | README quality, onboarding new devs |
50
+ | `/motionaudit` | Animation design | Transitions, easing, motion brand DNA |
51
+ | `/automationaudit` | Cron/scripts | Daemon health, scheduled tasks reliability |
52
+ | `/logicaudit` | Architecture | Algorithm efficiency, redundant logic |
53
+ | `/retentionaudit` | Product/CPO | Feature opportunities, RICE roadmap (READ-ONLY) |
54
+
55
+ ## The 3 Power Levels
56
+
57
+ ### ⚡ Level 1 — Quick (5-15 min)
58
+ - Top 5 critical findings only
59
+ - Skip Plan + Fix phases
60
+ - Output: `audits/.{name}audit/quick-report.md` (no verdict.json scoring)
61
+ - Use case: gut-check before a meeting, fast triage
62
+
63
+ ### 🎯 Level 2 — Standard (30-60 min, DEFAULT)
64
+ - Full phases: Audit → Plan → Fix → Re-audit
65
+ - Score normalized /100
66
+ - Output: complete `audits/.{name}audit/verdict.json` + reports
67
+ - Use case: regular quality cycle, pre-PR validation
68
+
69
+ ### 🔬 Level 3 — Forensic (1-4h per audit)
70
+ - Full Gestalt-Popper protocol, all phases extended
71
+ - Auto-fix every finding P0/P1/P2
72
+ - Re-audit cycles until 100/100 (or 3 cycle cap)
73
+ - Output: forensic-grade with falsification proofs + telemetry
74
+ - Use case: pre-launch, security/compliance gate, "make it bulletproof"
75
+
76
+ ## Smart Selection Algorithm
77
+
78
+ When user says ambiguous request like "audit my project":
79
+
80
+ ```
81
+ 1. DETECT PROJECT TYPE
82
+ - Check package.json: React/Next.js/Vue → UI audits relevant
83
+ - Check requirements.txt/pyproject.toml: Python → no motion/uiux
84
+ - Check .convex/ or prisma/: dataaudit relevant
85
+ - Check api/ or routes/: apiaudit relevant
86
+ - Check .github/workflows/: dxaudit + automationaudit
87
+ - No src/ but docs/: feature/copy/seo only (docs project)
88
+
89
+ 2. PARSE INTENT KEYWORDS (English + French)
90
+ - "speed/fast/lent/lenteur" → perfaudit (+ seoaudit if web)
91
+ - "security/sec/vuln/secure/sécurité" → secaudit + apiaudit
92
+ - "design/visual/UI/UX/style" → uiuxaudit + motionaudit
93
+ - "content/copy/messaging/text" → copyaudit
94
+ - "accessibility/a11y/WCAG/handicap" → a11yaudit
95
+ - "API/endpoint/contract" → apiaudit + dataaudit
96
+ - "complete/missing/done/ship-ready" → featureaudit
97
+ - "code/quality/refactor" → codeaudit + logicaudit
98
+ - "retention/features/CPO/sticky" → retentionaudit
99
+ - "data/schema/migration" → dataaudit
100
+ - "automation/cron/scripts" → automationaudit
101
+ - "bug/error/broken/runtime" → debugaudit
102
+ - "redesign/refonte/dashboard" → refontaudit
103
+ - "full/all/everything/complet" → ALL 17 audits
104
+
105
+ 3. PICK POWER LEVEL
106
+ - Default: Standard (Level 2)
107
+ - User mentions "quick/fast/rapide" → Quick (Level 1)
108
+ - User mentions "deep/forensic/production/launch/100" → Forensic (Level 3)
109
+
110
+ 4. CHECK PROJECT MATURITY
111
+ - Empty src/ or fresh scaffold → skip code-focused audits, run featureaudit+copyaudit
112
+ - Mature codebase → all relevant
113
+ - Pre-launch → add secaudit + a11yaudit + perfaudit (the "go-live trio")
114
+ ```
115
+
116
+ ## Execution Plan Output
117
+
118
+ Before dispatching, OUTPUT a plan like:
119
+
120
+ ```
121
+ 🎯 AUDIT PLAN — {project_name}
122
+
123
+ Detected:
124
+ Stack: Next.js + Tailwind + Convex
125
+ Maturity: Production (12 months)
126
+ Intent: "make sure it's secure before launch"
127
+
128
+ Recommended (Power Level: Forensic):
129
+ 1. /secaudit (OWASP + payment surfaces — primary)
130
+ 2. /apiaudit (auth matrix + rate limits — secondary)
131
+ 3. /dataaudit (RGPD + orphan records — context for /apiaudit)
132
+ 4. /a11yaudit (legal compliance — go-live blocker)
133
+ 5. /perfaudit (CWV — go-live blocker)
134
+
135
+ Estimated duration: 4-6h (parallel waves)
136
+ Estimated tokens: ~800K
137
+
138
+ Approve? [y/n/customize]
139
+ ```
140
+
141
+ ## Full Audit Mode
142
+
143
+ When user says "full audit" / "audit complet" / "tous les audits":
144
+
145
+ 1. Dispatch ALL 17 audits in 3 parallel waves (file-safety partitioned):
146
+ - **Wave 1** (read-only, can parallel): codeaudit, logicaudit, dataaudit, apiaudit, seoaudit, featureaudit, retentionaudit, copyaudit, dxaudit
147
+ - **Wave 2** (after Wave 1 verdicts exist): secaudit (reads apiaudit), perfaudit, debugaudit, automationaudit
148
+ - **Wave 3** (UI bundle, after Wave 1): uiuxaudit, motionaudit, a11yaudit, flowaudit
149
+ 2. After all done, generate `audits/SYNTHESIS.md` aggregating scores
150
+ 3. Score the project: average /100 across all audits + flag any < 80
151
+ 4. Telegram report with verdict + button to view each detailed report
152
+
153
+ ## State Tracking
154
+
155
+ Read `audits/SYNTHESIS.md` at start to know what's already done:
156
+
157
+ ```yaml
158
+ last_full_audit: 2026-05-13T12:00:00Z
159
+ scores:
160
+ codeaudit: 92/A
161
+ secaudit: 88/A
162
+ uiuxaudit: 91/S
163
+ ...
164
+ status:
165
+ fresh: [codeaudit, secaudit] # < 7 days old
166
+ stale: [perfaudit] # 7-30 days old
167
+ expired: [a11yaudit] # > 30 days, recommend re-run
168
+ ```
169
+
170
+ ## Output Convention
171
+
172
+ ALL audits MUST write to `audits/.{name}audit/` (the canonical post-2026-05-13
173
+ location). Never to `./.{name}audit/` at project root. The new audit-orchestrator
174
+ + audit-tracker skills assume this canonical path.
175
+
176
+ ## Anti-patterns
177
+
178
+ - ❌ Running `/codeaudit` when project has no source code (use /dxaudit instead)
179
+ - ❌ Running `/motionaudit` on CLI/library project (it ABORTS automatically)
180
+ - ❌ Forensic level on every audit (token waste; use Standard unless go-live)
181
+ - ❌ Skipping the plan-confirmation step (user wants to see what you'll run)
182
+ - ❌ Running audits in serial when waves allow parallelism
183
+ - ❌ Treating retentionaudit as fix-mode (it's READ-ONLY by design)
184
+
185
+ ## Workflow
186
+
187
+ ```
188
+ User: "/audit-orchestrator security"
189
+
190
+ You: parse "security" → secaudit + apiaudit + dataaudit
191
+ You: detect project at Standard level (no "deep/forensic" keyword)
192
+ You: emit plan markdown, ask confirmation
193
+
194
+ User: "y"
195
+
196
+ You: dispatch 3 audits in parallel via tmux work sessions
197
+ You: monitor verdict.json files appearing under audits/.{name}/
198
+ You: when all 3 done, write audits/SYNTHESIS.md
199
+ You: send Telegram report with aggregate score + per-audit links
200
+ ```
201
+
202
+ ## When to invoke alternative skills
203
+
204
+ - For a SINGLE specific audit → user types `/codeaudit` directly (not via orchestrator)
205
+ - For audit setup / .gitignore / progress dashboard → use `/audit-tracker`
206
+ - For oracle dispatch of audit chain → use `/aisb full`
207
+
208
+ ## Sources
209
+
210
+ - 17 Quality Arsenal audits in `~/.claude/commands/`
211
+ - Helper docs: `ARSENAL-ORCHESTRATION-PLAYBOOK.md`, `ARSENAL-INTERCONNECTIONS.md`
212
+ - Public mirror: https://github.com/agentik-os/quality-arsenal