--- name: ffp-code-review description: Review code changes for FFP project standards including multi-tenant security, British English, architecture patterns, and SOLID principles. Use when reviewing PRs, checking branch changes, or auditing code quality. allowed-tools: Read, Grep, Glob, Bash(git diff:*), Bash(git log:*), Bash(git branch:*) --- # FFP Code Review Skill ## Capabilities Senior-level code review specialising in: - **Multi-tenant security**: RLS enforcement, tenant isolation, JWT validation - **Healthcare data compliance**: OWASP Top 10, sensitive data protection - **FFP architecture patterns**: Domain-organised structure, Handler → Service → Repository flow - **British English enforcement**: Spelling, grammar, naming conventions - **TypeScript best practices**: Strict mode, type safety, explicit signatures ## Review Process ### 1. Gather Context **Check for review context (ALWAYS DO THIS FIRST):** - Try to read `.claude/review-context.md` using Read tool - If exists: Extract goals, requirements, changes made, focus areas, known limitations - If missing: Note "No review context provided" and proceed with general review **Get git changes:** ```bash git diff main...HEAD # All changes on current branch git log main..HEAD --oneline # Recent commits git branch --show-current # Current branch name ``` **Load project documentation:** - `CLAUDE.md` - Team-wide project standards - `CLAUDE.local.md` - Personal preferences and FFP-specific gotchas - `project-documentation/project-state.md` - Current sprint and task context - `project-documentation/architecture.md` - Architecture patterns and decisions - `project-documentation/security.md` - Security requirements and RLS patterns ### 2. Analyse Changes **Search for critical patterns using Grep:** - SQL queries: `query|execute|transaction` - Tenant checks: `tenant_id|tenantId` - Auth claims: `claims\[|custom:` - Error handling: `throw|catch|Error` - Database access: `db\.|repository|Repository` - Raw HTML elements: `|

|| // CORRECT: Use Button component ``` **When raw HTML is acceptable:** - Form inputs (input, textarea, select) - use FormTextInput instead - Structural elements (div, section, nav, header, footer) - Semantic elements (ul, ol, li, table, tr, td) - Special cases where component doesn't exist (rare) ## Colour Theme Enforcement **Use theme colours instead of hard-coded values:** ### Hard-coded Colours to Avoid ```typescript // WRONG: Hard-coded colour classes className="text-gray-900" className="text-gray-600" className="text-red-600" className="bg-blue-50" className="border-green-200" // CORRECT: Use theme colours via components className="bg-info/10" className="border-success/20" ``` ### Available Theme Colours **Text colours** (use via `Text` or `Title` components): - `foreground` - Primary text (dark) - `muted-foreground` - Secondary text (medium gray) - `primary` - FFP primary blue - `secondary` - FFP light purple - `success` - Green - `destructive` - Red (errors) - `warning` - Yellow/amber - `info` - Blue (informational) **Background/border colours** (use via Tailwind classes): - `bg-background`, `bg-foreground` - `bg-primary`, `bg-secondary`, `bg-success`, `bg-destructive`, `bg-warning`, `bg-info` - `bg-muted`, `bg-accent`, `bg-card` - Use opacity for lighter shades: `bg-primary/10`, `border-destructive/20` ### When Hard-coded Colours Are Acceptable - Gradients or complex visual effects (e.g., `bg-gradient-to-r from-success to-info`) - Temporary dev-only components - Very specific brand colours not in theme (must be rare) **Check files in scope:** - All `.tsx` files in `packages/web/src/pages/` - All `.tsx` files in `packages/web/src/components/` - Focus on production components (not dev pages) ## British English Enforcement **Important**: British English applies to FFP-specific code only. Framework/package integrations (e.g., TailwindCSS classes, library APIs) should use the framework's expected spelling. **Common mistakes to catch in FFP code:** | American (Wrong) | British (Correct) | | ------------------------ | ----------------- | | optimize (in FFP code) | optimise | | organize (in FFP code) | organise | | customize (in FFP code) | customise | | color (in FFP code) | colour | | behavior (in FFP code) | behaviour | | center (in FFP code) | centre | | license (noun, FFP code) | licence (noun) | **Check in:** - FFP variable/function names: `optimizeWorkout` → `optimiseWorkout` - FFP comments: "// Optimize the query" → "// Optimise the query" - FFP string literals: "Customization" → "Customisation" - User-facing messages: "Authorization failed" → "Authorisation failed" **DO NOT flag as errors:** - TailwindCSS classes: `text-center`, `bg-color-blue-500` (framework convention) - Library APIs: `color`, `initialize`, `center` (when part of framework interface) - Package configuration: `color`, `behavior` (when required by package) ## Review Philosophy 1. **Security first**: Healthcare data = zero tolerance for vulnerabilities 2. **Constructive feedback**: Explain why, show how to fix 3. **Specific examples**: Provide remediation code, not just descriptions 4. **Positive reinforcement**: Acknowledge good practices 5. **Phase 1 context**: Don't over-engineer; ship fast, iterate on feedback 6. **Senior perspective**: Mentor, don't just criticise ## Usage Examples **Invoke directly:** ``` Use the ffp-code-review skill to review my changes ``` **Focus on specific area:** ``` Use ffp-code-review to check security in my authentication code ``` **After making changes:** ``` Review my latest commit with ffp-code-review before I push ```