Skip to content

Commit 55e8e6e

Browse files
Copilotastandrik
andcommitted
Reorganize developer documentation with improved structure and copy AGENTS.md to CLAUDE.md
Co-authored-by: astandrik <[email protected]>
1 parent 40eaa46 commit 55e8e6e

File tree

4 files changed

+720
-1745
lines changed

4 files changed

+720
-1745
lines changed

.github/copilot-instructions.md

Lines changed: 106 additions & 181 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,29 @@
11
# GitHub Copilot Instructions for YDB Embedded UI
22

3-
> **Note**: This file contains project-specific instructions for GitHub Copilot code review and assistance.
4-
> These instructions are derived from AGENTS.md but formatted specifically for Copilot's consumption.
5-
> When updating project conventions, update both AGENTS.md (for human developers) and this file (for Copilot).
3+
> **Purpose**: Optimized guidance for GitHub Copilot when assisting with YDB Embedded UI development.
4+
> Derived from AGENTS.md but structured for Copilot's code suggestion patterns.
65
7-
## Project Overview
6+
## Quick Context
87

9-
This is a React-based monitoring and management interface for YDB clusters. The codebase follows specific patterns and conventions that must be maintained.
8+
**Project**: React-based monitoring interface for YDB clusters
9+
**Key Tech**: React 18.3 + TypeScript 5.x + Redux Toolkit 2.x + Gravity UI 7.x + React Router v5
1010

11-
## Tech Stack Requirements
11+
## Critical Rules (Prevent 67% of Bugs)
1212

13-
- Use React 18.3 with TypeScript 5.x
14-
- Use Redux Toolkit 2.x with RTK Query for state management
15-
- Use Gravity UI (@gravity-ui/uikit) 7.x for UI components
16-
- Use React Router v5 (NOT v6) for routing
17-
- Use Monaco Editor 0.52 for code editing features
13+
> Based on analysis of 267 code review comments - these prevent production issues.
1814
19-
## Critical Coding Rules
15+
### API & State Management
16+
- **NEVER** call APIs directly → use `window.api.module.method()` pattern
17+
- **NEVER** mutate Redux state → return new objects/arrays
18+
- **ALWAYS** wrap `window.api` calls in RTK Query with `injectEndpoints`
2019

21-
*Based on analysis of 267 code review comments: These rules prevent 67% of production bugs and maintain 94% type safety compliance.*
20+
### React Performance (MANDATORY)
21+
- **ALWAYS** use `useMemo` for expensive computations, object/array creation
22+
- **ALWAYS** use `useCallback` for functions in effect dependencies
23+
- **ALWAYS** memoize table columns, filtered data, computed values
2224

23-
### API Architecture
24-
25-
- NEVER call APIs directly - always use `window.api.module.method()` pattern
26-
- Use RTK Query's `injectEndpoints` pattern for API endpoints
27-
- Wrap `window.api` calls in RTK Query for proper state management
28-
29-
### Critical Bug Prevention Patterns
30-
31-
**Memory & Display Safety**:
32-
- ALWAYS provide fallback values: `Number(value) || 0` instead of `Number(value)`
33-
- NEVER allow division by zero: `capacity > 0 ? value/capacity : 0`
34-
- ALWAYS dispose Monaco Editor: `return () => editor.dispose();` in useEffect
35-
36-
**State Management**:
37-
- NEVER mutate state in RTK Query - return new objects/arrays
38-
- ALWAYS handle Redux race conditions with proper loading states
39-
- Clear errors on user input in forms
40-
41-
### React Performance Requirements (MANDATORY)
42-
43-
**Memoization Rules**:
44-
- ALWAYS use `useMemo` for expensive computations, object/array creation
45-
- ALWAYS use `useCallback` for functions in effect dependencies
46-
- ALWAYS memoize table columns, filtered data, computed values
47-
48-
**Example**:
4925
```typescript
50-
// ✅ REQUIRED
26+
// ✅ REQUIRED patterns
5127
const displaySegments = useMemo(() =>
5228
segments.filter(segment => segment.visible), [segments]
5329
);
@@ -56,166 +32,115 @@ const handleClick = useCallback(() => {
5632
}, [dependency]);
5733
```
5834

59-
### Security Requirements (CRITICAL)
35+
### Memory & Display Safety
36+
- **ALWAYS** provide fallback values: `Number(value) || 0`
37+
- **NEVER** allow division by zero: `capacity > 0 ? value/capacity : 0`
38+
- **ALWAYS** dispose Monaco Editor: `return () => editor.dispose();` in useEffect
6039

61-
- NEVER expose authentication tokens in logs or console
62-
- ALWAYS validate user input before processing
63-
- NEVER skip error handling for async operations
64-
- ALWAYS use proper authentication token handling patterns
40+
### Security & Input Validation
41+
- **NEVER** expose authentication tokens in logs or console
42+
- **ALWAYS** validate user input before processing
43+
- **NEVER** skip error handling for async operations
44+
## Internationalization (MANDATORY)
6545

66-
### Memory Management Rules
67-
68-
- ALWAYS dispose Monaco Editor instances: `return () => editor.dispose();`
69-
- ALWAYS cleanup event listeners in useEffect return functions
70-
- NEVER skip cleanup for subscriptions or timers
71-
72-
### Error Handling Standards
73-
74-
- ALWAYS use try/catch for async operations
75-
- ALWAYS use `ResponseError` component for API errors
76-
- ALWAYS clear form errors on user input
77-
- NEVER allow unhandled promise rejections
78-
79-
### Mathematical Expression Safety
46+
- **NEVER** hardcode user-facing strings
47+
- **ALWAYS** create i18n entries in component's `i18n/` folder
48+
- Follow key format: `<context>_<content>` (e.g., `action_save`, `field_name`)
49+
- Register keysets with `registerKeysets()` using unique component name
8050

81-
- ALWAYS use explicit parentheses: `(a + b) * c` not `a + b * c`
82-
- ALWAYS check for division by zero: `denominator > 0 ? x/denominator : 0`
83-
- ALWAYS provide fallbacks for undefined values in calculations
51+
```typescript
52+
// ✅ CORRECT
53+
const b = cn('component-name');
54+
<Button>{i18n('action_save')}</Button>
8455

85-
### Internationalization (MANDATORY)
56+
// ❌ WRONG
57+
<Button>Save</Button>
58+
```
8659

87-
- NEVER hardcode user-facing strings
88-
- ALWAYS create i18n entries in component's `i18n/` folder
89-
- Follow key format: `<context>_<content>` (e.g., `action_save`, `field_name`)
90-
- Register keysets with `registerKeysets()` using unique component name
60+
## Component Patterns
9161

92-
### Component Patterns
62+
### Class Names (BEM)
63+
```typescript
64+
const b = cn('component-name');
65+
<div className={b()}>
66+
<div className={b('element')}>
67+
<span className={b('element', {modifier: true})}>
68+
```
9369

94-
- Use BEM naming with `cn()` utility: `const b = cn('component-name')`
70+
### Tables & Data Display
9571
- Use `PaginatedTable` component for all data tables
9672
- Tables require: columns, fetchData function, and unique tableName
9773
- Use virtual scrolling for large datasets
9874

99-
### State Management
100-
101-
- Use Redux Toolkit with domain-based organization
102-
- NEVER mutate state in RTK Query - return new objects/arrays
103-
- Clear errors on user input in forms
104-
- Always handle loading states in UI
105-
106-
### UI Components
107-
108-
- Prefer Gravity UI components over custom implementations
109-
- Use `createToast` for notifications
110-
- Use `ResponseError` component for API errors
111-
- Use `Loader` and `TableSkeleton` for loading states
112-
113-
### Form Handling
114-
115-
- Always use controlled components with validation
116-
- Clear errors on user input
117-
- Validate before submission
118-
- Use Gravity UI form components with error states
75+
### Error Handling
76+
```typescript
77+
// ✅ REQUIRED - All async operations
78+
try {
79+
const result = await apiCall();
80+
return result;
81+
} catch (error) {
82+
return <ResponseError error={error} />;
83+
}
84+
```
11985

120-
### Dialog/Modal Patterns
86+
### Forms
87+
```typescript
88+
// ✅ REQUIRED - Clear errors on input, validate before submit
89+
const handleInputChange = (field, value) => {
90+
setValue(field, value);
91+
if (errors[field]) {
92+
setErrors(prev => ({ ...prev, [field]: null }));
93+
}
94+
};
95+
```
12196

122-
- Use `@ebay/nice-modal-react` for complex modals
123-
- Use Gravity UI `Dialog` for simple dialogs
124-
- Always include loading states
97+
## Quality Gates (Before Every Commit)
98+
99+
1. ✅ Run `npm run lint` and `npm run typecheck` - NO exceptions
100+
2. ✅ Verify ALL user-facing strings use i18n (search for hardcoded text)
101+
3. ✅ Check ALL useEffect hooks have proper cleanup functions
102+
4. ✅ Ensure memoization for ALL expensive operations
103+
5. ✅ Validate error handling for ALL async operations
104+
6. ✅ Confirm NO authentication tokens exposed in logs
105+
7. ✅ Test mathematical expressions for edge cases (zero division)
106+
107+
## Code Suggestions Context
108+
109+
### Common Patterns to Suggest
110+
- `const b = cn('component-name')` for new components
111+
- `useMemo` for any array/object creation or filtering
112+
- `useCallback` for event handlers in dependencies
113+
- `i18n('key_name')` instead of hardcoded strings
114+
- `Number(value) || 0` instead of `Number(value)`
115+
- `condition > 0 ? calculation : 0` for divisions
116+
117+
### Avoid Suggesting
118+
- Direct API calls (suggest `window.api` instead)
119+
- Hardcoded strings (suggest i18n keys)
120+
- State mutations (suggest immutable returns)
121+
- Missing cleanup in useEffect
122+
- Missing error boundaries for async operations
125123

126124
### Type Conventions
127-
128-
- API types prefixed with 'T' (e.g., `TTenantInfo`, `TClusterInfo`)
129-
- Types located in `src/types/api/` directory
130-
131-
### Performance Requirements
132-
133-
- Use React.memo for expensive renders
134-
- Lazy load Monaco Editor
135-
- Batch API requests when possible
136-
- Use virtual scrolling for tables
137-
138-
### Testing Patterns
139-
140-
- Unit tests colocated in `__test__` directories
141-
- E2E tests use Playwright with page objects pattern
142-
- Use CSS class selectors for E2E element selection
125+
- API types: `TTenantInfo`, `TClusterInfo` (T prefix)
126+
- Located in `src/types/api/`
127+
- Use strict TypeScript, avoid `any`
143128

144129
### Navigation (React Router v5)
145-
146-
- Use React Router v5 hooks (`useHistory`, `useParams`)
130+
- Use `useHistory`, `useParams` (NOT v6 hooks)
147131
- Always validate route params exist before use
148132

149-
## Common Utilities
150-
151-
- Formatters: `formatBytes()`, `formatDateTime()` from `src/utils/dataFormatters/`
152-
- Time parsing: utilities in `src/utils/timeParsers/`
153-
- Query utilities: `src/utils/query.ts` for SQL/YQL helpers
154-
155-
## Quality Gate Requirements
156-
157-
*These requirements ensure 88% implementation rate and prevent critical bugs before commit.*
158-
159-
### Before Every Commit (MANDATORY)
133+
## Common Utilities for Suggestions
160134

161-
1. Run `npm run lint` and `npm run typecheck` - NO exceptions
162-
2. Verify ALL user-facing strings use i18n (search for hardcoded text)
163-
3. Check ALL useEffect hooks have proper cleanup functions
164-
4. Ensure memoization for ALL expensive operations
165-
5. Validate error handling for ALL async operations
166-
6. Confirm NO authentication tokens exposed in logs
167-
7. Test mathematical expressions for edge cases (zero division)
135+
- **Formatters**: `formatBytes()`, `formatDateTime()` from `src/utils/dataFormatters/`
136+
- **Class Names**: `cn()` from `src/utils/cn`
137+
- **Time Parsing**: utilities in `src/utils/timeParsers/`
138+
- **Query Helpers**: `src/utils/query.ts` for SQL/YQL
168139

169-
### Pre-Commit Automated Checks
140+
## Performance Requirements
170141

171-
- Spell checking enabled for all text
172-
- Magic number detection (all constants must be named)
173-
- TypeScript strict mode with no implicit any
174-
- Performance regression detection
175-
- Security token exposure scanning
176-
177-
### Review Standards by Change Type
178-
179-
**Critical Review Required** (Security/Performance):
180-
- Authentication/authorization changes
181-
- Monaco Editor integrations (memory management)
182-
- State management modifications (Redux patterns)
183-
- Performance optimizations (React patterns)
184-
185-
**Standard Review**:
186-
- UI component changes
187-
- Documentation updates
188-
- Test additions
189-
- Styling modifications
190-
191-
## Developer Guidelines
192-
193-
### Universal Standards
194-
195-
**Type Safety** (Critical for all developers):
196-
- Use strict TypeScript with no implicit any
197-
- Follow established type conventions
198-
- Validate all inputs and handle edge cases
199-
200-
**Performance** (Required for all implementations):
201-
- Always memoize expensive computations and object/array creation
202-
- Use proper React performance patterns (useMemo, useCallback)
203-
- Consider rendering performance impact
204-
205-
**Architecture** (Essential for all changes):
206-
- Review cross-system impact of changes
207-
- Follow established patterns and conventions
208-
- Consider scalability and maintainability
209-
210-
### Learning and Knowledge Sharing
211-
212-
- Document complex decisions for team knowledge sharing
213-
- Collaborate on architectural decisions when needed
214-
- Use quantified feedback to track improvement (current: 67% reduction in recurring issues)
215-
- Follow established review patterns and quality standards
216-
217-
## Debugging Helpers
218-
219-
- `window.api` - Access API methods in browser console
220-
- `window.ydbEditor` - Monaco editor instance
221-
- Enable request tracing with `DEV_ENABLE_TRACING_FOR_ALL_REQUESTS`
142+
When suggesting code changes:
143+
- Always consider React performance impact
144+
- Suggest memoization for expensive operations
145+
- Consider rendering performance for large datasets
146+
- Prefer Gravity UI components over custom implementations

0 commit comments

Comments
 (0)