From ftitos-claude-code
Universal coding standards, best practices, and patterns for TypeScript, JavaScript, React, and Node.js development.
npx claudepluginhub nassimbf/ftitos-claude-codeThis skill uses the workspace's default tool permissions.
Universal coding standards applicable across all projects.
Expert guidance for Next.js Cache Components and Partial Prerendering (PPR). **PROACTIVE ACTIVATION**: Use this skill automatically when working in Next.js projects that have `cacheComponents: true` in their next.config.ts/next.config.js. When this config is detected, proactively apply Cache Components patterns and best practices to all React Server Component implementations. **DETECTION**: At the start of a session in a Next.js project, check for `cacheComponents: true` in next.config. If enabled, this skill's patterns should guide all component authoring, data fetching, and caching decisions. **USE CASES**: Implementing 'use cache' directive, configuring cache lifetimes with cacheLife(), tagging cached data with cacheTag(), invalidating caches with updateTag()/revalidateTag(), optimizing static vs dynamic content boundaries, debugging cache issues, and reviewing Cache Component implementations.
Guides building MCP servers enabling LLMs to interact with external services via tools. Covers best practices, TypeScript/Node (MCP SDK), Python (FastMCP).
Share bugs, ideas, or general feedback.
Universal coding standards applicable across all projects.
// GOOD: Descriptive names
const searchQuery = 'election'
const isUserAuthenticated = true
const totalRevenue = 1000
// BAD: Unclear names
const q = 'election'
const flag = true
const x = 1000
// GOOD: Verb-noun pattern
async function fetchItemData(itemId: string) { }
function calculateSimilarity(a: number[], b: number[]) { }
function isValidEmail(email: string): boolean { }
// BAD: Unclear or noun-only
async function item(id: string) { }
function similarity(a, b) { }
// ALWAYS use spread operator
const updatedUser = { ...user, name: 'New Name' }
const updatedArray = [...items, newItem]
// NEVER mutate directly
user.name = 'New Name' // BAD
items.push(newItem) // BAD
// GOOD: Comprehensive error handling
async function fetchData(url: string) {
try {
const response = await fetch(url)
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`)
}
return await response.json()
} catch (error) {
console.error('Fetch failed:', error)
throw new Error('Failed to fetch data')
}
}
// GOOD: Parallel execution when possible
const [users, items, stats] = await Promise.all([
fetchUsers(),
fetchItems(),
fetchStats()
])
// BAD: Sequential when unnecessary
const users = await fetchUsers()
const items = await fetchItems()
const stats = await fetchStats()
// GOOD: Proper types
interface Item {
id: string
name: string
status: 'active' | 'resolved' | 'closed'
created_at: Date
}
function getItem(id: string): Promise<Item> {
// Implementation
}
// BAD: Using 'any'
function getItem(id: any): Promise<any> {
// Implementation
}
interface ButtonProps {
children: React.ReactNode
onClick: () => void
disabled?: boolean
variant?: 'primary' | 'secondary'
}
export function Button({
children,
onClick,
disabled = false,
variant = 'primary'
}: ButtonProps) {
return (
<button
onClick={onClick}
disabled={disabled}
className={`btn btn-${variant}`}
>
{children}
</button>
)
}
export function useDebounce<T>(value: T, delay: number): T {
const [debouncedValue, setDebouncedValue] = useState<T>(value)
useEffect(() => {
const handler = setTimeout(() => {
setDebouncedValue(value)
}, delay)
return () => clearTimeout(handler)
}, [value, delay])
return debouncedValue
}
const [count, setCount] = useState(0)
// GOOD: Functional update for state based on previous state
setCount(prev => prev + 1)
// BAD: Direct state reference (can be stale in async scenarios)
setCount(count + 1)
GET /api/items # List all items
GET /api/items/:id # Get specific item
POST /api/items # Create new item
PUT /api/items/:id # Update item (full)
PATCH /api/items/:id # Update item (partial)
DELETE /api/items/:id # Delete item
# Query parameters for filtering
GET /api/items?status=active&limit=10&offset=0
interface ApiResponse<T> {
success: boolean
data?: T
error?: string
meta?: {
total: number
page: number
limit: number
}
}
import { z } from 'zod'
const CreateItemSchema = z.object({
name: z.string().min(1).max(200),
description: z.string().min(1).max(2000),
endDate: z.string().datetime(),
categories: z.array(z.string()).min(1)
})
// BAD: Function > 50 lines — split into smaller functions
function processData() {
const validated = validateData()
const transformed = transformData(validated)
return saveData(transformed)
}
// BAD: 5+ levels of nesting
// GOOD: Early returns
if (!user) return
if (!user.isAdmin) return
if (!item) return
// Do something
// BAD: Unexplained numbers
if (retryCount > 3) { }
// GOOD: Named constants
const MAX_RETRIES = 3
if (retryCount > MAX_RETRIES) { }
Remember: Code quality is not negotiable. Clear, maintainable code enables rapid development and confident refactoring.