mit einem Klick
pre-review
// Automated code review against established patterns before PR creation. Analyzes git diff for critical issues, pattern violations, test coverage, and generates a comprehensive report.
// Automated code review against established patterns before PR creation. Analyzes git diff for critical issues, pattern violations, test coverage, and generates a comprehensive report.
| name | pre-review |
| description | Automated code review against established patterns before PR creation. Analyzes git diff for critical issues, pattern violations, test coverage, and generates a comprehensive report. |
Analyzes code changes in the current branch against established patterns, catching common issues early before PR submission.
Generates a comprehensive report covering:
Arguments are parsed as follows:
--base <branch>: Base branch to compare against (default: master)--focus <areas>: Comma-separated focus areas (e.g., "state-management,testing")--skip <sections>: Skip report sections (e.g., "suggestions")Examples:
# Basic usage (analyzes current branch vs master)
/pre-review
# With custom base branch
/pre-review --base develop
# With focus areas
/pre-review --focus "state-management,testing"
# Skip sections
/pre-review --skip "suggestions"
Identify changed files
git diff master...HEAD --name-status
Categorize changes
.ts, .tsx) - non-test.spec.ts, .cy.tsx)__generated__/)Extract metrics
Run these checks and flag any violations:
git diff master...HEAD | grep -E "@ts-ignore|@ts-expect-error"
Pattern: All type suppressions must have:
Example:
// ✅ Good
// TODO[TICKET-123]: Fix validator types to accept EntityQuery[]
// Temporary: validator expects old structure
// @ts-ignore - validator type needs update
const validator = useValidateCombiner(sources, entities)
// ❌ Bad
// @ts-ignore wrong type; need a fix
const validator = useValidateCombiner(sources, entities)
git diff master...HEAD | grep -E "eslint-disable"
Pattern: All eslint-disable must have:
eslint-disable-line without rule)Example:
// ✅ Good
// Only re-run when mapping ID changes, not when formContext updates
// to avoid cascade reconstruction
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [formData?.id])
// ❌ Bad
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [formData?.id])
git diff master...HEAD | grep -E "^\+.*console\.(log|warn|error|debug)" | grep -v "\.spec\." | grep -v "\.cy\."
Pattern: No console.* in production code
git diff master...HEAD | grep -E "TODO|FIXME|XXX|HACK"
Pattern: All TODO comments must include:
TODO[TICKET-123]TODO[YourName]Example:
// ✅ Good
// TODO[38943/NVL]: Investigate reusing RJSF templates
// Current: manually extracting options from uiSchema
// Ideal: reuse built-in template system
// ❌ Bad
// TODO: Would prefer to reuse the templates; need investigation
Check: For each new exported function, ensure test exists
Pattern:
// New function in src/utils/foo.ts
export const newFunction = () => {}
// Must have test in src/utils/foo.spec.ts
describe('newFunction', () => {
it('should handle basic case', () => {})
it('should handle edge case', () => {})
})
git diff master...HEAD | grep -E "^\+.*<(Heading|Text|Button|Label).*>.*[A-Z]" | grep -v "t\("
Pattern: All user-facing text must use t() translation
Pattern: Use explicit interfaces, not inline object types
// ❌ Bad
const [state, setState] = useState<
| {
tags: DataIdentifierReference[]
topicFilters: DataIdentifierReference[]
}
| undefined
>()
// ✅ Good
import type { SelectedSources } from '@/modules/Mappings/types'
const [state, setState] = useState<SelectedSources | undefined>()
Pattern: No emojis in code comments (markdown docs are fine)
// ❌ Bad
adapterId: entity.id, // ✅ Direct access to entity
// ✅ Good
adapterId: entity.id, // Direct access to entity (no index needed)
Pattern: Extract constants
// ❌ Bad
if ((item as DomainTag).name) {
// Check by property
}
// ✅ Good
const isDomainTag = (item: unknown): item is DomainTag => {
return (item as DomainTag).name !== undefined
}
if (isDomainTag(item)) {
// Type-safe check
}
Pattern: Files > 300 lines should be considered for splitting
git diff master...HEAD --stat | awk '{if ($3 > 300) print $1, $3}'
Pattern: Follow project conventions
UserProfile.tsx)use (useUserData.ts)formatDate.ts)MAX_RETRY_COUNT)Rule: Every new/changed component needs test file
// src/components/NewComponent.tsx (new file)
// Must have: src/components/NewComponent.spec.cy.tsx
Pattern: Every component test must include:
it('should be accessible', () => {
cy.injectAxe()
cy.mountWithProviders(<Component />)
cy.checkAccessibility() // Last test in describe block
})
Pattern: Must use in priority order:
data-testid (best)// ✅ Good
cy.getByTestId('user-profile-name')
cy.findByRole('button', { name: 'Submit' })
// ❌ Bad
cy.get('.chakra-button')
cy.get('.css-abc123')
Rule: When deprecating or migrating, add compat tests
// Example: DataCombiningEditorDrawer.backward-compat.spec.cy.tsx
describe('backward compatibility', () => {
it('should handle old data format', () => {})
it('should handle new data format', () => {})
})
Check: For each new function, verify edge cases tested:
/**
* Extracts the adapterId (scope) for a given tag from context.
*
* @param tagId - The tag identifier to look up
* @param formContext - The combiner context
* @returns The adapterId if found, undefined otherwise
*
* @example
* const adapterId = getAdapterIdForTag('temperature', formContext)
*/
export const getAdapterIdForTag = (tagId: string, formContext?: CombinerContext) => {}
Check: For loops/iterations over large arrays:
.reduce() efficientlySuggest:
Suggest: For new visual components, add Storybook story
Generate a markdown report with structure:
# Pre-Review Report: [Branch Name]
**Branch:** {branch-name}
**Date:** {date}
**Scope:** {files changed}, {lines added/removed}
---
## Executive Summary
**Overall Assessment:** [Ready/Needs Work/Major Issues]
**Key Strengths:**
- ✅ ...
**Must Fix Before PR:**
- 🔴 ...
---
## Critical Issues (Must Fix Before PR)
### 🔴 1. [Issue Title]
**File:** {file}:{line}
**Issue:** {description}
**Why Critical:** {reason}
**Fix Required:**
{code example}
---
## Pattern Violations (Should Fix)
### ⚠️ 1. [Violation Title]
**File:** {file}:{line}
**Pattern:** {expected pattern}
**Current:**
{code}
**Fix:**
{code}
---
## Missing Test Coverage & Quality Gates
### ⚠️ 1. [Missing Coverage]
**Missing:** {what's missing}
**Recommended:**
{code example}
---
## Suggestions (Nice to Have)
### 💡 1. [Suggestion Title]
**File:** {file}
**Suggested:** {improvement}
**Benefit:** {why}
---
## Code Quality Metrics
| Metric | Score | Status |
| ------------- | -------- | -------- |
| Test Coverage | X files | ✅/⚠️/❌ |
| Type Safety | X issues | ✅/⚠️/❌ |
| ...
---
## Checklist Before PR Submission
### Critical (Must Do)
- [ ] Fix item 1
- [ ] Fix item 2
### Recommended (Should Do)
- [ ] Fix item 3
### Nice to Have (Could Do)
- [ ] Suggestion 1
---
## PR Description Template
{generated template based on changes}
The checklist is stored in .claude/skills/pre-review/checklist.yaml and can be extended:
critical_checks:
- id: type-safety
name: Type Safety Issues
pattern: '@ts-ignore|@ts-expect-error'
severity: critical
rule: 'Must have justification + TODO'
pattern_violations:
- id: inline-types
name: Inline Types vs Interfaces
severity: should-fix
rule: 'Use explicit interfaces'
test_coverage:
- id: accessibility
name: Accessibility Tests
severity: must-have
rule: 'Every component needs a11y test'
Add new checks by editing the YAML file.
The skill automatically:
.tasks/{task-id}/// In conversation:
User: "Check if my code is ready for PR"
Assistant: [Invokes /pre-review skill]
// Or explicit:
User: "/pre-review"
Assistant: [Analyzes current branch and generates report]
Use this skill when any artifact needs visual evidence of UI state. Invoke automatically when: creating a PR with UI changes (invoke before writing the PR body), updating docs/ with new screenshots, or preparing blog post visuals. Trigger phrases: "I need screenshots", "capture the UI", "show before/after", "add visuals to the PR".
Use this skill when writing user-facing documentation for a blog post, release notes, or feature announcement. Invoke automatically when: the user asks to "write a blog post", "write release notes", "document this feature for users", or "write a feature announcement". Produces structured ~500-word feature write-ups in plain language for non-technical readers (DevOps engineers, system administrators — not frontend developers).
Use this skill when creating or writing a pull request description. Invoke automatically when: the user says "create a PR", "open a pull request", "submit for review", "write the PR body", or "push this for review". If the PR includes UI changes, invoke the capture-screenshots skill before writing the description.
Use this skill when a Cypress test is failing and the cause is not immediately obvious. Invoke automatically when: a test throws "element not found", "expected to find element", "element is disabled", or any assertion failure. Also invoke before reaching for {force: true}, cy.wait(), or rewriting a test from scratch — investigate first.
Fetch and analyze SonarQube quality metrics for pull requests, reporting on code quality, bugs, vulnerabilities, coverage, and code smells
Review technical documentation against the HiveMQ writing guidelines, producing a structured quality report with actionable findings per file