Back to list
tienchinh21

react-discovery

by tienchinh21

0🍴 0📅 Jan 19, 2026

SKILL.md


name: react-discovery description: Research and understand React projects and features. Use when asked to explore a React codebase, check if a feature exists, understand component relationships, or map project structure. Specialized for React/Vite/Next.js projects.

React Discovery - React Project Research & Understanding

Skill chuyên biệt để nghiên cứu, khám phá và hiểu sâu về dự án React. Giúp AI hiểu rõ codebase trước khi đề xuất hoặc thực hiện thay đổi.

┌─────────────────────────────────────────────────────────────────┐
│                 REACT DISCOVERY PIPELINE                        │
├─────────────────────────────────────────────────────────────────┤
│  Detect → Explore → Map → Analyze → Report → Recommend          │
│     ↓        ↓        ↓       ↓         ↓          ↓           │
│ [PROJECT] [SEARCH] [VISUAL] [DEEP]  [SUMMARY] [NEXT STEPS]     │
└─────────────────────────────────────────────────────────────────┘

Supported React Stacks

StackDetectionKey Files
Vite + Reactvite in devDepsvite.config.ts
Next.jsnext in depsnext.config.js, app/ or pages/
Create React Appreact-scriptspublic/, src/index.tsx
Remix@remix-run/*remix.config.js

Phase 1: Project Detection

Goal: Tự động nhận diện loại React project

Step 1.1: Read package.json

// Detect từ dependencies
{
  "dependencies": {
    "react": "^18.x",      // ✅ React project
    "next": "^14.x",       // → Next.js
    "vite": "^5.x",        // → Vite
  }
}

Step 1.2: Identify UI Libraries

LibraryDetection KeyNotes
Tailwind CSStailwindcssCheck tailwind.config.js
Ant DesignantdCheck ConfigProvider
MUI@mui/materialCheck theme setup
Shadcn/uicomponents.jsonCheck components/ui/
Chakra UI@chakra-ui/reactCheck ChakraProvider

Step 1.3: Identify State Management

LibraryDetection KeyTypical Location
Zustandzustandsrc/stores/
Redux Toolkit@reduxjs/toolkitsrc/store/, src/redux/
React Query@tanstack/react-querysrc/hooks/, src/queries/
Jotaijotaisrc/atoms/
Recoilrecoilsrc/atoms/, src/recoil/

Step 1.4: Identify Routing

LibraryDetection KeyRoute Location
React Routerreact-router-domsrc/routes/, src/App.tsx
Next.js App Routernext + app/ folderapp/
Next.js Pages Routernext + pages/ folderpages/
TanStack Router@tanstack/react-routersrc/routes/

Detection Output

═══════════════════════════════════════════════════════════
[PROJECT DETECTED]
═══════════════════════════════════════════════════════════

📦 Project: <project-name>
⚛️  Stack: Vite + React + TypeScript
🎨 UI: Tailwind CSS + Shadcn/ui
📊 State: Zustand + React Query
🧭 Router: React Router v6

Key Config Files:
• vite.config.ts
• tailwind.config.js
• tsconfig.json
• components.json

Folder Structure Pattern: Feature-based

Ready to explore features...
═══════════════════════════════════════════════════════════

Phase 2: Project Structure Mapping

React Project Structures

Pattern A: Feature-based (FSD-like)

src/
├── features/
│   ├── auth/
│   │   ├── components/
│   │   ├── hooks/
│   │   ├── api/
│   │   └── types.ts
│   └── products/
│       ├── components/
│       ├── hooks/
│       └── api/
├── shared/
│   ├── ui/
│   ├── hooks/
│   └── utils/
└── app/
    ├── routes/
    └── providers/

Pattern B: Type-based (Traditional)

src/
├── components/
│   ├── common/
│   └── features/
├── hooks/
├── services/
├── stores/
├── types/
├── utils/
└── pages/

Pattern C: Page-based (Next.js style)

src/
├── pages/          # or app/
│   ├── index.tsx
│   ├── about/
│   └── products/
├── components/
├── hooks/
├── lib/
└── styles/

Auto-detect Structure Pattern

1. Check if `src/features/` exists → Feature-based
2. Check if `app/` exists → Next.js App Router
3. Check if `pages/` exists → Next.js Pages / Page-based
4. Default → Type-based

Phase 3: Feature Exploration

3.1 Search Strategy by Structure

For Feature-based:

Feature "auth" location:
1. src/features/auth/
2. src/modules/auth/
3. src/domains/auth/

For Type-based:

Feature "auth" components:
1. src/pages/auth/          # Pages
2. src/components/auth/     # Components  
3. src/hooks/useAuth*.ts    # Hooks
4. src/services/auth*.ts    # Services
5. src/stores/auth*.ts      # Stores

For Next.js App Router:

Feature "auth" location:
1. app/(auth)/              # Route group
2. app/login/, app/register/
3. components/auth/
4. lib/auth.ts

3.2 Component Discovery Commands

## Find all components of a feature

# By folder
Read: src/pages/<feature>/
Read: src/components/<feature>/

# By naming
glob: src/**/*<Feature>*.tsx
glob: src/**/*<feature>*.tsx

# By imports
Grep: "from.*<feature>" trong src/

3.3 Hook Discovery

## Find hooks related to feature

glob: src/hooks/use<Feature>*.ts
glob: src/**/use<Feature>*.ts
Grep: "function use<Feature>"
Grep: "const use<Feature>"

3.4 API/Service Discovery

## Find API calls

glob: src/services/<feature>*.ts
glob: src/api/<feature>*.ts
Grep: "fetch\|axios\|api" trong <feature> files
Grep: "useMutation\|useQuery" trong <feature> files

3.5 State Discovery

## Find state management

# Zustand
glob: src/stores/*<feature>*.ts
Grep: "create\(" trong stores/

# Redux
glob: src/store/*<feature>*.ts
glob: src/redux/*<feature>*.ts

# React Query
Grep: "useQuery.*<feature>"
Grep: "queryKey.*<feature>"

Phase 4: Component Analysis

4.1 Component Anatomy

## Analyzing: <ComponentName>.tsx

### Props Interface
| Prop | Type | Required | Default |
|------|------|----------|---------|
| title | string | ✅ | - |
| onClick | () => void | ❌ | - |

### Hooks Used
| Hook | Purpose |
|------|---------|
| useState | Local state for X |
| useAuth | Get current user |
| useQuery | Fetch data |

### Child Components
- <Button /> from shared/ui
- <Modal /> from shared/ui
- <UserAvatar /> from features/user

### Events/Handlers
| Handler | Triggers | Action |
|---------|----------|--------|
| handleSubmit | form submit | Call API |
| handleClose | click outside | Close modal |

### Renders
| Condition | What renders |
|-----------|--------------|
| loading | Skeleton |
| error | ErrorMessage |
| data | Main content |
| empty | EmptyState |

4.2 Data Flow Analysis

flowchart TD
    A[User Action] --> B[Event Handler]
    B --> C{API Call?}
    C -->|Yes| D[useMutation/fetch]
    C -->|No| E[Local State Update]
    D --> F[Server]
    F --> G[Response]
    G --> H[Cache Update/Refetch]
    H --> I[Re-render]
    E --> I

4.3 State Flow Analysis

flowchart LR
    subgraph Component
        A[Props] --> D[Render]
        B[Local State] --> D
        C[Store State] --> D
    end
    
    subgraph External
        E[Zustand Store]
        F[React Query Cache]
        G[URL Params]
    end
    
    E --> C
    F --> C
    G --> A

Phase 5: Feature Completeness Check

CRUD Checklist

## Feature: <FeatureName>

### Operations
| Op | Status | Component | API | Notes |
|----|--------|-----------|-----|-------|
| Create | ✅ | CreateForm.tsx | POST /api/x | With validation |
| Read List | ✅ | List.tsx | GET /api/x | With pagination |
| Read Detail | ✅ | Detail.tsx | GET /api/x/:id | - |
| Update | ⚠️ | EditForm.tsx | PUT /api/x/:id | Missing fields |
| Delete | ❌ | - | - | Not implemented |

### UI States
| State | Status | Component | Notes |
|-------|--------|-----------|-------|
| Loading | ✅ | Skeleton | - |
| Empty | ✅ | EmptyState | - |
| Error | ❌ | - | No error UI |
| Success | ⚠️ | Toast | Basic only |

### UX Features
| Feature | Status | Notes |
|---------|--------|-------|
| Form validation | ✅ | Zod + react-hook-form |
| Optimistic update | ❌ | - |
| Infinite scroll | ❌ | Using pagination |
| Search/Filter | ⚠️ | Search only |
| Sort | ❌ | - |

React-specific Checks

## React Best Practices

### Performance
- [ ] React.memo on heavy components
- [ ] useMemo/useCallback where needed
- [ ] Code splitting with lazy()
- [ ] Image optimization

### Accessibility
- [ ] Semantic HTML
- [ ] ARIA labels
- [ ] Keyboard navigation
- [ ] Focus management

### Error Handling
- [ ] Error boundaries
- [ ] API error states
- [ ] Form validation errors
- [ ] 404 pages

Phase 6: Report Template

═══════════════════════════════════════════════════════════
[REACT DISCOVERY REPORT]
═══════════════════════════════════════════════════════════

# Feature: <Feature Name>

## 📊 Quick Summary

| Aspect | Status |
|--------|--------|
| Feature exists | ✅ Yes / ⚠️ Partial / ❌ No |
| Completeness | X% |
| Code quality | Good / Medium / Needs work |

---

## ⚛️ Project Context

**Stack**: Vite + React 18 + TypeScript
**UI**: Tailwind + Shadcn/ui  
**State**: Zustand + React Query
**Pattern**: Feature-based

---

## 📁 Feature Location

src/ ├── pages// │ ├── index.tsx # Entry │ └── components/ │ ├── List.tsx # List view │ ├── Detail.tsx # Detail view │ └── Form.tsx # Create/Edit ├── hooks/ │ └── use.ts # Business logic ├── services/ │ └── .service.ts # API calls └── stores/ └── .store.ts # State


---

## 🔄 How It Works

### Component Tree
<mermaid graph>

### Data Flow
<mermaid flowchart>

---

## 📋 Feature Inventory

| Function | Status | Location | LOC |
|----------|--------|----------|-----|
| List | ✅ | List.tsx | 120 |
| Create | ✅ | Form.tsx | 80 |
| Update | ⚠️ | Form.tsx | 80 |
| Delete | ❌ | - | - |

---

## 🔍 Key Code

### Main Component
`src/pages/<feature>/index.tsx`
```tsx
export default function FeaturePage() {
  const { data, isLoading } = useFeatureList();
  // ...
}

Main Hook

src/hooks/useFeature.ts

export function useFeatureList() {
  return useQuery({
    queryKey: ['features'],
    queryFn: featureService.getAll,
  });
}

⚠️ Gaps Found

GapImpactEffort
No error handlingHighS
Missing deleteMediumM
No testsHighL

🚀 Recommendations

  1. Quick wins (< 1h):

    • Add error boundary
    • Add loading skeleton
  2. Should do (1-4h):

    • Implement delete
    • Add form validation
  3. Nice to have (> 4h):

    • Add unit tests
    • Add E2E tests

═══════════════════════════════════════════════════════════


---

## Quick Commands

### "Tính năng X có chưa?"
  1. glob: src/**/.tsx
  2. Grep: "" trong src/
  3. → Report: Exists / Partial / Missing

### "Giải thích component Y"
  1. Read: component file
  2. Trace: imports & exports
  3. Map: props, hooks, children
  4. → Report: Anatomy + Flow diagram

### "Liệt kê tất cả pages"
  1. Read: src/pages/ hoặc app/
  2. glob: src/pages/**/index.tsx
  3. → Report: Page list + routes

### "Dự án dùng những gì?"
  1. Read: package.json
  2. Detect: stack, UI, state, router
  3. Read: config files
  4. → Report: Tech stack summary

---

## Save Context (Optional)

Sau khi explore, có thể lưu context vào `.amp/project-context.md`:

```markdown
# Project Context

## Stack
- Framework: Vite + React 18
- Language: TypeScript 5.x
- UI: Tailwind CSS + Shadcn/ui
- State: Zustand + React Query
- Router: React Router v6
- Form: React Hook Form + Zod

## Structure
- Pattern: Feature-based
- Pages: src/pages/
- Components: src/components/
- Hooks: src/hooks/
- Services: src/services/
- Stores: src/stores/

## Key Features
- auth: src/pages/auth/
- products: src/pages/products/
- cart: src/pages/cart/

## Conventions
- Component naming: PascalCase
- Hook naming: use<Name>
- Service naming: <name>.service.ts
- Store naming: <name>.store.ts

Last updated: <date>

Anti-Patterns

❌ Don't✅ Do Instead
Assume project structureDetect first
Search without contextKnow the stack first
Report without evidenceShow code locations
Skip diagramsAlways visualize
Forget state managementCheck stores/queries

Score

Total Score

45/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

0/5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon