| Dimension | Shared | Only in A | Only in B | Overlap |
|---|---|---|---|---|
| Sections | 0 | 6 | 41 | 0% |
| Commands | 0 | 0 | 6 | 0% |
| Section tags | 2 | 0 | 15 | 12% |
What each file covers
Sections
0 shared · 6 only in A · 41 only in B- − Cline Rules for Megarepo
- − Rules Structure
- − How Cline Uses These Rules
- − Customization
- − Rules Bank Approach
- − Consistency with Other AI Assistants
- + Cursor Rules for Megarepo - AI Setup Repository
- + Repository Overview
- + Core Development Principles
- + 1. AI-First Development
- + 2. Security & API Key Management
- + 3. Code Quality Standards
- + Technology Stack Guidelines
- + Node.js/Next.js Development
- + AI Integration Patterns
- + Common AI Dependencies
- + File Structure and Organization
- + Expected Project Structure
- + Key Directories
- + Development Workflow
- + Before Writing Code
- + Code Development
- + Testing AI Components
- + Environment Setup
- + Required Environment Variables
- + AI Service Keys
- + Application Settings
- + Database (if needed)
- + Development Commands
- + AI-Specific Best Practices
- + 1. Prompt Engineering
- + 2. Response Handling
- + 3. Performance Optimization
- + 4. User Experience
- + Code Style and Formatting
- + TypeScript Preferences
- + React Patterns
- + API Development
- + Error Handling and Monitoring
- + AI Service Errors
- + Monitoring and Logging
- + Documentation Requirements
- + Code Documentation
- + API Documentation
- + Security Considerations
- + Data Privacy
- + API Security
Commands
0 shared · 0 only in A · 6 only in B- + npm install
- + npm run dev
- + npm run build
- + npm run test
- + npm run lint
- + npm run type-check
Section tags
2 shared · 0 only in A · 15 only in B- + setup
- + build
- + test
- + lint-format
- + code-style
- + types
- + testing-strategy
- + git-pr
- + security
- + dependencies
- + database
- + api
- + performance
- + agent-behaviour
- + docs
- architecture
- do-not
Line diff
HerringtonDarkholme/megarepo · .clinerules/README.md
@@ −1 @@
1# Cline Rules for Megarepo
2
3This directory contains Cline Rules that provide system-level guidance for the Cline AI assistant when working on this AI setup repository.
4
5## Rules Structure
6
7The rules are organized into focused files that build upon each other:
8
91. **`01-core-principles.md`** - Fundamental principles including minimal change philosophy and AI-first development
102. **`02-development.md`** - Development guidelines for Node.js/Next.js AI projects
113. **`03-documentation.md`** - Documentation requirements and standards
124. **`04-security.md`** - Security guidelines for AI projects and API key management
13
14## How Cline Uses These Rules
15
16Cline automatically processes all Markdown files in this directory, combining them into a unified set of rules. The numeric prefixes help organize the files in a logical sequence, ensuring core principles are established before specific guidelines.
17
18## Customization
19
20These rules are tailored specifically for the Megarepo AI setup repository and should be updated as the project evolves. The rules emphasize:
21
22- **Minimal Changes**: Surgical, precise modifications that respect the repository's intentional simplicity
23- **AI-First Development**: Patterns and practices optimized for AI service integrations
24- **Security Best Practices**: Safe handling of API keys and sensitive data
25- **Node.js/Next.js Patterns**: Guidelines specific to the target technology stack
26
27## Rules Bank Approach
28
29This repository follows the "active rules" pattern where the `.clinerules/` directory contains only the rules that should be active. For projects with multiple contexts, consider creating a `clinerules-bank/` directory with additional rule sets that can be activated as needed.
30
31## Consistency with Other AI Assistants
32
33These rules are designed to work alongside other AI assistant configurations in this repository:
34- GitHub Copilot (`.github/copilot-instructions.md`)
35- Claude AI (`CLAUDE.md`)
36- Cursor AI (`.cursorrules`)
37- Gemini CLI (`GEMINI.md`)
38- Universal AI guidelines (`AGENT.md`, `AGENTS.md`)
39
40All configurations share common principles while being optimized for each assistant's specific capabilities.
HerringtonDarkholme/megarepo · .cursorrules
@@ +1 @@
1# Cursor Rules for Megarepo - AI Setup Repository
2
3You are an expert AI developer working in the Megarepo, a comprehensive AI setup repository designed for AI-related projects. Follow these rules when assisting with code development, analysis, and project setup.
4
5## Repository Overview
6
7This is a minimal AI setup repository template configured for Node.js/Next.js development. The repository serves as a foundation for AI-related projects and contains basic setup files with comprehensive development guidelines.
8
9**Current State**: Minimal setup with basic configuration files
10- Use these rules to guide development when source code is added
11- Follow Node.js/Next.js patterns and best practices
12- Prioritize AI-specific development patterns and security
13
14## Core Development Principles
15
16### 1. AI-First Development
17- Prioritize AI integration patterns and best practices
18- Consider model performance, API efficiency, and token usage
19- Implement proper error handling for AI service failures
20- Design for scalability with AI workloads
21
22### 2. Security & API Key Management
23- **NEVER** commit API keys, secrets, or credentials to version control
24- Always use environment variables for sensitive data
25- Create `.env.example` files to document required environment variables
26- Implement proper API key rotation and management patterns
27- Use secure storage solutions for production deployments
28
29### 3. Code Quality Standards
30- Write clean, readable, and well-documented code
31- Use TypeScript for type safety when applicable
32- Implement comprehensive error handling and logging
33- Follow established linting and formatting rules
34- Write meaningful commit messages and documentation
35
36## Technology Stack Guidelines
37
38### Node.js/Next.js Development
39- Follow Next.js 13+ App Router patterns when applicable
40- Use modern ES6+ JavaScript/TypeScript features
41- Implement proper async/await patterns for AI API calls
42- Use React Server Components where appropriate
43- Optimize for both development and production environments
44
45### AI Integration Patterns
46```javascript
47// Preferred AI API integration pattern
48const aiResponse = await fetch('/api/ai-service', {
49 method: 'POST',
50 headers: {
51 'Content-Type': 'application/json',
52 'Authorization': `Bearer ${process.env.AI_API_KEY}`
53 },
54 body: JSON.stringify({ prompt, options })
55});
56
57if (!aiResponse.ok) {
58 throw new Error(`AI service error: ${aiResponse.status}`);
59}
60```
61
62### Common AI Dependencies
63When adding AI functionality, prefer these well-established packages:
64- `openai` - Official OpenAI API client
65- `@langchain/core` - LangChain framework
66- `@vercel/ai` - Vercel AI SDK
67- `@huggingface/inference` - Hugging Face API client
68
69## File Structure and Organization
70
71### Expected Project Structure
72```
73.
74├── README.md # Project documentation
75├── LICENSE # MIT license
76├── .gitignore # Node.js/Next.js patterns
77├── .cursorrules # This file
78├── .env.example # Environment variable template
79├── package.json # Dependencies and scripts
80├── next.config.js # Next.js configuration
81├── tsconfig.json # TypeScript configuration
82├── src/
83│ ├── app/ # Next.js app directory
84│ ├── components/ # React components
85│ ├── lib/ # Utility functions and AI clients
86│ ├── types/ # TypeScript type definitions
87│ └── utils/ # Helper functions
88├── public/ # Static assets
89└── docs/ # Additional documentation
90```
91
92### Key Directories
93- `src/lib/` - Place AI client configurations and utilities here
94- `src/components/` - Reusable UI components, including AI-powered components
95- `src/app/api/` - API routes for AI services and integrations
96- `src/types/` - TypeScript definitions for AI responses and data models
97
98## Development Workflow
99
100### Before Writing Code
1011. Check if `package.json` exists before running npm commands
1022. Review existing environment variable requirements
1033. Understand the AI service integrations being used
1044. Consider rate limiting and usage patterns
105
106### Code Development
1071. Write TypeScript definitions for AI API responses
1082. Implement proper error handling for AI service failures
1093. Add loading states and user feedback for AI operations
1104. Consider performance implications of AI API calls
1115. Implement caching strategies where appropriate
112
113### Testing AI Components
114```javascript
115// Example AI component test pattern
116describe('AI Chat Component', () => {
117 it('handles API errors gracefully', async () => {
118 // Mock AI service failure
119 mockAIService.mockRejectedValue(new Error('API Error'));
120
121 render(<ChatComponent />);
122
123 // Test error handling and user feedback
124 expect(screen.getByText(/error/i)).toBeInTheDocument();
125 });
126});
127```
128
129## Environment Setup
130
131### Required Environment Variables
132Create `.env.local` with these patterns:
133```bash
134# AI Service Keys
135OPENAI_API_KEY=your_openai_key_here
136ANTHROPIC_API_KEY=your_anthropic_key_here
137
138# Application Settings
139NEXT_PUBLIC_APP_URL=http://localhost:3000
140NODE_ENV=development
141
142# Database (if needed)
143DATABASE_URL=your_database_url_here
144```
145
146### Development Commands
147When `package.json` exists, use these commands:
148```bash
149npm install # Install dependencies
150npm run dev # Start development server
151npm run build # Production build
152npm run test # Run tests
153npm run lint # Run linter
154npm run type-check # TypeScript validation
155```
156
157## AI-Specific Best Practices
158
159### 1. Prompt Engineering
160- Store prompts in separate files or constants
161- Use template literals for dynamic prompt generation
162- Implement prompt versioning for A/B testing
163- Consider token limits and optimize prompt length
164
165### 2. Response Handling
166- Always validate AI responses before using them
167- Implement fallback mechanisms for failed requests
168- Log AI interactions for debugging and monitoring
169- Handle streaming responses appropriately
170
171### 3. Performance Optimization
172- Cache AI responses when appropriate
173- Implement request debouncing for user inputs
174- Use background processing for long-running AI tasks
175- Consider edge functions for AI API proxying
176
177### 4. User Experience
178- Provide clear loading indicators for AI operations
179- Implement progressive disclosure for complex AI features
180- Give users control over AI behavior and settings
181- Provide feedback mechanisms for AI output quality
182
183## Code Style and Formatting
184
185### TypeScript Preferences
186- Use strict type checking
187- Define interfaces for all AI API responses
188- Use union types for AI model selections
189- Implement proper error type definitions
190
191### React Patterns
192- Use functional components with hooks
193- Implement proper cleanup for AI subscriptions
194- Use React.memo for expensive AI-powered components
195- Handle loading and error states consistently
196
197### API Development
198- Follow RESTful principles for AI service endpoints
199- Implement proper rate limiting and authentication
200- Use middleware for common AI service operations
201- Document API endpoints with clear examples
202
203## Error Handling and Monitoring
204
205### AI Service Errors
206```javascript
207// Comprehensive error handling pattern
208try {
209 const response = await aiClient.complete(prompt);
210 return response;
211} catch (error) {
212 if (error.code === 'rate_limit_exceeded') {
213 // Implement backoff strategy
214 await delay(exponentialBackoff(retryCount));
215 return retry();
216 } else if (error.code === 'insufficient_quota') {
217 // Handle quota issues
218 throw new QuotaExceededError('AI service quota exceeded');
219 } else {
220 // Log and handle unexpected errors
221 logger.error('AI service error', error);
222 throw new AIServiceError('Unexpected AI service error');
223 }
224}
225```
226
227### Monitoring and Logging
228- Log AI API usage and costs
229- Monitor response times and error rates
230- Track user interactions with AI features
231- Implement health checks for AI services
232
233## Documentation Requirements
234
235### Code Documentation
236- Document all AI-related functions and components
237- Include usage examples for AI integrations
238- Explain prompt engineering decisions
239- Document environment setup requirements
240
241### API Documentation
242- Document all AI service endpoints
243- Include request/response examples
244- Explain rate limiting and authentication
245- Provide troubleshooting guides
246
247## Security Considerations
248
249### Data Privacy
250- Avoid sending sensitive user data to AI services
251- Implement data anonymization where possible
252- Follow GDPR and privacy regulations
253- Document data usage and retention policies
254
255### API Security
256- Validate all inputs before sending to AI services
257- Implement proper CORS settings
258- Use HTTPS for all AI API communications
259- Regularly rotate API keys and secrets
260
261Remember: This repository is designed as a foundation for AI projects. Always consider the specific AI use case when implementing features, and prioritize user experience, security, and performance in all AI-related development.
@@ −1 +1 @@
1−# Cline Rules for Megarepo
1+# Cursor Rules for Megarepo - AI Setup Repository
22
3−This directory contains Cline Rules that provide system-level guidance for the Cline AI assistant when working on this AI setup repository.
3+You are an expert AI developer working in the Megarepo, a comprehensive AI setup repository designed for AI-related projects. Follow these rules when assisting with code development, analysis, and project setup.
44
5−## Rules Structure
5+## Repository Overview
66
7−The rules are organized into focused files that build upon each other:
7+This is a minimal AI setup repository template configured for Node.js/Next.js development. The repository serves as a foundation for AI-related projects and contains basic setup files with comprehensive development guidelines.
88
9−1. **`01-core-principles.md`** - Fundamental principles including minimal change philosophy and AI-first development
10−2. **`02-development.md`** - Development guidelines for Node.js/Next.js AI projects
11−3. **`03-documentation.md`** - Documentation requirements and standards
12−4. **`04-security.md`** - Security guidelines for AI projects and API key management
9+**Current State**: Minimal setup with basic configuration files
10+- Use these rules to guide development when source code is added
11+- Follow Node.js/Next.js patterns and best practices
12+- Prioritize AI-specific development patterns and security
1313
14−## How Cline Uses These Rules
14+## Core Development Principles
1515
16−Cline automatically processes all Markdown files in this directory, combining them into a unified set of rules. The numeric prefixes help organize the files in a logical sequence, ensuring core principles are established before specific guidelines.
16+### 1. AI-First Development
17+- Prioritize AI integration patterns and best practices
18+- Consider model performance, API efficiency, and token usage
19+- Implement proper error handling for AI service failures
20+- Design for scalability with AI workloads
1721
18−## Customization
22+### 2. Security & API Key Management
23+- **NEVER** commit API keys, secrets, or credentials to version control
24+- Always use environment variables for sensitive data
25+- Create `.env.example` files to document required environment variables
26+- Implement proper API key rotation and management patterns
27+- Use secure storage solutions for production deployments
1928
20−These rules are tailored specifically for the Megarepo AI setup repository and should be updated as the project evolves. The rules emphasize:
29+### 3. Code Quality Standards
30+- Write clean, readable, and well-documented code
31+- Use TypeScript for type safety when applicable
32+- Implement comprehensive error handling and logging
33+- Follow established linting and formatting rules
34+- Write meaningful commit messages and documentation
2135
22−- **Minimal Changes**: Surgical, precise modifications that respect the repository's intentional simplicity
23−- **AI-First Development**: Patterns and practices optimized for AI service integrations
24−- **Security Best Practices**: Safe handling of API keys and sensitive data
25−- **Node.js/Next.js Patterns**: Guidelines specific to the target technology stack
36+## Technology Stack Guidelines
2637
27−## Rules Bank Approach
38+### Node.js/Next.js Development
39+- Follow Next.js 13+ App Router patterns when applicable
40+- Use modern ES6+ JavaScript/TypeScript features
41+- Implement proper async/await patterns for AI API calls
42+- Use React Server Components where appropriate
43+- Optimize for both development and production environments
2844
29−This repository follows the "active rules" pattern where the `.clinerules/` directory contains only the rules that should be active. For projects with multiple contexts, consider creating a `clinerules-bank/` directory with additional rule sets that can be activated as needed.
45+### AI Integration Patterns
46+```javascript
47+// Preferred AI API integration pattern
48+const aiResponse = await fetch('/api/ai-service', {
49+ method: 'POST',
50+ headers: {
51+ 'Content-Type': 'application/json',
52+ 'Authorization': `Bearer ${process.env.AI_API_KEY}`
53+ },
54+ body: JSON.stringify({ prompt, options })
55+});
3056
31−## Consistency with Other AI Assistants
57+if (!aiResponse.ok) {
58+ throw new Error(`AI service error: ${aiResponse.status}`);
59+}
60+```
3261
33−These rules are designed to work alongside other AI assistant configurations in this repository:
34−- GitHub Copilot (`.github/copilot-instructions.md`)
35−- Claude AI (`CLAUDE.md`)
36−- Cursor AI (`.cursorrules`)
37−- Gemini CLI (`GEMINI.md`)
38−- Universal AI guidelines (`AGENT.md`, `AGENTS.md`)
62+### Common AI Dependencies
63+When adding AI functionality, prefer these well-established packages:
64+- `openai` - Official OpenAI API client
65+- `@langchain/core` - LangChain framework
66+- `@vercel/ai` - Vercel AI SDK
67+- `@huggingface/inference` - Hugging Face API client
3968
40−All configurations share common principles while being optimized for each assistant's specific capabilities.
69+## File Structure and Organization
70+
71+### Expected Project Structure
72+```
73+.
74+├── README.md # Project documentation
75+├── LICENSE # MIT license
76+├── .gitignore # Node.js/Next.js patterns
77+├── .cursorrules # This file
78+├── .env.example # Environment variable template
79+├── package.json # Dependencies and scripts
80+├── next.config.js # Next.js configuration
81+├── tsconfig.json # TypeScript configuration
82+├── src/
83+│ ├── app/ # Next.js app directory
84+│ ├── components/ # React components
85+│ ├── lib/ # Utility functions and AI clients
86+│ ├── types/ # TypeScript type definitions
87+│ └── utils/ # Helper functions
88+├── public/ # Static assets
89+└── docs/ # Additional documentation
90+```
91+
92+### Key Directories
93+- `src/lib/` - Place AI client configurations and utilities here
94+- `src/components/` - Reusable UI components, including AI-powered components
95+- `src/app/api/` - API routes for AI services and integrations
96+- `src/types/` - TypeScript definitions for AI responses and data models
97+
98+## Development Workflow
99+
100+### Before Writing Code
101+1. Check if `package.json` exists before running npm commands
102+2. Review existing environment variable requirements
103+3. Understand the AI service integrations being used
104+4. Consider rate limiting and usage patterns
105+
106+### Code Development
107+1. Write TypeScript definitions for AI API responses
108+2. Implement proper error handling for AI service failures
109+3. Add loading states and user feedback for AI operations
110+4. Consider performance implications of AI API calls
111+5. Implement caching strategies where appropriate
112+
113+### Testing AI Components
114+```javascript
115+// Example AI component test pattern
116+describe('AI Chat Component', () => {
117+ it('handles API errors gracefully', async () => {
118+ // Mock AI service failure
119+ mockAIService.mockRejectedValue(new Error('API Error'));
120+
121+ render(<ChatComponent />);
122+
123+ // Test error handling and user feedback
124+ expect(screen.getByText(/error/i)).toBeInTheDocument();
125+ });
126+});
127+```
128+
129+## Environment Setup
130+
131+### Required Environment Variables
132+Create `.env.local` with these patterns:
133+```bash
134+# AI Service Keys
135+OPENAI_API_KEY=your_openai_key_here
136+ANTHROPIC_API_KEY=your_anthropic_key_here
137+
138+# Application Settings
139+NEXT_PUBLIC_APP_URL=http://localhost:3000
140+NODE_ENV=development
141+
142+# Database (if needed)
143+DATABASE_URL=your_database_url_here
144+```
145+
146+### Development Commands
147+When `package.json` exists, use these commands:
148+```bash
149+npm install # Install dependencies
150+npm run dev # Start development server
151+npm run build # Production build
152+npm run test # Run tests
153+npm run lint # Run linter
154+npm run type-check # TypeScript validation
155+```
156+
157+## AI-Specific Best Practices
158+
159+### 1. Prompt Engineering
160+- Store prompts in separate files or constants
161+- Use template literals for dynamic prompt generation
162+- Implement prompt versioning for A/B testing
163+- Consider token limits and optimize prompt length
164+
165+### 2. Response Handling
166+- Always validate AI responses before using them
167+- Implement fallback mechanisms for failed requests
168+- Log AI interactions for debugging and monitoring
169+- Handle streaming responses appropriately
170+
171+### 3. Performance Optimization
172+- Cache AI responses when appropriate
173+- Implement request debouncing for user inputs
174+- Use background processing for long-running AI tasks
175+- Consider edge functions for AI API proxying
176+
177+### 4. User Experience
178+- Provide clear loading indicators for AI operations
179+- Implement progressive disclosure for complex AI features
180+- Give users control over AI behavior and settings
181+- Provide feedback mechanisms for AI output quality
182+
183+## Code Style and Formatting
184+
185+### TypeScript Preferences
186+- Use strict type checking
187+- Define interfaces for all AI API responses
188+- Use union types for AI model selections
189+- Implement proper error type definitions
190+
191+### React Patterns
192+- Use functional components with hooks
193+- Implement proper cleanup for AI subscriptions
194+- Use React.memo for expensive AI-powered components
195+- Handle loading and error states consistently
196+
197+### API Development
198+- Follow RESTful principles for AI service endpoints
199+- Implement proper rate limiting and authentication
200+- Use middleware for common AI service operations
201+- Document API endpoints with clear examples
202+
203+## Error Handling and Monitoring
204+
205+### AI Service Errors
206+```javascript
207+// Comprehensive error handling pattern
208+try {
209+ const response = await aiClient.complete(prompt);
210+ return response;
211+} catch (error) {
212+ if (error.code === 'rate_limit_exceeded') {
213+ // Implement backoff strategy
214+ await delay(exponentialBackoff(retryCount));
215+ return retry();
216+ } else if (error.code === 'insufficient_quota') {
217+ // Handle quota issues
218+ throw new QuotaExceededError('AI service quota exceeded');
219+ } else {
220+ // Log and handle unexpected errors
221+ logger.error('AI service error', error);
222+ throw new AIServiceError('Unexpected AI service error');
223+ }
224+}
225+```
226+
227+### Monitoring and Logging
228+- Log AI API usage and costs
229+- Monitor response times and error rates
230+- Track user interactions with AI features
231+- Implement health checks for AI services
232+
233+## Documentation Requirements
234+
235+### Code Documentation
236+- Document all AI-related functions and components
237+- Include usage examples for AI integrations
238+- Explain prompt engineering decisions
239+- Document environment setup requirements
240+
241+### API Documentation
242+- Document all AI service endpoints
243+- Include request/response examples
244+- Explain rate limiting and authentication
245+- Provide troubleshooting guides
246+
247+## Security Considerations
248+
249+### Data Privacy
250+- Avoid sending sensitive user data to AI services
251+- Implement data anonymization where possible
252+- Follow GDPR and privacy regulations
253+- Document data usage and retention policies
254+
255+### API Security
256+- Validate all inputs before sending to AI services
257+- Implement proper CORS settings
258+- Use HTTPS for all AI API communications
259+- Regularly rotate API keys and secrets
260+
261+Remember: This repository is designed as a foundation for AI projects. Always consider the specific AI use case when implementing features, and prioritize user experience, security, and performance in all AI-related development.
