xiaohongshu
xiaohongshu
coding-standards
Universal coding standards and best practices for TypeScript, JavaScript, React, and Node.js. Use when: writing code, reviewing code quality, establishing conventions. Focuses on modern patterns, explicit conventions, and rationale for best practices.
Full skill instructions
Modern coding standards applicable across TypeScript, JavaScript, React, and Node.js projects.
| If you need... | MANDATORY READ WHEN... | File |
|---|---|---|
| Type patterns | WRITING TYPES | references/type-patterns.md |
| React patterns | WRITING COMPONENTS | references/react-patterns.md |
| API patterns | DESIGNING APIS | references/api-patterns.md |
| Testing patterns | WRITING TESTS | references/testing-patterns.md |
WHY: Code is read 10x more than written. Optimize for the reader.
Practices:
Recognition: "Would a new team member understand this without explanation?"
WHY: Prevents stale closures, makes state predictable, enables React optimizations.
✅ ALWAYS use spread operator:
const updatedUser = { ...user, name: 'New Name' }
const updatedArray = [...items, newItem]
❌ NEVER mutate directly:
user.name = 'New Name' // BAD - causes bugs
items.push(newItem) // BAD - breaks React optimizations
Best practice: Use Lodash (cloneDeep), Immer, or structuredClone for deep objects.
WHY: Prevents stale closure bugs in async scenarios.
✅ GOOD (functional update):
setCount(prev => prev + 1)
setData(prev => ({ ...prev, field: value }))
❌ BAD (direct reference - can be stale):
setCount(count + 1) // May use stale value
setData({ ...data, field: value }) // Can miss updates
WHY: Unhandled errors crash processes, cause bad UX, make debugging impossible.
✅ GOOD pattern:
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')
}
}
❌ BAD (no error handling):
async function fetchData(url) {
const response = await fetch(url)
return response.json() // Crashes on network failure
}
WHY: Sequential awaits waste time. Parallel execution is faster.
✅ GOOD (parallel when possible):
const [users, markets, stats] = await Promise.all([
fetchUsers(),
fetchMarkets(),
fetchStats()
])
❌ BAD (sequential when unnecessary):
const users = await fetchUsers() // Waits 100ms
const markets = await fetchMarkets() // Waits 100ms (total: 200ms)
const stats = await fetchStats() // Waits 100ms (total: 300ms)
Recognition: "Can these operations run in parallel?" → Use Promise.all
WHY: Types catch bugs at compile-time, serve as documentation, enable refactoring.
✅ GOOD (proper types):
interface Market {
id: string
name: string
status: 'active' | 'resolved' | 'closed'
}
function getMarket(id: string): Promise<Market> { }
❌ BAD (using any):
function getMarket(id: any): Promise<any> { }
Recognition: "Could I use a more specific type?" → Always prefer specificity
✅ GOOD (descriptive, camelCase):
const marketSearchQuery = 'election'
const isUserAuthenticated = true
const totalRevenue = 1000
async function fetchMarketData(marketId: string) { }
function calculateSimilarity(a: number[], b: number[]) { }
❌ BAD (unclear, abbreviated):
const q = 'election'
const flag = true
const x = 1000
async function market(id: string) { }
function similarity(a, b) { }
Prefix with is, has, should, can:
const isLoading = true
const hasPermission = false
const shouldRetry = true
const canEdit = true
Use UPPER_SNAKE_CASE for true constants (never reassigned):
const MAX_RETRIES = 3
const DEFAULT_TIMEOUT_MS = 5000
const API_BASE_URL = 'https://api.example.com'
src/
├── components/ # React components
│ ├── ui/ # Generic, reusable
│ └── features/ # Feature-specific
├── hooks/ # Custom React hooks
├── lib/ # Utilities and helpers
│ ├── api/ # API clients
│ ├── utils/ # Helper functions
│ └── constants/ # Constants
├── types/ # TypeScript types
└── styles/ # Global styles
| Type | Pattern | Example |
|---|---|---|
| Components | PascalCase | Button.tsx, MarketCard.tsx |
| Hooks | camelCase with use prefix | useAuth.ts, useDebounce.ts |
| Utilities | camelCase | formatDate.ts, calculateTotal.ts |
| Types | camelCase with .types suffix | market.types.ts |
| Constants | camelCase with constants suffix | api.constants.ts |
❌ BAD:
if (retryCount > 3) { }
setTimeout(callback, 500)
✅ GOOD:
const MAX_RETRIES = 3
const DEBOUNCE_DELAY_MS = 500
if (retryCount > MAX_RETRIES) { }
setTimeout(callback, DEBOUNCE_DELAY_MS)
❌ BAD (5+ levels):
if (user) {
if (user.isAdmin) {
if (market) {
if (market.isActive) {
if (hasPermission) {
// Do something
}
}
}
}
}
✅ GOOD (early returns):
if (!user) return
if (!user.isAdmin) return
if (!market) return
if (!market.isActive) return
if (!hasPermission) return
// Do something
❌ BAD:
console.log('User logged in', user)
console.error('Error occurred', error)
✅ GOOD:
// Use proper logging library
logger.info('User logged in', { userId: user.id })
logger.error('Error occurred', { error, context })
❌ BAD:
// @ts-ignore
const data = JSON.parse uncertain
✅ GOOD:
const data = JSON.parse uncertain as unknown as ExpectedType
// Or use zod/joi for validation
Use for:
useMemo)useCallback)React.memo)const sortedMarkets = useMemo(() => {
return markets.sort((a, b) => b.volume - a.volume)
}, [markets])
const handleSearch = useCallback((query: string) => {
setSearchQuery(query)
}, [])
Use for:
lazy, Suspense)const HeavyChart = lazy(() => import('./HeavyChart'))
<Suspense fallback={<ChartSkeleton />}>
<HeavyChart data={data} />
</Suspense>
Before considering code complete:
any without justification)This skill integrates with:
frontend-patterns - React/Next.js specific patternsbackend-patterns - API and database patternstdd-workflow - Testing standardsverify - Quality gate verificationRecognition: "Am I following WHY-based best practices?" → If you're doing something "because that's how it's done," you're missing the rationale.
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience