AgentVerse / rules
Cursor rule318 starsChanged 11 months agoMITView on GitHub
When a file approaches 200 lines: - Code Review: Always flag files over 250 lines - Linting: Consider adding file size limits to linting rules - Documentation: Document the reasoning for any files over 200 lines - Refactoring: Prioritize splitting large files in technical debt reviews description: globs: alwa
We split this file-size-limits.mdc into the rules it gives an agent
5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
When to split: If a file exceeds 200 lines, consider refactoring
- Distinctive: line 75
When a file approaches 200 lines:
- Distinctive: line 117
Code Review: Always flag files over 250 lines
- Distinctive: line 118
Linting: Consider adding file size limits to linting rules
- Distinctive: line 119
Documentation: Document the reasoning for any files over 200 lines
≈ “Common” is an estimate: at least 1 in 5 of the 6,350 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
# File Size Limits and Code Organization
## Core Principle: Keep Files Small and Focused
### File Size Guidelines
- **Target**: Under 100 lines per file
- **Maximum**: 250 lines per file
- **When to split**: If a file exceeds 200 lines, consider refactoring
### Why Small Files Matter
1. **Maintainability**: Easier to understand and modify
2. **Testability**: Smaller units are easier to test
3. **Reusability**: Focused modules can be reused independently
4. **Collaboration**: Multiple developers can work on different files simultaneously
5. **Code Review**: Smaller changes are easier to review
## Refactoring Patterns
### When a File Gets Too Large
#### 1. Extract Types and Interfaces
```typescript
// Before: 300+ lines with mixed types and implementation
// After: Separate types.ts file
export interface MyInterface { ... }
export type MyType = ...;
```
#### 2. Split by Responsibility
```typescript
// Before: One large class with multiple responsibilities
// After: Multiple focused classes
- base-class.ts
- implementation-a.ts
- implementation-b.ts
```
#### 3. Extract Utilities
```typescript
// Before: Utility functions mixed with business logic
// After: Dedicated utils file
export function utilityFunction() { ... }
```
#### 4. Separate Concerns
```typescript
// Before: UI, logic, and data access in one file
// After: Separate files for each concern
- component.tsx (UI only)
- logic.ts (Business logic)
- data.ts (Data access)
```
## Directory Organization
### Service Bus Portal Example
The portal system demonstrates proper file organization:
```
portal/
├── types.ts # 80 lines - Type definitions only
├── base-portal.ts # 50 lines - Abstract base class
├── postmessage-portal.ts # 90 lines - PostMessage implementation
├── event-target-portal.ts # 70 lines - EventTarget implementation
├── portal-factory.ts # 60 lines - Factory methods
├── service-bus-portal-connector.ts # 80 lines - Service integration
├── service-bus-portal-proxy.ts # 90 lines - Proxy implementation
├── portal-composer.ts # 80 lines - Multi-portal management
├── compatibility.ts # 70 lines - Legacy support
└── index.ts # 30 lines - Exports only
```
## Refactoring Checklist
When a file approaches 200 lines:
- [ ] Can types be extracted to a separate file?
- [ ] Can the class be split into multiple classes?
- [ ] Can utility functions be moved to a utils file?
- [ ] Can the file be split by feature or responsibility?
- [ ] Are there clear boundaries between different concerns?
- [ ] Can some logic be moved to a separate service or hook?
## Benefits of Small Files
1. **Single Responsibility**: Each file has one clear purpose
2. **Easier Navigation**: Developers can quickly find relevant code
3. **Better Testing**: Smaller units are easier to test in isolation
4. **Reduced Conflicts**: Less chance of merge conflicts
5. **Improved Performance**: Smaller files load and parse faster
6. **Better IDE Support**: Faster autocomplete and navigation
## Examples of Good File Organization
### Before (Monolithic - 650 lines)
```typescript
// connect-service-bus-with-portal.ts - 650 lines
// Contains: types, implementations, factories, adapters, compatibility
```
### After (Modular - 10 files, each under 100 lines)
```typescript
// types.ts - 80 lines
// base-portal.ts - 50 lines
// postmessage-portal.ts - 90 lines
// event-target-portal.ts - 70 lines
// portal-factory.ts - 60 lines
// service-bus-portal-connector.ts - 80 lines
// service-bus-portal-proxy.ts - 90 lines
// portal-composer.ts - 80 lines
// compatibility.ts - 70 lines
// index.ts - 30 lines
```
## Enforcement
- **Code Review**: Always flag files over 250 lines
- **Linting**: Consider adding file size limits to linting rules
- **Documentation**: Document the reasoning for any files over 200 lines
- **Refactoring**: Prioritize splitting large files in technical debt reviews
description:
globs:
alwaysApply: false
---
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 3,978 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository15 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .cursor/rules/agentverse-project.mdcCursor rule
- .cursor/rules/code-simplicity.mdcCursor rule
- .cursor/rules/commit.mdcCursor rule
- .cursor/rules/core.mdcCursor rule
- .cursor/rules/customization.mdcCursor rule
- .cursor/rules/file-organization.mdcCursor rule
- .cursor/rules/generate-world-class-artistic-ui.mdcCursor rule
- .cursor/rules/naming-conventions.mdcCursor rule
- .cursor/rules/portal-service-bus-architecture.mdcCursor rule
- .cursor/rules/quick-commands.mdcCursor rule
- .cursor/rules/README.mdCursor rule
- .cursor/rules/riper-workflow.mdcCursor rule
- .cursor/rules/start-phase.mdcCursor rule
- .cursor/rules/state.mdcCursor rule
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

