| name | pre-implementation-checklist |
| description | MANDATORY checklist before writing ANY new code. Use this skill FIRST before implementing any feature, component, utility, type, or hook. Enforces DRY principle and existing pattern reuse. |
Pre-Implementation Checklist (MANDATORY)
⚠️ STOP! Before writing ANY code, complete this checklist.
This skill enforces the DRY principle and ensures you search for existing patterns before creating new ones. Skipping this checklist leads to code duplication and inconsistency.
✅ MANDATORY CHECKLIST (Complete Before Coding)
Step 1: Search for Existing Patterns
Before creating ANYTHING new, search the codebase:
grep -r "slug validation" --include="*.ts" --include="*.tsx"
grep -r "price format" --include="*.ts" --include="*.tsx"
grep -r "isValid" --include="*.ts" utils/
grep -r "format" --include="*.ts" utils/
grep -r "build" --include="*.ts" utils/
grep -r "use[A-Z]" --include="*.ts" components/hooks/
grep -r "YOUR_REGEX_PATTERN" --include="*.ts"
Report findings BEFORE proposing implementation:
- ✅ "Found
isValidCategorySlugFormat in utils/category-mapping.ts - will reuse"
- ✅ "Found similar hook
useImageRetry in components/hooks/ - will extend"
- ✅ "No existing pattern found - will create new utility"
Step 2: Check Canonical Locations
| What You're Creating | Where to Search First |
|---|
| Type/Interface | types/ directory, check types/README.md |
| Validation function | utils/ for isValid*, validate* |
| Helper/Utility | utils/, lib/ |
| Constant/Config | utils/constants.ts, config/ |
| Component | components/ui/ |
| Hook | components/hooks/ |
| API call | lib/api/ |
Step 3: Verify No Duplication
Check these specific files for existing patterns:
types/common.ts → NavigationItem, SocialLinks, shared types
types/props.ts → Reusable component props
types/api/*.ts → DTOs (CitySummaryResponseDTO, etc.)
utils/constants.ts → Shared constants (dates, distances, labels)
utils/api-helpers.ts → buildEventsQuery, buildNewsQuery, getInternalApiUrl
config/filters.ts → Filter configurations
Step 4: Propose Plan (No Code Yet)
After searching, propose a 2-4 step plan:
Plan:
1. Reuse `isValidSlug` from utils/validation.ts
2. Create new `PriceFilter` component in components/ui/filters/
3. Add type to types/filters.ts (extending existing FilterConfig)
4. Update tests in test/filter-system.test.ts
Wait for user confirmation before implementing.
🚫 ANTI-PATTERNS (Stop Immediately If You're Doing This)
❌ Writing Code First, Searching Later
const isValidSlug = (slug: string) => /^[a-z0-9-]+$/.test(slug);
❌ Creating Types Outside /types
type ButtonProps = { variant: string; size: string };
export interface ButtonProps {
variant: ButtonVariant;
size: ButtonSize;
}
❌ Duplicating Constants
const DEFAULT_DISTANCE = 50;
const DATE_OPTIONS = ["avui", "dema", "setmana"];
import { DEFAULT_DISTANCE, DATE_OPTIONS } from "@utils/constants";
❌ Creating Helper Used Only Once
const formatEventTitle = (title: string) => title.trim();
<h1>{event.title.trim()}</h1>;
❌ Creating Barrel Files (index.ts) for Component Folders
export { default as SponsorBannerSlot } from "./SponsorBannerSlot";
export { default as CheckoutButton } from "./CheckoutButton";
export { default as PricingSectionClient } from "./PricingSectionClient";
import { SponsorBannerSlot } from "@components/ui/sponsor";
import SponsorBannerSlot from "@components/ui/sponsor/SponsorBannerSlot";
Why: In Next.js RSC, every "use client" module re-exported from a barrel gets registered in the client-reference-manifest of every route that imports from that barrel. This caused 24 KB of bloat on /[place] (Feb 2026). optimizePackageImports only works for npm packages.
❌ Time-Dependent Conditional Rendering in Server Components Without connection()
const status = computeTemporalStatus(event.startDate);
return (
<>
{status.state !== "past" && <EventWeather />} // tree shape changes over time!
{status.state === "past" && <PastEventBanner />}
</>
);
import { connection } from "next/server";
await connection();
const status = computeTemporalStatus(event.startDate);
Why: With cacheComponents: true, React caches the RSC payload. If new Date() produces a different tree shape on replay (e.g., event went from "upcoming" to "past"), React throws "Couldn't find all resumable slots" and falls back to full client rendering — killing SSR performance and SEO. This caused repeated errors in production (Apr 2026). Content-only date usage (formatting text) is fine without connection().
📋 Decision Tree: Should I Create New Code?
┌─────────────────────────────────────────┐
│ Need to implement something new? │
└─────────────────┬───────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ Did you search for existing patterns? │
│ (grep, semantic_search, file_search) │
├─────────────────┬───────────────────────┤
│ NO │ YES │
│ ↓ │ ↓ │
│ STOP! │ Continue │
│ Search first │ │
└─────────────────┴───────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ Found existing pattern? │
├─────────────────┬───────────────────────┤
│ YES │ NO │
│ ↓ │ ↓ │
│ REUSE or │ Create new, but: │
│ EXTEND it │ - Place in canonical │
│ │ location │
│ │ - Follow conventions │
│ │ - Add tests │
└─────────────────┴───────────────────────┘
📍 Canonical Locations Reference
Types (MUST go in /types)
types/
├── common.ts # Shared UI types (NavigationItem, SocialLinks)
├── props.ts # Component props (ButtonProps, CardProps)
├── event.ts # Event domain types
├── filters.ts # Filter types (FilterConfig, FilterState)
├── api/
│ ├── event.ts # EventDTO, EventResponseDTO
│ ├── news.ts # NewsDTO, NewsResponseDTO
│ ├── city.ts # CitySummaryResponseDTO
│ └── ...
└── README.md # Type organization guide
Utilities (Check before creating)
utils/
├── constants.ts # Shared constants (CHECK FIRST!)
├── api-helpers.ts # API query builders
├── url-filters.ts # URL building
├── url-parsing.ts # URL parsing
├── date-helpers.ts # Date formatting
├── category-mapping.ts # Category validation
└── ...
Components (Feature folders)
components/
├── ui/
│ ├── filters/ # Filter components
│ ├── events/ # Event cards, lists
│ ├── forms/ # Form components
│ └── ...
├── hooks/ # Custom hooks (useXxx)
└── partials/ # Layout partials
✅ Verification Checklist (Before PR)
🔧 Quick Search Commands
grep -r "interface\|type " types/ --include="*.ts"
ls components/hooks/
ls utils/
grep -r "export const" utils/constants.ts
grep -r "isValid\|validate" utils/ --include="*.ts"
grep -r "format\|Format" utils/ --include="*.ts"
Remember: 5 minutes of searching saves 30 minutes of refactoring.
Last Updated: January 15, 2026