ai-devx 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/templates/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
- package/templates/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
- package/templates/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
- package/templates/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/templates/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
- package/templates/.agent/ARCHITECTURE.md +288 -0
- package/templates/.agent/agents/backend-specialist.md +251 -135
- package/templates/.agent/agents/code-archaeologist.md +106 -0
- package/templates/.agent/agents/database-architect.md +222 -160
- package/templates/.agent/agents/debugger.md +205 -108
- package/templates/.agent/agents/devops-engineer.md +226 -169
- package/templates/.agent/agents/documentation-writer.md +104 -0
- package/templates/.agent/agents/explorer-agent.md +73 -0
- package/templates/.agent/agents/frontend-specialist.md +587 -116
- package/templates/.agent/agents/game-developer.md +162 -0
- package/templates/.agent/agents/mobile-developer.md +377 -0
- package/templates/.agent/agents/orchestrator.md +412 -133
- package/templates/.agent/agents/penetration-tester.md +188 -0
- package/templates/.agent/agents/performance-optimizer.md +187 -0
- package/templates/.agent/agents/product-manager.md +112 -0
- package/templates/.agent/agents/product-owner.md +95 -0
- package/templates/.agent/agents/project-planner.md +390 -111
- package/templates/.agent/agents/qa-automation-engineer.md +103 -0
- package/templates/.agent/agents/security-auditor.md +158 -110
- package/templates/.agent/agents/seo-specialist.md +111 -0
- package/templates/.agent/agents/test-engineer.md +136 -154
- package/templates/.agent/mcp_config.json +24 -0
- package/templates/.agent/rules/GEMINI.md +273 -0
- package/templates/.agent/scripts/auto_preview.py +148 -0
- package/templates/.agent/scripts/checklist.py +217 -0
- package/templates/.agent/scripts/session_manager.py +120 -0
- package/templates/.agent/scripts/verify_all.py +327 -0
- package/templates/.agent/skills/api-patterns/SKILL.md +77 -232
- package/templates/.agent/skills/api-patterns/api-style.md +42 -0
- package/templates/.agent/skills/api-patterns/auth.md +24 -0
- package/templates/.agent/skills/api-patterns/documentation.md +26 -0
- package/templates/.agent/skills/api-patterns/graphql.md +41 -0
- package/templates/.agent/skills/api-patterns/rate-limiting.md +31 -0
- package/templates/.agent/skills/api-patterns/response.md +37 -0
- package/templates/.agent/skills/api-patterns/rest.md +40 -0
- package/templates/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
- package/templates/.agent/skills/api-patterns/security-testing.md +122 -0
- package/templates/.agent/skills/api-patterns/trpc.md +41 -0
- package/templates/.agent/skills/api-patterns/versioning.md +22 -0
- package/templates/.agent/skills/app-builder/SKILL.md +75 -0
- package/templates/.agent/skills/app-builder/agent-coordination.md +71 -0
- package/templates/.agent/skills/app-builder/feature-building.md +53 -0
- package/templates/.agent/skills/app-builder/project-detection.md +34 -0
- package/templates/.agent/skills/app-builder/scaffolding.md +118 -0
- package/templates/.agent/skills/app-builder/tech-stack.md +40 -0
- package/templates/.agent/skills/app-builder/templates/SKILL.md +39 -0
- package/templates/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/templates/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/templates/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/templates/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/templates/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/templates/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/templates/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/templates/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
- package/templates/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
- package/templates/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
- package/templates/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
- package/templates/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/templates/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
- package/templates/.agent/skills/architecture/SKILL.md +55 -0
- package/templates/.agent/skills/architecture/context-discovery.md +43 -0
- package/templates/.agent/skills/architecture/examples.md +94 -0
- package/templates/.agent/skills/architecture/pattern-selection.md +68 -0
- package/templates/.agent/skills/architecture/patterns-reference.md +50 -0
- package/templates/.agent/skills/architecture/trade-off-analysis.md +77 -0
- package/templates/.agent/skills/bash-linux/SKILL.md +199 -0
- package/templates/.agent/skills/behavioral-modes/SKILL.md +242 -0
- package/templates/.agent/skills/brainstorming/SKILL.md +163 -0
- package/templates/.agent/skills/brainstorming/dynamic-questioning.md +350 -0
- package/templates/.agent/skills/clean-code/SKILL.md +201 -0
- package/templates/.agent/skills/code-review-checklist/SKILL.md +109 -0
- package/templates/.agent/skills/database-design/SKILL.md +34 -285
- package/templates/.agent/skills/database-design/database-selection.md +43 -0
- package/templates/.agent/skills/database-design/indexing.md +39 -0
- package/templates/.agent/skills/database-design/migrations.md +48 -0
- package/templates/.agent/skills/database-design/optimization.md +36 -0
- package/templates/.agent/skills/database-design/orm-selection.md +30 -0
- package/templates/.agent/skills/database-design/schema-design.md +56 -0
- package/templates/.agent/skills/database-design/scripts/schema_validator.py +172 -0
- package/templates/.agent/skills/deployment-procedures/SKILL.md +241 -0
- package/templates/.agent/skills/doc.md +177 -0
- package/templates/.agent/skills/documentation-templates/SKILL.md +194 -0
- package/templates/.agent/skills/frontend-design/SKILL.md +418 -0
- package/templates/.agent/skills/frontend-design/animation-guide.md +331 -0
- package/templates/.agent/skills/frontend-design/color-system.md +311 -0
- package/templates/.agent/skills/frontend-design/decision-trees.md +418 -0
- package/templates/.agent/skills/frontend-design/motion-graphics.md +306 -0
- package/templates/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/templates/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/templates/.agent/skills/frontend-design/typography-system.md +345 -0
- package/templates/.agent/skills/frontend-design/ux-psychology.md +1116 -0
- package/templates/.agent/skills/frontend-design/visual-effects.md +383 -0
- package/templates/.agent/skills/game-development/2d-games/SKILL.md +119 -0
- package/templates/.agent/skills/game-development/3d-games/SKILL.md +135 -0
- package/templates/.agent/skills/game-development/SKILL.md +167 -0
- package/templates/.agent/skills/game-development/game-art/SKILL.md +185 -0
- package/templates/.agent/skills/game-development/game-audio/SKILL.md +190 -0
- package/templates/.agent/skills/game-development/game-design/SKILL.md +129 -0
- package/templates/.agent/skills/game-development/mobile-games/SKILL.md +108 -0
- package/templates/.agent/skills/game-development/multiplayer/SKILL.md +132 -0
- package/templates/.agent/skills/game-development/pc-games/SKILL.md +144 -0
- package/templates/.agent/skills/game-development/vr-ar/SKILL.md +123 -0
- package/templates/.agent/skills/game-development/web-games/SKILL.md +150 -0
- package/templates/.agent/skills/geo-fundamentals/SKILL.md +156 -0
- package/templates/.agent/skills/geo-fundamentals/scripts/geo_checker.py +289 -0
- package/templates/.agent/skills/i18n-localization/SKILL.md +154 -0
- package/templates/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
- package/templates/.agent/skills/intelligent-routing/SKILL.md +335 -0
- package/templates/.agent/skills/lint-and-validate/SKILL.md +45 -0
- package/templates/.agent/skills/lint-and-validate/scripts/lint_runner.py +184 -0
- package/templates/.agent/skills/lint-and-validate/scripts/type_coverage.py +173 -0
- package/templates/.agent/skills/mcp-builder/SKILL.md +176 -0
- package/templates/.agent/skills/mobile-design/SKILL.md +394 -0
- package/templates/.agent/skills/mobile-design/decision-trees.md +516 -0
- package/templates/.agent/skills/mobile-design/mobile-backend.md +491 -0
- package/templates/.agent/skills/mobile-design/mobile-color-system.md +420 -0
- package/templates/.agent/skills/mobile-design/mobile-debugging.md +122 -0
- package/templates/.agent/skills/mobile-design/mobile-design-thinking.md +357 -0
- package/templates/.agent/skills/mobile-design/mobile-navigation.md +458 -0
- package/templates/.agent/skills/mobile-design/mobile-performance.md +767 -0
- package/templates/.agent/skills/mobile-design/mobile-testing.md +356 -0
- package/templates/.agent/skills/mobile-design/mobile-typography.md +433 -0
- package/templates/.agent/skills/mobile-design/platform-android.md +666 -0
- package/templates/.agent/skills/mobile-design/platform-ios.md +561 -0
- package/templates/.agent/skills/mobile-design/scripts/mobile_audit.py +670 -0
- package/templates/.agent/skills/mobile-design/touch-psychology.md +537 -0
- package/templates/.agent/skills/nextjs-react-expert/1-async-eliminating-waterfalls.md +312 -0
- package/templates/.agent/skills/nextjs-react-expert/2-bundle-bundle-size-optimization.md +240 -0
- package/templates/.agent/skills/nextjs-react-expert/3-server-server-side-performance.md +490 -0
- package/templates/.agent/skills/nextjs-react-expert/4-client-client-side-data-fetching.md +264 -0
- package/templates/.agent/skills/nextjs-react-expert/5-rerender-re-render-optimization.md +581 -0
- package/templates/.agent/skills/nextjs-react-expert/6-rendering-rendering-performance.md +432 -0
- package/templates/.agent/skills/nextjs-react-expert/7-js-javascript-performance.md +684 -0
- package/templates/.agent/skills/nextjs-react-expert/8-advanced-advanced-patterns.md +150 -0
- package/templates/.agent/skills/nextjs-react-expert/SKILL.md +286 -0
- package/templates/.agent/skills/nextjs-react-expert/scripts/convert_rules.py +222 -0
- package/templates/.agent/skills/nextjs-react-expert/scripts/react_performance_checker.py +252 -0
- package/templates/.agent/skills/nodejs-best-practices/SKILL.md +333 -0
- package/templates/.agent/skills/parallel-agents/SKILL.md +175 -0
- package/templates/.agent/skills/performance-profiling/SKILL.md +143 -0
- package/templates/.agent/skills/performance-profiling/scripts/lighthouse_audit.py +76 -0
- package/templates/.agent/skills/plan-writing/SKILL.md +152 -0
- package/templates/.agent/skills/powershell-windows/SKILL.md +167 -0
- package/templates/.agent/skills/python-patterns/SKILL.md +441 -0
- package/templates/.agent/skills/red-team-tactics/SKILL.md +199 -0
- package/templates/.agent/skills/rust-pro/SKILL.md +176 -0
- package/templates/.agent/skills/seo-fundamentals/SKILL.md +129 -0
- package/templates/.agent/skills/seo-fundamentals/scripts/seo_checker.py +219 -0
- package/templates/.agent/skills/server-management/SKILL.md +161 -0
- package/templates/.agent/skills/systematic-debugging/SKILL.md +109 -0
- package/templates/.agent/skills/tailwind-patterns/SKILL.md +269 -0
- package/templates/.agent/skills/tdd-workflow/SKILL.md +149 -0
- package/templates/.agent/skills/testing-patterns/SKILL.md +156 -240
- package/templates/.agent/skills/testing-patterns/scripts/test_runner.py +219 -0
- package/templates/.agent/skills/vulnerability-scanner/SKILL.md +276 -0
- package/templates/.agent/skills/vulnerability-scanner/checklists.md +121 -0
- package/templates/.agent/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/templates/.agent/skills/web-design-guidelines/SKILL.md +57 -0
- package/templates/.agent/skills/webapp-testing/SKILL.md +187 -0
- package/templates/.agent/skills/webapp-testing/scripts/playwright_runner.py +173 -0
- package/templates/.agent/workflows/brainstorm.md +113 -0
- package/templates/.agent/workflows/create.md +40 -112
- package/templates/.agent/workflows/debug.md +82 -117
- package/templates/.agent/workflows/deploy.md +142 -129
- package/templates/.agent/workflows/enhance.md +63 -0
- package/templates/.agent/workflows/orchestrate.md +237 -0
- package/templates/.agent/workflows/plan.md +74 -138
- package/templates/.agent/workflows/preview.md +81 -0
- package/templates/.agent/workflows/status.md +86 -0
- package/templates/.agent/workflows/test.md +109 -130
- package/templates/.agent/workflows/ui-ux-pro-max.md +296 -0
- package/templates/.agent/scripts/checklist.js +0 -260
- package/templates/.agent/scripts/security_scan.js +0 -251
- package/templates/.agent/skills/docker-expert/SKILL.md +0 -286
- package/templates/.agent/skills/react-best-practices/SKILL.md +0 -246
- package/templates/.agent/workflows/security.md +0 -181
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: react-best-practices
|
|
3
|
-
description: Modern React development patterns, hooks, and performance optimization
|
|
4
|
-
version: "1.0.0"
|
|
5
|
-
requires: []
|
|
6
|
-
related:
|
|
7
|
-
- frontend-design
|
|
8
|
-
- testing-patterns
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# React Best Practices Skill
|
|
12
|
-
|
|
13
|
-
## Core Principles
|
|
14
|
-
|
|
15
|
-
### 1. Functional Components
|
|
16
|
-
Always use functional components with hooks instead of class components.
|
|
17
|
-
|
|
18
|
-
```tsx
|
|
19
|
-
// ✅ Good
|
|
20
|
-
function UserCard({ user }: UserCardProps) {
|
|
21
|
-
return <div>{user.name}</div>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// ❌ Avoid
|
|
25
|
-
class UserCard extends React.Component {
|
|
26
|
-
render() {
|
|
27
|
-
return <div>{this.props.user.name}</div>;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
### 2. Hooks Rules
|
|
33
|
-
- Only call hooks at the top level
|
|
34
|
-
- Only call hooks from React functions
|
|
35
|
-
- Use eslint-plugin-react-hooks
|
|
36
|
-
|
|
37
|
-
```tsx
|
|
38
|
-
// ✅ Good
|
|
39
|
-
function Component() {
|
|
40
|
-
const [state, setState] = useState(0);
|
|
41
|
-
useEffect(() => {}, []);
|
|
42
|
-
return <div />;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// ❌ Bad - Hook inside condition
|
|
46
|
-
function Component() {
|
|
47
|
-
if (condition) {
|
|
48
|
-
useEffect(() => {}, []);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### 3. Custom Hooks
|
|
54
|
-
Extract reusable logic into custom hooks.
|
|
55
|
-
|
|
56
|
-
```tsx
|
|
57
|
-
// useUser.ts
|
|
58
|
-
export function useUser(userId: string) {
|
|
59
|
-
const [user, setUser] = useState<User | null>(null);
|
|
60
|
-
const [loading, setLoading] = useState(true);
|
|
61
|
-
const [error, setError] = useState<Error | null>(null);
|
|
62
|
-
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
fetchUser(userId)
|
|
65
|
-
.then(setUser)
|
|
66
|
-
.catch(setError)
|
|
67
|
-
.finally(() => setLoading(false));
|
|
68
|
-
}, [userId]);
|
|
69
|
-
|
|
70
|
-
return { user, loading, error };
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Usage
|
|
74
|
-
function UserProfile({ userId }: { userId: string }) {
|
|
75
|
-
const { user, loading, error } = useUser(userId);
|
|
76
|
-
|
|
77
|
-
if (loading) return <Spinner />;
|
|
78
|
-
if (error) return <Error message={error.message} />;
|
|
79
|
-
return <div>{user?.name}</div>;
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## State Management
|
|
84
|
-
|
|
85
|
-
### useState
|
|
86
|
-
- Use for simple, local state
|
|
87
|
-
- Prefer multiple state variables over single object
|
|
88
|
-
|
|
89
|
-
```tsx
|
|
90
|
-
// ✅ Good
|
|
91
|
-
const [name, setName] = useState('');
|
|
92
|
-
const [email, setEmail] = useState('');
|
|
93
|
-
|
|
94
|
-
// ❌ Avoid unless related
|
|
95
|
-
const [form, setForm] = useState({ name: '', email: '' });
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### useReducer
|
|
99
|
-
- Use for complex state logic
|
|
100
|
-
- Multiple related state transitions
|
|
101
|
-
|
|
102
|
-
```tsx
|
|
103
|
-
interface State {
|
|
104
|
-
loading: boolean;
|
|
105
|
-
data: Data | null;
|
|
106
|
-
error: Error | null;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
type Action =
|
|
110
|
-
| { type: 'FETCH_START' }
|
|
111
|
-
| { type: 'FETCH_SUCCESS'; payload: Data }
|
|
112
|
-
| { type: 'FETCH_ERROR'; payload: Error };
|
|
113
|
-
|
|
114
|
-
function reducer(state: State, action: Action): State {
|
|
115
|
-
switch (action.type) {
|
|
116
|
-
case 'FETCH_START':
|
|
117
|
-
return { ...state, loading: true, error: null };
|
|
118
|
-
case 'FETCH_SUCCESS':
|
|
119
|
-
return { ...state, loading: false, data: action.payload };
|
|
120
|
-
case 'FETCH_ERROR':
|
|
121
|
-
return { ...state, loading: false, error: action.payload };
|
|
122
|
-
default:
|
|
123
|
-
return state;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### Context API
|
|
129
|
-
- Use for global state (theme, auth, user)
|
|
130
|
-
- Avoid prop drilling
|
|
131
|
-
|
|
132
|
-
```tsx
|
|
133
|
-
// ThemeContext.tsx
|
|
134
|
-
const ThemeContext = createContext<ThemeContextType | undefined>(undefined);
|
|
135
|
-
|
|
136
|
-
export function ThemeProvider({ children }: { children: ReactNode }) {
|
|
137
|
-
const [theme, setTheme] = useState('light');
|
|
138
|
-
|
|
139
|
-
return (
|
|
140
|
-
<ThemeContext.Provider value={{ theme, setTheme }}>
|
|
141
|
-
{children}
|
|
142
|
-
</ThemeContext.Provider>
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export const useTheme = () => {
|
|
147
|
-
const context = useContext(ThemeContext);
|
|
148
|
-
if (!context) throw new Error('useTheme must be used within ThemeProvider');
|
|
149
|
-
return context;
|
|
150
|
-
};
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
## Performance Optimization
|
|
154
|
-
|
|
155
|
-
### 1. React.memo
|
|
156
|
-
Prevent unnecessary re-renders for pure components.
|
|
157
|
-
|
|
158
|
-
```tsx
|
|
159
|
-
const ExpensiveComponent = React.memo(function ExpensiveComponent({ data }) {
|
|
160
|
-
// Only re-renders if data changes
|
|
161
|
-
return <div>{/* expensive rendering */}</div>;
|
|
162
|
-
});
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
### 2. useMemo
|
|
166
|
-
Cache expensive calculations.
|
|
167
|
-
|
|
168
|
-
```tsx
|
|
169
|
-
const sortedData = useMemo(() => {
|
|
170
|
-
return data.sort((a, b) => a.value - b.value);
|
|
171
|
-
}, [data]);
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
### 3. useCallback
|
|
175
|
-
Cache function references.
|
|
176
|
-
|
|
177
|
-
```tsx
|
|
178
|
-
const handleClick = useCallback(() => {
|
|
179
|
-
doSomething(id);
|
|
180
|
-
}, [id]);
|
|
181
|
-
|
|
182
|
-
// Now Child won't re-render unnecessarily
|
|
183
|
-
<Child onClick={handleClick} />
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
### 4. Code Splitting
|
|
187
|
-
```tsx
|
|
188
|
-
const LazyComponent = lazy(() => import('./HeavyComponent'));
|
|
189
|
-
|
|
190
|
-
function App() {
|
|
191
|
-
return (
|
|
192
|
-
<Suspense fallback={<Spinner />}>
|
|
193
|
-
<LazyComponent />
|
|
194
|
-
</Suspense>
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
## Component Patterns
|
|
200
|
-
|
|
201
|
-
### Compound Components
|
|
202
|
-
```tsx
|
|
203
|
-
function Select({ children }: { children: ReactNode }) {
|
|
204
|
-
const [selected, setSelected] = useState<string | null>(null);
|
|
205
|
-
return <SelectContext.Provider value={{ selected, setSelected }}>{children}</SelectContext.Provider>;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
Select.Option = function Option({ value, children }: OptionProps) {
|
|
209
|
-
const { selected, setSelected } = useSelectContext();
|
|
210
|
-
return <div onClick={() => setSelected(value)}>{children}</div>;
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
// Usage
|
|
214
|
-
<Select>
|
|
215
|
-
<Select.Option value="1">Option 1</Select.Option>
|
|
216
|
-
<Select.Option value="2">Option 2</Select.Option>
|
|
217
|
-
</Select>
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
## File Organization
|
|
221
|
-
```
|
|
222
|
-
src/
|
|
223
|
-
├── components/ # Reusable UI components
|
|
224
|
-
│ ├── Button/
|
|
225
|
-
│ │ ├── Button.tsx
|
|
226
|
-
│ │ ├── Button.test.tsx
|
|
227
|
-
│ │ └── index.ts
|
|
228
|
-
│ └── Card/
|
|
229
|
-
├── hooks/ # Custom hooks
|
|
230
|
-
│ ├── useAuth.ts
|
|
231
|
-
│ ├── useLocalStorage.ts
|
|
232
|
-
│ └── index.ts
|
|
233
|
-
├── contexts/ # React contexts
|
|
234
|
-
│ ├── AuthContext.tsx
|
|
235
|
-
│ └── ThemeContext.tsx
|
|
236
|
-
├── lib/ # Utilities
|
|
237
|
-
│ ├── api.ts
|
|
238
|
-
│ └── utils.ts
|
|
239
|
-
├── types/ # TypeScript types
|
|
240
|
-
│ └── index.ts
|
|
241
|
-
└── pages/ # Page components
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
## Related Skills
|
|
245
|
-
- After coding: `frontend-design` for styling
|
|
246
|
-
- Before deployment: `testing-patterns` for tests
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
command: /security
|
|
3
|
-
description: Security audit, vulnerability scanning, and security fixes
|
|
4
|
-
agent: security-auditor
|
|
5
|
-
skills:
|
|
6
|
-
- vulnerability-scanner
|
|
7
|
-
- security-best-practices
|
|
8
|
-
- authentication-patterns
|
|
9
|
-
mode: strict
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
# /security Workflow
|
|
13
|
-
|
|
14
|
-
## Purpose
|
|
15
|
-
Perform security audits, scan for vulnerabilities, and implement security fixes.
|
|
16
|
-
|
|
17
|
-
## Trigger
|
|
18
|
-
User types: `/security` or `/security audit`
|
|
19
|
-
|
|
20
|
-
## Execution Steps
|
|
21
|
-
|
|
22
|
-
### Step 1: Code Scan
|
|
23
|
-
Check for:
|
|
24
|
-
- Hardcoded secrets
|
|
25
|
-
- SQL injection vulnerabilities
|
|
26
|
-
- XSS vulnerabilities
|
|
27
|
-
- Insecure dependencies
|
|
28
|
-
- Weak authentication
|
|
29
|
-
- Missing authorization
|
|
30
|
-
|
|
31
|
-
### Step 2: Dependency Scan
|
|
32
|
-
Check for:
|
|
33
|
-
- Known vulnerabilities in dependencies
|
|
34
|
-
- Outdated packages
|
|
35
|
-
- License compliance
|
|
36
|
-
|
|
37
|
-
### Step 3: Configuration Review
|
|
38
|
-
Check:
|
|
39
|
-
- Environment variables
|
|
40
|
-
- Security headers
|
|
41
|
-
- CORS settings
|
|
42
|
-
- SSL/TLS configuration
|
|
43
|
-
- Authentication settings
|
|
44
|
-
|
|
45
|
-
### Step 4: Vulnerability Assessment
|
|
46
|
-
Classify findings:
|
|
47
|
-
- **Critical**: Immediate action required
|
|
48
|
-
- **High**: Fix within 24 hours
|
|
49
|
-
- **Medium**: Fix within 1 week
|
|
50
|
-
- **Low**: Fix when convenient
|
|
51
|
-
- **Info**: Best practices
|
|
52
|
-
|
|
53
|
-
### Step 5: Remediation
|
|
54
|
-
Provide fixes for each vulnerability:
|
|
55
|
-
- Code examples
|
|
56
|
-
- Configuration changes
|
|
57
|
-
- Dependency updates
|
|
58
|
-
|
|
59
|
-
### Step 6: Validation
|
|
60
|
-
Verify fixes:
|
|
61
|
-
- Re-run security scans
|
|
62
|
-
- Test application functionality
|
|
63
|
-
- Check for regressions
|
|
64
|
-
|
|
65
|
-
## Response Format
|
|
66
|
-
|
|
67
|
-
```
|
|
68
|
-
⚡ Executing /security
|
|
69
|
-
|
|
70
|
-
🤖 Applying @security-auditor...
|
|
71
|
-
|
|
72
|
-
## Security Audit Results
|
|
73
|
-
|
|
74
|
-
### Summary
|
|
75
|
-
🔴 Critical: 1
|
|
76
|
-
🟠 High: 2
|
|
77
|
-
🟡 Medium: 3
|
|
78
|
-
🟢 Low: 5
|
|
79
|
-
|
|
80
|
-
### Critical Issues
|
|
81
|
-
|
|
82
|
-
#### 1. Hardcoded API Key
|
|
83
|
-
**Location**: `src/config.ts:15`
|
|
84
|
-
**Severity**: 🔴 Critical
|
|
85
|
-
|
|
86
|
-
**Issue**:
|
|
87
|
-
```typescript
|
|
88
|
-
const API_KEY = "sk-1234567890abcdef";
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
**Fix**:
|
|
92
|
-
```typescript
|
|
93
|
-
const API_KEY = process.env.API_KEY;
|
|
94
|
-
if (!API_KEY) {
|
|
95
|
-
throw new Error('API_KEY environment variable required');
|
|
96
|
-
}
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
#### 2. SQL Injection Risk
|
|
100
|
-
**Location**: `src/routes/users.ts:23`
|
|
101
|
-
**Severity**: 🔴 Critical
|
|
102
|
-
|
|
103
|
-
**Issue**:
|
|
104
|
-
```typescript
|
|
105
|
-
const query = `SELECT * FROM users WHERE id = ${userId}`;
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
**Fix**:
|
|
109
|
-
```typescript
|
|
110
|
-
const query = 'SELECT * FROM users WHERE id = $1';
|
|
111
|
-
const result = await db.query(query, [userId]);
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Dependency Vulnerabilities
|
|
115
|
-
|
|
116
|
-
| Package | Version | CVE | Severity | Fix |
|
|
117
|
-
|---------|---------|-----|----------|-----|
|
|
118
|
-
| lodash | 4.17.15 | CVE-2021-23337 | High | Upgrade to 4.17.21 |
|
|
119
|
-
| express | 4.17.1 | CVE-2022-24999 | Medium | Upgrade to 4.18.2 |
|
|
120
|
-
|
|
121
|
-
### Recommendations
|
|
122
|
-
- Enable Dependabot
|
|
123
|
-
- Set up security alerts
|
|
124
|
-
- Regular dependency updates
|
|
125
|
-
- Security training for team
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
## Security Checklist
|
|
129
|
-
|
|
130
|
-
### Code Security
|
|
131
|
-
- [ ] No hardcoded secrets
|
|
132
|
-
- [ ] Input validation on all endpoints
|
|
133
|
-
- [ ] Output encoding
|
|
134
|
-
- [ ] Parameterized queries
|
|
135
|
-
- [ ] CSRF protection
|
|
136
|
-
- [ ] XSS prevention
|
|
137
|
-
|
|
138
|
-
### Authentication
|
|
139
|
-
- [ ] Strong password policy
|
|
140
|
-
- [ ] Rate limiting on auth endpoints
|
|
141
|
-
- [ ] Session timeout
|
|
142
|
-
- [ ] Secure session storage
|
|
143
|
-
- [ ] MFA available
|
|
144
|
-
|
|
145
|
-
### Authorization
|
|
146
|
-
- [ ] RBAC implemented
|
|
147
|
-
- [ ] Resource-level checks
|
|
148
|
-
- [ ] No privilege escalation
|
|
149
|
-
|
|
150
|
-
### Infrastructure
|
|
151
|
-
- [ ] HTTPS enforced
|
|
152
|
-
- [ ] Security headers set
|
|
153
|
-
- [ ] CORS configured
|
|
154
|
-
- [ ] Secrets management
|
|
155
|
-
- [ ] Logging enabled
|
|
156
|
-
|
|
157
|
-
## Commands
|
|
158
|
-
|
|
159
|
-
```bash
|
|
160
|
-
# Scan dependencies
|
|
161
|
-
npm audit
|
|
162
|
-
|
|
163
|
-
# Fix vulnerabilities
|
|
164
|
-
npm audit fix
|
|
165
|
-
|
|
166
|
-
# Security headers check
|
|
167
|
-
npx helmet
|
|
168
|
-
|
|
169
|
-
# Secrets scanning
|
|
170
|
-
git-secrets --scan
|
|
171
|
-
|
|
172
|
-
# SAST scanning
|
|
173
|
-
sonar-scanner
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
## Success Criteria
|
|
177
|
-
- No critical vulnerabilities
|
|
178
|
-
- No high vulnerabilities
|
|
179
|
-
- All medium vulnerabilities planned
|
|
180
|
-
- Dependencies up to date
|
|
181
|
-
- Security headers configured
|