opensync / rules
Cursor rule410 starsChanged 10 months agoMITView on GitHub
OpenSync ecosystem development guidelines for building and maintaining plugins
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 1,533 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 repository12 other files it gives its agents.
- .cursor/rules/about.mdcCursor rule
- .cursor/rules/changelog.mdcCursor rule
- .cursor/rules/convex2.mdcCursor rule
- .cursor/rules/convex-write-conflicts.mdcCursor rule
- .cursor/rules/dev2.mdcCursor rule
- .cursor/rules/gitruels.mdcCursor rule
- .cursor/rules/help.mdcCursor rule
- .cursor/rules/rulesforconvex.mdcCursor rule
- .cursor/rules/sec-check.mdcCursor rule
- .cursor/rules/task.mdcCursor rule
- .cursor/rules/write.mdcCursor rule
- public/llms.txtllms.txt
The file
Show its rules and text
We split this opensync-ecosystem.mdc into the rules it gives an agent
14 rules. About 0 are common, 10 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 35
Every plugin MUST have a unique source identifier:
- Distinctive: line 96
Always use upsert pattern for sync operations:
- Distinctive: line 115
Always use indexes, never filters:
- Distinctive: line 127
Use batch mutations to reduce write conflicts:
- Distinctive: line 140
Every plugin should implement:
- Distinctive: line 160
Use standard pricing lookup by model:
- Distinctive: line 172
Before publishing a plugin:
- Very specific: line 174
Test login stores credentials
- Very specific: line 175
Test status shows connection state
- Very specific: line 176
Test sync creates sessions in dashboard
- Distinctive: line 177
Verify source filter includes your plugin
- Distinctive: line 178
Check token counts and costs are accurate
- Very specific: line 184
Commit to the correct repo (check pwd first)
- Distinctive: line 190
Keep updated in each plugin:
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 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
---
description: OpenSync ecosystem development guidelines for building and maintaining plugins
globs: **/*.ts,**/*.tsx,**/*.js,**/*.jsx
alwaysApply: true
---
# OpenSync Ecosystem Development Rules
## Overview
OpenSync is a platform for syncing AI coding sessions. This rule covers the ecosystem of plugins and the main application.
## Architecture
### Main Application (opensync/)
- React + Vite frontend
- Convex backend
- WorkOS AuthKit authentication
- Dashboard for viewing sessions
### Plugins (separate repos)
Each plugin syncs sessions from a specific CLI tool:
- `codex-sync` - Codex CLI (source: "codex-cli")
- `claude-code-sync` - Claude Code (source: "claude-code")
- `opencode-sync` - OpenCode (source: "opencode")
- `cursor-cli-sync` - Cursor (source: "cursor")
## Plugin Development
### Source Identifiers
Every plugin MUST have a unique source identifier:
- Used in session `source` field
- Appears in dashboard source filter
- Format: lowercase with hyphens (e.g., "amp-cli", "agent-trace")
### Required Fields for Sessions
```typescript
{
externalId: string, // Unique session ID from your plugin
source: string, // Your plugin identifier
promptTokens: number, // Input tokens
completionTokens: number,// Output tokens
cost: number, // Calculated USD cost
}
```
### Required Fields for Messages
```typescript
{
sessionExternalId: string, // Links to session externalId
externalId: string, // Unique message ID
role: "user" | "assistant" | "system" | "tool" | "unknown",
}
```
## API Integration
### Endpoints
- `POST /sync/session` - Sync a session
- `POST /sync/message` - Sync a message
- `POST /sync/batch` - Batch sync (preferred for multiple items)
- `GET /health` - Health check
### URL Normalization
Convex URLs must be converted for HTTP endpoints:
```typescript
const httpUrl = convexUrl.replace(".convex.cloud", ".convex.site");
```
### Authentication
Plugins use API key authentication:
```typescript
headers: {
'Authorization': `Bearer ${apiKey}`, // Format: osk_xxxxx
'Content-Type': 'application/json',
'User-Agent': `plugin-name/${version}`,
}
```
## Convex Backend Patterns
### Idempotent Upserts
Always use upsert pattern for sync operations:
```typescript
const existing = await ctx.db
.query("sessions")
.withIndex("by_user_external", (q) =>
q.eq("userId", userId).eq("externalId", externalId),
)
.first();
if (existing) {
await ctx.db.patch(existing._id, updates);
} else {
await ctx.db.insert("sessions", data);
}
```
### Indexed Queries
Always use indexes, never filters:
```typescript
// Good
.withIndex("by_user", (q) => q.eq("userId", userId))
// Bad - causes performance issues
.filter((q) => q.eq(q.field("userId"), userId))
```
### Batch Operations
Use batch mutations to reduce write conflicts:
```typescript
export const batchUpsert = internalMutation({
args: { userId: v.id("users"), sessions: v.array(...) },
handler: async (ctx, args) => {
// Process all items in one transaction
},
});
```
## CLI Commands
Every plugin should implement:
- `login` - Configure API key and Convex URL
- `status` - Show configuration and connection status
- `sync` - Sync sessions to OpenSync
- `logout` - Clear configuration
## Configuration Storage
Standard config location: `~/.plugin-name/config.json`
```json
{
"convexUrl": "https://app.convex.cloud",
"apiKey": "osk_xxxxx"
}
```
## Cost Calculation
Use standard pricing lookup by model:
```typescript
const MODEL_PRICING = {
"gpt-4o": { input: 2.5, cached: 1.25, output: 10.0 },
"claude-3-5-sonnet": { input: 3.0, cached: 1.5, output: 15.0 },
// ... per 1M tokens
};
```
## Testing
Before publishing a plugin:
1. Test `login` stores credentials
2. Test `status` shows connection state
3. Test `sync` creates sessions in dashboard
4. Verify source filter includes your plugin
5. Check token counts and costs are accurate
## Git Workflow
Each plugin is a separate repository:
- Commit to the correct repo (check `pwd` first)
- Each repo has its own version and changelog
- Publish independently with `npm publish`
## Documentation
Keep updated in each plugin:
- `README.md` - Installation and usage
- `changelog.md` - Version history
- `files.md` - Codebase structure
## Common Mistakes to Avoid
1. Using `.convex.cloud` instead of `.convex.site` for HTTP endpoints
2. Missing `source` field in session data
3. Using `filter()` instead of `withIndex()`
4. Committing to wrong repository in multi-repo workspace
5. Forgetting to update version before `npm publish`
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.

