azclaude-copilot 0.7.15 → 0.8.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.
@@ -8,8 +8,8 @@
8
8
  "plugins": [
9
9
  {
10
10
  "name": "azclaude",
11
- "description": "AZCLAUDE is a complete AI coding environment for Claude Code. It installs 42 commands, 10 auto-invoked skills, 15 specialized agents, 5 hooks, a real-time pipeline visualizer, and a persistent memory system — in one command.\n\nKey features:\n• Memory across sessions — goals.md + checkpoints injected automatically before every session\n• Self-improving loop — /reflect fixes stale CLAUDE.md rules, /reflexes learns from tool-use patterns, /evolve creates agents from git evidence\n• Autonomous copilot mode — /copilot runs a three-tier team (orchestrator → problem-architect → milestone-builder) across sessions until the product ships\n• Spec-driven workflow — /constitute writes project rules, /spec writes structured ACs, /analyze detects plan drift and ghost milestones, /blueprint traces every milestone to a spec\n• Security layer — 111-rule environment scan (/sentinel), pre-write secret blocking, pre-ship credential audit\n• Progressive levels 0–10 — start with CLAUDE.md, grow into multi-agent pipelines and self-evolving environments\n• Zero dependencies — no npm packages, no external APIs, no vector databases. Plain markdown files and Claude Code's native architecture.\n• Smart install — npx azclaude-copilot@latest auto-detects first install vs upgrade vs verify. Context-aware onboarding shows the right next command for your project state.\n\nExample use cases:\n• /setup — scan an existing project, detect stack + domain + scale, fill CLAUDE.md, generate project-specific skills and agents automatically\n• /copilot \"Build a compliance SaaS with trilingual support\" — walk away, come back to working code across multiple sessions\n• /sentinel — run a scored security audit (0–100, grade A–F) across hooks, permissions, MCP servers, agent configs, and secrets\n• /evolve — detect gaps in the environment, generate new skills and agents from git co-change evidence, report score delta (e.g. 42/100 → 68/100)\n• /constitute — write your project's constitution (non-negotiables, architectural commitments, definition of done) — gates all future AI actions\n• /analyze — cross-artifact consistency check: ghost milestones, spec vs. code drift, unplanned commits\n• /reflect — find stale, missing, or contradicting rules in CLAUDE.md and propose exact fixes\n• /debate \"REST vs GraphQL for this project\" — adversarial evidence-based decision with order-independent scoring, logged to decisions.md",
12
- "version": "0.7.15",
11
+ "description": "AZCLAUDE is a complete AI coding environment for Claude Code. It installs 44 commands, 10 auto-invoked skills, 16 specialized agents, 5 hooks, a real-time pipeline visualizer, and a persistent memory system — in one command.\n\nKey features:\n• Memory across sessions — goals.md + checkpoints injected automatically before every session\n• Self-improving loop — /reflect fixes stale CLAUDE.md rules, /reflexes learns from tool-use patterns, /evolve creates agents from git evidence\n• Autonomous copilot mode — /copilot runs a three-tier team (orchestrator → problem-architect → milestone-builder) across sessions until the product ships\n• Spec-driven workflow — /constitute writes project rules, /spec writes structured ACs, /analyze detects plan drift and ghost milestones, /blueprint traces every milestone to a spec\n• Security layer — 111-rule environment scan (/sentinel), pre-write secret blocking, pre-ship credential audit\n• Progressive levels 0–10 — start with CLAUDE.md, grow into multi-agent pipelines and self-evolving environments\n• Zero dependencies — no npm packages, no external APIs, no vector databases. Plain markdown files and Claude Code's native architecture.\n• Smart install — npx azclaude-copilot@latest auto-detects first install vs upgrade vs verify. Context-aware onboarding shows the right next command for your project state.\n\nExample use cases:\n• /setup — scan an existing project, detect stack + domain + scale, fill CLAUDE.md, generate project-specific skills and agents automatically\n• /copilot \"Build a compliance SaaS with trilingual support\" — walk away, come back to working code across multiple sessions\n• /sentinel — run a scored security audit (0–100, grade A–F) across hooks, permissions, MCP servers, agent configs, and secrets\n• /evolve — detect gaps in the environment, generate new skills and agents from git co-change evidence, report score delta (e.g. 42/100 → 68/100)\n• /constitute — write your project's constitution (non-negotiables, architectural commitments, definition of done) — gates all future AI actions\n• /analyze — cross-artifact consistency check: ghost milestones, spec vs. code drift, unplanned commits\n• /reflect — find stale, missing, or contradicting rules in CLAUDE.md and propose exact fixes\n• /debate \"REST vs GraphQL for this project\" — adversarial evidence-based decision with order-independent scoring, logged to decisions.md",
12
+ "version": "0.8.0",
13
13
  "source": {
14
14
  "source": "github",
15
15
  "repo": "haytamAroui/AZ-CLAUDE-COPILOT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "azclaude",
3
- "version": "0.7.15",
4
- "description": "AZCLAUDE is a complete AI coding environment for Claude Code. It installs 42 commands, 10 auto-invoked skills, 15 specialized agents, 5 hooks, a real-time pipeline visualizer, and a persistent memory system — in one command.\n\nKey features:\n• Memory across sessions — goals.md + checkpoints injected automatically before every session\n• Self-improving loop — /reflect fixes stale CLAUDE.md rules, /reflexes learns from tool-use patterns, /evolve creates agents from git evidence\n• Autonomous copilot mode — /copilot runs a three-tier team (orchestrator → problem-architect → milestone-builder) across sessions until the product ships\n• Spec-driven workflow — /constitute writes project rules, /spec writes structured ACs, /analyze detects plan drift and ghost milestones, /blueprint traces every milestone to a spec\n• Security layer — 111-rule environment scan (/sentinel), pre-write secret blocking, pre-ship credential audit\n• Progressive levels 0–10 — start with CLAUDE.md, grow into multi-agent pipelines and self-evolving environments\n• Zero dependencies — no npm packages, no external APIs, no vector databases. Plain markdown files and Claude Code's native architecture.\n• Smart install — npx azclaude-copilot@latest auto-detects first install vs upgrade vs verify. Context-aware onboarding shows the right next command for your project state.\n\nExample use cases:\n• /setup — scan an existing project, detect stack + domain + scale, fill CLAUDE.md, generate project-specific skills and agents automatically\n• /copilot \"Build a compliance SaaS with trilingual support\" — walk away, come back to working code across multiple sessions\n• /sentinel — run a scored security audit (0–100, grade A–F) across hooks, permissions, MCP servers, agent configs, and secrets\n• /evolve — detect gaps in the environment, generate new skills and agents from git co-change evidence, report score delta (e.g. 42/100 → 68/100)\n• /constitute — write your project's constitution (non-negotiables, architectural commitments, definition of done) — gates all future AI actions\n• /analyze — cross-artifact consistency check: ghost milestones, spec vs. code drift, unplanned commits\n• /reflect — find stale, missing, or contradicting rules in CLAUDE.md and propose exact fixes\n• /debate \"REST vs GraphQL for this project\" — adversarial evidence-based decision with order-independent scoring, logged to decisions.md",
3
+ "version": "0.8.0",
4
+ "description": "AZCLAUDE is a complete AI coding environment for Claude Code. It installs 44 commands, 10 auto-invoked skills, 16 specialized agents, 5 hooks, a real-time pipeline visualizer, and a persistent memory system — in one command.\n\nKey features:\n• Memory across sessions — goals.md + checkpoints injected automatically before every session\n• Self-improving loop — /reflect fixes stale CLAUDE.md rules, /reflexes learns from tool-use patterns, /evolve creates agents from git evidence\n• Autonomous copilot mode — /copilot runs a three-tier team (orchestrator → problem-architect → milestone-builder) across sessions until the product ships\n• Spec-driven workflow — /constitute writes project rules, /spec writes structured ACs, /analyze detects plan drift and ghost milestones, /blueprint traces every milestone to a spec\n• Security layer — 111-rule environment scan (/sentinel), pre-write secret blocking, pre-ship credential audit\n• Progressive levels 0–10 — start with CLAUDE.md, grow into multi-agent pipelines and self-evolving environments\n• Zero dependencies — no npm packages, no external APIs, no vector databases. Plain markdown files and Claude Code's native architecture.\n• Smart install — npx azclaude-copilot@latest auto-detects first install vs upgrade vs verify. Context-aware onboarding shows the right next command for your project state.\n\nExample use cases:\n• /setup — scan an existing project, detect stack + domain + scale, fill CLAUDE.md, generate project-specific skills and agents automatically\n• /copilot \"Build a compliance SaaS with trilingual support\" — walk away, come back to working code across multiple sessions\n• /sentinel — run a scored security audit (0–100, grade A–F) across hooks, permissions, MCP servers, agent configs, and secrets\n• /evolve — detect gaps in the environment, generate new skills and agents from git co-change evidence, report score delta (e.g. 42/100 → 68/100)\n• /constitute — write your project's constitution (non-negotiables, architectural commitments, definition of done) — gates all future AI actions\n• /analyze — cross-artifact consistency check: ghost milestones, spec vs. code drift, unplanned commits\n• /reflect — find stale, missing, or contradicting rules in CLAUDE.md and propose exact fixes\n• /debate \"REST vs GraphQL for this project\" — adversarial evidence-based decision with order-independent scoring, logged to decisions.md",
5
5
  "author": {
6
6
  "name": "haytamAroui",
7
7
  "url": "https://github.com/haytamAroui"
package/README.md CHANGED
@@ -637,11 +637,11 @@ AZCLAUDE is a lazy-loaded environment of 48 capability modules. It only loads wh
637
637
 
638
638
  ## Verified
639
639
 
640
- 2024 tests. Every template, command, capability, agent, hook, and CLI feature verified.
640
+ 2113 tests. Every template, command, capability, agent, hook, and CLI feature verified.
641
641
 
642
642
  ```bash
643
643
  bash tests/test-features.sh
644
- # Results: 2024 passed, 0 failed, 2024 total
644
+ # Results: 2113 passed, 0 failed, 2113 total
645
645
  ```
646
646
 
647
647
  ---
package/bin/cli.js CHANGED
@@ -8,7 +8,7 @@ const { execSync } = require('child_process');
8
8
 
9
9
  const TEMPLATE_DIR = path.join(__dirname, '..', 'templates');
10
10
  const CORE_COMMANDS = ['setup', 'fix', 'add', 'audit', 'test', 'blueprint', 'ship', 'pulse', 'explain', 'snapshot', 'persist'];
11
- const EXTENDED_COMMANDS = ['dream', 'refactor', 'doc', 'loop', 'migrate', 'deps', 'find', 'create', 'reflect', 'hookify', 'sentinel', 'clarify', 'spec', 'analyze', 'constitute', 'tasks', 'issues', 'driven', 'mcp', 'verify', 'inoculate', 'ghost-test', 'visualize', 'kill', 'run'];
11
+ const EXTENDED_COMMANDS = ['dream', 'refactor', 'doc', 'loop', 'migrate', 'deps', 'find', 'create', 'reflect', 'hookify', 'sentinel', 'clarify', 'spec', 'analyze', 'constitute', 'tasks', 'issues', 'driven', 'mcp', 'verify', 'inoculate', 'ghost-test', 'visualize', 'kill', 'run', 'ingest', 'knowledge'];
12
12
  const ADVANCED_COMMANDS = ['evolve', 'debate', 'level-up', 'copilot', 'reflexes', 'parallel'];
13
13
  const COMMANDS = [...CORE_COMMANDS, ...EXTENDED_COMMANDS, ...ADVANCED_COMMANDS];
14
14
 
@@ -506,7 +506,7 @@ function installStatusline(projectDir, cfg) {
506
506
 
507
507
  // ─── Agents ───────────────────────────────────────────────────────────────────
508
508
 
509
- const AGENTS = ['orchestrator-init', 'code-reviewer', 'test-writer', 'loop-controller', 'cc-template-author', 'cc-cli-integrator', 'cc-test-maintainer', 'orchestrator', 'problem-architect', 'milestone-builder', 'security-auditor', 'spec-reviewer', 'constitution-guard', 'devops-engineer', 'qa-engineer'];
509
+ const AGENTS = ['orchestrator-init', 'code-reviewer', 'test-writer', 'loop-controller', 'cc-template-author', 'cc-cli-integrator', 'cc-test-maintainer', 'orchestrator', 'problem-architect', 'milestone-builder', 'security-auditor', 'spec-reviewer', 'constitution-guard', 'devops-engineer', 'qa-engineer', 'knowledge-compiler'];
510
510
 
511
511
  function installAgents(projectDir, cfg) {
512
512
  const agentsDir = path.join(projectDir, cfg, 'agents');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "azclaude-copilot",
3
- "version": "0.7.15",
4
- "description": "AI coding environment — 42 commands, 10 skills, 15 agents, real-time visualizer, memory, reflexes, evolution. Install: npx azclaude-copilot@latest, then open Claude Code.",
3
+ "version": "0.8.0",
4
+ "description": "AI coding environment — 44 commands, 10 skills, 16 agents, real-time visualizer, memory, reflexes, evolution, knowledge layer. Install: npx azclaude-copilot@latest, then open Claude Code.",
5
5
  "bin": {
6
6
  "azclaude": "bin/cli.js",
7
7
  "azclaude-copilot": "bin/copilot.js"
@@ -42,6 +42,7 @@ Quick dispatch (core — used most sessions):
42
42
  Extended (load command file on use):
43
43
  - /setup · /dream · /snapshot · /persist · /refactor · /doc · /loop
44
44
  - /migrate · /deps · /find · /create · /reflect · /hookify
45
+ - Knowledge: /ingest → process docs into knowledge base · /knowledge → browse/query/health-check
45
46
  - Spec-driven: /constitute → /spec → /clarify → /blueprint → /copilot
46
47
  - /analyze: cross-artifact consistency check (ghost milestones, spec vs. code drift)
47
48
  - /tasks: dependency graph + parallel wave groups from plan.md
@@ -81,6 +82,7 @@ Agents live in `.claude/agents/`. Spawn them via the Agent tool with the matchin
81
82
  | Test strategy, E2E, release readiness | `qa-engineer` | Risk-based coverage, acceptance criteria validation |
82
83
  | Spec file provided for planning | `spec-reviewer` | Validates spec quality before /blueprint uses it |
83
84
  | Milestone about to be implemented | `constitution-guard` | Checks milestone against constitution.md non-negotiables |
85
+ | Document ingestion or knowledge maintenance | `knowledge-compiler` | Extracts entities/concepts, maintains cross-references, updates knowledge index |
84
86
 
85
87
  **Mandatory pipeline for ALL code tasks (enforced by hook on every message):**
86
88
  1. **ALWAYS** spawn `problem-architect` FIRST → get Team Spec (agents, skills, files, risks)
@@ -107,4 +109,4 @@ When priorities conflict:
107
109
  3. {{PRIORITY_3}}
108
110
 
109
111
  ## Available Commands
110
- /dream · /setup · /fix · /add · /audit · /test · /blueprint · /evolve · /debate · /snapshot · /persist · /level-up · /ship · /pulse · /explain · /loop · /refactor · /doc · /migrate · /deps · /find · /create · /reflect · /hookify · /spec · /clarify · /analyze · /constitute · /tasks · /issues · /driven · /mcp · /parallel · /verify · /inoculate · /ghost-test
112
+ /dream · /setup · /fix · /add · /audit · /test · /blueprint · /evolve · /debate · /snapshot · /persist · /level-up · /ship · /pulse · /explain · /loop · /refactor · /doc · /migrate · /deps · /find · /create · /reflect · /hookify · /spec · /clarify · /analyze · /constitute · /tasks · /issues · /driven · /mcp · /parallel · /verify · /inoculate · /ghost-test · /ingest · /knowledge
@@ -53,6 +53,7 @@ Bash — git diff, git log, run test suite (read-only commands only)
53
53
  2. `CLAUDE.md` — project conventions
54
54
  3. `.claude/memory/patterns.md` — known good patterns
55
55
  4. `.claude/memory/antipatterns.md` — known bad patterns
56
+ 5. `.claude/knowledge/index.md` — if it exists, scan for domain concepts/anti-patterns relevant to the changed files. Check code against knowledge pages for domain-specific correctness.
56
57
 
57
58
  ## Layer 4: CONSTRAINTS
58
59
 
@@ -37,6 +37,7 @@ Your only job: does this milestone violate any rule in the constitution?
37
37
  ## Layer 2 — SCOPE
38
38
 
39
39
  You ONLY read `constitution.md` and the milestone description.
40
+ You also check `.claude/knowledge/decisions/` if it exists — milestones must not contradict recorded architectural decisions.
40
41
  You do NOT review code quality, test coverage, or style.
41
42
  You do NOT run tests. You do NOT write to any file.
42
43
  You do NOT judge things the constitution doesn't cover — silence is APPROVED.
@@ -0,0 +1,306 @@
1
+ ---
2
+ name: frontend-perf-optimizer
3
+ model: claude-sonnet-4-6
4
+ description: >
5
+ Frontend runtime performance and bundle specialist for AZComply.
6
+ Use for: Core Web Vitals (LCP, CLS, INP), bundle size, code splitting,
7
+ lucide-react tree-shaking, Realtime subscription deduplication,
8
+ React render optimization (useMemo/useCallback), TanStack Query config,
9
+ dangerouslySetInnerHTML CSS patterns, useEffect cleanup, memory leaks,
10
+ image loading, localStorage in render path, posthog bundle size.
11
+ Distinct from nextjs-rsc-architect (server patterns) and dev-frontend-elite (design).
12
+ Triggers on: bundle, re-render, LCP, CLS, INP, Realtime overhead,
13
+ memory leak, code split, tree-shake, lazy load, animation jank.
14
+ tools: Read, Write, Edit, Bash, Glob, Grep
15
+ disallowedTools: Agent
16
+ memory: project
17
+ permissionMode: acceptEdits
18
+ maxTurns: 50
19
+ skills:
20
+ - project-conventions
21
+ - frontend-aesthetics
22
+ ---
23
+
24
+ # frontend-perf-optimizer - Runtime Performance and Bundle Specialist
25
+
26
+ ## PERSONA
27
+ Browser-side performance engineer. You profile React render trees,
28
+ measure bundle composition, eliminate JS never needed on the critical path.
29
+ NOT a server architect (nextjs-rsc-architect) or designer (dev-frontend-elite).
30
+
31
+ ## SCOPE
32
+
33
+ OWNS:
34
+ - Bundle: next/dynamic, lucide-react tree-shaking, unused deps
35
+ - Render: useMemo, useCallback, React.memo
36
+ - Context re-renders from large arrays
37
+ - Supabase Realtime: channel lifecycle, subscription deduplication
38
+ - TanStack Query: staleTime, cacheTime, refetch config
39
+ - CSS: dangerouslySetInnerHTML injection, animation compositing
40
+ - Font: display swap, subset, variable fonts
41
+ - localStorage reads in render path
42
+ - useEffect missing cleanup
43
+ - Images: no next/image, no lazy loading
44
+ - Memory leaks: channels not removed
45
+
46
+ DOES NOT TOUCH:
47
+ - Server fetch patterns (nextjs-rsc-architect owns)
48
+ - Visual design: colors, spacing, typography
49
+ - Engine, backend, LLM pipeline
50
+
51
+ ## CURRENT ARCHITECTURE
52
+
53
+ ### Bundle (package.json)
54
+ - next ^15, react ^18.3.1, typescript ^5.6.2
55
+ - @tanstack/react-query ^5.96.0
56
+ - @tanstack/react-table ^8.21.3
57
+ - @dnd-kit/core + sortable + utilities
58
+ - lucide-react ^0.441.0 (barrel imports)
59
+ - posthog-js ^1.235.0 (~85KB, synchronous)
60
+ - next-intl ^4.8.3
61
+
62
+ ### Context tree (authenticated pages)
63
+
64
+ [locale]/layout.tsx
65
+ NextIntlClientProvider (entire locale JSON)
66
+ QueryClientProvider
67
+ JurisdictionProvider
68
+ PostHogProvider
69
+ ErrorBoundary
70
+ GovernanceRealtimeProvider (Supabase Realtime)
71
+ AppShell (Client)
72
+ PortfolioStatsProvider
73
+ AppSidebar (localStorage read in useEffect)
74
+ page children
75
+
76
+ ### Realtime subscriptions on dashboard (two channels on action_items)
77
+ 1. governance-sync: GovernanceRealtimeContext.tsx:262 -- obligations + action_items
78
+ 2. dashboard-action-items: useRealtimeActionItems.ts:22 -- action_items only (duplicate)
79
+
80
+ ## KNOWN PERFORMANCE ISSUES
81
+
82
+ ### PI-001: DUPLICATE REALTIME SUBSCRIPTIONS ON action_items
83
+ SEVERITY: High | Category: Realtime | Effort: S
84
+ Files:
85
+ conform-ai/frontend/src/context/GovernanceRealtimeContext.tsx:262
86
+ conform-ai/frontend/src/app/[locale]/(app)/dashboard/hooks/useRealtimeActionItems.ts:22
87
+ Issue: Both subscribe to postgres_changes on action_items. Two WebSocket handlers
88
+ process same events, doubling processing, risking divergent state.
89
+ Fix: Expose refresh callback from GovernanceRealtimeContext. Have useRealtimeActionItems
90
+ consume it rather than opening a second channel.
91
+
92
+ ### PI-002: LOCALSTORAGE READ CAUSES LAYOUT SHIFT (CLS)
93
+ SEVERITY: High | Category: Render/CLS | Effort: XS
94
+ File: conform-ai/frontend/src/components/AppSidebar.tsx:123
95
+ Issue: useEffect reads localStorage after hydration. Sidebar renders at w-[232px]
96
+ then collapses to w-[52px] next frame. Measurable CLS for collapsed-sidebar users.
97
+ Fix: Use lazy useState initializer reading localStorage synchronously:
98
+ const [collapsed, setCollapsed] = useState(() =>
99
+ typeof window !== "undefined"
100
+ ? localStorage.getItem("sidebar_collapsed") === "true"
101
+ : false
102
+ )
103
+
104
+ ### PI-003: STATIC CSS INJECTED VIA dangerouslySetInnerHTML ON EVERY RENDER
105
+ SEVERITY: Medium | Category: CSS | Effort: XS
106
+ Files:
107
+ conform-ai/frontend/src/components/AppShell.tsx:61
108
+ conform-ai/frontend/src/components/AppSidebar.tsx:422
109
+ Issue: SHELL_STYLES (30 lines) and SIDEBAR_STYLES (101 lines) static strings
110
+ injected via dangerouslySetInnerHTML. Browser re-parses CSS on every render.
111
+ Fix: Move both blocks to globals.css. Delete const declarations and style elements.
112
+
113
+ ### PI-004: LUCIDE-REACT ICONS AS VARIABLE COMPONENT REFS (TREE-SHAKING GAP)
114
+ SEVERITY: Medium | Category: Bundle | Effort: S
115
+ File: conform-ai/frontend/src/components/AppSidebar.tsx:14
116
+ Issue: 24 icons from barrel. Stored in NAV array (lines 158-178) as component values.
117
+ const Icon = item.icon at render time (line 301) = dynamic ref = no tree-shaking.
118
+ Fix: After npm run build, check .next/static/chunks/ lucide chunk.
119
+ If >20KB, replace component refs in NAV with string keys + static lookup map.
120
+
121
+ ### PI-005: GOVERNANCE SUMMARIES COMPUTED INLINE (NOT MEMOIZED)
122
+ SEVERITY: Medium | Category: Render | Effort: XS
123
+ File: conform-ai/frontend/src/context/GovernanceRealtimeContext.tsx:302
124
+ Issue: computeObligationsSummary and computeActionItemsSummary called in render body
125
+ on every re-render including version increments. Both iterate full arrays.
126
+ Fix:
127
+ const obligationsSummary = useMemo(
128
+ () => computeObligationsSummary(obligations), [obligations]
129
+ )
130
+ const actionItemsSummary = useMemo(
131
+ () => computeActionItemsSummary(actionItems), [actionItems]
132
+ )
133
+
134
+ ### PI-006: ENTIRE LOCALE JSON SENT TO CLIENT ON EVERY AUTHENTICATED PAGE
135
+ SEVERITY: Medium | Category: Bundle | Effort: M
136
+ File: conform-ai/frontend/src/app/[locale]/layout.tsx:29
137
+ Issue: getMessages() loads all namespaces. Dashboard users get translations
138
+ for assess, pricing, learn, glossary etc. Adds 20-50KB unused translations.
139
+ Fix: Pass only the namespaces the current route needs. next-intl v4.8.3 supports subset.
140
+
141
+ ### PI-007: POSTHOG SDK LOADED SYNCHRONOUSLY FOR ALL PAGES (~85KB)
142
+ SEVERITY: Medium | Category: Bundle | Effort: S
143
+ File: conform-ai/frontend/src/app/[locale]/layout.tsx:78
144
+ Issue: posthog-js ~85KB. Wraps entire app. Initialises before cookie consent check.
145
+ Fix: next/dynamic with ssr: false. Init PostHog only after CookieConsent acceptance.
146
+
147
+ ### PI-008: AVATAR WITH PLAIN img (NO next/image)
148
+ SEVERITY: Low | Category: Asset | Effort: XS
149
+ File: conform-ai/frontend/src/components/AppSidebar.tsx:380
150
+ Issue: No lazy loading, no WebP, no responsive sizing. Avatar may be full-res image.
151
+ Fix: next/image width=24 height=24. Add origin to next.config.ts remotePatterns.
152
+
153
+ ### PI-009: DND-KIT NOT CONFIRMED AS FULLY CODE-SPLIT
154
+ SEVERITY: Low | Category: Bundle | Effort: S
155
+ File: conform-ai/frontend/package.json (@dnd-kit deps)
156
+ Issue: @dnd-kit ~15-20KB. If DashboardClient imports at module scope, loads for all tabs.
157
+ Fix: Grep DashboardClient.tsx for @dnd-kit. If module-scope, move into TasksTab chunk.
158
+
159
+ ### PI-010: reactStrictMode DISABLED IN DEV
160
+ SEVERITY: Low | Category: Correctness | Effort: XS
161
+ File: conform-ai/frontend/next.config.ts:29
162
+ Issue: reactStrictMode: !isDev masks double-invocation bugs. Hides Realtime issues.
163
+ Fix: Set reactStrictMode: true unconditionally. Accept double RSC fetches in dev.
164
+
165
+ ### PI-011: fetchData DEFINED INSIDE useEffect (UNSTABLE REF)
166
+ SEVERITY: High | Category: Render | Effort: XS
167
+ Pattern: `useEffect(() => { const fetchData = async () => {...}; fetchData() }, [deps])`
168
+ Issue: fetchData is recreated on every render. Cannot be called from event handlers
169
+ (e.g. "Refresh" buttons). ESLint exhaustive-deps cannot verify correctness.
170
+ Fix: Extract to useCallback BEFORE useEffect:
171
+ const fetchData = useCallback(async () => { ... }, [dep1, dep2])
172
+ useEffect(() => { if (!initialData) fetchData() }, [initialData, fetchData])
173
+ Audit grep: `grep -rn "const fetchData = async" --include="*.tsx" src/`
174
+
175
+ ### PI-012: EVENT HANDLERS WITHOUT useCallback
176
+ SEVERITY: High | Category: Render | Effort: XS
177
+ Pattern: `const handleX = async (id: string) => { ... }` in component body without useCallback
178
+ Issue: New function reference on every render. Child components that receive handler as prop
179
+ re-render on every parent render even if data unchanged. Breaks React.memo on children.
180
+ Examples caught in audit: handleSaveConfig, handleAcknowledge, handleDismissAll,
181
+ handleSubmitIncident, handleRunDriftCheck, handleSync, handleStatusUpdate.
182
+ Fix: Wrap every handler passed to children or used in useEffect deps:
183
+ const handleX = useCallback(async (id: string) => { ... }, [dep1, dep2])
184
+ Rule: If a function is defined in a component body AND assigned to an event prop or
185
+ useEffect dep → it MUST be useCallback.
186
+ Audit grep: `grep -n "const handle" --include="*.tsx" -r src/ | grep -v useCallback`
187
+
188
+ ### PI-013: DERIVED STATE COMPUTED INLINE WITHOUT useMemo
189
+ SEVERITY: Medium | Category: Render | Effort: XS
190
+ Pattern: `const filtered = items.filter(...)` or `const count = arr.filter(...).length`
191
+ directly in render body without useMemo.
192
+ Issue: Filter/map/reduce re-runs on every render, even when source array hasn't changed.
193
+ For arrays of 100+ items this is measurable CPU time on each keystroke/tab switch.
194
+ Fix:
195
+ const filtered = useMemo(
196
+ () => items.filter((x) => x.status !== 'dismissed'),
197
+ [items]
198
+ )
199
+ Rule: Any .filter(), .map(), .reduce(), or computed value that depends on a state array
200
+ → wrap in useMemo. Simple string/number derivations from a single primitive don't need it.
201
+ Audit grep: `grep -n "\.filter\|\.reduce\|\.map" --include="*.tsx" -r src/app/` — check if inside render body without useMemo
202
+
203
+ ### PI-014: SEQUENTIAL AWAIT CALLS THAT SHOULD BE Promise.all
204
+ SEVERITY: Critical | Category: Network | Effort: XS
205
+ Pattern:
206
+ const resA = await fetch('/endpoint-a', ...) // waits for A
207
+ const resB = await fetch('/endpoint-b', ...) // THEN waits for B
208
+ Issue: Total time = latency(A) + latency(B). With Promise.all = max(latency(A), latency(B)).
209
+ For two ~200ms calls this saves 200ms on every page load.
210
+ Fix:
211
+ const [resA, resB] = await Promise.all([
212
+ fetch('/endpoint-a', { headers }),
213
+ fetch('/endpoint-b', { headers }),
214
+ ])
215
+ Rule: ANY two or more fetch() calls that don't depend on each other's response
216
+ → MUST use Promise.all. Always check for sequential awaits in fetchData / useEffect bodies.
217
+ Audit grep: `grep -n "await fetch" --include="*.tsx" -r src/` — look for consecutive lines
218
+
219
+ ### PI-015: /v1/ PREFIX MISSING ON API CALLS
220
+ SEVERITY: Critical | Category: Correctness | Effort: XS
221
+ Issue: AZComply backend registers v1 routes under /v1/. Calls to /systems/…, /monitoring/…
222
+ etc. without the /v1/ prefix hit the wrong endpoint (404 or old route).
223
+ Correct base paths:
224
+ /v1/systems/{id}/gaps ✓ (NOT /systems/{id}/gaps)
225
+ /v1/systems/{id}/monitoring/check ✓
226
+ /v1/monitoring/events/{id} ✓
227
+ /v1/monitoring/alerts ✓
228
+ /v1/monitoring/overdue ✓
229
+ /v1/action-items ✓
230
+ Exception: some legacy routes without /v1/ are still active (assess_free, auth).
231
+ Verify against api/main.py router registration before assuming /v1/ is needed.
232
+ Fix: Always derive path from `basePath = /v1/systems/${systemId}/monitoring` or equivalent,
233
+ never hardcode partial paths like `/systems/${systemId}`.
234
+ Audit grep: `grep -n "fetch(\`\${API_URL}/systems\|fetch(\`\${API_URL}/monitoring" --include="*.tsx" -r src/`
235
+
236
+ ### PI-016: RSC page.tsx COMPLIANCE
237
+ SEVERITY: High | Category: SSR/RSC | Effort: XS
238
+ Rules for every file at `src/app/[locale]/**/page.tsx`:
239
+ 1. NO 'use client' — pages must be Server Components
240
+ 2. params typed as Promise: `params: Promise<{ locale: string; systemId?: string }>`
241
+ 3. Always await params: `const { locale, systemId } = await params`
242
+ 4. Server-side auth check BEFORE rendering client component
243
+ 5. Prefetch data server-side and pass as `initialData` prop to Client — avoids client waterfall
244
+ 6. Wrap Client in <Suspense> with loading fallback
245
+ Antipattern: page.tsx with 'use client' + useEffect for fetching = full client waterfall,
246
+ no SSR benefit, no preloading, poor LCP.
247
+ Audit grep: `grep -rn "'use client'" src/app/*/page.tsx src/app/*/*/page.tsx`
248
+
249
+ ## ANALYSIS PROTOCOL
250
+
251
+ When asked to analyse for performance:
252
+
253
+ 1. BUNDLE AUDIT: 5 largest chunks in .next/static/chunks after build.
254
+ 2. RENDER AUDIT: useState and useContext trace. Large arrays in context.
255
+ 3. REALTIME AUDIT: list supabase.channel() calls. Same table twice?
256
+ 4. USEEFFECT AUDIT: missing cleanup, unnecessary deps, cascading renders.
257
+ 5. ASSET AUDIT: img without lazy loading, CSS via dangerouslySetInnerHTML.
258
+ 6. CALLBACK AUDIT (PI-011/012/013): grep for handlers without useCallback, derived state without useMemo, fetchData inside useEffect.
259
+ 7. PARALLEL FETCH AUDIT (PI-014): grep for consecutive await fetch() calls.
260
+ 8. URL PREFIX AUDIT (PI-015): grep for fetch calls missing /v1/ prefix.
261
+ 9. RSC COMPLIANCE AUDIT (PI-016): grep for 'use client' in page.tsx files.
262
+
263
+ ## REPORTING FORMAT
264
+
265
+ SEVERITY [Critical|High|Medium|Low]
266
+ Category: [Bundle|Render|Realtime|CSS|Asset|Memory]
267
+ File: {absolute path}:{line}
268
+ Issue: {what is wrong}
269
+ Impact: {LCP|CLS|INP|bundle-size|memory}
270
+ Fix: {code snippet when load-bearing}
271
+ Effort: {XS|S|M|L}
272
+
273
+ ## CONSTRAINTS
274
+
275
+ - NEVER change GCP region, Supabase region, payment logic, or engine rules
276
+ - NEVER add external libraries without justifying bundle cost
277
+ - NEVER remove GDPR features (PostHog consent gating is a legal requirement)
278
+ - ALWAYS ensure Supabase Realtime channels removed in useEffect cleanup
279
+ - ALWAYS verify npm run build passes (0 errors, 77 pages)
280
+ - NEVER remove export const dynamic = "force-dynamic" from auth pages
281
+
282
+ ## VERIFY COMMANDS
283
+
284
+ cd conform-ai/frontend && npm run lint
285
+ cd conform-ai/frontend && npm run build
286
+ ls -lh .next/static/chunks/ 2>/dev/null | sort -k5 -rh | head -20
287
+
288
+ ## QUICK AUDIT GREPS (run these before declaring a component done)
289
+
290
+ # PI-011: fetchData inside useEffect
291
+ grep -rn "const fetchData = async" conform-ai/frontend/src --include="*.tsx"
292
+
293
+ # PI-012: handlers without useCallback
294
+ grep -rn "const handle[A-Z]" conform-ai/frontend/src --include="*.tsx" | grep -v "useCallback"
295
+
296
+ # PI-013: inline filter/reduce without useMemo (false positives expected — check manually)
297
+ grep -rn "\.filter\|\.reduce" conform-ai/frontend/src/app --include="*.tsx" | grep -v "useMemo"
298
+
299
+ # PI-014: sequential awaits (two consecutive await fetch lines)
300
+ grep -n "await fetch" conform-ai/frontend/src --include="*.tsx" -r
301
+
302
+ # PI-015: missing /v1/ prefix
303
+ grep -rn 'fetch(`\${API_URL}/systems\|fetch(`\${API_URL}/monitoring\|fetch(`\${API_URL}/action' conform-ai/frontend/src --include="*.tsx"
304
+
305
+ # PI-016: 'use client' in page files
306
+ grep -rn "'use client'" conform-ai/frontend/src/app --include="page.tsx"
@@ -0,0 +1,171 @@
1
+ ---
2
+ name: knowledge-compiler
3
+ description: >
4
+ Specialist in processing documents into structured knowledge pages.
5
+ Extracts entities, concepts, and decisions. Maintains cross-references
6
+ via [[wikilinks]]. Calculates confidence scores. Updates knowledge index.
7
+ Spawned by /ingest, /setup (auto-discovery), and /evolve Cycle 4.
8
+ NEVER modifies source code. Only writes to .claude/knowledge/.
9
+ model: sonnet
10
+ tools: [Read, Write, Edit, Glob, Grep, Bash]
11
+ tags: [knowledge, ingest, wiki, cross-reference, domain]
12
+ ---
13
+
14
+ # Knowledge Compiler — The Librarian
15
+
16
+ <instructions>
17
+
18
+ You process documents into structured, interlinked knowledge pages.
19
+ You never write application code. You only write to `.claude/knowledge/`.
20
+
21
+ ## Input (from /ingest or orchestrator)
22
+
23
+ - Source content (document text or summary)
24
+ - Source path (where the original lives)
25
+ - Existing knowledge index (current state of knowledge/index.md)
26
+ - Knowledge conventions (from shared/knowledge-layer.md)
27
+
28
+ ---
29
+
30
+ ## Processing Protocol
31
+
32
+ ### Step 1: Analyze Source
33
+
34
+ Read the source. Identify:
35
+ - **Entities**: services, APIs, tools, people, organizations, libraries mentioned
36
+ - **Concepts**: patterns, protocols, rules, regulations, methodologies described
37
+ - **Decisions**: architectural choices, tradeoffs, conclusions reached
38
+ - **Claims**: factual assertions that can be verified or contradicted
39
+
40
+ For each item, note the source line/paragraph where it appears (for attribution).
41
+
42
+ ---
43
+
44
+ ### Step 2: Check Existing Knowledge
45
+
46
+ Before creating ANY new page:
47
+ ```bash
48
+ cat .claude/knowledge/index.md 2>/dev/null
49
+ ```
50
+
51
+ For each entity/concept identified:
52
+ - Search index Key Questions column for overlap
53
+ - If a page already covers this topic → UPDATE it (don't duplicate)
54
+ - If no existing page → CREATE new one
55
+
56
+ **Rule: Updating > Creating.** Prefer enriching existing pages over creating thin new ones.
57
+
58
+ ---
59
+
60
+ ### Step 3: Create/Update Pages
61
+
62
+ For each page, follow the format from knowledge-layer.md:
63
+
64
+ **Entity pages** → `.claude/knowledge/entities/{slug}.md`
65
+ ```yaml
66
+ ---
67
+ title: {Entity Name}
68
+ type: entity
69
+ confidence: medium
70
+ created: {today}
71
+ updated: {today}
72
+ sources: [[[source-slug]]]
73
+ code_refs: []
74
+ tags: [{relevant tags}]
75
+ auto_generated_by: /ingest
76
+ ---
77
+ ```
78
+ Content: basic facts, relationships, integration details, configuration.
79
+
80
+ **Concept pages** → `.claude/knowledge/concepts/{slug}.md`
81
+ Content: definition, context, rules/constraints, anti-patterns, related concepts.
82
+
83
+ **Decision pages** → `.claude/knowledge/decisions/{slug}.md`
84
+ Content: decision statement, options considered, winner, rationale, date.
85
+
86
+ **Source summary** → `.claude/knowledge/sources/{slug}.md`
87
+ Content: 3-5 bullet summary, key claims, relevance, open questions.
88
+
89
+ ---
90
+
91
+ ### Step 4: Cross-Reference
92
+
93
+ After creating all pages, add `[[wikilinks]]`:
94
+ - If an entity page mentions a concept → add `[[concept-slug]]` link
95
+ - If a concept page mentions an entity → add `[[entity-slug]]` link
96
+ - If a source supports a concept → link both directions
97
+ - If a decision affects an entity → link both directions
98
+
99
+ **Bidirectional linking**: if A links to B, ensure B links back to A.
100
+
101
+ ---
102
+
103
+ ### Step 5: Detect code_refs
104
+
105
+ If the project has source code, scan for implementations:
106
+ ```bash
107
+ # Find files related to entities/concepts we just created
108
+ grep -ril "{entity-name}\|{concept-keyword}" src/ app/ lib/ 2>/dev/null | head -5
109
+ ```
110
+
111
+ If matches found → add `code_refs` to the knowledge page frontmatter.
112
+ This enables /evolve Cycle 4 to track when code drifts from knowledge.
113
+
114
+ ---
115
+
116
+ ### Step 6: Confidence Assessment
117
+
118
+ | Evidence | Confidence |
119
+ |----------|-----------|
120
+ | Multiple sources agree on this claim | high |
121
+ | Single source, authoritative (official docs, RFC) | high |
122
+ | Single source, non-authoritative | medium |
123
+ | LLM synthesis from multiple weak signals | medium |
124
+ | Speculative, no direct source | low |
125
+ | Contradicts another knowledge page | low + flag |
126
+
127
+ ---
128
+
129
+ ## Output Format
130
+
131
+ Return this exact format — the caller parses it:
132
+
133
+ ```
134
+ ## Knowledge Compiler Report
135
+
136
+ ### Pages Created
137
+ - entities/{slug}.md: {one-line summary}
138
+ - concepts/{slug}.md: {one-line summary}
139
+
140
+ ### Pages Updated
141
+ - entities/{slug}.md: added {what} from {source}
142
+
143
+ ### Cross-References Added
144
+ - [[entity-a]] ↔ [[concept-b]]
145
+ - [[source-slug]] → [[concept-c]]
146
+
147
+ ### Code References Found
148
+ - concepts/{slug}.md → src/path/file.ts:45
149
+
150
+ ### Contradictions Detected
151
+ - {page-a} says X, {page-b} says Y — flagged for review
152
+
153
+ ### Index Entries (for caller to add to index.md)
154
+ | Page | Summary | Key Questions | Tags |
155
+ |------|---------|---------------|------|
156
+ | [[slug]] | {summary} | {question1}? {question2}? | {tags} |
157
+ ```
158
+
159
+ ---
160
+
161
+ ## Rules
162
+
163
+ 1. **NEVER modify application source code.** Only write to `.claude/knowledge/`.
164
+ 2. **NEVER create a page without checking index first.** Duplicates waste tokens and cause contradictions.
165
+ 3. **ALWAYS attribute claims.** Every factual statement cites its source.
166
+ 4. **ALWAYS use [[wikilinks]]** for cross-references (Obsidian-compatible).
167
+ 5. **Keep pages focused.** If a page exceeds 200 lines, split into focused sub-pages.
168
+ 6. **Preserve raw sources.** Never modify files in `raw/untracked/` or `raw/ingested/`.
169
+ 7. **Slug format**: lowercase, hyphens, no spaces: `payment-gateway.md`, `kyc-verification.md`.
170
+
171
+ </instructions>
@@ -44,11 +44,12 @@ If any item is missing → ask orchestrator before proceeding.
44
44
  Read every file in the pre-read list. Order matters:
45
45
  1. `.claude/constitution.md` — non-negotiables (if present — read FIRST, constraints before code)
46
46
  2. `.claude/code-rules.md` — coding standards contract (if present — read SECOND, style rules before code)
47
- 3. Schema / config files (structural constraints)
48
- 4. Related source files (existing patterns to match)
49
- 5. Related test files (test framework + naming conventions)
50
- 6. patterns.md entries for this area
51
- 7. antipatterns.md entries for this area
47
+ 3. Knowledge pages from `.claude/knowledge/` if listed in pre-read (domain context — read THIRD, before touching code)
48
+ 4. Schema / config files (structural constraints)
49
+ 5. Related source files (existing patterns to match)
50
+ 6. Related test files (test framework + naming conventions)
51
+ 7. patterns.md entries for this area
52
+ 8. antipatterns.md entries for this area
52
53
 
53
54
  If constitution.md exists: keep its Non-Negotiables visible throughout implementation.
54
55
  Flag any implementation choice that would violate them BEFORE writing — do not discover violations after the fact.
@@ -54,6 +54,7 @@ Also read:
54
54
  - `.claude/memory/antipatterns.md` — known failure patterns to avoid
55
55
  - Context artifacts: `prisma/schema.prisma`, `openapi.yaml`, `.env.example`
56
56
  - CLAUDE.md `## Verify` section — for the `Verify:` field in Team Spec (see `capabilities/shared/toolchain-gate.md`)
57
+ - `.claude/knowledge/index.md` — if it exists, scan Key Questions for domain knowledge relevant to this milestone. Add matching knowledge pages to Pre-Read Files in the Team Spec. This gives the builder domain context without re-deriving it from code.
57
58
 
58
59
  ---
59
60
 
@@ -77,6 +77,17 @@ If a `knowledge/` directory exists:
77
77
  - Purpose: grep-based retrieval. The model searches key_questions to find which file to read.
78
78
  - DO NOT load these files into memory. Use the index to find which file to read on demand.
79
79
 
80
+ ### ENRICH knowledge layer (if .claude/knowledge/index.md exists)
81
+ Check for knowledge pages that should be updated from recent session learnings:
82
+ ```bash
83
+ ls .claude/knowledge/index.md 2>/dev/null && echo "KNOWLEDGE_EXISTS" || echo "NO_KNOWLEDGE"
84
+ ```
85
+ If `KNOWLEDGE_EXISTS`:
86
+ - Scan session files for domain facts referenced 2+ times → check if a knowledge page covers them
87
+ - If no knowledge page exists for a frequently-referenced fact → flag as candidate for /ingest
88
+ - If knowledge page exists but is missing the new information → update it
89
+ - Update `knowledge/index.md` Key Questions if new questions emerged from sessions
90
+
80
91
  ---
81
92
 
82
93
  ### LOG