Skip to content

Commit a515562

Browse files
Copilotastandrik
andcommitted
feat: implement pr comment analysis and improve agent guidelines
- Create analysis script to identify code review patterns - Update AGENTS.md with comprehensive code review guidelines - Replace CLAUDE.md with Claude-specific instructions - Enhance GitHub Copilot instructions with historical patterns - Add structured anti-patterns and best practices sections Co-authored-by: astandrik <[email protected]>
1 parent 66fc94d commit a515562

File tree

4 files changed

+710
-280
lines changed

4 files changed

+710
-280
lines changed

.github/copilot-instructions.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,61 @@ 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+
107+
108+
## Code Review Patterns (Historical Analysis)
109+
110+
### Common Review Feedback to Address
111+
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
117+
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
123+
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
129+
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
136+
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
143+
144+
## Copilot-Specific Guidelines
145+
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
152+
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
159+
160+
106161
## Debugging Helpers
107162

108163
- `window.api` - Access API methods in browser console

AGENTS.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,82 @@ Build artifacts are placed in `/build` directory. For embedded deployments, file
280280
2. **Bundle size**: Run `npm run analyze` to identify large dependencies
281281
3. **Memory leaks**: Check for missing cleanup in useEffect hooks
282282

283+
284+
## Code Review Guidelines (Based on Historical Patterns)
285+
286+
### Common Code Review Feedback Patterns
287+
288+
#### TypeScript Best Practices
289+
- Use proper TypeScript types instead of any
290+
- Define interfaces for API responses
291+
- Use strict type checking
292+
- Avoid type assertions, use type guards
293+
294+
#### React Development Patterns
295+
- Use React.memo for performance optimization
296+
- Implement proper error boundaries
297+
- Use useCallback and useMemo appropriately
298+
- Follow React hooks rules
299+
300+
#### State Management (Redux/RTK Query)
301+
- Use RTK Query for API calls instead of direct fetch
302+
- Implement proper loading states
303+
- Handle errors in Redux slices
304+
- Use injectEndpoints pattern
305+
306+
#### Internationalization Requirements
307+
- Never hardcode user-facing strings
308+
- Create i18n keys for all text
309+
- Use registerKeysets for new components
310+
- Follow i18n naming conventions
311+
312+
#### Component Architecture
313+
- Use BEM naming with cn() utility
314+
- Implement proper prop interfaces
315+
- Follow component file organization
316+
- Use Gravity UI components consistently
317+
318+
#### Testing Standards
319+
- Add unit tests for new components
320+
- Use testing-library best practices
321+
- Test error scenarios
322+
- Mock external dependencies properly
323+
324+
### Anti-Patterns to Avoid
325+
- ❌ Direct API calls instead of window.api pattern
326+
- ❌ Hardcoded strings instead of i18n
327+
- ❌ Mutating Redux state directly
328+
- ❌ Using React Router v6 patterns (project uses v5)
329+
- ❌ Missing loading states in UI
330+
- ❌ Not handling error cases
331+
- ❌ Inconsistent naming conventions
332+
- ❌ Missing TypeScript types
333+
334+
### Recommended Best Practices
335+
- ✅ Use window.api.module.method() pattern for API calls
336+
- ✅ Implement proper error handling with ResponseError component
337+
- ✅ Use PaginatedTable for data tables
338+
- ✅ Implement virtual scrolling for large datasets
339+
- ✅ Use Monaco Editor for code editing features
340+
- ✅ Follow conventional commit message format
341+
- ✅ Run lint and typecheck before committing
342+
- ✅ Use Gravity UI components over custom implementations
343+
344+
### Code Review Checklist
345+
346+
Before submitting a PR, ensure:
347+
348+
- [ ] TypeScript types are properly defined (no `any` types)
349+
- [ ] All user-facing strings are internationalized
350+
- [ ] API calls use `window.api` pattern
351+
- [ ] Components follow BEM naming with `cn()` utility
352+
- [ ] Loading states and error handling are implemented
353+
- [ ] Tests are added for new functionality
354+
- [ ] Code follows project conventions
355+
- [ ] `npm run lint` and `npm run typecheck` pass
356+
- [ ] Commit messages follow conventional format
357+
358+
283359
## Reference Resources
284360

285361
- **YDB Documentation**: https://ydb.tech/en/docs/

0 commit comments

Comments
 (0)