coding-guidelines
npx skills add https://github.com/imaimai17468/imaimai-front-templete --skill coding-guidelines
Agent 安装分布
Skill 文档
Coding Guidelines
Guidelines for React/Next.js development focusing on testability, Server Components, and proper architecture. Each guideline file contains principles, code examples, and anti-patterns to avoid.
Quick Reference
- Server Components & Data Fetching â server-components.md
- Testability & Props Control â testability.md
- useEffect Guidelines & Dependencies â useeffect-guidelines.md
- Architecture & Patterns â architecture.md
- Test Guidelines (Vitest/RTL) â test-guidelines.md
- Storybook Guidelines â storybook-guidelines.md
When to Use What
Server Components
When: Writing server-side data fetching or async components Read: server-components.md
Key topics:
- Server Component Pattern (async/await, Suspense)
- Promise Handling (.then().catch() vs try-catch)
- When NOT to use “use client”
Testability
When: Writing “use client” components, useEffect, or event handlers Read: testability.md
Key topics:
- Props Control (all states controllable via props)
- Closure Variable Dependencies (extract to pure functions)
- Conditional Branch Extraction (JSX â components, useEffect â pure functions)
useEffect Guidelines & Dependencies
When: Deciding whether to use useEffect, managing dependencies, or avoiding unnecessary re-renders Read: useeffect-guidelines.md
Key topics:
- When you DON’T need useEffect (data transformation, expensive calculations)
- When you DO need useEffect (external system synchronization)
- Event handlers vs Effects decision framework
- Data fetching patterns and race conditions
- Separating reactive and non-reactive logic
- Managing dependencies (updater functions, useEffectEvent, avoiding objects/functions)
- Reactive values and dependency array rules
- Never suppress the exhaustive-deps linter
Architecture
When: Creating files, functions, or organizing code structure Read: architecture.md
Key topics:
- Directory Structure (component collocation, naming)
- Entity/Gateway Pattern (data types and fetching)
- Function Extraction (action-based design)
- Presenter Pattern (conditional text)
Test Guidelines
When: Creating or updating test code during Phase 2 (Testing & Stories) Read: test-guidelines.md
Key topics:
- AAA Pattern (Arrange-Act-Assert)
- Test Structure (describe/test descriptions in Japanese)
- Coverage Standards (branch coverage, exception paths)
- React Testing Library best practices
- Snapshot testing guidelines
Storybook Guidelines
When: Creating Storybook stories for components with conditional rendering during Phase 2 (Testing & Stories) Read: storybook-guidelines.md
Key topics:
- Story Creation Rules (conditional branching focus)
- Meta Configuration (minimal setup)
- Event Handlers (fn() usage)
- Anti-patterns to avoid
Core Principles
- Server Component First: Default to Server Components, use “use client” only when necessary
- Props Control Everything: All UI states must be controllable via props for testability
- Pure Functions: Extract all conditional logic from useEffect/handlers
- No Closure Dependencies: Pass all variables as function arguments
- Entity/Gateway Pattern: Separate data types (entity) from fetching logic (gateway)
- Collocate Functions: Place function files at same level as components, no utils/ directories
Quick Decision Tree
Are you writing a component?
ââ Does it need interactivity? (onClick, useState, useEffect)
â ââ YES â "use client" required
â â ââ Using useEffect?
â â â ââ Read: useeffect-guidelines.md (Do you really need it? + Managing dependencies)
â â ââ Read: testability.md
â ââ NO â Server Component (default)
â ââ Read: server-components.md
â
ââ Does it fetch data?
â ââ Read: server-components.md + architecture.md (Entity/Gateway)
â
ââ Are you organizing files/functions?
â ââ Read: architecture.md (Directory Structure)
â
ââ Are you writing tests?
â ââ Read: test-guidelines.md (AAA Pattern, Coverage, RTL)
â
ââ Are you creating Storybook stories?
ââ Read: storybook-guidelines.md (Conditional Branching, Story Structure)