Skip to content

Commit 52faab1

Browse files
Copilotastandrik
andcommitted
fix: address feedback - make CLAUDE.md identical to AGENTS.md, remove analysis script, use enhanced docs
Co-authored-by: astandrik <[email protected]>
1 parent a515562 commit 52faab1

File tree

4 files changed

+741
-696
lines changed

4 files changed

+741
-696
lines changed

.github/copilot-instructions.md

Lines changed: 101 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -103,63 +103,121 @@ This is a React-based monitoring and management interface for YDB clusters. The
103103
- Ensure all user-facing text is internationalized
104104
- Test with a local YDB instance when possible
105105

106+
## MANDATORY Code Review Rules (From 435 PR Analysis)
107+
108+
### Top 5 Issues to Prevent
109+
110+
1. **Hardcoded Strings (42 occurrences)** - #1 issue
111+
- NEVER use hardcoded strings for user-facing text
112+
- Even dashes must use i18n: `i18n('context_no-data')` not `'–'`
113+
2. **Missing Tests (39 occurrences)**
114+
- ALL new features must have tests
115+
- Unit tests for components, E2E tests for features
116+
3. **Improper State Management (16 occurrences)**
117+
- Use Redux selectors, not direct state access
118+
- NEVER mutate state in RTK Query
119+
4. **Missing Loading States (12 occurrences)**
120+
- ALL async operations must show loading indicators
121+
- Use Loader and TableSkeleton components
122+
5. **Poor Error Handling (9 occurrences)**
123+
- Use ResponseError component for API errors
124+
- Clear errors on user input
125+
126+
### NEVER Do These
127+
128+
- Use mock data in production code
129+
- Make direct fetch/axios calls (use `window.api`)
130+
- Skip required API parameters
131+
- Create duplicate API calls
132+
- Use improper type names (API types need 'T' prefix)
133+
- Commit without running lint and typecheck
134+
135+
### ALWAYS Do These
136+
137+
- Test with real YDB backend: `docker run -dp 8765:8765 ghcr.io/ydb-platform/local-ydb:nightly`
138+
- Include `fields_required: -1` for sysinfo API calls
139+
- Make tables sortable, resizable with sticky headers
140+
- Clear errors on user input in forms
141+
- Use conventional commits with lowercase subjects
142+
143+
### Specific API Requirements
144+
145+
```typescript
146+
// Required for threads data (PR #2599)
147+
window.api.viewer.getSysInfo({
148+
nodeId: nodeId,
149+
fields_required: -1, // MANDATORY parameter
150+
});
151+
```
152+
153+
### Review Priority Matrix
154+
155+
| Priority | Issue | Check For |
156+
| -------- | ----------------- | ------------------------------- |
157+
| P0 | Hardcoded strings | All text uses i18n() |
158+
| P0 | Missing tests | New features have test coverage |
159+
| P1 | Mock data | Only real backend data used |
160+
| P1 | API patterns | window.api usage, no fetch() |
161+
| P2 | Type naming | API types prefixed with 'T' |
162+
163+
## Universal Code Review Standards
164+
165+
Apply these standards consistently for ALL code reviews:
166+
167+
### Backend & API Standards
106168

169+
- NO mock data - always use real backend data
170+
- Verify all required API parameters are included
171+
- Check for duplicate API calls
172+
- Ensure proper error handling
107173

108-
## Code Review Patterns (Historical Analysis)
174+
### UI/UX Standards
109175

110-
### Common Review Feedback to Address
176+
- Tables must have sticky headers, be sortable and resizable
177+
- Proper data alignment in all UI components
178+
- Use existing patterns from the codebase
179+
- Loading states for all async operations
111180

112-
#### TypeScript Quality
113-
- Use proper TypeScript types instead of any
114-
- Define interfaces for API responses
115-
- Use strict type checking
116-
- Avoid type assertions, use type guards
181+
### Code Quality Standards
117182

118-
#### React Implementation
119-
- Use React.memo for performance optimization
120-
- Implement proper error boundaries
121-
- Use useCallback and useMemo appropriately
122-
- Follow React hooks rules
183+
- Conventional commit format with lowercase subjects
184+
- No unnecessary files (test scripts, debug code)
185+
- No duplicate code or tests
186+
- Proper TypeScript types (API types prefixed with 'T')
187+
- Simplified event handler types
123188

124-
#### State Management
125-
- Use RTK Query for API calls instead of direct fetch
126-
- Implement proper loading states
127-
- Handle errors in Redux slices
128-
- Use injectEndpoints pattern
189+
### Testing Standards
129190

130-
### Critical Anti-Patterns (Auto-fix when detected)
131-
- Direct API calls instead of window.api pattern
132-
- Hardcoded strings instead of i18n
133-
- Mutating Redux state directly
134-
- Using React Router v6 patterns (project uses v5)
135-
- Missing loading states in UI
191+
- All new features must have tests
192+
- Verify functionality with real YDB instance
193+
- Remove all console.logs and debug statements
136194

137-
### Best Practice Enforcement
138-
- Use window.api.module.method() pattern for API calls
139-
- Implement proper error handling with ResponseError component
140-
- Use PaginatedTable for data tables
141-
- Implement virtual scrolling for large datasets
142-
- Use Monaco Editor for code editing features
195+
## Common Code Patterns to Flag
143196

144-
## Copilot-Specific Guidelines
197+
```typescript
198+
// ❌ Hardcoded string
199+
{
200+
value || '';
201+
}
145202

146-
### Auto-completion Priorities
147-
1. Suggest `window.api` calls over direct fetch
148-
2. Propose i18n keys for any string literals
149-
3. Recommend Gravity UI components
150-
4. Suggest proper TypeScript types
151-
5. Include error handling patterns
203+
// ✅ Internationalized
204+
{
205+
value || i18n('context_no-data');
206+
}
152207

153-
### Code Generation Rules
154-
- Always generate TypeScript interfaces for new data structures
155-
- Include i18n setup for new components
156-
- Add loading states for async operations
157-
- Implement proper error boundaries
158-
- Follow BEM naming conventions
208+
// ❌ Verbose event type
209+
(event: React.MouseEvent<HTMLButtonElement, MouseEvent>) =>
210+
// ✅ Simplified
211+
(event: React.MouseEvent<HTMLButtonElement>) =>
212+
// ❌ Direct API call
213+
fetch('/api/data');
159214

215+
// ✅ Via window.api
216+
window.api.module.getData();
217+
```
160218

161219
## Debugging Helpers
162220

163221
- `window.api` - Access API methods in browser console
164222
- `window.ydbEditor` - Monaco editor instance
165-
- Enable request tracing with `DEV_ENABLE_TRACING_FOR_ALL_REQUESTS`
223+
- Enable request tracing with `DEV_ENABLE_TRACING_FOR_ALL_REQUESTS`

0 commit comments

Comments
 (0)