Eliminate code duplication by extracting common functionality into shared utilities, constants, and base classes. When you notice repeated code patterns, logic, or constants across multiple files, consolidate them into reusable components.

Key practices:

Example:

// Before: Duplicated HTML template
const contentPlaceholder = '<div style="border: 1px dashed #E1E4EA;">...</div>';

// After: Shared constant
import { LAYOUT_PREVIEW_CONTENT_PLACEHOLDER } from '@novu/shared';
return body?.replace(regex, LAYOUT_PREVIEW_CONTENT_PLACEHOLDER);

This approach improves maintainability, reduces bugs from inconsistent implementations, and makes future changes easier by having a single source of truth.