---
name: catalyst-review-module
description: >
  Deep coherence review of a complete frontend module's component tree, services, and patterns.
  Audits naming, structure, consistency, and alignment with project skills. Trigger: When reviewing
  a frontend module before closing it, or when running /review-module on a frontend path.
license: MIT
metadata:
  author: aurora
  version: '1.0'
  auto_invoke: 'Frontend module review, coherence audit, component tree analysis'
allowed-tools: Read, Edit, Glob, Grep, Bash, Agent, Task
---

## Purpose

Perform a deep coherence review of an entire frontend module to ensure all its pieces — components,
services, models, pipes, directives, translations — form a consistent whole and align with the
project's established patterns.

This is NOT a code simplification pass. It is a **structural and semantic audit**.

## When to Use

- Before closing/finalizing a frontend module
- After a significant refactor spanning multiple files
- When onboarding to an unfamiliar module to assess its health
- Periodically as a hygiene check

## Review Process (MANDATORY ORDER)

### 1. Map the Module Tree

Read `frontend/.claude/skills/catalyst-project-structure/SKILL.md` to understand the expected
directory structure for the module type (infrastructure vs domain feature).

Then read the full directory tree of the target module and list every file. Understand the hierarchy
before analyzing anything. Do NOT assume a fixed structure — read the actual directory first and
compare against the project structure skill.

### 2. Load Applicable Skills

Before reviewing, read ALL skills that apply to the module's code:

- `frontend/.claude/skills/catalyst-project-structure/SKILL.md` — file placement rules
- `frontend/.claude/skills/transloco-i18n/SKILL.md` — if module has i18n
- `frontend/.claude/skills/catalyst-data-table-management/SKILL.md` — if module has data tables
- `frontend/.claude/skills/layout-design-system/SKILL.md` — if module has layouts/dashboards
- `.claude/skills/typescript/SKILL.md` — TypeScript patterns (always applies)

These skills define the **expected patterns**. The review compares reality against them.

### 3. Audit Dimensions

Review each dimension and report findings:

#### A. Naming Coherence

- Component selectors follow a consistent prefix pattern
- File names match Angular conventions (`kebab-case.type.ts`)
- Service, model, and interface names align with domain language
- Translation keys follow a consistent structure within the module
- No mixed naming styles (e.g., some camelCase, some kebab-case in the same context)

#### B. Structural Consistency

- Components follow the same internal structure (signals, inputs, outputs, inject, computed order)
- All components use `ChangeDetectionStrategy.OnPush`
- Services follow the same dependency injection pattern (`inject()` not constructor)
- Routes follow lazy loading patterns
- No orphaned files (created but never imported/used)

#### C. Pattern Alignment

- Code follows the patterns documented in loaded skills
- No divergent patterns solving the same problem differently within the module
- Shared utilities are extracted when a pattern repeats 3+ times within the module
- Translation scope configuration matches the `transloco-i18n` skill patterns

#### D. Component Tree Logic

- Parent-child relationships make semantic sense
- Data flows downward (inputs), events flow upward (outputs)
- No component does "too much" (multiple unrelated responsibilities)
- Smart vs presentational component separation is consistent
- No circular or confusing dependency chains between components

#### E. Explicit Code

- Variable and function names describe **what**, not **how**
- No nested ternaries or dense one-liners that obscure intent
- Public/exported functions have explicit return types
- Intermediate variables are used to clarify complex expressions

## Output Format

Generate a report with this structure:

```markdown
## Module Review: {module-name}

### Summary

{1-2 sentences: overall health assessment}

### Findings

#### Aligned

- {Things that are correct and consistent}

#### Inconsistencies

- {Pattern divergences, naming mismatches, structural issues}
- Each item: **What** is wrong > **Where** (file:line) > **Why** it matters > **Suggested fix**

#### Critical

- {Violations of REQUIRED patterns from skills, broken conventions}

### Metrics

| Dimension              | Status                  |
| ---------------------- | ----------------------- |
| Naming Coherence       | OK / Warning / Critical |
| Structural Consistency | OK / Warning / Critical |
| Pattern Alignment      | OK / Warning / Critical |
| Component Tree Logic   | OK / Warning / Critical |
| Explicit Code          | OK / Warning / Critical |

### Recommended Actions

1. {Prioritized list of actions to fix findings}
```

## CRITICAL

- **Read skills before reviewing** — you cannot assess alignment without knowing the standard
- **Report facts, not opinions** — every finding must reference a specific file and line
- **Don't auto-fix** — this is an audit. Present findings and let the user decide what to act on
- **Scope to the module** — don't review code outside the target module unless it directly impacts
  coherence
